Example #1
0
 /// <summary>
 /// This is the event handler that occurs when the form is opened
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void BMICalculator_Load(object sender, EventArgs e)
 {
     ImperialRadioButton.Checked = true;
     BackSpaceButton.Hide();
     ZeroButton.Hide();
     OneButtton.Hide();
     TwoButton.Hide();
     ThreeButton.Hide();
     FourButton.Hide();
     FiveButton.Hide();
     SixButton.Hide();
     SevenButton.Hide();
     EightButton.Hide();
     NineButton.Hide();
     this.ProgressBar.Increment(10);
     HeightTextBox.Enabled = true;
     WeightTextBox.Enabled = true;
 }
Example #2
0
 /// <summary>
 /// When the HeightTextBox is clicked, the following code starts functioning
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void HeightTextBox_Click(object sender, EventArgs e)
 {
     OneButtton.Show();
     TwoButton.Show();
     ThreeButton.Show();
     FourButton.Show();
     FiveButton.Show();
     SixButton.Show();
     SevenButton.Show();
     EightButton.Show();
     NineButton.Show();
     BackSpaceButton.Show();
     HeightTextBox.Enabled = true;
     if ((ImperialRadioButton.Checked) || (MetricRadioButton.Checked))
     {
         if (HeightTextBox.Text != "")
         {
             ProgressBar.Value = 25;
         }
     }
 }
Example #3
0
        // Calculator_KeyPress: Checks for user input through KeyPresses and performs
        // the corresponding Click-event for the appropriate button.
        // Pre: -
        // Post: The KeyPress-event has been handled and, if there's a match, the appropriate
        // buttons Click-event has been fired.
        private void Calculator_KeyPress(object sender, KeyPressEventArgs e)
        {
            switch (e.KeyChar)
            {
            case '1': OneButton.PerformClick(); break;

            case '2': TwoButton.PerformClick(); break;

            case '3': ThreeButton.PerformClick(); break;

            case '4': FourButton.PerformClick(); break;

            case '5': FiveButton.PerformClick(); break;

            case '6': SixButton.PerformClick(); break;

            case '7': SevenButton.PerformClick(); break;

            case '8': EightButton.PerformClick(); break;

            case '9': NineButton.PerformClick(); break;

            case '0': ZeroButton.PerformClick(); break;

            case '/': DivideButton.PerformClick(); break;

            case '*': MultiplyButton.PerformClick(); break;

            case '-': SubtractButton.PerformClick(); break;

            case '+': AddButton.PerformClick(); break;

            case ',': CommaButton.PerformClick(); break;

            case 'C': ClearButton.PerformClick(); break;

            case 'c': ClearButton.PerformClick(); break;
            }
            e.Handled = true;
        }
