Example #1
0
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        public override void Update(GameTime gameTime)
        {
            base.Update(gameTime);

            this.UpdateDrawPositionByConfigAndParent();
            this.UpdateDrawSizeByConfig();
        }
Example #2
0
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        public override void Update(GameTime gameTime)
        {
            // **** do the basic stuff
            base.Update(gameTime);

            if (Config.Changed)
            {
                this.RedrawSizeControl = true;
                this.RedrawTitleControl = true;

                this.UpdateDrawSourceRectangleByConfig();
                this.UpdateDrawPositionByConfigAndParent();
                this.UpdateDrawSizeByConfig();

                Manager.ImageCompositor.Delete(this.CurrentTextureName);
                this.CurrentTextureName = Manager.ImageCompositor.CreateRectangleTexture(
                                        this.Name,
                                        (int)State.Width,
                                        (int)State.Height,
                                        Theme.BorderWidth,
                                        Theme.WindowFillColor,
                                        Theme.BorderColor);
                Config.ResetChanged();
            }
        }
Example #3
0
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        public override void Update(GameTime gameTime)
        {
            // do the basic stuff first
            base.Update(gameTime);

            if (Config.Changed)
            {
                Config.ResetChanged();
                this.SetVisibility();
            }

            // take the config position , and stick it in the current visual state
            this.UpdateDrawPositionByConfigAndParent();

            // the next code will be all about dragging
            if (!this.Dragging)
            {
                return;
            }

            // find out the movement, compared to from the point where we started dragging
            this.DragCurrent = this.PointRelative(Manager.InputManager.ReadMouseLocation());
            var delta = DragCurrent - DragStart;

            // Debug.WriteLine("Dragging is now at " + DragCurrentLocation + " with Delta " + delta);

            // move the indicator the distance as the mouse moved.
            this.IndicatorCurrent = this.IndicatorStartPosition + delta;

            // Debug.WriteLine("'New Indicator location " + IndicatorCurrent);
            // force the new location for the indicator in between the min and max button
            var scrollIndicatorLocationX = IndicatorCurrent.X;
            if (scrollIndicatorLocationX < MinButton.Config.PositionX + MinButton.Config.Width)
            {
                scrollIndicatorLocationX = MinButton.Config.PositionX + MinButton.Config.Width;
            }

            if (scrollIndicatorLocationX + ScrollIndicator.Config.Width > MaxButton.Config.PositionX)
            {
                scrollIndicatorLocationX = MaxButton.Config.PositionX - ScrollIndicator.Config.Width;
            }

            // convert the new Indicator location into a new value , and use that value
            var scrollIndicatorDrawnCentre = scrollIndicatorLocationX + (ScrollIndicator.Config.Width / 2);

            // get the minimum that the drawn center for the indicator can be set
            var left = MinButton.Config.Width + (ScrollIndicator.Config.Width / 2);

            // get the maximum that the drawn center for the indicator can be set
            var right = Config.Width - MaxButton.Config.Width - (ScrollIndicator.Config.Width / 2);

            var percentage = (scrollIndicatorDrawnCentre - left) / (right - left);
            Debug.WriteLine((int)(percentage * 100) + "%");
            var value = ConfigMin + ((ConfigMax - ConfigMin) * percentage);
            Debug.WriteLine("message" + value);
            this.ConfigValue = value;
        }
Example #4
0
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        public override void Update(GameTime gameTime)
        {
            base.Update(gameTime);

            if (Config.Changed)
            {
                this.Text.Config.Visible = this.Config.Visible;
            }
        }
Example #5
0
        /// <summary>
        /// Updates the scene-graph.
        /// And finds the control that has focus.
        /// </summary>
        /// <param name="gameTime">The game time.</param>
        public void Update(GameTime gameTime)
        {
            // update the scene graph
            Debug.Assert(this.sceneGraph != null, "SceneGraph can never be null ! Fix this.");
            this.sceneGraph.Update(gameTime);

            // Calculate focus based on update index
            this.FindFocusedControl();
        }
Example #6
0
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        public override void Update(GameTime gameTime)
        {
            base.Update(gameTime);

            if (this.MustRedraw)
            {
                this.MustRedraw = false;
                this.Redraw();
            }
        }
Example #7
0
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        public override void Update(GameTime gameTime)
        {
            base.Update(gameTime);

            this.UpdateDrawPositionByConfigAndParent();
            this.UpdateDrawSizeByConfig();
            this.UpdateDrawSourceRectangleByConfig();

            if (this.CheckIsFocused())
            {
            }
        }
Example #8
0
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        public override void Update(GameTime gameTime)
        {
            base.Update(gameTime);

            var pos = Manager.InputManager.ReadMouseLocation();
            Config.PositionX = pos.X;
            Config.PositionY = pos.Y;

            State.DrawPosition = new DVector2(pos.X, pos.Y);
            State.Offset = new DVector2(-Config.Width / 8, -Config.Height / 8);
            State.Width = Config.Width / 4;
            State.Height = Config.Height / 4;
        }
Example #9
0
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        public override void Update(GameTime gameTime)
        {
            if (Config.Changed)
            {
                this.Config.ResetChanged();
                this.SetVisibility();
            }

            base.Update(gameTime);

            this.UpdateDrawPositionByConfigAndParent();

            if (!this.Dragging)
            {
                return;
            }

            // find out the movement, compared to from the point where we started dragging
            this.DragCurrent = this.PointRelative(Manager.InputManager.ReadMouseLocation());
            var delta = DragCurrent - DragStart;

            //// Debug.WriteLine("Dragging is now at " + DragCurrentLocation + " with Delta " + delta);

            // move the indicator the distance as the mouse moved.
            this.IndicatorCurrent = this.IndicatorStartPosition + delta;

            //// Debug.WriteLine("'New Indicator location " + IndicatorCurrent);

            // force the new location for the indicator in between the min and max button
            var indicatorLocationY = IndicatorCurrent.Y;
            if (indicatorLocationY < MinButton.Config.PositionY + MinButton.Config.Height)
            {
                indicatorLocationY = MinButton.Config.PositionY + MinButton.Config.Height;
            }

            if (indicatorLocationY + ScrollIndicator.Config.Height > MaxButton.Config.PositionY)
            {
                indicatorLocationY = MaxButton.Config.PositionY - ScrollIndicator.Config.Height;
            }

            // convert the new Indicator location into a new value , and use that value
            var scrollIndicatorDrawnCentre = indicatorLocationY + (ScrollIndicator.Config.Height / 2);
            var top = MinButton.Config.Height + (ScrollIndicator.Config.Height / 2); // get the minimum that the drawn center for the indicator can be set
            var bottom = Config.Height - MaxButton.Config.Height - (ScrollIndicator.Config.Height / 2); // get the maximum that the drawn center for the indicator can be set
            var percentage = (scrollIndicatorDrawnCentre - top) / (bottom - top);
            Debug.WriteLine((int)(percentage * 100) + "%");
            var value = ConfigMin + ((ConfigMax - ConfigMin) * percentage);
            Debug.WriteLine("message" + value);
            this.ConfigValue = value;
        }
Example #10
0
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        public override void Update(GameTime gameTime)
        {
            base.Update(gameTime);

            // use all current configuration towards current visual state
            this.UpdateDrawPositionByConfigAndParent();
            this.UpdateDrawSizeByConfig();

            // if we have a change in config.. then take it to the text-box too
            if (Config.Changed)
            {
                this.Text.Config.Visible = this.Config.Visible;
            }

            // if the mouse is over me
            var hover = State.MouseHoveringOver;
            if (hover)
            {
                // show that the mouse is over me
                this.CurrentTextureName = this.TextureNameHover;

                // read the mouse
                var mousePress = Manager.InputManager.ReadLeftMousePressed();
                if (mousePress == true && this.mouseClicked == false)
                {
                    this.mouseClicked = true;
                    this.RaiseMouseClick();
                }

                var mouseReleased = Manager.InputManager.ReadLeftMouseReleased();
                if (mouseReleased)
                {
                    this.mouseClicked = false;
                }
            }
            else
            {
                // show that the mouse is not over me
                this.CurrentTextureName = this.TextureNameDefault;
            }
        }
Example #11
0
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        public override void Update(GameTime gameTime)
        {
            // do the basic stuff first
            base.Update(gameTime);

            // get all the values from current configuration , 
            // and create a visual state that can be drawn from it
            this.UpdateDrawPositionByConfigAndParent();
            this.UpdateDrawSizeByConfig();
            this.UpdateDrawSourceRectangleByConfig();

            // Update the title
            this.TextLabel.ConfigText = this.ConfigText;

            // take mouse input
            var leftMousePressed = this.Manager.InputManager.ReadLeftMousePressed();
            var leftMouseReleased = this.Manager.InputManager.ReadLeftMouseReleased();

            // is the control visible ?
            if (this.Config.Visible)
            {
                // Is mouse hovering over, and does the control have focus ?
                if (this.State.MouseHoveringOver && this.CheckIsFocused())
                {
                    // Is there a mouse press and the button is OFF ? 
                    if (leftMousePressed && this.StateIsPressed == false)
                    {
                        this.StateIsPressed = true;
                    }
                    else if (leftMouseReleased && this.StateIsPressed == true)
                    {
                        this.StateIsPressed = false;
                    }
                }
                else if (leftMouseReleased)
                {
                    this.StateIsPressed = false;
                }
            }
        }
Example #12
0
File: Grid.cs Project: xxy1991/cozy
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        public override void Update(GameTime gameTime)
        {
            base.Update(gameTime);

            if (this.mustredraw)
            {
                this.Calculate();
                this.Populate();

                this.CurrentTextureName = Manager.ImageCompositor.CreateRectangleTexture(this.Name + "-Background", (int)Config.Width, (int)Config.Height, 1, Theme.WindowFillColor, Theme.BorderColor);
                this.mustredraw = false;
            }
        }
Example #13
0
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        public override void Update(GameTime gameTime)
        {
            base.Update(gameTime);

            this.colorBoxGradient.HSL = this.slider.HSL;
            this.colorBoxSolid.HSL = this.colorBoxGradient.HSL;
        }
Example #14
0
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        public override void Update(GameTime gameTime)
        {
            base.Update(gameTime);

            var pos = Manager.InputManager.ReadMouseLocation();
            Config.PositionX = pos.X;
            Config.PositionY = pos.Y;
            State.DrawPosition = new DVector2(pos.X, pos.Y) + new DVector2(10, 0);
            this.Label.ConfigText = this.GetParentTooltipText();

            // check if parent has focus , if not: turn off drawing
            if (this.Parent != null)
            {
                this.parentHasFocus = Parent.CheckIsFocused();
            }
        }
Example #15
0
 /// <summary>
 /// Allows the game to run logic such as updating the world,
 /// checking for collisions, gathering input, and playing audio.
 /// </summary>
 /// <param name="gameTime">Provides a snapshot of timing values.</param>
 public override void Update(GameTime gameTime)
 {
     this.UpdateDrawPositionByConfigAndParent();
     this.UpdateTextWhenNeeded();
 }
Example #16
0
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        public override void Update(GameTime gameTime)
        {
            // set draw-position
            if (this.Parent == null)
            {
                return;
            }

            var newPosition = Parent.State.DrawPosition + new DVector2(Config.PositionX, Config.PositionY);
            State.DrawPosition = newPosition;
        }
Example #17
0
        public void UpdateKeyboardInput(GameTime gameTime)
        {
#if DEBUG
            if (gameTime == null)
            {
                throw new ArgumentNullException("gameTime", "Gametime is used here, can not be null.");
            }
#endif

            // read the keyboard state
            this.keyboardState = Keyboard.GetState();

            if (this.DebugMode)
            {
                var s = "Pressed keys";

                foreach (var pressedKey in this.keyboardState.GetPressedKeys())
                {
                    s = string.Format("{0} {1}", s, pressedKey);
                }

                Debug.WriteLine(s);

                this.PressedKeys = s;
            }

            // Remove any keys from last pressed keys if time has expired, or if they're released
            // Use a fast repeat keys list after the initial delay to input keys faster after being held down for a short time (windows textbox-like behavior)
            // What it does is catch the last pressed keys, and if they are pressed long enough, convert them to fast-repeat keys
            var culledKeys = new List<Keys>();

            // list of keys that can be repeated again because they have timed out or key is lifted
            foreach (var keyPair in this.lastPressedKeys)
            {
                if (this.keyboardState.IsKeyUp(keyPair.Key))
                {
                    if (this.fastRepeatKeys.Contains(keyPair.Key))
                    {
                        this.fastRepeatKeys.Remove(keyPair.Key);
                    }

                    culledKeys.Add(keyPair.Key);
                }
                else
                {
                    var keyTimeSpan = gameTime.TotalGameTime - keyPair.Value;

                    if (keyTimeSpan > this.keyRepeatTime && !this.fastRepeatKeys.Contains(keyPair.Key))
                    {
                        // Input key and then add to the fast list
                        culledKeys.Add(keyPair.Key);
                        this.fastRepeatKeys.Add(keyPair.Key);
                    }
                    else if (keyTimeSpan > this.fastKeyRepeatTime && this.fastRepeatKeys.Contains(keyPair.Key))
                    {
                        // Fast repeat
                        culledKeys.Add(keyPair.Key);
                    }
                }
            }

            foreach (var key in culledKeys)
            {
                this.lastPressedKeys.Remove(key);
            }

            if (this.lastPressedKeys.Count != this.lastPressedKeysCount)
            {
                KeySwitches.ChangeText = true;
                this.lastPressedKeysCount = this.lastPressedKeys.Count;
            }

            // ****************************************** do the commands ******************************************

            // Select All (Ctrl+A)
            if (KeyFilter.IsSelectAll(this.keyboardState))
            {
                this.RaiseSelectAll();
            }

            // Left Shift Control 
            if (KeyFilter.IsLeftShiftControl(this.keyboardState))
            {
                return;
            }

            // Backspace
            if (KeyFilter.IsBackspace(this.keyboardState) && !this.lastPressedKeys.ContainsKey(Keys.Back))
            {
                this.RaiseKeyBackSpace();
                this.lastPressedKeys.Add(Keys.Back, gameTime.TotalGameTime);
            }
            else if (KeyFilter.IsDelete(this.keyboardState) && !this.lastPressedKeys.ContainsKey(Keys.Delete))
            {
                // Delete
                this.RaiseKeyDelete();
                this.lastPressedKeys.Add(Keys.Delete, gameTime.TotalGameTime);
            }
            else if (KeyFilter.IsEnter(this.keyboardState) && this.Text.Length > 0 && !this.lastPressedKeys.ContainsKey(Keys.Enter))
            {
                // Enter
                this.lastPressedKeys.Add(Keys.Enter, gameTime.TotalGameTime);
                this.RaiseEnterPressed();
            }
            else
            {
                string textToInsert = null;
                var keys = this.keyboardState.GetPressedKeys();

                foreach (var key in keys)
                {
                    if (this.lastPressedKeys.ContainsKey(key))
                    {
                        continue;
                    }

                    // if key is left or if key is right
                    if (KeyFilter.IsKeyLeft(key))
                    {
                        this.RaiseGoLeft();
                    }
                    else if (KeyFilter.IsKeyRight(key))
                    {
                        this.RaiseGoRight();
                    }
                    
                    // if key is a number
                    if (KeyFilter.IsKeyNumber(key))
                    {
                        if (KeyFilter.IsKeyLeftShift(this.keyboardState))
                        {
                            textToInsert += key.ToString().Replace("D", string.Empty);
                        }
                        else
                        {
                            textToInsert += KeyFilter.ParseNumbersAsShifted(key);
                        }
                    }
                    else if (KeyFilter.IsKeyAlphabet(key))
                    {
                        // if key is a character from the alphabet
                        if (this.keyboardState.IsKeyUp(Keys.LeftShift) && this.keyboardState.IsKeyUp(Keys.CapsLock))
                        {
                            textToInsert += key.ToString().ToLower();
                        }
                        else
                        {
                            textToInsert += key;
                        }
                    }
                    else
                    {
                        // if the key is uppercase
                        if (KeyFilter.IsKeyLeftShift(this.keyboardState))
                        {
                            textToInsert += KeyFilter.ParseSpecialAsShifted(key);
                        }
                        else
                        {
                            textToInsert += KeyFilter.ParseSpecialAsNormal(key);
                        }

                        // if there is a spacebar
                        if (KeyFilter.IsKeySpacebar(key))
                        {
                            textToInsert += " ";
                        }
                    }

                    // if the key is grammatical
                    if (KeyFilter.IsKeyGrammatical(key))
                    {
                        textToInsert += key;
                    }

                    // If we have input a valid string
                    if (string.IsNullOrEmpty(textToInsert) == false)
                    {
                        this.RaiseInsertText(textToInsert);
                    }

                    this.lastPressedKeys.Add(key, gameTime.TotalGameTime);
                }
            }
        }
