Exemple #1
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;
        }
Exemple #2
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;
         }
     }
 }
Exemple #3
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;
            }
        }
Exemple #4
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;
                 }
             }
         }
     }
 }
Exemple #5
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();
         }
     }
 }
Exemple #6
0
 /// <summary>
 /// 局部刷新
 /// </summary>
 public void Draw(MControlBase cb)
 {
     try
     {
         if (cb.Visible)
         {
             cp.SetClip(cb.Rectangle);
             cb.DoPaint(args);
             cp.EndPaint();
         }
     }
     catch
     {
     }
 }
Exemple #7
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;
             }
         }
     }
 }
Exemple #8
0
 /// <summary>
 /// 从集合删除控件
 /// </summary>
 /// <param name="control"></param>
 public void RemoveControl(MControlBase control)
 {
     this.objectsNeedToBeDraw.Remove(control);
 }
Exemple #9
0
 /// <summary>
 /// 添加控件进集合
 /// </summary>
 /// <param name="control"></param>
 public void AddControl(MControlBase control)
 {
     this.objectsNeedToBeDraw.Add(control);
     control.Parent = this;
 }
Exemple #10
0
 /// <summary>
 /// 鼠标移动
 /// </summary>
 /// <param name="e"></param>
 protected override void OnMouseMove(MMouseEventArgs e)
 {
     if (!this.Enable)
     {
         return;
     }
     if (previousControl != null)
     {
         if (isMouseDown && previousControl is MVScrollBar)
         {
             previousControl.DoMouseMove(e);
         }
         else if (previousControl.Rectangle.Contains(e.MouseEventArgs.X, e.MouseEventArgs.Y))
         {
             previousControl.DoMouseMove(e);
         }
         else
         {
             if (!isMouseDown)
             {
                 this.previousControl.DoMouseLeave(e);
                 this.previousControl = null;
             }
         }
     }
     else
     {
         SelectRow = null;
         MControlBase control = null;
         if (scrollbar1.Visible && scrollbar1.Rectangle.Contains(e.MouseEventArgs.X, e.MouseEventArgs.Y))
         {
             control = scrollbar1;
         }
         else if (scrollbar2.Visible && scrollbar2.Rectangle.Contains(e.MouseEventArgs.X, e.MouseEventArgs.Y))
         {
             control = scrollbar2;
         }
         else
         {
             for (int i = buyData.Count - 1; i >= 0; i--)
             {
                 MControlBase controlBase = buyData[i].data;
                 if (controlBase != null && controlBase.Visible && !(controlBase is MRectangle) && controlBase.Rectangle.Contains(e.MouseEventArgs.X, e.MouseEventArgs.Y))
                 {
                     control = controlBase;
                     break;
                 }
             }
             if (control == null)
             {
                 for (int i = sellData.Count - 1; i >= 0; i--)
                 {
                     MControlBase controlBase = sellData[i].data;
                     if (controlBase.Visible && !(controlBase is MRectangle) && controlBase.Rectangle.Contains(e.MouseEventArgs.X, e.MouseEventArgs.Y))
                     {
                         control = controlBase;
                         break;
                     }
                 }
             }
         }
         if (control != null)
         {
             control.DoMouseEnter(e);
             this.previousControl = control;
             if (control is MLabels)
             {
                 MLabels mbs = control as MLabels;
                 if (mbs != null)
                 {
                     SelectRow = control;
                 }
             }
         }
     }
 }
Exemple #11
0
 /// <summary>
 /// 构造方法
 /// </summary>
 /// <param name="args"></param>
 /// <param name="board"></param>
 /// <param name="control"></param>
 public MMouseEventArgs(MouseEventArgs args, MBorad board, MControlBase control)
 {
     this.mouseEventArgs = args;
     this.board          = board;
     this.control        = control;
 }