Example #4
0
        /* The CreateControls() function sets up the screen with everything it needs to display properly. */
        private void CreateControls()
        {
            /* First, the background texture sheet is loaded in using Content.Load<T>().
             * Then, a new array is made to hold the Rectangle of each individual background on the sheet.
             * The array is filled with the correct Rectangles, which are each 240x112 pixels.
             * As there are three backgrounds per row on the sheet, the x coordinate is found using modulo function and the y coordinate by floor division. */
            backgroundSheet = Game.Content.Load <Texture2D>(@"Backgrounds/battlescreen");
            backgroundRects = new Rectangle[12];
            for (int i = 0; i < backgroundRects.Length; i++)
            {
                int x = (i % 3) * 240;
                int y = (i / 3) * 112;
                backgroundRects[i] = new Rectangle(x, y, 240, 112);
            }

            /* The background, player Pokemon, and opponent Pokemon picture boxes are constructed with the images corresponding to the first Pokemon in their team. */
            background = new PictureBox(backgroundSheet, new Rectangle(0, 0, 640, 300));
            ControlManager.Add(background);

            playerPokemon = new PictureBox(DataManager.PkmnBackSprites[battle.CurrentPlayer.PokemonID], new Rectangle(0, 92, 288, 288));
            ControlManager.Add(playerPokemon);

            opponentPokemon = new PictureBox(DataManager.PkmnFrontSprites[battle.CurrentOpponent.PokemonID], new Rectangle(325, 0, 288, 288));
            ControlManager.Add(opponentPokemon);

            /* The FourButton menu is initialized with the FourButton background, and its position and size are set to clamp it to the bottom of the screen.
             * It has the BattleFont and is added to the ControlManager. */
            mainMenu            = new FourButton(Game.Content.Load <Texture2D>(@"Backgrounds/fourButton"));
            mainMenu.Position   = new Vector2(0, 300);
            mainMenu.Size       = new Vector2(GameRef.ScreenRectangle.Width, GameRef.ScreenRectangle.Height - mainMenu.Position.Y);
            mainMenu.SpriteFont = Game.Content.Load <SpriteFont>(@"Fonts/BattleFont");
            ControlManager.Add(mainMenu);

            /* The BattleLog control also uses the FourButton background, and is passed a reference to the battle's log along with 0.1 seconds as the character interval.
             * As it covers the main menu, it has the same size, position, and font. */
            log            = new BattleLog(Game.Content.Load <Texture2D>(@"Backgrounds/fourButton"), battle.LogList, 0.1);
            log.Position   = mainMenu.Position;
            log.Size       = mainMenu.Size;
            log.SpriteFont = mainMenu.SpriteFont;
            ControlManager.Add(log);

            /* Each of the labels on the screen is constructed, set with its position, and added to the ControlManager so it gets updated and drawn. */
            opponentName          = new Label();
            opponentName.Position = new Vector2(0, 0);
            ControlManager.Add(opponentName);

            opponentLevel          = new Label();
            opponentLevel.Position = new Vector2(0, 20);
            ControlManager.Add(opponentLevel);

            opponentHealth          = new Label();
            opponentHealth.Position = new Vector2(0, 40);
            ControlManager.Add(opponentHealth);

            playerName          = new Label();
            playerName.Position = new Vector2(400, 200);
            ControlManager.Add(playerName);

            playerLevel          = new Label();
            playerLevel.Position = new Vector2(400, 220);
            ControlManager.Add(playerLevel);

            playerHealth          = new Label();
            playerHealth.Position = new Vector2(400, 240);
            ControlManager.Add(playerHealth);

            /* Finally, ResetBattleScreen() is called to set the menu up with the initial options and the events attached to each option.
             * UpdateLabels() will set the correct text into each of the labels on the screen. */
            ResetBattleScreen();
            UpdateLabels();
        }
        void ReleaseDesignerOutlets()
        {
            if (AboutButton != null)
            {
                AboutButton.Dispose();
                AboutButton = null;
            }

            if (AdditionButton != null)
            {
                AdditionButton.Dispose();
                AdditionButton = null;
            }

            if (ClearButton != null)
            {
                ClearButton.Dispose();
                ClearButton = null;
            }

            if (DisplayLabel != null)
            {
                DisplayLabel.Dispose();
                DisplayLabel = null;
            }

            if (DivisionButton != null)
            {
                DivisionButton.Dispose();
                DivisionButton = null;
            }

            if (EightButton != null)
            {
                EightButton.Dispose();
                EightButton = null;
            }

            if (EqualsButton != null)
            {
                EqualsButton.Dispose();
                EqualsButton = null;
            }

            if (FiveButton != null)
            {
                FiveButton.Dispose();
                FiveButton = null;
            }

            if (FourButton != null)
            {
                FourButton.Dispose();
                FourButton = null;
            }

            if (historyCalcSwipeGesture != null)
            {
                historyCalcSwipeGesture.Dispose();
                historyCalcSwipeGesture = null;
            }

            if (MultiplyButton != null)
            {
                MultiplyButton.Dispose();
                MultiplyButton = null;
            }

            if (NineButton != null)
            {
                NineButton.Dispose();
                NineButton = null;
            }

            if (OneButton != null)
            {
                OneButton.Dispose();
                OneButton = null;
            }

            if (SevenButton != null)
            {
                SevenButton.Dispose();
                SevenButton = null;
            }

            if (SixButton != null)
            {
                SixButton.Dispose();
                SixButton = null;
            }

            if (SubtractButton != null)
            {
                SubtractButton.Dispose();
                SubtractButton = null;
            }

            if (SymbolLabel != null)
            {
                SymbolLabel.Dispose();
                SymbolLabel = null;
            }

            if (ThreeButton != null)
            {
                ThreeButton.Dispose();
                ThreeButton = null;
            }

            if (TwoButton != null)
            {
                TwoButton.Dispose();
                TwoButton = null;
            }

            if (ZeroButton != null)
            {
                ZeroButton.Dispose();
                ZeroButton = null;
            }
        }
        void ReleaseDesignerOutlets()
        {
            if (ClearButton != null)
            {
                ClearButton.Dispose();
                ClearButton = null;
            }

            if (CodeLabel != null)
            {
                CodeLabel.Dispose();
                CodeLabel = null;
            }

            if (EightButton != null)
            {
                EightButton.Dispose();
                EightButton = null;
            }

            if (FiveButton != null)
            {
                FiveButton.Dispose();
                FiveButton = null;
            }

            if (FourButton != null)
            {
                FourButton.Dispose();
                FourButton = null;
            }

            if (LoginButton != null)
            {
                LoginButton.Dispose();
                LoginButton = null;
            }

            if (LoginFrameView != null)
            {
                LoginFrameView.Dispose();
                LoginFrameView = null;
            }

            if (LoginTitleLabel != null)
            {
                LoginTitleLabel.Dispose();
                LoginTitleLabel = null;
            }

            if (NineButton != null)
            {
                NineButton.Dispose();
                NineButton = null;
            }

            if (OneButton != null)
            {
                OneButton.Dispose();
                OneButton = null;
            }

            if (RoleButton != null)
            {
                RoleButton.Dispose();
                RoleButton = null;
            }

            if (RolePickerView != null)
            {
                RolePickerView.Dispose();
                RolePickerView = null;
            }

            if (SevenButton != null)
            {
                SevenButton.Dispose();
                SevenButton = null;
            }

            if (SixButton != null)
            {
                SixButton.Dispose();
                SixButton = null;
            }

            if (ThreeButton != null)
            {
                ThreeButton.Dispose();
                ThreeButton = null;
            }

            if (TwoButton != null)
            {
                TwoButton.Dispose();
                TwoButton = null;
            }

            if (ZeroButton != null)
            {
                ZeroButton.Dispose();
                ZeroButton = null;
            }
        }
