Advertisement
Guest User

Untitled

a guest
May 15th, 2017
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 6.64 KB | None | 0 0
  1. using System;
  2. using Microsoft.Xna.Framework.Graphics;
  3. using TomShane.Neoforce.Controls;
  4. using Omnion.SquadOmega.Shared.Secruity;
  5. using Omnion.SquadOmega.Shared.Diagnostic;
  6. using Omnion.SquadOmega.Shared.IO;
  7. using Omnion.SquadOmega.Shared.Networking;
  8. using Omnion.SquadOmegaClient.Networking;
  9.  
  10. namespace Omnion.SquadOmegaClient.MainMenuScreen
  11. {
  12.     public class RegisterWindow : Window
  13.     {
  14.         public const int UsernameMin = 4, UsernameMax = 20,
  15.             PasswordMin = 6, PasswordMax = 20,
  16.             PlayerNameMin = 4, PlayerNameMax = 20;
  17.         public const string UserTooSmall = "Username must be at least 4 characters long.",
  18.             UserTooLarge = "Username can't be larger than 20 characters.",
  19.             PassTooSmall = "Password must be at least 6 characters long.",
  20.             PassTooLarge = "Password can't be larger than 20 characters.",
  21.             NonConformingPass = "Password confirmation doesn't match password.",
  22.             PlayerSmall = "Player name must be at least 4 characters long.",
  23.             PlayerLarge = "Player name can't be larger than 20 characters.";
  24.         FlexLabel userL, passL, confirmPassL, playerNameL;
  25.         TextBox userTB, passTB, confirmPassTB, playerNameTB;
  26.  
  27.         Label errorL;
  28.         Button registerB, cancelB;
  29.  
  30.         Window mainMenu;
  31.         SocketManager sockets;
  32.  
  33.         public RegisterWindow(Manager manager, Window mainMenu)
  34.             : base(manager)
  35.         {
  36.             this.mainMenu = mainMenu;
  37.             this.sockets = SocketManager.GetSockets(manager.Game);
  38.         }
  39.  
  40.         public override void Init()
  41.         {
  42.             base.Init();
  43.             this.Text = "Register";
  44.             this.Width = 500;
  45.             this.Height = 400;
  46.             this.Resizable = false;
  47.             this.Movable = false;
  48.             this.CloseButtonVisible = false;
  49.             this.Center();
  50.  
  51.             this.InitControls();
  52.         }
  53.  
  54.         private void InitControls()
  55.         {
  56.             this.userL = new FlexLabel(this.Manager);
  57.             this.userL.Text = "Username : ";
  58.             this.userL.Left = Layout.LargeSpace;
  59.             this.userL.Top = Layout.LargeSpace;
  60.             this.userL.Ellipsis = false;
  61.             this.userL.Parent = this;
  62.  
  63.             this.userTB = new TextBox(this.Manager);
  64.             this.userTB.Left = this.userL.Left + this.userL.Width + Layout.SmallSpace;
  65.             this.userTB.Top = this.userL.Top;
  66.             this.userTB.Width = this.ClientWidth - (Layout.LargeSpace + this.userTB.Left);
  67.             this.userTB.Parent = this;
  68.  
  69.             this.passL = new FlexLabel(this.Manager);
  70.             this.passL.Text = "Password : ";
  71.             this.passL.Left = this.userL.Left;
  72.             this.passL.Top = this.userTB.Top + this.userTB.Height + Layout.SmallSpace;
  73.             this.passL.Ellipsis = false;
  74.             this.passL.Parent = this;
  75.  
  76.             this.passTB = new TextBox(this.Manager);
  77.             this.passTB.Left = this.passL.Left + this.passL.Width + Layout.SmallSpace;
  78.             this.passTB.Top = this.passL.Top;
  79.             this.passTB.Width = this.ClientWidth - (Layout.LargeSpace + this.passTB.Left);
  80.             this.passTB.Mode = TextBoxMode.Password;
  81.             this.passTB.Parent = this;
  82.  
  83.             this.confirmPassL = new FlexLabel(this.Manager);
  84.             this.confirmPassL.Text = "Confirm Password : ";
  85.             this.confirmPassL.Left = this.userL.Left;
  86.             this.confirmPassL.Top = this.passTB.Top + this.passTB.Height + Layout.SmallSpace;
  87.             this.confirmPassL.Ellipsis = false;
  88.             this.confirmPassL.Parent = this;
  89.  
  90.             this.confirmPassTB = new TextBox(this.Manager);
  91.             this.confirmPassTB.Left = this.confirmPassL.Left + this.confirmPassL.Width + Layout.SmallSpace;
  92.             this.confirmPassTB.Top = this.confirmPassL.Top;
  93.             this.confirmPassTB.Width = this.ClientWidth - (Layout.LargeSpace + this.confirmPassTB.Left);
  94.             this.confirmPassTB.Mode = TextBoxMode.Password;
  95.             this.confirmPassTB.Parent = this;
  96.  
  97.             this.playerNameL = new FlexLabel(this.Manager);
  98.             this.playerNameL.Text = "Player Name : ";
  99.             this.playerNameL.Left = this.userL.Left;
  100.             this.playerNameL.Top = this.confirmPassTB.Top + this.confirmPassTB.Height + Layout.SmallSpace;
  101.             this.playerNameL.Ellipsis = false;
  102.             this.playerNameL.Parent = this;
  103.  
  104.             this.playerNameTB = new TextBox(this.Manager);
  105.             this.playerNameTB.Left = this.playerNameL.Left + this.playerNameL.Width + Layout.SmallSpace;
  106.             this.playerNameTB.Top = this.playerNameL.Top;
  107.             this.playerNameTB.Width = this.ClientWidth - (Layout.LargeSpace + this.playerNameTB.Left);
  108.             this.playerNameTB.Parent = this;
  109.  
  110.             this.userTB.Left = this.passTB.Left = this.playerNameTB.Left = this.confirmPassTB.Left;
  111.             this.userTB.Width = this.passTB.Width = this.playerNameTB.Width = this.confirmPassTB.Width;
  112.             this.userL.Width = this.passL.Width = this.playerNameL.Width = this.confirmPassL.Width;
  113.             this.userL.Alignment = this.passL.Alignment = this.confirmPassL.Alignment = this.playerNameL.Alignment
  114.                 = Alignment.MiddleRight;
  115.             this.userL.TextColor = this.passL.TextColor = this.confirmPassL.TextColor = this.playerNameL.TextColor =
  116.                 Color.Silver;
  117.  
  118.             this.errorL = new Label(this.Manager);
  119.             this.errorL.Left = this.userL.Left;
  120.             this.errorL.Top = this.playerNameTB.Top + this.playerNameTB.Height + Layout.SmallSpace;
  121.             this.errorL.Width = this.ClientWidth - (Layout.LargeSpace * 2);
  122.             this.errorL.Alignment = Alignment.BottomCenter;
  123.             this.errorL.Parent = this;
  124.             this.errorL.Hide();
  125.  
  126.             this.registerB = new Button(this.Manager);
  127.             this.registerB.Text = "Register";
  128.             this.registerB.Left = this.errorL.Left;
  129.             this.registerB.Top = this.errorL.Top + this.errorL.Height + Layout.SmallSpace;
  130.             this.registerB.Width = (this.ClientWidth - (Layout.SmallSpace + (Layout.LargeSpace * 2))) / 2;
  131.             this.registerB.Parent = this;
  132.  
  133.             this.cancelB = new Button(this.Manager);
  134.             this.cancelB.Text = "Cancel";
  135.             this.cancelB.Left = this.registerB.Left + this.registerB.Width + Layout.SmallSpace;
  136.             this.cancelB.Top = this.registerB.Top;
  137.             this.cancelB.Width = this.registerB.Width;
  138.             this.cancelB.Parent = this;
  139.  
  140.             this.ClientHeight = this.cancelB.Top + this.cancelB.Height + Layout.LargeSpace;
  141.             this.Center();
  142.         }
  143.     }
  144. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement