Beispiel #1
0
 protected override void OnMouseLeave(EventArgs e)
 {
     _MouseState = MouseStates.None;
     tmrAnimation.Start();
     Invalidate();
     base.OnMouseLeave(e);
 }
Beispiel #2
0
 protected override void OnMouseUp(MouseEventArgs e)
 {
     _MouseState = MouseStates.Over;
     tmrAnimation.Start();
     Invalidate();
     base.OnMouseUp(e);
 }
 private void mouse_leftDOWN(object sender, MouseEventArgs e)
 {
     isLeftDown = true;
     if (isRightDown)
     {
         State = MouseStates.DOUBLEDOWN;
         isDoublePressed = true;
         OnMouseButtonActivity?.Invoke(this, e);
     }else
     {
         State = MouseStates.LEFTDOWN;
         OnMouseButtonActivity?.Invoke(this, e);
     }
 }
        public void MouseMoveIn(MouseStates state)
        {
            switch (state)
            {
                case MouseStates.LEFTDOWN:
                    MouseLeftDown();

                    break;

                case MouseStates.NONE:
                    MeshHighlight();
                    break;

                case MouseStates.DOUBLEDOWN:
                    MouseDoubleDown();
                    break;

                default: break;
            }
        }
Beispiel #5
0
        private void MouseDown_Handler(object sender, MouseEventArgs e)
        {
            MouseState = MouseStates.Down;
            mouseDelta = new Point(e.X, e.Y);
            ClickedCountry = null;

            // figure out the country that was clicked
            foreach (KeyValuePair<string, List<Region>> entry in countryRegions)
            {
                foreach (Region r in entry.Value)
                {
                    if (r.IsVisible(e.Location))
                    {
                        ClickedCountry = Countries[entry.Key];
                        return;
                    }
                }
            }
        }
Beispiel #6
0
        public void OnMouseButtonActivity(object sender, Point pt, MouseStates state)
        {
            TestLabel.Text = gridPoint.ToString() + "---" + pt.ToString() + MouseState.ToString() + MouseLocation.ToString();

            ParentForm.Invalidate();

            MouseState = state;
            SingleMeshClass mesh = GetMeshFromPoint(pt);
            if(mesh != null)
            {
                switch (MouseState)
                {
                    case MouseStates.NONE:
                        mesh.MeshCover();
                        break;

                    case MouseStates.LEFTDOWN:
                        mesh.MouseLeftDown();
                        break;

                    case MouseStates.LEFTCLICK:
                        mesh.Open();
                        TestTextBox.Text += "mesh " + mesh.MeshID.ToString() + " is " + mesh.MeshState.ToString() + "  value = " + mesh.MeshValue.ToString() + Environment.NewLine;
                        MouseState = MouseStates.NONE;
                        break;

                    case MouseStates.DOUBLEDOWN:
                        mesh.MouseDoubleDown();
                        break;

                    case MouseStates.RIGHTDOWN:
                        mesh.MouseRightDown();
                        MouseState = MouseStates.NONE;
                        break;

                    default: break;
                }
            }
        }
Beispiel #7
0
 protected override void OnMouseDown(MouseEventArgs e)
 {
     State = MouseStates.Down;
     Invalidate();
     base.OnMouseDown(e);
 }
        /// <summary>Get the control back color state.</summary>
        /// <param name="hoverColorState">The hover Color State.</param>
        /// <param name="enabled">The enabled toggle.</param>
        /// <param name="mouseState">The mouse state.</param>
        /// <returns>
        ///     <see cref="Color" />
        /// </returns>
        public static Color BackColorState(HoverColorState hoverColorState, bool enabled, MouseStates mouseState)
        {
            Color _color;

            if (enabled)
            {
                switch (mouseState)
                {
                case MouseStates.Normal:
                {
                    _color = hoverColorState.Enabled;
                    break;
                }

                case MouseStates.Hover:
                {
                    _color = hoverColorState.Hover;
                    break;
                }

                default:
                {
                    throw new ArgumentOutOfRangeException(nameof(mouseState), mouseState, null);
                }
                }
            }
            else
            {
                _color = hoverColorState.Disabled;
            }

            return(_color);
        }
        protected virtual void ImpListBoxBase_MouseMove(object sender, MouseEventArgs e)
        {
            if (touchManipulating)
            {
                return;
            }

            if (pressedState == MouseStates.PanRightPressed)
            {
                ScrollBarMove(e.GetPosition(this).Y);
                return;
            }

            if (HitTest(e.GetPosition(this)))
            {
                var tempIndex = lowIndex + (int)Math.Floor(e.GetPosition(this).Y / sStyle.RowHeight);
                if (tempIndex == MouseoverIndex)
                {
                    return; // nothing to do here
                }
                MouseoverIndex = tempIndex;

                if (ScrollBarVisible && e.GetPosition(this).X >= ActualWidth - sStyle.ScrollbarWidth ||
                    MouseoverIndex > HighIndex)
                {
                    MouseoverIndex = -1;
                    return; // no action, not over any item
                }


                if (e.LeftButton.HasFlag(MouseButtonState.Pressed) && pressedState == MouseStates.WindowPressed)
                {
                    if (GlobalKeyboard.ModKeys == ModifierKeys.None && ItemsDragable == false)
                    {
                        controller.Select(SelectionMode.One, MouseoverIndex);
                    }
                    else if (GlobalKeyboard.ModKeys == ModifierKeys.Shift)
                    {
                        controller.Select(SelectionMode.AddGroup, MouseoverIndex);
                    }
                    else if (GlobalKeyboard.ModKeys == ModifierKeys.Control)
                    {
                        controller.Select(SelectionMode.Inverse, MouseoverIndex);
                    }
                    else if (GlobalKeyboard.ModKeys == (ModifierKeys.Control | ModifierKeys.Shift))
                    {
                        controller.Select(SelectionMode.Add, MouseoverIndex);
                    }
                    else if (GlobalKeyboard.ModKeys == ModifierKeys.None & ItemsDragable)
                    {
                        DragShow(tempIndex);
                    }
                }
            }
            else
            {
                if (!Pressed)
                {
                    ReleaseMouseCapture();
                }
                mouseoverState = MouseStates.None;
            }
        }
 protected override void ControlGetsHidden()
 {
     base.ControlGetsHidden();
     pressedState = MouseStates.None;
 }
Beispiel #11
0
        /// <summary>Render the text using the text style.</summary>
        /// <param name="graphics">The specified graphics to draw on.</param>
        /// <param name="clientRectangle">The client rectangle.</param>
        /// <param name="text">The text to draw.</param>
        /// <param name="font">The font to  draw.</param>
        /// <param name="enabled">The enabled.</param>
        /// <param name="mouseState">The mouse State.</param>
        /// <param name="textStyle">The text Style.</param>
        public static void RenderText(Graphics graphics, Rectangle clientRectangle, string text, Font font, bool enabled, MouseStates mouseState, TextStyle textStyle)
        {
            Color _textColor = TextStyle.GetColorState(enabled, mouseState, textStyle);

            RenderText(graphics, clientRectangle, text, font, _textColor, textStyle.StringFormat);
        }
Beispiel #12
0
 public MouseData(Point coord, MouseCodes key, MouseStates mouseState)
 {
     Coord = coord;
     Key = new MouseCode(key);
     State = new MouseState(mouseState);
 }
Beispiel #13
0
        /// <summary>Draws an arrow button.</summary>
        /// <param name="graphics">The <see cref="Graphics" /> used to paint.</param>
        /// <param name="arrowUp">true for an up arrow, false otherwise.</param>
        /// <param name="border">The border.</param>
        /// <param name="color">The color.</param>
        /// <param name="enabled">The enabled.</param>
        /// <param name="orientation">The <see cref="Orientation" />.</param>
        /// <param name="rectangle">The rectangle in which to paint.</param>
        /// <param name="state">The <see cref="MouseStates" /> of the arrow button.</param>
        public static void DrawArrowButton(Graphics graphics, bool arrowUp, Border border, ControlColorState color, bool enabled, Orientation orientation, Rectangle rectangle, MouseStates state)
        {
            if (graphics == null)
            {
                throw new ArgumentNullException("graphics");
            }

            if (rectangle.IsEmpty || graphics.IsVisibleClipEmpty || !graphics.VisibleClipBounds.IntersectsWith(rectangle))
            {
                return;
            }

            Color _thumbBackColor = ControlColorState.BackColorState(color, enabled, state);

            VisualBackgroundRenderer.DrawBackground(graphics, _thumbBackColor, state, rectangle, border);

            GraphicsPath _buttonGraphicsPath = VisualBorderRenderer.CreateBorderTypePath(rectangle, border);

            VisualBorderRenderer.DrawBorderStyle(graphics, border, _buttonGraphicsPath, state);

            Image _arrowImage = RetrieveButtonArrowImage(enabled);

            _arrowImage = RotateImageByOrientation(_arrowImage, orientation, arrowUp);
            graphics.DrawImage(_arrowImage, rectangle);
        }
 public MouseStateEventArgs(MouseStates mouseStates)
 {
     _mouseStates = mouseStates;
 }
        /// <summary>Draws a border around the custom path, with the specified mouse state.</summary>
        /// <param name="graphics">Graphics controller.</param>
        /// <param name="border">The border type.</param>
        /// <param name="customPath">The custom Path.</param>
        /// <param name="mouseState">The mouse state.</param>
        public static void DrawBorderStyle(Graphics graphics, Border border, GraphicsPath customPath, MouseStates mouseState)
        {
            if (!border.Visible)
            {
                return;
            }

            switch (mouseState)
            {
            case MouseStates.Normal:
            {
                DrawBorder(graphics, customPath, border.Color, border.Thickness);
                break;
            }

            case MouseStates.Hover:
            {
                DrawBorder(graphics, customPath, border.HoverVisible ? border.HoverColor : border.Color, border.Thickness);
                break;
            }

            case MouseStates.Down:
            {
                DrawBorder(graphics, customPath, border.HoverVisible ? border.HoverColor : border.Color, border.Thickness);
                break;
            }

            default:
            {
                throw new ArgumentOutOfRangeException(nameof(mouseState), mouseState, null);
            }
            }
        }
