예제 #1
0
    public void TestSimpleInput() {
      InputControl input = new InputControl();
      
      IWritable writable = input as IWritable;
      Assert.IsNotNull(writable);

      writable.OnCharacterEntered('H');
      writable.OnCharacterEntered('e');
      writable.OnCharacterEntered('l');
      writable.OnCharacterEntered('l');
      writable.OnCharacterEntered('o');

      Assert.AreEqual("Hello", input.Text);
    }
예제 #2
0
        public void TestInjectCharacter()
        {
            Screen screen = new Screen(100.0f, 100.0f);

            Controls.Desktop.InputControl control = new Controls.Desktop.InputControl();
            screen.Desktop.Children.Add(control);

            screen.InjectCharacter('a');
            Assert.AreEqual(string.Empty, control.Text);

            screen.FocusedControl = control;

            screen.InjectCharacter('a');
            Assert.AreEqual("a", control.Text);
        }
예제 #3
0
    public void TestMillisecondsSinceLastCaretMovement() {
      InputControl input = new InputControl();
      input.ProcessCharacter('H');
      
      int start = Environment.TickCount;
      int end;
      do {
        Thread.Sleep(1);
        end = Environment.TickCount;
      } while(start == end);

      int elapsedMilliseconds = end - start;
      
      Assert.GreaterOrEqual(
        input.MillisecondsSinceLastCaretMovement, elapsedMilliseconds
      );
    }
예제 #4
0
    public void TestMoveCaretByMouseWitLocator() {
      Screen screen = new Screen(100, 100);
      InputControl input = new InputControl();
      input.Bounds = new UniRectangle(10, 10, 100, 100);
      screen.Desktop.Children.Add(input);

      input.Text = "Hello World";
      input.CaretPosition = 0;

      // Assign a dummy locator for text openings which will always report that
      // the mouse is between the 4th and 5th letters.
      input.OpeningLocator = new DummyLocator(4);

      // This should move the caret. Because the dummy locator is assigned, it
      // should be asked for the position the user has clicked on.
      input.ProcessMouseMove(100, 100, 50, 50);
      input.ProcessMousePress(MouseButtons.Left);

      Assert.AreEqual(4, input.CaretPosition);
    }
예제 #5
0
    public void TestMoveCaretByMouseWithoutLocator() {
      Screen screen = new Screen(100, 100);
      InputControl input = new InputControl();
      input.Bounds = new UniRectangle(10, 10, 100, 100);
      screen.Desktop.Children.Add(input);

      input.Text = "Hello World";
      input.CaretPosition = 0;

      // This should move the caret. Because the control has no locator and it
      // doesn't know which font is being used (controls have no connection to
      // their rendering code), it can only move the caret to the end.      
      input.ProcessMouseMove(100, 100, 50, 50);
      input.ProcessMousePress(MouseButtons.Left);

      Assert.AreEqual(input.Text.Length, input.CaretPosition);
    }
예제 #6
0
    public void TestInputFocus() {
      Screen screen = new Screen();
      InputControl input = new InputControl();
      screen.Desktop.Children.Add(input);

      Assert.IsFalse(input.HasFocus);

      screen.FocusedControl = input;

      Assert.IsTrue(input.HasFocus);
    }
예제 #7
0
        /// <summary>
        ///   Required method for user interface initialization -
        ///   do modify the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            this.lblBabyPackage       = new Nuclex.UserInterface.Controls.LabelControl();
            this.lblBabyPackagePath   = new Nuclex.UserInterface.Controls.LabelControl();
            this.btnBabyPackageBrowse = new Nuclex.UserInterface.Controls.Desktop.ButtonControl();

            this.lblKeyBashingThreshold = new Nuclex.UserInterface.Controls.LabelControl();
            this.txtKeyBashingThreshold = new Nuclex.UserInterface.Controls.Desktop.InputControl();

            this.lblRunOnAllMonitors = new Nuclex.UserInterface.Controls.LabelControl();
            this.chkRunOnAllMonitors = new Nuclex.UserInterface.Controls.Desktop.OptionControl();

            this.lblMouseRequired = new Nuclex.UserInterface.Controls.LabelControl();
            this.chkMouseRequired = new Nuclex.UserInterface.Controls.Desktop.OptionControl();

            this.lblAutoPublishErrors = new Nuclex.UserInterface.Controls.LabelControl();
            this.chkAutoPublishErrors = new Nuclex.UserInterface.Controls.Desktop.OptionControl();

            this.lblDeveloperMode = new Nuclex.UserInterface.Controls.LabelControl();
            this.chkDeveloperMode = new Nuclex.UserInterface.Controls.Desktop.OptionControl();

            this.lblDisabledKeys     = new Nuclex.UserInterface.Controls.LabelControl();
            this.lblDisabledKeyCount = new Nuclex.UserInterface.Controls.LabelControl();
            this.btnDisableKeys      = new Nuclex.UserInterface.Controls.Desktop.ButtonControl();

            this.lblErrorMessage = new Nuclex.UserInterface.Controls.LabelControl();


            this.btnUndo  = new Nuclex.UserInterface.Controls.Desktop.ButtonControl();
            this.btnClose = new Nuclex.UserInterface.Controls.Desktop.ButtonControl();
            this.btnAbout = new Nuclex.UserInterface.Controls.Desktop.ButtonControl();

            //
            // lblBabyPackage
            //
            this.lblBabyPackage.Text   = "Baby Package of sounds and shapes:";
            this.lblBabyPackage.Bounds = new UniRectangle(20.0f, 30.0f, 300.0f, 30.0f);
            //
            // lblBabyPackagePath
            //
            this.lblBabyPackagePath.Bounds = new UniRectangle(30.0f, 50.0f, 300.0f, 30.0f);
            //
            // btnBabyPackageBrowse
            //
            this.btnBabyPackageBrowse.Bounds   = new UniRectangle(350.0f, 30.0f, 80.0f, 24.0f);
            this.btnBabyPackageBrowse.Pressed += new EventHandler(this.btnBabyPackageBrowse_Pressed);
            this.btnBabyPackageBrowse.Text     = "Select";

            //
            // lblKeyBashingThreshold
            //
            this.lblKeyBashingThreshold.Text   = "Key Bashing Threshold (0 to turn off):";
            this.lblKeyBashingThreshold.Bounds = new UniRectangle(20.0f, 90.0f, 300.0f, 30.0f);
            //
            // txtKeyBashingThreshold
            //
            this.txtKeyBashingThreshold.Bounds = new UniRectangle(350.0f, 90.0f, 60.0f, 30.0f);


            //
            // lblMouseRequired
            //
            this.lblMouseRequired.Text   = "Must Press Mouse Button When Moving:";
            this.lblMouseRequired.Bounds = new UniRectangle(20.0f, 120.0f, 300.0f, 30.0f);
            //
            // chkMouseRequired
            //
            this.chkMouseRequired.Bounds = new UniRectangle(350.0f, 120.0f, 60.0f, 30.0f);


            //
            // lblAutoPublishErrors
            //
            this.lblAutoPublishErrors.Text   = "Automatically Publish Errors to Murray:";
            this.lblAutoPublishErrors.Bounds = new UniRectangle(20.0f, 150.0f, 300.0f, 30.0f);
            //
            // chkAutoPublishErrors
            //
            this.chkAutoPublishErrors.Bounds = new UniRectangle(350.0f, 150.0f, 60.0f, 30.0f);


            //
            // lblDeveloperMode
            //
            this.lblDeveloperMode.Text   = "Developer Mode:";
            this.lblDeveloperMode.Bounds = new UniRectangle(20.0f, 180.0f, 300.0f, 30.0f);
            //
            // chkDeveloperMode
            //
            this.chkDeveloperMode.Bounds = new UniRectangle(350.0f, 180.0f, 60.0f, 30.0f);


            //
            // lblRunOnAllMonitors
            //
            this.lblRunOnAllMonitors.Text   = "Run on all Monitors (Must Restart BabyBash):";
            this.lblRunOnAllMonitors.Bounds = new UniRectangle(20.0f, 150.0f, 300.0f, 30.0f);
            //
            // chkRunOnAllMonitors
            //
            this.chkRunOnAllMonitors.Bounds = new UniRectangle(350.0f, 150.0f, 60.0f, 30.0f);


            //
            // lblDisabledKeys
            //
            this.lblDisabledKeys.Text   = "Deactivated Keys:";
            this.lblDisabledKeys.Bounds = new UniRectangle(20.0f, 180.0f, 300.0f, 30.0f);
            //
            // lblDisabledKeyCount
            //
            this.lblDisabledKeyCount.Text   = "{0} Deactivated";
            this.lblDisabledKeyCount.Bounds = new UniRectangle(450.0f, 180.0f, 300.0f, 30.0f);
            //
            // btnDisableKeys
            //
            this.btnDisableKeys.Bounds   = new UniRectangle(350.0f, 180.0f, 80f, 24f);
            this.btnDisableKeys.Pressed += new EventHandler(this.btnDisableKeys_Pressed);
            this.btnDisableKeys.Text     = "Choose";


            //
            // lblErrorMessage
            //
            this.lblErrorMessage.Text   = "";
            this.lblErrorMessage.Bounds = new UniRectangle(20.0f, 230.0f, 300.0f, 30.0f);

            //
            // btnUndo
            //
            this.btnUndo.Bounds = new UniRectangle(
                new UniScalar(1.0f, -250.0f), new UniScalar(1.0f, -40.0f), 80, 24
                );
            this.btnUndo.Pressed += new EventHandler(this.undoButton_Pressed);
            this.btnUndo.Text     = "Undo";
            //
            // btnClose
            //
            this.btnClose.Bounds = new UniRectangle(
                new UniScalar(1.0f, -160.0f), new UniScalar(1.0f, -40.0f), 140, 24
                );
            this.btnClose.Pressed += new EventHandler(this.closeButton_Pressed);
            this.btnClose.Text     = "Save and Close";
            //
            // btnAbout
            //
            this.btnAbout.Bounds = new UniRectangle(
                new UniScalar(0.0f, 40.0f), new UniScalar(1.0f, -40.0f), 80, 24
                );
            this.btnAbout.Pressed += new EventHandler(this.creditsButton_Pressed);
            this.btnAbout.Text     = "About";

            //
            // DemoDialog
            //
            this.Bounds = new UniRectangle(new UniScalar(0, 0), new UniScalar(0, 0), 600f, 300f);
            this.Title  = "Options";

            this.Children.Add(this.lblBabyPackage);
            this.Children.Add(this.lblBabyPackagePath);
            this.Children.Add(this.btnBabyPackageBrowse);

            this.Children.Add(this.lblKeyBashingThreshold);
            this.Children.Add(this.txtKeyBashingThreshold);

            this.Children.Add(this.lblMouseRequired);
            this.Children.Add(this.chkMouseRequired);

            this.Children.Add(this.lblAutoPublishErrors);
            this.Children.Add(this.chkAutoPublishErrors);

            this.Children.Add(this.lblDeveloperMode);
            this.Children.Add(this.chkDeveloperMode);

            // Disable these until they're implemented.
            //this.Children.Add(this.lblRunOnAllMonitors);
            //this.Children.Add(this.chkRunOnAllMonitors);

            //this.Children.Add(this.lblDisabledKeys);
            //this.Children.Add(this.lblDisabledKeyCount);
            //this.Children.Add(this.btnDisableKeys);

            this.Children.Add(this.lblErrorMessage);

            this.Children.Add(this.btnUndo);
            this.Children.Add(this.btnClose);
            this.Children.Add(this.btnAbout);
        }
예제 #8
0
        protected void InitializeComponents()
        {
            this.callsignLabel = new LabelControl();
            this.tagLabel = new LabelControl();
            this.hostLabel = new LabelControl();
            this.teamLabel = new LabelControl();

            this.callsignInput = new InputControl();
            this.tagInput = new InputControl();
            this.hostInput = new InputControl();

            this.joinButton = new ButtonControl();
            this.backButton = new ButtonControl();
            this.teamChoice = new Control();

            this.redTeam = new ChoiceControl();
            this.blueTeam = new ChoiceControl();
            this.greenTeam = new ChoiceControl();

            this.callsignLabel.Text = "Callsign: ";
            this.callsignLabel.Bounds = new UniRectangle(new UniScalar(.7f, 0f), new UniScalar(.2f, 0f), 50, 24);

            this.callsignInput.Bounds = new UniRectangle(new UniScalar(.7f, 80f), new UniScalar(0.2f, 0f), 150, 24);
            this.callsignInput.Enabled = true;
            
            this.tagLabel.Text = "Tag: ";
            this.tagLabel.Bounds = new UniRectangle(new UniScalar(0.7f, 0f), new UniScalar(0.3f, 0f), 50, 24);

            this.tagInput.Bounds = new UniRectangle(new UniScalar(0.7f, 80f), new UniScalar(0.3f, 0f), 150, 24);
            this.tagInput.Enabled = true;

            this.hostLabel.Text = "Host: ";
            this.hostLabel.Bounds = new UniRectangle(new UniScalar(0.7f, 0f), new UniScalar(0.4f, 0f), 50, 24);

            this.hostInput.Bounds = new UniRectangle(new UniScalar(0.7f, 80f), new UniScalar(0.4f, 0f), 150, 24);
            this.hostInput.Enabled = true;

            this.teamLabel.Text = "Team: ";
            this.teamLabel.Bounds = new UniRectangle(new UniScalar(0.7f, 0f), new UniScalar(0.5f, 0f), 50, 24);

            this.teamChoice.Bounds = new UniRectangle(new UniScalar(0.7f, 0f), new UniScalar(0.5f, 0f), 150, 94);

            this.redTeam.Text = "Red Team";
            this.redTeam.Bounds = new UniRectangle(new UniScalar(0.0f, 80f), new UniScalar(0.0f, 10f), 10, 10);
            this.redTeam.Enabled = true;

            this.blueTeam.Text = "Blue Team";
            this.blueTeam.Bounds = new UniRectangle(new UniScalar(0.0f, 80f), new UniScalar(0.0f, 30f), 10, 10);
            this.blueTeam.Enabled = true;

            this.greenTeam.Text = "Green Team";
            this.greenTeam.Bounds = new UniRectangle(new UniScalar(0.0f, 80f), new UniScalar(0.0f, 50f), 10, 10);
            this.greenTeam.Enabled = true;

            this.joinButton.Text = "Join!";
            this.joinButton.Bounds = new UniRectangle(new UniScalar(.7f, 80f), new UniScalar(0.7f, 0f), 150, 72);
            // 80, 24 for regular button

            this.backButton.Text = "Back";
            this.backButton.Bounds = new UniRectangle(new UniScalar(0.1f, 0.0f), new UniScalar(0.9f, 0f), 80, 24);

            joinScreen.Desktop.Children.Add(callsignLabel);
            joinScreen.Desktop.Children.Add(callsignInput);
            joinScreen.Desktop.Children.Add(tagLabel);
            joinScreen.Desktop.Children.Add(tagInput);
            joinScreen.Desktop.Children.Add(hostLabel);
            joinScreen.Desktop.Children.Add(hostInput);
            joinScreen.Desktop.Children.Add(teamLabel);
            joinScreen.Desktop.Children.Add(teamChoice);
            joinScreen.Desktop.Children.Add(joinButton);
            joinScreen.Desktop.Children.Add(backButton);

            teamChoice.Children.Add(redTeam);
            teamChoice.Children.Add(blueTeam);
            teamChoice.Children.Add(greenTeam);
        }
예제 #9
0
    public void TestDelete() {
      Screen screen = new Screen();
      InputControl input = new InputControl();
      screen.Desktop.Children.Add(input);
      screen.FocusedControl = input;

      input.ProcessCharacter('T');
      input.ProcessCharacter('e');
      input.ProcessCharacter('l');
      input.ProcessCharacter('l');
      input.ProcessCharacter('o');

      input.ProcessKeyPress(Keys.Home, false);
      input.ProcessKeyPress(Keys.Delete, false);

      input.ProcessCharacter('H');

      Assert.AreEqual("Hello", input.Text);
    }
예제 #10
0
    public void TestUnfocusedKeyPress() {
      InputControl input = new InputControl();

      Assert.IsFalse(input.ProcessKeyPress(Keys.Left, false));
      Assert.IsFalse(input.ProcessKeyPress(Keys.Right, false));
    }
예제 #11
0
    public void TestUnhandledKeyPress() {
      Screen screen = new Screen();
      InputControl input = new InputControl();
      screen.Desktop.Children.Add(input);
      screen.FocusedControl = input;

      Assert.IsTrue(input.ProcessKeyPress(Keys.Left, false));
      input.ProcessKeyRelease(Keys.Left);
      Assert.IsTrue(input.ProcessKeyPress(Keys.Right, false));
      input.ProcessKeyRelease(Keys.Right);
      
      Assert.IsFalse(input.ProcessKeyPress(Keys.Up, false));
      Assert.IsFalse(input.ProcessKeyPress(Keys.Down, false));
    }
예제 #12
0
    public void TestCaretMovementByCursor() {
      Screen screen = new Screen();
      InputControl input = new InputControl();
      screen.Desktop.Children.Add(input);
      screen.FocusedControl = input;

      input.ProcessCharacter('H');
      input.ProcessCharacter('e');
      input.ProcessCharacter('l');
      input.ProcessCharacter('o');

      input.ProcessKeyPress(Keys.Left, false);

      input.ProcessCharacter('l');

      input.ProcessKeyPress(Keys.Right, false);

      input.ProcessCharacter('!');

      Assert.AreEqual("Hello!", input.Text);
    }
예제 #13
0
    public void TestHomeAndEnd() {
      Screen screen = new Screen();
      InputControl input = new InputControl();
      screen.Desktop.Children.Add(input);
      screen.FocusedControl = input;

      input.ProcessCharacter('W');
      input.ProcessCharacter('o');
      input.ProcessCharacter('r');
      input.ProcessCharacter('l');
      input.ProcessCharacter('d');

      input.ProcessKeyPress(Keys.Home, false);

      input.ProcessCharacter('H');
      input.ProcessCharacter('e');
      input.ProcessCharacter('l');
      input.ProcessCharacter('l');
      input.ProcessCharacter('o');
      input.ProcessCharacter(' ');

      input.ProcessKeyPress(Keys.End, false);

      input.ProcessCharacter('!');

      Assert.AreEqual("Hello World!", input.Text);
    }
예제 #14
0
        private void LoadContent(Screen mainScreen, ContentManager content)
        {
            background = content.Load<Texture2D>("Images\\CreateRoom\\background2");
            header = content.Load<SpriteFont>("Images\\CreateRoom\\header");

            LabelControl roomNameLabel = new LabelControl("Room Name");
            roomNameLabel.Bounds = new UniRectangle(44, 91, 98, 20);
            roomNameLabel.Name = "Label Room Name";

            roomNameInput = new InputControl();
            roomNameInput.Bounds = new UniRectangle(217, 88, 213, 26);
            roomNameInput.Name = "Input Room Name";

            LabelControl maxPlayerLabel = new LabelControl("Maimum Player");
            maxPlayerLabel.Bounds = new UniRectangle(44, 155, 123, 20);
            maxPlayerLabel.Name = "Label Maximum Player";

            twoChoice = new ChoiceControl();
            twoChoice.Name = "Choice Two Player";
            twoChoice.Text = "2";
            twoChoice.Bounds = new UniRectangle(217, 155, 35, 20);
            twoChoice.Selected = true;

            fourChoice = new ChoiceControl();
            fourChoice.Name = "Choice Four Player";
            fourChoice.Text = "4";
            fourChoice.Bounds = new UniRectangle(258, 155, 35, 20);

            sixChoice = new ChoiceControl();
            sixChoice.Name = "Choice Six Player";
            sixChoice.Text = "6";
            sixChoice.Bounds = new UniRectangle(299, 155, 35, 20);

            eightChoice = new ChoiceControl();
            eightChoice.Name = "Choice Eight Player";
            eightChoice.Text = "8";
            eightChoice.Bounds = new UniRectangle(340, 155, 35, 20);

            ButtonControl createRoomButton = new ButtonControl();
            createRoomButton.Bounds = new UniRectangle(48, 208, 104, 46);
            createRoomButton.Name = "Create Room Button";
            createRoomButton.Pressed += new EventHandler(createRoomPressed);
            createRoomButton.Text = "Create";

            ButtonControl cancelButton = new ButtonControl();
            cancelButton.Bounds = new UniRectangle(326, 208, 104, 46);
            cancelButton.Name = "Cancel Button";
            cancelButton.Pressed += new EventHandler(cancelPressed);
            cancelButton.Text = "Cancel";

            mainScreen.Desktop.Children.Add(roomNameLabel);
            mainScreen.Desktop.Children.Add(roomNameInput);
            mainScreen.Desktop.Children.Add(maxPlayerLabel);
            mainScreen.Desktop.Children.Add(twoChoice);
            mainScreen.Desktop.Children.Add(fourChoice);
            mainScreen.Desktop.Children.Add(sixChoice);
            mainScreen.Desktop.Children.Add(eightChoice);

            mainScreen.Desktop.Children.Add(createRoomButton);
            mainScreen.Desktop.Children.Add(cancelButton);
        }
예제 #15
0
    public void TestInjectCharacter() {
      Screen screen = new Screen(100.0f, 100.0f);
      Controls.Desktop.InputControl control = new Controls.Desktop.InputControl();
      screen.Desktop.Children.Add(control);

      screen.InjectCharacter('a');
      Assert.AreEqual(string.Empty, control.Text);

      screen.FocusedControl = control;

      screen.InjectCharacter('a');
      Assert.AreEqual("a", control.Text);
    }
예제 #16
0
    public void TestGuideTitleAndDescription() {
      InputControl input = new InputControl();
      input.GuideTitle = "Test123";
      input.GuideDescription = "123Test";

      IWritable writable = input as IWritable;
      Assert.IsNotNull(writable);
      
      Assert.AreEqual("Test123", writable.GuideTitle);
      Assert.AreEqual("123Test", writable.GuideDescription);
    }
예제 #17
0
    public void TestTextShorteningAdjustsCaret() {
      Screen screen = new Screen();
      InputControl input = new InputControl();
      screen.Desktop.Children.Add(input);
      screen.FocusedControl = input;

      input.Text = "Hello World";
      input.CaretPosition = 11;

      Assert.AreEqual(11, input.CaretPosition);

      input.Text = "Hello";

      Assert.AreEqual(5, input.CaretPosition);
    }
예제 #18
0
    public void TestThrowOnInvalidCaretPosition() {
      Screen screen = new Screen();
      InputControl input = new InputControl();
      screen.Desktop.Children.Add(input);
      screen.FocusedControl = input;

      Assert.Throws<ArgumentException>(
        delegate() {
          input.CaretPosition = -1;
        }
      );
      Assert.Throws<ArgumentException>(
        delegate() {
          input.CaretPosition = 1;
        }
      );
    }
예제 #19
0
        private void IngresoNuevoUsuario(Screen mainScreen)
        {
            LabelControl  nameEntryLabel = new Nuclex.UserInterface.Controls.LabelControl();
            InputControl  nameEntryBox   = new Nuclex.UserInterface.Controls.Desktop.InputControl();
            ButtonControl okButton       = new Nuclex.UserInterface.Controls.Desktop.ButtonControl();
            WindowControl w = new WindowControl();

            //
            // nameEntryLabel
            //
            nameEntryLabel.Text   = "Por favor elija su nombre";
            nameEntryLabel.Bounds = new UniRectangle(
                graphics.PreferredBackBufferWidth / 2 - 75, 200, 150, 50
                );
            mainScreen.Desktop.Children.Add(nameEntryLabel);

            //
            // nameEntryBox
            //
            nameEntryBox.Bounds = new UniRectangle(
                graphics.PreferredBackBufferWidth / 2 - 150, 280, 300, 30
                );
            mainScreen.Desktop.Children.Add(nameEntryBox);

            //
            //okButton
            //
            okButton.Text   = "Guardar";
            okButton.Bounds = new UniRectangle(
                graphics.PreferredBackBufferWidth / 2 - 100, 360, 200, 30
                );

            mainScreen.Desktop.Children.Add(okButton);
            okButton.Pressed += delegate(object sender, EventArgs arguments)
            {
                if ((JugadorExistenteEnArchivo(nameEntryBox.Text)) || (nameEntryBox.Text.Trim() == ""))
                {
                    okButton.Enabled = false;

                    WindowControl window = new WindowControl();
                    window.Title = "Error";

                    LabelControl labelExiste = new LabelControl("El jugador ingresado ya existe o es invalido");
                    labelExiste.Bounds = new UniRectangle(10.0f, 30.0f, 120.0f, 15.0f);

                    ButtonControl aceptarButton = new ButtonControl();
                    aceptarButton.Text   = "Aceptar";
                    aceptarButton.Bounds = new UniRectangle(110, 60, 80, 30);

                    window.Bounds = new UniRectangle(graphics.PreferredBackBufferWidth / 2 - 150, 450, 300, 100);
                    window.Children.Add(labelExiste);
                    window.Children.Add(aceptarButton);

                    mainScreen.Desktop.Children.Add(window);

                    aceptarButton.Pressed += delegate(object senderWindow, EventArgs argumentsWindow)
                    {
                        okButton.Enabled = true;
                        window.Close();
                    };
                }
                else
                {
                    nombre = nameEntryBox.Text;
                    StreamWriter sw = new StreamWriter("Jugadores.txt", true);

                    sw.WriteLine(nameEntryBox.Text.Trim());

                    sw.Close();

                    mainScreen.Desktop.Children.Clear();
                    menuUsuarioNuevo = false;
                    menuGeneral      = true;
                }
            };
        }
예제 #20
0
        private void LoadContent(Screen mainScreen, ContentManager content)
        {
            background = content.Load<Texture2D>("Images\\MainMenu\\background1");
            backgroundMusic = content.Load<Song>("Music\\02 Gunbound- The Lobby");

            LabelControl usernameLabel = new LabelControl("Username");
            usernameLabel.Bounds = new UniRectangle(16, 27, 83, 24);
            usernameLabel.Name = "Label Username";

            usernameInput = new InputControl();
            usernameInput.Bounds = new UniRectangle(106, 27, 216, 26);
            usernameInput.Name = "Input Username";

            ButtonControl loginGameButton = new ButtonControl();
            loginGameButton.Bounds = new UniRectangle(32, 82, 120, 35);
            loginGameButton.Name = "Login Button";
            loginGameButton.imageTexture = content.Load<Texture2D>("Images\\MainMenu\\Login");
            loginGameButton.imageHover = content.Load<Texture2D>("Images\\MainMenu\\Login-hover");
            loginGameButton.Pressed += new EventHandler(loginPressed);

            ButtonControl exitGameButton = new ButtonControl();
            exitGameButton.Bounds = new UniRectangle(185, 82, 120, 35);
            exitGameButton.Name = "Exit Button";
            exitGameButton.imageTexture = content.Load<Texture2D>("Images\\MainMenu\\exitb");
            exitGameButton.imageHover = content.Load<Texture2D>("Images\\MainMenu\\exitb-hover");
            exitGameButton.Pressed += new EventHandler(exitPressed);

            mainScreen.Desktop.Children.Add(usernameLabel);
            mainScreen.Desktop.Children.Add(usernameInput);
            mainScreen.Desktop.Children.Add(loginGameButton);
            mainScreen.Desktop.Children.Add(exitGameButton);

            inputService.GetMouse().MouseMoved += mouseMove;
            inputService.GetKeyboard().KeyPressed += keyHit;
        }