Example #18
0
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        public override void Update(GameTime gameTime)
        {
            base.Update(gameTime);

            // calculate the draw position , by adding my parents pos + my pos + where the cursor should be
            State.DrawPosition = Parent.State.DrawPosition + new DVector2(Config.PositionX, Config.PositionY);

            // set cursor-blink on or off per time chunk
            if (this.cursorFlashCounter >= CursorFlashTime)
            {
                this.ConfigBlinking = !this.ConfigBlinking;
                this.cursorFlashCounter = 0;
                if (this.ConfigDebugMode)
                {
                    Debug.WriteLine("Blink : " + this.ConfigBlinking);
                }
            }

            this.cursorFlashCounter++;
        }
Example #19
0
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        public override void Update(GameTime gameTime)
        {
            // retrieve the mouse pressed
            var leftMousePressed = Manager.InputManager.ReadLeftMousePressed();
            var leftMouseReleased = Manager.InputManager.ReadLeftMouseReleased();

            // update the label
            if (this.ConfigText != Label.ConfigText)
            {
                Label.ConfigText = this.ConfigText;
            }

            // update the visibility
            if (this.Config.Changed)
            {
                this.Config.ResetChanged();
                this.Label.Config.Visible = this.Config.Visible;
            }

            // is the control visible ?
            if (Config.Visible)
            {
                // Is mouse hovering over, and does the control have focus ?
                if (State.MouseHoveringOver && this.CheckIsFocused())
                {
                    this.CurrentTextureName = this.TextureNameHover;

                    // Is there a mouse press and the button is OFF ? 
                    if (leftMousePressed && this.ButtonState == ButtonState.Off)
                    {
                        this.RaiseMouseDownEvent(gameTime);
                        this.CurrentTextureName = this.textureNameLeftMouseDown;
                        this.ButtonState = ButtonState.On;
                    }
                    else if (leftMouseReleased && this.ButtonState == ButtonState.On)
                    {
                        this.ButtonState = ButtonState.Off;

                        Config.HoverColorsEnabled = true;

                        this.RaiseMouseUpEvent(gameTime);
                        this.RaiseMouseClickEvent(gameTime);
                    }
                }
                else
                {
                    this.CurrentTextureName = this.TextureNameDefault;

                    // turn it off if the mouse hovers off it
                    if (this.ButtonState == ButtonState.On)
                    {
                        this.ButtonState = ButtonState.Off;
                        this.RaiseMouseUpEvent(gameTime);
                    }
                }
            }

            base.Update(gameTime);
        }
Example #20
0
        /// <summary>Tells that we start drawing , draws the scene-graph ,  and them stops the drawing.</summary>
        /// <param name="gameTime">The game time.</param>
        public void Draw(GameTime gameTime)
        {
            Debug.Assert(this.sceneGraph != null, "SceneGraph can never be null ! Fix this.");

            ImageCompositor.BeginDraw();
            this.sceneGraph.Draw(gameTime);
            ImageCompositor.EndDraw();
        }