Beispiel #16
0
        protected override void OnMouseEnter(EventArgs e)
        {
            m_mouseState = MouseStates.Enter;

            base.OnMouseEnter(e);
        }
 protected override void OnMouseHover(EventArgs e)
 {
     base.OnMouseHover(e);
     _mouseState = MouseStates.Hover;
     Invalidate();
 }
 private void ClearMouse()
 {
     MouseoverIndex = -1;
     mouseoverState = MouseStates.None;
 }
Beispiel #19
0
 /// <summary>
 /// Обработчик мыши
 /// </summary>
 /// <param name="ms">Текущее состояние мыши</param>
 /// <param name="oms">Предыдущее состояние мыши</param>
 /// <param name="state">Состояние MouseStates мыши</param>
 protected abstract void MouseHandler(MouseState ms, MouseState oms, MouseStates state);
Beispiel #20
0
 protected override void OnMouseLeave(EventArgs e)
 {
     base.OnMouseLeave(e);
     _mouseState = MouseStates.Normal;
     Invalidate();
 }
Beispiel #21
0
 protected override void OnMouseEnter(EventArgs e)
 {
     State = MouseStates.Over;
     Invalidate();
     base.OnMouseEnter(e);
 }
 /// <summary>Draws a check box control in the specified state and with the specified text.</summary>
 /// <param name="graphics">The graphics to draw on.</param>
 /// <param name="border">The border type.</param>
 /// <param name="checkStyle">The check mark type.</param>
 /// <param name="rectangle">The rectangle that represents the dimensions of the check box.</param>
 /// <param name="state">The toggle state of the check mark.</param>
 /// <param name="enabled">The state to draw the check mark in.</param>
 /// <param name="color">The brush used to fill the background.</param>
 /// <param name="backgroundImage">The background Image.</param>
 /// <param name="mouseState">The state of the mouse on the control.</param>
 /// <param name="text">The text.</param>
 /// <param name="font">The font.</param>
 /// <param name="foreColor">The fore Color.</param>
 /// <param name="textPoint">The text Point.</param>
 public static void DrawCheckBox(Graphics graphics, Border border, CheckStyle checkStyle, Rectangle rectangle, bool state, bool enabled, Color color, Image backgroundImage, MouseStates mouseState, string text, Font font, Color foreColor, Point textPoint)
 {
     DrawCheckBox(graphics, border, checkStyle, rectangle, state, enabled, color, backgroundImage, mouseState);
     graphics.DrawString(text, font, new SolidBrush(foreColor), textPoint);
 }
Beispiel #23
0
 public MouseListener()
 {
     State = MouseStates.NONE;
 }
        /// <summary>Draws a check box control in the specified state and location.</summary>
        /// <param name="graphics">The graphics to draw on.</param>
        /// <param name="border">The border type.</param>
        /// <param name="checkStyle">The check mark type.</param>
        /// <param name="rectangle">The rectangle that represents the dimensions of the check box.</param>
        /// <param name="checkState">The check State.</param>
        /// <param name="enabled">The state to draw the check mark in.</param>
        /// <param name="color">The background color.</param>
        /// <param name="backgroundImage">The background Image.</param>
        /// <param name="mouseStates">The mouse States.</param>
        public static void DrawCheckBox(Graphics graphics, Border border, CheckStyle checkStyle, Rectangle rectangle, bool checkState, bool enabled, Color color, Image backgroundImage, MouseStates mouseStates)
        {
            GraphicsPath _boxGraphicsPath = VisualBorderRenderer.CreateBorderTypePath(rectangle, border);

            graphics.SetClip(_boxGraphicsPath);
            VisualBackgroundRenderer.DrawBackground(graphics, color, backgroundImage, mouseStates, rectangle, border);

            if (checkState)
            {
                DrawCheckMark(graphics, checkStyle, rectangle, enabled);
            }

            VisualBorderRenderer.DrawBorderStyle(graphics, border, _boxGraphicsPath, mouseStates);
            graphics.ResetClip();
        }
Beispiel #25
0
 private void mouse_leftUP(object sender, MouseEventArgs e)
 {
     isLeftDown = false;
     if (isDoublePressed)
     {
         isDoublePressed = false;
         State = MouseStates.NONE;
         OnMouseButtonActivity?.Invoke(this, e);
     }
     else
     {
         State = MouseStates.LEFTCLICK;
         OnMouseButtonActivity?.Invoke(this, e);
     }
 }
Beispiel #26
0
        /// <summary>Draws the control background, with a BackColor and the specified BackgroundImage.</summary>
        /// <param name="graphics">The graphics to draw on.</param>
        /// <param name="backColor">The color to use for the background.</param>
        /// <param name="mouseState">The mouse state.</param>
        /// <param name="rectangle">The coordinates of the rectangle to draw.</param>
        /// <param name="shape">The shape settings.</param>
        public static void DrawBackground(Graphics graphics, Color backColor, MouseStates mouseState, Rectangle rectangle, Border shape)
        {
            GraphicsPath _controlGraphicsPath = FillBackgroundPath(graphics, backColor, rectangle, shape);

            VisualBorderRenderer.DrawBorderStyle(graphics, shape, _controlGraphicsPath, mouseState);
        }
Beispiel #27
0
 private void MouseUp_Handler(object sender, MouseEventArgs e)
 {
     MouseState = MouseStates.Up;
 }
Beispiel #28
0
        /// <summary>Draws a background with a border style.</summary>
        /// <param name="graphics">The graphics to draw on.</param>
        /// <param name="background">The background color.</param>
        /// <param name="border">The border type.</param>
        /// <param name="mouseState">The control mouse state.</param>
        /// <param name="rectangle">The coordinates of the rectangle to draw.</param>
        public static void DrawBackground(Graphics graphics, Color background, Border border, MouseStates mouseState, Rectangle rectangle)
        {
            GraphicsPath backgroundPath = FillBackgroundPath(graphics, background, rectangle, border);

            VisualBorderRenderer.DrawBorderStyle(graphics, border, backgroundPath, mouseState);
        }
 public void MouseMoveOut(MouseStates state)
 {
     MeshCover();
     if (state == MouseStates.DOUBLEDOWN)
     {
         MeshNearbyUp?.Invoke(this, new MeshEventArgs(MeshID));
     }
 }
Beispiel #30
0
        /// <summary>Draws a background with a linear gradient still border style.</summary>
        /// <param name="graphics">The graphics to draw on.</param>
        /// <param name="background">The background linear gradient.</param>
        /// <param name="border">The border type.</param>
        /// <param name="mouseState">The control mouse state.</param>
        /// <param name="rectangle">The coordinates of the rectangle to draw.</param>
        public static void DrawBackground(Graphics graphics, LinearGradientBrush background, Border border, MouseStates mouseState, Rectangle rectangle)
        {
            GraphicsPath backgroundPath = VisualBorderRenderer.CreateBorderTypePath(rectangle, border);

            FillBackground(graphics, backgroundPath, background);
            VisualBorderRenderer.DrawBorderStyle(graphics, border, backgroundPath, mouseState);
        }
Beispiel #31
0
        /// <summary>Draws the control background, with a BackColor and the specified BackgroundImage.</summary>
        /// <param name="graphics">The graphics to draw on.</param>
        /// <param name="backColor">The color to use for the background.</param>
        /// <param name="backgroundImage">The background image to use for the background.</param>
        /// <param name="mouseState">The mouse state.</param>
        /// <param name="rectangle">The coordinates of the rectangle to draw.</param>
        /// <param name="border">The shape settings.</param>
        public static void DrawBackground(Graphics graphics, Color backColor, Image backgroundImage, MouseStates mouseState, Rectangle rectangle, Border border)
        {
            GraphicsPath _controlGraphicsPath = FillBackgroundPath(graphics, backColor, rectangle, border);

            if (backgroundImage != null)
            {
                Point _location = new Point(rectangle.Width - backgroundImage.Width, rectangle.Height - backgroundImage.Height);
                Size  _size     = new Size(backgroundImage.Width, backgroundImage.Height);
                graphics.SetClip(_controlGraphicsPath);
                graphics.DrawImage(backgroundImage, new Rectangle(_location, _size));
                graphics.ResetClip();
            }
        }
