Esempio n. 1
0
        /// <summary>
        /// 鼠标点击
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void CBoard_MouseDown(object sender, MouseEventArgs e)
        {
            //将鼠标坐标赋给窗体左上角坐标
            isMouseDown       = true;
            mouseDownLocation = new POINT(e.Location);
            MControlBase control = null;

            for (int i = this.objectsNeedToBeDraw.Count - 1; i >= 0; i--)
            {
                MControlBase v = objectsNeedToBeDraw[i];
                if (v.Enable && v.Visible && !(v is MRectangle) && v.Rectangle.Contains(mouseDownLocation))
                {
                    control = v;
                    break;
                }
            }
            if (control != null)
            {
                mouseDownControl = control;
                MMouseEventArgs args = new MMouseEventArgs(e, this, control);
                control.DoMouseDown(args);
                this.Draw();
            }
            if (!(control is MUseTable))
            {
                beginMove = true;
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 鼠标抬起
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void CBoard_MouseUp(object sender, MouseEventArgs e)
        {
            isMouseDown = false;
            beginMove   = false;
            MControlBase control = null;

            for (int i = this.objectsNeedToBeDraw.Count - 1; i >= 0; i--)
            {
                MControlBase v = objectsNeedToBeDraw[i];
                if (v.Enable && v.Visible && !(v is MRectangle) && v.Rectangle.Contains(mouseDownLocation))
                {
                    control = v;
                    break;
                }
            }
            if (control != null)
            {
                MMouseEventArgs args = new MMouseEventArgs(e, this, control);
                control.DoMouseUp(args);
                if (control == this.mouseDownControl)
                {
                    control.DoClick(args);
                }
                mouseDownControl = null;
                this.Draw();
            }
            mouseDownControl = null;
        }
Esempio n. 3
0
 /// <summary>
 /// 鼠标移动
 /// </summary>
 /// <param name="e"></param>
 protected override void OnMouseMove(MMouseEventArgs e)
 {
     if (!this.Enable)
     {
         return;
     }
     if (e.MouseEventArgs.Button == MouseButtons.None)
     {
         if (previousControl != null)
         {
             if (!previousControl.Rectangle.Contains(e.MouseEventArgs.X, e.MouseEventArgs.Y))
             {
                 previousControl.DoMouseLeave(e);
                 previousControl = null;
             }
         }
         else
         {
             foreach (var v in btns)
             {
                 if (v.Rectangle.Contains(e.MouseEventArgs.X, e.MouseEventArgs.Y))
                 {
                     v.DoMouseEnter(e);
                     previousControl = v;
                     break;
                 }
             }
         }
     }
 }
Esempio n. 4
0
 /// <summary>
 /// 鼠标抬起
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void CBoard_MouseUp(object sender, MouseEventArgs e)
 {
     isMouseDown = false;
     //beginMove = false;
     //MControlBase control = null;
     //for (int i = this.objectsNeedToBeDraw.Count - 1; i >= 0; i--)
     //{
     //    MControlBase v = objectsNeedToBeDraw[i];
     //    if (v.Enable && v.Visible && !(v is MRectangle) && v.Rectangle.Contains(mouseDownLocation))
     //    {
     //        control = v;
     //        break;
     //    }
     //}
     if (previousControl != null)
     {
         MMouseEventArgs args = new MMouseEventArgs(e, this, previousControl);
         previousControl.DoMouseUp(args);
         previousControl.DoClick(args);
         //Draw(previousControl);
         Draw();
         //if (control == this.mouseDownControl)
         //{
         //    control.DoClick(args);
         //}
         //mouseDownControl = null;
         //this.Draw();
     }
     //mouseDownControl = null;
 }
Esempio n. 5
0
 /// <summary>
 /// 鼠标移动
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected override void OnMouseMove(MMouseEventArgs e)
 {
     if (previousControl != null)
     {
         if (previousControl.Rectangle.Contains(e.MouseEventArgs.Location))
         {
             previousControl.DoMouseMove(e);
         }
         else
         {
             this.previousControl.DoMouseLeave(e);
             this.previousControl = null;
         }
     }
     else
     {
         MControlBase control = null;
         for (int i = lbs.Count - 1; i >= 0; i--)
         {
             MControlBase controlBase = lbs[i];
             if (controlBase.Visible && controlBase.Rectangle.Contains(e.MouseEventArgs.Location))
             {
                 control = controlBase;
                 break;
             }
         }
         if (control != null)
         {
             control.DoMouseEnter(e);
             this.previousControl = control;
         }
     }
 }
Esempio n. 6
0
 /// <summary>
 /// 鼠标按下
 /// </summary>
 /// <param name="e"></param>
 protected override void OnMouseDown(MMouseEventArgs e)
 {
     if (!this.Enable)
     {
         return;
     }
     if (e.MouseEventArgs.Button == MouseButtons.Left)
     {
         this.isMouseDown = true;
         if (scrollbar1 != null)
         {
             if (scrollbar1.Rectangle.Contains(e.MouseEventArgs.X, e.MouseEventArgs.Y))
             {
                 scrollbar1.DoMouseDown(e);
             }
         }
         if (scrollbar2 != null)
         {
             if (scrollbar2.Rectangle.Contains(e.MouseEventArgs.X, e.MouseEventArgs.Y))
             {
                 scrollbar2.DoMouseDown(e);
             }
         }
     }
 }
Esempio n. 7
0
 /// <summary>
 /// 鼠标点击
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void CBoard_MouseDown(object sender, MouseEventArgs e)
 {
     //将鼠标坐标赋给窗体左上角坐标
     isMouseDown = true;
     //mouseDownLocation = new POINT(e.Location);
     //MControlBase control = null;
     //for (int i = this.objectsNeedToBeDraw.Count - 1; i >= 0; i--)
     //{
     //    MControlBase v = objectsNeedToBeDraw[i];
     //    if (v.Enable && v.Visible &&!(v is MRectangle)&& v.Rectangle.Contains(mouseDownLocation))
     //    {
     //        control = v;
     //        break;
     //    }
     //}
     if (previousControl != null)
     {
         //mouseDownControl = control;
         MMouseEventArgs args = new MMouseEventArgs(e, this, previousControl);
         previousControl.DoMouseDown(args);
         //Draw(previousControl);
         Draw();
     }
     //if(!(control is MUseTable))
     //{
     //    beginMove = true;
     //}
 }
Esempio n. 8
0
 /// <summary>
 /// 鼠标进入
 /// </summary>
 /// <param name="e"></param>
 protected override void OnMouseEnter(MMouseEventArgs e)
 {
     if (!this.Enable)
     {
         return;
     }
     if (e.MouseEventArgs.Button == MouseButtons.None)
     {
         this.isMouseEnter = true;
         e.Board.Cursor    = Cursors.Hand;
         if (scrollbar1 != null)
         {
             if (scrollbar1.Rectangle.Contains(e.MouseEventArgs.X, e.MouseEventArgs.Y))
             {
                 scrollbar1.DoMouseEnter(e);
             }
         }
         if (scrollbar2 != null)
         {
             if (scrollbar2.Rectangle.Contains(e.MouseEventArgs.X, e.MouseEventArgs.Y))
             {
                 scrollbar2.DoMouseEnter(e);
             }
         }
     }
 }
Esempio n. 9
0
 /// <summary>
 /// 执行点击事件的方法
 /// </summary>
 /// <param name="e"></param>
 public void DoClick(MMouseEventArgs e)
 {
     this.OnClick(e);
     if (this.Click != null)
     {
         this.Click(this, e);
     }
 }
Esempio n. 10
0
 /// <summary>
 /// 执行鼠标滚动
 /// </summary>
 /// <param name="e"></param>
 public void DoMouseWheel(MMouseEventArgs e)
 {
     this.OnMouseWheel(e);
     if (this.MouseWheel != null)
     {
         this.MouseWheel(this, e);
     }
 }
Esempio n. 11
0
 /// <summary>
 /// 执行离开事件
 /// </summary>
 /// <param name="e"></param>
 public void DoMouseLeave(MMouseEventArgs e)
 {
     this.OnMouseLeave(e);
     if (this.MouseLeave != null)
     {
         this.MouseLeave(this, e);
     }
 }
Esempio n. 12
0
 /// <summary>
 /// 执行进入事件
 /// </summary>
 /// <param name="e"></param>
 public void DoMouseEnter(MMouseEventArgs e)
 {
     this.OnMouseEnter(e);
     if (this.MouseEnter != null)
     {
         this.MouseEnter(this, e);
     }
 }
Esempio n. 13
0
 /// <summary>
 /// 执行抬起事件
 /// </summary>
 /// <param name="e"></param>
 public void DoMouseUp(MMouseEventArgs e)
 {
     this.OnMouseUp(e);
     if (this.MouseUp != null)
     {
         this.MouseUp(this, e);
     }
 }
Esempio n. 14
0
 /// <summary>
 /// 执行按下事件
 /// </summary>
 /// <param name="e"></param>
 public void DoMouseDown(MMouseEventArgs e)
 {
     this.OnMouseDown(e);
     if (this.MouseDown != null)
     {
         this.MouseDown(this, e);
     }
 }
Esempio n. 15
0
 /// <summary>
 /// 鼠标移动
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void CBoard_MouseMove(object sender, MouseEventArgs e)
 {
     if (previousControl != null)
     {
         if (previousControl.Rectangle.Contains(e.Location.X, e.Location.Y))
         {
             MMouseEventArgs enterArgs = new MMouseEventArgs(e, this, previousControl);
             previousControl.DoMouseMove(enterArgs);
             //Draw(previousControl);
             Draw();
         }
         else
         {
             MMouseEventArgs args = new MMouseEventArgs(e, this, this.previousControl);
             this.previousControl.DoMouseLeave(args);
             //Draw(previousControl);
             Draw();
             this.previousControl = null;
         }
     }
     else
     {
         List <MControlBase> controls = new List <MControlBase>();
         foreach (var controlBase in objectsNeedToBeDraw)
         {
             if (controlBase.Enable && controlBase.Visible &&
                 controlBase.Rectangle.Contains(e.Location.X, e.Location.Y))
             {
                 controls.Add(controlBase);
             }
         }
         MControlBase control = null;
         foreach (var v in controls)
         {
             if (control != null)
             {
                 if (v.ZOrder > control.ZOrder)
                 {
                     control = v;
                 }
             }
             else
             {
                 control = v;
             }
         }
         if (control != null)
         {
             MMouseEventArgs enterArgs = new MMouseEventArgs(e, this, control);
             control.DoMouseEnter(enterArgs);
             this.previousControl = control;
             //Draw(previousControl);
             Draw();
         }
     }
 }
Esempio n. 16
0
        /// <summary>
        /// 鼠标抬起
        /// </summary>
        /// <param name="e"></param>
        protected override void OnMouseUp(MMouseEventArgs e)
        {
            if (!this.Enable)
            {
                return;
            }
            if (e.MouseEventArgs.Button == MouseButtons.Left)
            {
                this.isMouseDown = false;
                if (image3 != null)
                {
                    if (!image2.Rectangle.Contains(e.MouseEventArgs.X, e.MouseEventArgs.Y))
                    {
                        image3.Visible = false;
                    }
                    else
                    {
                        image3.Visible = true;
                        int image3X = e.MouseEventArgs.X;
                        int image3Y = e.MouseEventArgs.Y;
                        image3.Rectangle = new RECT(image3X + 10, e.MouseEventArgs.Y + 5, image3Y + image3.BackgroundImage.Width / 2 + 10, image3Y + image3.BackgroundImage.Height / 2 + 5);
                    }
                }
                if (scrollbar1 != null)
                {
                    scrollbar1.DoMouseUp(e);
                }
                if (scrollbar2 != null)
                {
                    scrollbar2.DoMouseUp(e);
                }

                if (SelectRow != null)
                {
                    UData ud = SelectRow.Tag as UData;
                    if (ud != null && ud.house != null)
                    {
                        if (ud.house.Rectangle.Contains(e.MouseEventArgs.Location))
                        {
                            MouseLeftUpEvent?.Invoke(ud.obj, e.MouseEventArgs.Location);
                        }
                    }
                }
            }
            else if (e.MouseEventArgs.Button == MouseButtons.Right)
            {
                if (SelectRow != null)
                {
                    UData ud = SelectRow.Tag as UData;
                    if (ud != null)
                    {
                        MouseRightUpEvent?.Invoke(ud.obj, e.MouseEventArgs.Location);
                    }
                }
            }
        }
Esempio n. 17
0
 /// <summary>
 /// 滚动
 /// </summary>
 /// <param name="e"></param>
 protected override void OnMouseWheel(MMouseEventArgs e)
 {
     if (e.MouseEventArgs.Y > scrollbar1.Rectangle.top && e.MouseEventArgs.Y < scrollbar1.Rectangle.bottom)
     {
         scrollbar1.DoMouseWheel(e);
     }
     if (e.MouseEventArgs.Y > scrollbar2.Rectangle.top && e.MouseEventArgs.Y < scrollbar2.Rectangle.bottom)
     {
         scrollbar2.DoMouseWheel(e);
     }
 }
Esempio n. 18
0
 /// <summary>
 /// 鼠标抬起
 /// </summary>
 /// <param name="e"></param>
 protected override void OnMouseUp(MMouseEventArgs e)
 {
     if (!this.Enable)
     {
         return;
     }
     if (e.MouseEventArgs.Button == MouseButtons.Left)
     {
         this.isMouseDown = false;
     }
 }
Esempio n. 19
0
 /// <summary>
 /// 最大化按钮点击事件
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void Btnmax_Click(object sender, MMouseEventArgs e)
 {
     if (this.WindowState == FormWindowState.Maximized)
     {
         this.WindowState = FormWindowState.Normal;
     }
     else
     {
         this.WindowState = FormWindowState.Maximized;
     }
 }
Esempio n. 20
0
 /// <summary>
 /// 鼠标离开
 /// </summary>
 /// <param name="e"></param>
 protected override void OnMouseLeave(MMouseEventArgs e)
 {
     if (!this.Enable)
     {
         return;
     }
     if (e.MouseEventArgs.Button == MouseButtons.None)
     {
         this.isMouseEnter = false;
         e.Board.Cursor    = Cursors.Default;
     }
 }
Esempio n. 21
0
 /// <summary>
 /// 鼠标进入
 /// </summary>
 /// <param name="e"></param>
 protected override void OnMouseEnter(MMouseEventArgs e)
 {
     if (!this.Enable)
     {
         return;
     }
     if (e.MouseEventArgs.Button == MouseButtons.None)
     {
         this.isMouseEnter = true;
         e.Board.Cursor    = Cursors.Hand;
     }
 }
Esempio n. 22
0
 /// <summary>
 /// 鼠标按下
 /// </summary>
 /// <param name="e"></param>
 protected override void OnMouseDown(MMouseEventArgs e)
 {
     if (!this.Enable)
     {
         return;
     }
     if (e.MouseEventArgs.Button == MouseButtons.Left)
     {
         this.isMouseDown = true;
         SetChoose();
     }
 }
Esempio n. 23
0
 /// <summary>
 /// 滚动
 /// </summary>
 /// <param name="e"></param>
 protected override void OnMouseWheel(MMouseEventArgs e)
 {
     if (e.MouseEventArgs.Delta > 0)
     {
         sliderMoveValue -= scrollInterval;
     }
     else
     {
         sliderMoveValue += scrollInterval;
     }
     ChangeRectangle();
 }
Esempio n. 24
0
 /// <summary>
 /// 鼠标离开
 /// </summary>
 /// <param name="e"></param>
 protected override void OnMouseLeave(MMouseEventArgs e)
 {
     if (!this.Enable)
     {
         return;
     }
     if (e.MouseEventArgs.Button == MouseButtons.None)
     {
         this.isMouseEnter = false;
         e.Board.Cursor    = Cursors.Default;
         XY.x       = int.MaxValue;
         XY.y       = int.MaxValue;
         currentObj = null;
     }
 }
Esempio n. 25
0
        /// <summary>
        /// 滚动鼠标滚轮
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void CBoard_MouseWheel(object sender, MouseEventArgs e)
        {
            MMouseEventArgs args = new MMouseEventArgs(e, this, this.previousControl);

            foreach (var controlBase in objectsNeedToBeDraw)
            {
                if (controlBase.Visible)
                {
                    if (e.Y > controlBase.Rectangle.top && e.Y < controlBase.Rectangle.bottom)
                    {
                        controlBase.DoMouseWheel(args);
                    }
                }
            }
            this.Draw();
        }
Esempio n. 26
0
 /// <summary>
 /// 鼠标按下
 /// </summary>
 /// <param name="e"></param>
 protected override void OnMouseDown(MMouseEventArgs e)
 {
     if (!this.Enable)
     {
         return;
     }
     if (e.MouseEventArgs.Button == MouseButtons.Left)
     {
         this.isMouseDown = true;
         SetChoose(e.MouseEventArgs.X, e.MouseEventArgs.Y);
         if (Current != null)
         {
             Current.DoMouseDown(e);
         }
     }
 }
Esempio n. 27
0
 /// <summary>
 /// 鼠标移动
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void CBoard_MouseMove(object sender, MouseEventArgs e)
 {
     if (beginMove)
     {
         WinAPI.ReleaseCapture();
         WinAPI.SendMessage(this.Parent.Handle, WinAPI.WM_SYSCOMMAND, WinAPI.SC_MOVE + WinAPI.HTCAPTION, 0);
     }
     else
     {
         if (previousControl != null)
         {
             if (previousControl.Rectangle.Contains(e.Location.X, e.Location.Y))
             {
                 MMouseEventArgs enterArgs = new MMouseEventArgs(e, this, previousControl);
                 previousControl.DoMouseMove(enterArgs);
                 this.Draw();
             }
             else
             {
                 MMouseEventArgs args = new MMouseEventArgs(e, this, this.previousControl);
                 this.previousControl.DoMouseLeave(args);
                 this.Draw();
                 this.previousControl = null;
             }
         }
         else
         {
             MControlBase control = null;
             for (int i = this.objectsNeedToBeDraw.Count - 1; i >= 0; i--)
             {
                 MControlBase controlBase = objectsNeedToBeDraw[i];
                 if (controlBase.Visible && !(controlBase is MRectangle) && controlBase.Rectangle.Contains(new POINT(e.Location)))
                 {
                     control = controlBase;
                     break;
                 }
             }
             if (control != null)
             {
                 MMouseEventArgs enterArgs = new MMouseEventArgs(e, this, control);
                 control.DoMouseEnter(enterArgs);
                 this.Draw();
                 this.previousControl = control;
             }
         }
     }
 }
Esempio n. 28
0
 /// <summary>
 /// 鼠标离开
 /// </summary>
 /// <param name="e"></param>
 protected override void OnMouseLeave(MMouseEventArgs e)
 {
     if (!this.Enable)
     {
         return;
     }
     if (e.MouseEventArgs.Button == MouseButtons.None)
     {
         this.isMouseEnter = false;
         e.Board.Cursor    = Cursors.Default;
         foreach (var v in btns)
         {
             //v.Redraw = true;
             v.DoMouseLeave(e);
         }
     }
 }
Esempio n. 29
0
 /// <summary>
 /// 鼠标移动
 /// </summary>
 /// <param name="e"></param>
 protected override void OnMouseMove(MMouseEventArgs e)
 {
     if (!this.Enable)
     {
         return;
     }
     if (e.MouseEventArgs.Button == MouseButtons.Left)
     {
         //按着滑块移动
         if (isSliderMouseDown)
         {
             sliderMoveValue += e.MouseEventArgs.Y - sliderMouseDownY;
             sliderMouseDownY = e.MouseEventArgs.Y;
             ChangeRectangle();
         }
     }
 }
Esempio n. 30
0
 /// <summary>
 /// 鼠标离开
 /// </summary>
 /// <param name="e"></param>
 protected override void OnMouseLeave(MMouseEventArgs e)
 {
     if (!this.Enable)
     {
         return;
     }
     if (e.MouseEventArgs.Button == MouseButtons.None)
     {
         this.isMouseEnter = false;
         e.Board.Cursor    = Cursors.Default;
         if (scrollbar1 != null)
         {
             scrollbar1.DoMouseLeave(e);
         }
         if (scrollbar2 != null)
         {
             scrollbar2.DoMouseLeave(e);
         }
     }
 }