Example #21
0
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        public override void Update(GameTime gameTime)
        {
            // do the basic stuff first
            base.Update(gameTime);

            // ? huh no code to take config into visual-state ?
            // get all the values from current configuration , 
            // and create a visual state that can be drawn from it
            this.UpdateDrawPositionByConfigAndParent();
            this.UpdateDrawSizeByConfig();
            this.UpdateDrawSourceRectangleByConfig();

            // redraw the title if we must
            this.RedrawTitleControl = true;
            if (this.RedrawTitleControl == true)
            {
                this.RedrawTitleControl = false;
                this.TitleBar.ConfigText = this.title;
                this.TitleBar.Config.Width = this.Config.Width;
            }

            // redraw the sizer if we must
            this.RedrawSizeControl = true;
            if (this.RedrawSizeControl == true)
            {
                this.RedrawSizeControl = false;
                this.SizingCorner.Config.PositionX = this.Config.Width - this.SizingCorner.Config.Width;
                this.SizingCorner.Config.PositionY = this.Config.Height - this.SizingCorner.Config.Height;
            }

            // redraw the menu-bar if we must
            this.RedrawMenuBarControl = true;
            if (this.RedrawMenuBarControl == true)
            {
                this.RedrawMenuBarControl = false;
                this.MenuBarHorizontal.WindowModus = true;
                this.MenuBarHorizontal.Config.Width = this.Config.Width - 2;
                this.MenuBarHorizontal.Config.PositionX = 1;
                this.MenuBarHorizontal.Config.PositionY = this.TitleBar.Config.Height;
                this.MenuBarHorizontal.Config.Height = this.Theme.ControlHeight;
            }

            // read dragging
            this.ReadIfDragging();
            this.ReadIfEndDragging();
            if (this.Dragging)
            {
                // find out the movement, compared to from the point where we started dragging
                if (this.Parent != null)
                {
                    this.DragCurrentLocation = this.Parent.PointRelative(this.Manager.InputManager.ReadMouseLocation());
                }
                else
                {
                    this.DragCurrentLocation = this.Manager.InputManager.ReadMouseLocation();
                }

                var delta = this.DragCurrentLocation - this.DragStartLocation;
                var formCurrent = this.WindowDragStartLocation + delta;
                this.Config.PositionX = formCurrent.X;
                this.Config.PositionY = formCurrent.Y;
                // this.Title = string.Format("{0},{1}", this.Config.PositionX, this.Config.PositionY);
                this.UpdateDrawPositionByConfigAndParent();
            }
        }
Example #22
0
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        public override void Update(GameTime gameTime)
        {
            base.Update(gameTime);

            if (this.mustRedraw)
            {
                this.RedrawControl();
            }

            this.UpdateDrawPositionByConfigAndParent();
            this.UpdateDrawSizeByConfig();
            this.UpdateDrawSourceRectangleByConfig();

            var leftMousePressed = Manager.InputManager.ReadLeftMousePressed();
            var mouseLocation = Manager.InputManager.ReadMouseLocation();

            if (this.CheckIsFocused() && leftMousePressed)
            {
                this.dragging = true;
            }

            if (this.dragging && leftMousePressed)
            {
                var relativeLocation = PointRelative(mouseLocation);
                this.sliderValue = relativeLocation.Y / Config.Height;
                this.RedrawControl();
                this.TakeValue(this.sliderValue);
                Debug.WriteLine("Rel " + relativeLocation + " val " + this.sliderValue);
            }

            if (this.dragging && leftMousePressed == false)
            {
                this.dragging = false;
            }
        }
Example #23
0
 /// <summary>
 /// Initializes a new instance of the <see cref="GameTimeEventArgs"/> class.
 /// </summary>
 /// <param name="gameTime">The game time.</param>
 public GameTimeEventArgs(GameTime gameTime)
 {
     this.GameTime = gameTime;
 }
