Exemple #1
0
        /// <summary>
        /// Pass back the data to the CatalogManager
        /// </summary>
        private void SaveChanges()
        {
            int   tempInt   = 0;
            float tempFloat = 0;

            _exercise    = new Exercise();
            _exercise.Id = _itemId;

            /** Check the validity of the data first for the Repitition value */
            GuiInputBox guiInputBox = (GuiInputBox)_guiDrawable[_repetitionIndex];

            if (int.TryParse(guiInputBox.Value, out tempInt))
            {
                _exercise.Repetitions = tempInt;
            }

            /** Check the validity of the data first for the Variance value */
            guiInputBox = (GuiInputBox)_guiDrawable[_varianceIndex];
            if (float.TryParse(guiInputBox.Value, out tempFloat))
            {
                _exercise.Variance = tempFloat;
            }

            _catalogManager.SetExerciseOptions(_exercise);
        }
Exemple #2
0
        /// <summary>
        /// Update the input boxes with the saved data from the CatalogManager.
        /// </summary>
        /// <param name="id">Exercise ID</param>
        public void OpenScreen(string id)
        {
            _exercise = _catalogManager.GetExercise(id);

            _itemId = _exercise.Id;

            GuiInputBox guiInputBox = (GuiInputBox)_guiDrawable[_repetitionIndex];

            guiInputBox.Value = _exercise.Repetitions.ToString();

            guiInputBox       = (GuiInputBox)_guiDrawable[_varianceIndex];
            guiInputBox.Value = _exercise.Variance.ToString();
        }
        public void InputBox_Usage()
        {
            gui = new GuiInputBox("button", new Vector2(500f, 500f), Vector2.Zero, game, 10f, 100f, 0f);

            gui.LoadContent(game, contentManager, spriteBatch);

            MouseState currentMouseState =
                new MouseState(
                    50,
                    50,
                    0,
                    ButtonState.Released,
                    ButtonState.Released,
                    ButtonState.Released,
                    ButtonState.Released,
                    ButtonState.Released
                );

            MouseState oldMouseState =
                new MouseState(
                    currentMouseState.X,
                    currentMouseState.Y,
                    currentMouseState.ScrollWheelValue,
                    ButtonState.Released,
                    currentMouseState.MiddleButton,
                    currentMouseState.RightButton,
                    currentMouseState.XButton1,
                    currentMouseState.XButton2
                );

            Assert.IsNotNull(currentMouseState);
            Assert.IsNotNull(oldMouseState);
            Assert.AreEqual(gui.Value, "10");
            Assert.AreEqual(gui.State, CheckboxState.Default);

            gui.Update(currentMouseState, oldMouseState, new Rectangle(currentMouseState.X, currentMouseState.Y, 1, 1), new GameTime());

            Assert.AreEqual(gui.State, CheckboxState.Hovered);

            oldMouseState =
                new MouseState(
                    currentMouseState.X,
                    currentMouseState.Y,
                    currentMouseState.ScrollWheelValue,
                    ButtonState.Pressed,
                    currentMouseState.MiddleButton,
                    currentMouseState.RightButton,
                    currentMouseState.XButton1,
                    currentMouseState.XButton2
                );

            gui.Update(currentMouseState, oldMouseState, new Rectangle(currentMouseState.X, currentMouseState.Y, 1, 1), new GameTime());
            Assert.AreEqual(gui.State, CheckboxState.Blinking);

            currentMouseState =
                new MouseState(
                    -100,
                    -100,
                    0,
                    ButtonState.Released,
                    ButtonState.Released,
                    ButtonState.Released,
                    ButtonState.Released,
                    ButtonState.Released
                );

            gui.Update(currentMouseState, oldMouseState, new Rectangle(currentMouseState.X, currentMouseState.Y, 1, 1), new GameTime());
            Assert.AreEqual(gui.State, CheckboxState.Blinking);

            /** uncheck */
            currentMouseState =
                new MouseState(
                    50,
                    50,
                    0,
                    ButtonState.Released,
                    ButtonState.Released,
                    ButtonState.Released,
                    ButtonState.Released,
                    ButtonState.Released
                );

            oldMouseState =
                new MouseState(
                    currentMouseState.X,
                    currentMouseState.Y,
                    currentMouseState.ScrollWheelValue,
                    ButtonState.Pressed,
                    currentMouseState.MiddleButton,
                    currentMouseState.RightButton,
                    currentMouseState.XButton1,
                    currentMouseState.XButton2
                );

            gui.Update(currentMouseState, oldMouseState, new Rectangle(currentMouseState.X, currentMouseState.Y, 1, 1), new GameTime());
            Assert.AreEqual(gui.State, CheckboxState.Blinking);

            currentMouseState =
                new MouseState(
                    -100,
                    -100,
                    0,
                    ButtonState.Released,
                    ButtonState.Released,
                    ButtonState.Released,
                    ButtonState.Released,
                    ButtonState.Released
                );

            gui.Update(currentMouseState, oldMouseState, new Rectangle(currentMouseState.X, currentMouseState.Y, 1, 1), new GameTime());
            Assert.AreEqual(gui.State, CheckboxState.Blinking);
        }