Example #7
0
        private void Form1_KeyPress(object sender, KeyPressEventArgs e)
        {
            switch (e.KeyChar.ToString())
            {
            case ("0"):
                ZeroButton.PerformClick();
                break;

            case ("1"):
                OneButton.PerformClick();
                break;

            case ("2"):
                TwoButton.PerformClick();
                break;

            case ("3"):
                ThreeButton.PerformClick();
                break;

            case ("4"):
                FourButton.PerformClick();
                break;

            case ("5"):
                FiveButton.PerformClick();
                break;

            case ("6"):
                SixButton.PerformClick();
                break;

            case ("7"):
                SevenButton.PerformClick();
                break;

            case ("8"):
                EightButton.PerformClick();
                break;

            case ("9"):
                NineButton.PerformClick();
                break;

            case ("\r"):
                EqualsButton.PerformClick();
                break;

            case ("."):
                PointButton.PerformClick();
                break;

            case ("/"):
                DivideButton.PerformClick();
                break;

            case ("*"):
                TimesButton.PerformClick();
                break;

            case ("-"):
                MinusButton.PerformClick();
                break;

            case ("+"):
                PlusButton.PerformClick();
                break;
            }
        }
Example #8
0
        void ReleaseDesignerOutlets()
        {
            if (CalculateButton != null)
            {
                CalculateButton.Dispose();
                CalculateButton = null;
            }

            if (DivideButton != null)
            {
                DivideButton.Dispose();
                DivideButton = null;
            }

            if (EightButton != null)
            {
                EightButton.Dispose();
                EightButton = null;
            }

            if (FiveButton != null)
            {
                FiveButton.Dispose();
                FiveButton = null;
            }

            if (FourButton != null)
            {
                FourButton.Dispose();
                FourButton = null;
            }

            if (MinusButton != null)
            {
                MinusButton.Dispose();
                MinusButton = null;
            }

            if (MultiplyButton != null)
            {
                MultiplyButton.Dispose();
                MultiplyButton = null;
            }

            if (NineButton != null)
            {
                NineButton.Dispose();
                NineButton = null;
            }

            if (OneButton != null)
            {
                OneButton.Dispose();
                OneButton = null;
            }

            if (PlusButton != null)
            {
                PlusButton.Dispose();
                PlusButton = null;
            }

            if (ResultBox != null)
            {
                ResultBox.Dispose();
                ResultBox = null;
            }

            if (SevenButton != null)
            {
                SevenButton.Dispose();
                SevenButton = null;
            }

            if (SixButton != null)
            {
                SixButton.Dispose();
                SixButton = null;
            }

            if (ThreeButton != null)
            {
                ThreeButton.Dispose();
                ThreeButton = null;
            }

            if (TwoButton != null)
            {
                TwoButton.Dispose();
                TwoButton = null;
            }

            if (ZeroButton != null)
            {
                ZeroButton.Dispose();
                ZeroButton = null;
            }
        }