Beispiel #1
0
 private void DrawAllAnchors(Graphics g, Pen pen)
 {
     foreach (var ancor in Anchors)
     {
         BRectangle rect = GetRectangle(ancor);
         g.DrawRectangle(pen, rect.ToRectangle());
     }
 }
Beispiel #2
0
        private void CreateNewRect()
        {
            BRectangle rec = new BRectangle(MouseX - 20, MouseY - 20, 23, 23);

            _currentRectangles.Add(rec);
            _aRect = rec;
            _curAn = AnchorType.BottomRight;
            picBox.Refresh();
        }
Beispiel #3
0
 public AnchorType GetHitAnchor(int x, int y)
 {
     foreach (AnchorType ancor in Anchors)
     {
         BRectangle rec = GetRectangle(ancor);
         if (rec.Contains(x, y))
         {
             return(ancor);
         }
     }
     return(AnchorType.None);
 }
Beispiel #4
0
        private void picBox_MouseMove(object sender, MouseEventArgs e)
        {
            MouseX = e.X;
            MouseY = e.Y;
            if (_aRect == null)
            {
                picBox.Cursor = Cursors.Default;
            }
            else
            {
                AnchorType a = _aRect.GetHitAnchor(MouseX, MouseY);
                picBox.Cursor = BRectangle.GetCursor(a);
            }
            switch (CurrentAction)
            {
            case RectAction.NoAction:
                GetActiveRectangle(e.X, e.Y);
                if (_aRect != null)
                {
                    CurrentAction = RectAction.Selecting;
                }
                break;

            case RectAction.Selecting:
                GetActiveRectangle(e.X, e.Y);
                if (_aRect == null)
                {
                    CurrentAction = RectAction.NoAction;
                }
                break;

            case RectAction.Editing:
                if (_aRect != null)
                {
                    ProcessEdit();
                }
                break;

            default:
                break;
            }
            _oldx = e.X;
            _oldy = e.Y;
            picBox.Refresh();
        }
Beispiel #5
0
 private void GetActiveRectangle(int x, int y)
 {
     if (_currentRectangles == null)
     {
         _aRect = null;
     }
     else
     {
         BRectangle act = null;
         foreach (BRectangle r in _currentRectangles)
         {
             if (r.Contains(x, y))
             {
                 act = r;
                 break;
             }
         }
         _aRect = act;
     }
 }