Esempio n. 1
0
        /// <summary>
        /// 根据鼠标位置获取选中的Win
        /// </summary>
        /// <param name="de"></param>
        /// <returns></returns>
        public WinBase FindMouseOnRect(Point de)
        {
            if (SubWinList == null || SubWinList.Count == 0)
            {
                return(this);
            }
            WinBase centerRect = null;

            foreach (WinBase rct in SubWinList ?? new List <WinBase>())
            {
                Direction dtemp = rct.MouseOverWhere(de);
                switch (dtemp)
                {
                case Direction.outside:
                    break;

                case Direction.center:
                    //如果没有边,反馈先找到的中心框。
                    if (centerRect == null || rct == CurFocus)
                    {
                        centerRect = rct;
                    }
                    break;

                default:
                    return(rct);
                }
            }
            if (centerRect == null)
            {
                return(this);
            }
            WinBase win = centerRect.FindMouseOnRect(de);

            if (win != null)
            {
                return(win);
            }
            if (CurFocus != null)
            {
                Direction fdir = CurFocus.MouseOverWhere(de);
                Direction mdir = centerRect.MouseOverWhere(de);
                if (MoreFocus(mdir, fdir))
                {
                    return(centerRect);
                }
                else
                {
                    if (CurFocus == TheBoard && mdir > Direction.outside)
                    {
                        return(centerRect);
                    }
                    else
                    {
                        return(CurFocus);
                    }
                }
            }
            return(centerRect);
        }
Esempio n. 2
0
        /// <summary>
        /// 根据点相对方框的方位设置控件中显示的鼠标形状.
        /// </summary>
        /// <param name="mp">控件</param>
        /// <param name="e">点的板坐标</param>
        private void SetCursor(Point e)
        {
            Direction dir = CurFocus?.MouseOverWhere(e) ?? Direction.outside;

            switch (dir)
            {
            case Direction.center:
                Cursor = Cursors.SizeAll;
                break;

            case Direction.top:
            case Direction.bottom:
                Cursor = Cursors.SizeNS;
                break;

            case Direction.topRight:
            case Direction.bottomLeft:
                Cursor = Cursors.SizeNESW;
                break;

            case Direction.topLeft:
            case Direction.bottomRight:
                Cursor = Cursors.SizeNWSE;
                break;

            case Direction.left:
            case Direction.right:
                Cursor = Cursors.SizeWE;
                break;

            default:
                Cursor = Cursors.Default;
                break;
            }
        }
Esempio n. 3
0
 private void MarkedPicture_MouseDown(object sender, MouseEventArgs e)
 {
     ChangeFocus.CreateInstance()?.Hide();
     SetDownDelt(e.Location);
     if (e.Button == MouseButtons.Left)
     {
         mouseDownPosition = e.Location;  //记录每次点击时鼠标按下的位置
         MouseLeftDown     = true;
     }
     else if (e.Button == MouseButtons.Right)
     {
         if (CurFocus != null && CurFocus != TheBoard)
         {
             Point     de  = ShowToPos(e.Location);
             Direction dir = CurFocus.MouseOverWhere(de);
             if (dir > Direction.outside)
             {
                 Point       p  = e.Location;
                 ChangeFocus cf = ChangeFocus.CreateInstance();
                 p.Offset(getRealLocation(this, theMainForm));
                 cf.Location = p;
                 if (cf.Bottom > Screen.PrimaryScreen.Bounds.Height)
                 {
                     p.Offset(0, -cf.Height);
                     cf.Location = p;
                 }
                 cf.Show();
             }
         }
     }
     TheBoard?.OnMouseDown(sender, e);//ShowToPos(e.Location));
 }
Esempio n. 4
0
        private void MarkedPicture_MouseMove(object sender, MouseEventArgs e)
        {
            Point de = ShowToPos(e.Location);

            if (IsChangingWinNow)
            {
                if (MarkedPicture.ChangingEdge == Direction.center && CurFocus is Board)
                {
                    theMarkPicture.SetXY(MouseDownDelt.X - (int)(e.Location.X / CurDisplayRate), MouseDownDelt.Y - (int)(e.Location.Y / CurDisplayRate));
                }
                //else if ((CurFocus as MarkPoint)==null)
                //{

                //}
                else
                {
                    CurFocus?.ChangeRect(e.Location);
                }
                SetCursor(de);
                //Refresh();
            }
            else if (e.Button == MouseButtons.Right)
            {
            }
            else
            {
                MouseOnWin = TheBoard?.FindMouseOnRect(de);

                if ((MouseOnWin == CurFocus) && (CurFocus != TheBoard))
                {
                    //鼠标移动到当前焦点的范围内时,根据相对位置设置鼠标形状指示将改变哪个边。
                    SetCursor(de);
                }
                else
                {
                    //鼠标不在焦点范围时,显示为默认鼠标。
                    Cursor = Cursors.Default;
                }
            }
            Refresh();
        }
Esempio n. 5
0
 private void ColorsList_SelectedIndexChanged(object sender, EventArgs e)
 {
     SetDataTo(curColor);
     settingData = true;
     if (ColorsList.SelectedIndex < colors.Count)
     {
         curColor = colors[ColorsList.SelectedIndex];
         GetDataFrom(curColor);
     }
     else if (ColorsList.SelectedIndex == colors.Count)
     {
         int oindex = ColorsList.SelectedIndex;
         curColor = new ColorRange();
         GetDataFrom(curColor);
         colors.Add(curColor);
         ColorsList.Items.RemoveAt(oindex);
         ColorsList.Items.Add("颜色范围" + oindex.ToString());
         ColorsList.Items.Add("新建颜色项");
         ColorsList.SelectedIndex = oindex;
         if (DataChanged != null)
         {
             DataChanged(this, new EventArgs());
         }
     }
     if (colors.Count > 1)
     {
         DelButton.Text    = "删除" + ColorsList.SelectedIndex.ToString();
         DelButton.Enabled = true;
     }
     else
     {
         DelButton.Enabled = false;
     }
     ColorPic.Focus();
     CurFocus.ChangeColorRange(this);
     settingData = false;
 }
Esempio n. 6
0
 void LeaveHandle()
 {
     this.BorderStyle = BorderStyle.FixedSingle;
     CurFocus.ChangeColorRange(null);
 }
Esempio n. 7
0
 void EnterHandle()
 {
     this.BorderStyle = BorderStyle.Fixed3D;
     CurFocus.ChangeColorRange(this);
 }