Example #24
0
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        public override void Update(GameTime gameTime)
        {
            base.Update(gameTime);
            if (this.mustRevalidate)
            {
                this.Revalidate();
                this.mustRevalidate = false;
            }

            if (this.mustRedraw)
            {
                this.Redraw();
                this.mustRedraw = false;
            }
        }
Example #25
0
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        public virtual void Update(GameTime gameTime)
        {
            if (this.mustReload)
            {
                this.mustReload = false;
                this.UnloadContent();
                this.IsLoaded = false;
            }

            this.UpdateDrawPositionByConfigAndParent();
        }
Example #26
0
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        public override void Update(GameTime gameTime)
        {
            base.Update(gameTime);

            this.UpdateDrawPositionByConfigAndParent();
            this.UpdateDrawSizeByConfig();
            this.UpdateDrawSourceRectangleByConfig();

            var leftMousePressed = Manager.InputManager.ReadLeftMousePressed();
            var mouseLocation = Manager.InputManager.ReadMouseLocation();

            // check the redraw FLAG !
            if (this.redrawControlFlag == true)
            {
                this.RedrawControl();
                this.redrawControlFlag = false;
            }

            if (this.CheckIsFocused() && leftMousePressed)
            {
                this.dragging = true;
            }

            if (this.dragging && leftMousePressed)
            {
                var relativeLocation = PointRelative(mouseLocation);
                this.gradientValue = new DVector2(relativeLocation.X / Config.Width, relativeLocation.Y / Config.Height);
                this.redrawControlFlag = true;
                this.TakeValue(this.gradientValue);
                Debug.WriteLine("Rel " + relativeLocation + " val " + this.gradientValue);
            }

            if (this.dragging && leftMousePressed == false)
            {
                this.dragging = false;
            }
        }
Example #27
0
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        public override void Update(GameTime gameTime)
        {
            base.Update(gameTime);

            if (this.doRebuild)
            {
                this.doRebuild = false;
                this.textBoxUtility.ValidateAndRepair(this);
            }

            if (this.CheckIsFocused() && Config.Enabled && !this.ReadOnly)
            {
                // do keyboard
                Manager.InputManager.UpdateKeyboardInput(gameTime);
                this.ReadKeyboardMessages();

                // show cursor
                this.TextBoxCursor.ConfigShowCursor = true;
            }
            else
            {
                // hide cursor
                this.TextBoxCursor.ConfigShowCursor = false;
            }
        }
Example #28
0
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        public override void Update(GameTime gameTime)
        {
            base.Update(gameTime);

            var leftPressed = this.Manager.InputManager.ReadLeftMousePressed();
            if (leftPressed)
            {
                Debug.WriteLine("ComboBox pressed !");
            }

            ////if (!_dropDownButton.State.MouseHoveringOver && !DropDownList.State.MouseHoveringOver && leftPressed && _listShown)
            ////{
            ////    _dropDownButton.Toggle(this, new ButtonStateEventArgs(ButtonState.Off));
            ////    OnToggleDropDown(this, new ButtonStateEventArgs(ButtonState.Off));
            ////}
        }
Example #29
0
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        public override void Update(GameTime gameTime)
        {
            base.Update(gameTime);

            this.UpdateDrawPositionByConfigAndParent();
            this.UpdateDrawSizeByConfig();
            this.UpdateDrawSourceRectangleByConfig();

            if (this.mustRedraw)
            {
                this.Redraw();
                this.mustRedraw = false;
            }
        }
Example #30
0
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        public override void Update(GameTime gameTime)
        {
            base.Update(gameTime);
            this.UpdateDrawPositionByConfigAndParent();
            this.UpdateDrawSizeByConfig();

            if (this.mustRedrawBox)
            {
                this.RedrawBox();
            }

            if (this.ConfigDebug)
            {
                var rnd = new Random();
                var r = rnd.Next(255);
                var g = rnd.Next(255);
                var b = rnd.Next(255);
                var a = rnd.Next(255);
                this.RGBA = new GUIColor((byte)r, (byte)g, (byte)b, (byte)a);
            }
        }