Exemple #1
0
        /// <summary>
        /// Called when the mouse exits the area of the control. Raises the MouseExit event and calls the <see cref="DetermineAppearance"/> method.
        /// </summary>
        /// <param name="state">The current mouse data</param>
        protected virtual void OnMouseExit(Input.MouseConsoleState state)
        {
            isMouseOver = false;
            MouseExit?.Invoke(this, new MouseEventArgs(state));

            DetermineAppearance();
        }
Exemple #2
0
        /// <summary>
        /// Called when the right mouse button is clicked. Raises the MouseButtonClicked event and calls the <see cref="DetermineAppearance"/> method.
        /// </summary>
        /// <param name="state">The current mouse data</param>
        protected virtual void OnRightMouseClicked(Input.MouseConsoleState state)
        {
            if (MouseButtonClicked != null)
            {
                MouseButtonClicked(this, new MouseEventArgs(state));
            }

            DetermineAppearance();
        }
Exemple #3
0
        /// <summary>
        /// Called as the mouse moves around the control area. Raises the MouseMove event and calls the <see cref="DetermineAppearance"/> method.
        /// </summary>
        /// <param name="state">The current mouse data</param>
        protected virtual void OnMouseIn(Input.MouseConsoleState state)
        {
            if (MouseMove != null)
            {
                MouseMove(this, new MouseEventArgs(state));
            }

            DetermineAppearance();
        }
Exemple #4
0
        protected override void OnLeftMouseClicked(Input.MouseConsoleState state)
        {
            base.OnLeftMouseClicked(state);

            if (isEnabled)
            {
                IsSelected = true;
            }
        }
Exemple #5
0
        /// <summary>
        /// Called when the left-mouse button is clicked.
        /// </summary>
        /// <param name="state">The mouse state.</param>
        protected override void OnLeftMouseClicked(Input.MouseConsoleState state)
        {
            base.OnLeftMouseClicked(state);

            if (isEnabled)
            {
                DoClick();
            }
        }
Exemple #6
0
        /// <summary>
        /// Called when the left mouse button is clicked. Raises the MouseButtonClicked event and calls the <see cref="DetermineAppearance"/> method.
        /// </summary>
        /// <param name="state">The current mouse data</param>
        protected virtual void OnLeftMouseClicked(Input.MouseConsoleState state)
        {
            if (MouseButtonClicked != null)
            {
                MouseButtonClicked(this, new MouseEventArgs(state));
            }

            if (FocusOnClick)
            {
                this.IsFocused = true;
            }

            DetermineAppearance();
        }
Exemple #7
0
        protected override void OnLeftMouseClicked(Input.MouseConsoleState state)
        {
            if (!DisableMouse)
            {
                base.OnLeftMouseClicked(state);

                DisableKeyboard = false;

                if (!IsFocused)
                {
                    Parent.FocusedControl = this;
                }

                IsDirty = true;
            }
        }
Exemple #8
0
        /// <summary>
        /// Checks if the mouse is the control and calls the appropriate mouse methods.
        /// </summary>
        /// <param name="state">Mouse information.</param>
        /// <returns>Always returns false.</returns>
        public virtual bool ProcessMouse(Input.MouseConsoleState state)
        {
            if (IsEnabled && UseMouse)
            {
                if (bounds.Contains(state.CellPosition))
                {
                    if (isMouseOver != true)
                    {
                        isMouseOver = true;
                        OnMouseEnter(state);
                    }

                    OnMouseIn(state);

                    if (state.Mouse.LeftClicked)
                    {
                        OnLeftMouseClicked(state);
                    }

                    if (state.Mouse.RightClicked)
                    {
                        OnRightMouseClicked(state);
                    }
                }
                else
                {
                    if (isMouseOver)
                    {
                        isMouseOver = false;
                        OnMouseExit(state);
                    }
                }
            }

            return(false);
        }
Exemple #9
0
        // Locking the mouse to this control is actually locking the parent console to the engine, and then
        // letting the controls console know that this control wants exclusive focus until mouse is unclicked.

        public override bool ProcessMouse(Input.MouseConsoleState state)
        {
            if (IsEnabled)
            {
                base.ProcessMouse(state);


                var mouseControlPosition = new Point(state.ConsolePosition.X - this.Position.X, state.ConsolePosition.Y - this.Position.Y);

                // This becomes the active mouse subject when the bar is being dragged.
                if (Parent.CapturedControl == null)
                {
                    if (state.ConsolePosition.X >= this.Position.X && state.ConsolePosition.X < this.Position.X + textSurface.Width &&
                        state.ConsolePosition.Y >= this.Position.Y && state.ConsolePosition.Y < this.Position.Y + textSurface.Height)
                    {
                        if (state.Mouse.LeftClicked)
                        {
                            if (_barOrientation == System.Windows.Controls.Orientation.Horizontal)
                            {
                                if (mouseControlPosition.X == 0)
                                {
                                    Value -= Step;
                                }
                                if (mouseControlPosition.X == textSurface.Width - 1)
                                {
                                    Value += Step;
                                }
                            }
                            else
                            {
                                if (mouseControlPosition.Y == 0)
                                {
                                    Value -= Step;
                                }
                                if (mouseControlPosition.Y == textSurface.Height - 1)
                                {
                                    Value += Step;
                                }
                            }

                            Parent.FocusedControl = this;
                        }

                        // Need to set a flag signalling that we've locked in a drag.
                        // When the mouse button is let go, clear the flag.
                        if (state.Mouse.LeftButtonDown)
                        {
                            if (_barOrientation == System.Windows.Controls.Orientation.Horizontal)
                            {
                                if (mouseControlPosition.Y == 0)
                                {
                                    if (mouseControlPosition.X == _currentSliderPosition + 1)
                                    {
                                        Parent.CaptureControl(this);
                                    }
                                }
                            }
                            else
                            {
                                if (mouseControlPosition.X == 0)
                                {
                                    if (mouseControlPosition.Y == _currentSliderPosition + 1)
                                    {
                                        Parent.CaptureControl(this);
                                    }
                                }
                            }

                            Parent.FocusedControl = this;
                        }

                        return(true);
                    }
                }
                else if (Parent.CapturedControl == this)
                {
                    if (state.ConsolePosition.X >= this.Position.X - 2 && state.ConsolePosition.X < this.Position.X + textSurface.Width + 2 &&
                        state.ConsolePosition.Y >= this.Position.Y - 3 && state.ConsolePosition.Y < this.Position.Y + textSurface.Height + 3)
                    {
                        if (state.Mouse.LeftButtonDown)
                        {
                            if (_barOrientation == System.Windows.Controls.Orientation.Horizontal)
                            {
                                //if (mouseControlPosition.Y == 0)
                                //{
                                //    if (mouseControlPosition.X == _currentSliderPosition + 1)
                                //        Value -= Step;
                                //}


                                if (mouseControlPosition.X >= 1 && mouseControlPosition.X <= _sliderBarSize)
                                {
                                    _currentSliderPosition = mouseControlPosition.X - 1;

                                    if (_sliderPositionValues[_currentSliderPosition] != -1)
                                    {
                                        _value = _sliderPositionValues[_currentSliderPosition];
                                        if (ValueChanged != null)
                                        {
                                            ValueChanged.Invoke(this, EventArgs.Empty);
                                        }

                                        this.IsDirty = true;
                                    }
                                }
                            }
                            else
                            {
                                if (mouseControlPosition.Y >= 1 && mouseControlPosition.Y <= _sliderBarSize)
                                {
                                    _currentSliderPosition = mouseControlPosition.Y - 1;

                                    if (_sliderPositionValues[_currentSliderPosition] != -1)
                                    {
                                        _value = _sliderPositionValues[_currentSliderPosition];
                                        if (ValueChanged != null)
                                        {
                                            ValueChanged.Invoke(this, EventArgs.Empty);
                                        }

                                        this.IsDirty = true;
                                    }
                                }
                            }

                            return(true);
                        }
                        else
                        {
                            Parent.ReleaseControl();
                        }

                        return(false);
                    }
                }

                //else if(Parent.CapturedControl == this && !info.LeftButtonDown)
                //{
                //    Parent.ReleaseControl();
                //}
            }

            return(false);
        }
Exemple #10
0
        /// <summary>
        /// Called when the mouse leaves the control area.
        /// </summary>
        /// <param name="state">The mouse state.</param>
        protected override void OnMouseExit(Input.MouseConsoleState state)
        {
            isMouseDown = false;

            base.OnMouseExit(state);
        }
Exemple #11
0
        /// <summary>
        /// Called when the mouse is in the control area.
        /// </summary>
        /// <param name="state">The mouse state.</param>
        protected override void OnMouseIn(Input.MouseConsoleState state)
        {
            isMouseDown = state.Mouse.LeftButtonDown;

            base.OnMouseIn(state);
        }
Exemple #12
0
 protected override void OnLeftMouseClicked(Input.MouseConsoleState state)
 {
     base.OnLeftMouseClicked(state);
 }
Exemple #13
0
        protected override void OnMouseIn(Input.MouseConsoleState state)
        {
            isMouseOver = true;

            base.OnMouseIn(state);
        }