Beispiel #32
0
        public SearchControl()
        {
            #region -Init-
            InitializeComponent();
            SetStyle(ControlStyles.SupportsTransparentBackColor, true);

            #region -Init Attributes-
            m_speed           = 1; //tốc độ di chuyển hiện tại
            m_deltaSpeed      = 2; //tốc độ biến thiên
            m_opacity         = 1;
            m_firstTimeChange = false;

            m_hideSize = new System.Drawing.Size(30, this.Height);
            m_showSize = new System.Drawing.Size(250, this.Height);
            #endregion

            #region -Button Search-
            m_bt           = new Button();
            m_bt.Size      = new System.Drawing.Size(25, m_showSize.Height);
            m_bt.Location  = new System.Drawing.Point(this.Location.X, this.Location.Y);
            m_bt.Image     = new Bitmap(QuanLyHocSinh.Properties.Resources.showButton, new Size((int)(m_bt.Width * 0.8), m_bt.Height));
            m_bt.Anchor    = AnchorStyles.Left;
            m_bt.FlatStyle = FlatStyle.Flat;
            m_bt.FlatAppearance.BorderSize = 0;
            m_bt.MouseMove  += m_MouseMove;
            m_bt.BackColor   = Color.Transparent;
            m_bt.MouseClick += (o, e) =>
            {
                if (m_state == States.Show)
                {
                    m_btClick    = true;
                    m_mouseState = MouseStates.Leave;
                    m_timer.Start();
                }
                else
                {
                    if (e.X < this.Location.X || e.X > this.Location.X + this.Width || e.Y < this.Location.Y ||
                        e.Y > this.Location.Y + this.Height)
                    {
                        //khi vào control, cho chạy timmer lúc này sẽ kéo dài control ra
                        m_mouseState = MouseStates.Hover;
                        m_timer.Start();
                    }
                }
            };

            m_bt.SizeChanged += (o, e) =>
            {
                m_bt.Location = new Point(this.HideSize.Width - m_bt.Width, 0);
            };

            #endregion

            #region -TextBox Search-
            m_tb            = new TextBox();
            m_tb.Size       = new System.Drawing.Size(this.Width - m_bt.Width - 10, this.Height * 2 / 3);
            m_tb.Location   = new Point(m_bt.Location.X + m_bt.Width + 5, this.Height / 2 - m_tb.Height / 2);
            m_tb.Font       = new System.Drawing.Font("Tahoma", 10, FontStyle.Italic);
            m_tb.Text       = "Nhập tên học sinh";
            m_tb.Anchor     = AnchorStyles.Left;
            m_tb.MouseMove += m_MouseMove;
            //khi TextBox được Focus thì xóa text để cho người dùng nhập text
            m_tb.GotFocus += (o, e) =>
            {
                m_tb.Text = "";
            };
            //khi TextBox không còn được focus thì đóng control lại
            #endregion

            #region -Label-
            m_lb           = new Label();
            m_lb.AutoSize  = true;
            m_lb.Font      = new System.Drawing.Font("Tahoma", 12, FontStyle.Bold);
            m_lb.Text      = "Tìm kiếm học sinh";
            m_lb.Location  = new Point(m_tb.Location.X + (m_showSize.Width / 2 - m_lb.Width), this.Location.Y + 5);//this.Location;
            m_lb.ForeColor = Color.Red;
            m_lb.BackColor = Color.Transparent;
            #endregion

            #region -Add controls-
            this.Controls.Add(m_bt);
            this.Controls.Add(m_tb);
            this.Controls.Add(m_lb);
            #endregion

            #region -Timers-
            m_timer          = new Timer();
            m_timer.Interval = 100;
            m_timer.Tick    += m_timer_Tick;
            m_timer.Enabled  = true;
            m_timer.Stop();

            m_timerGlowAlpha          = new Timer();
            m_timerGlowAlpha.Interval = 100;
            m_timerGlowAlpha.Tick    += m_timer_Tick;
            m_timerGlowAlpha.Enabled  = true;
            m_timerGlowAlpha.Stop();
            #endregion

            this.LocationChanged += (o, e) =>
            {
                if (m_state != States.Moving)
                {
                    //kiểm tra trường hợp thay đổi Location của control ta phải cập nhật lại để khi control di chuyển thì dừng
                    //đúng vị trí không bị lệch
                    m_oldLocation = this.Location;
                }
            };

            this.SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.ContainerControl | ControlStyles.AllPaintingInWmPaint, true);
            #endregion
        }