2 using System.Collections.Generic;
5 namespace FooEditEngine
7 struct GripperRectangle
9 public Gripper TopLeft;
10 public Gripper TopRight;
11 public Gripper BottomLeft;
12 public Gripper BottomRight;
13 public GripperRectangle(Gripper bottom_left,Gripper bottom_right)
17 this.BottomLeft = bottom_left;
18 this.BottomRight = bottom_right;
23 public const int GripperWidth = 10;
24 public const int HitAreaWidth = 48;
36 public Rectangle Rectangle
41 public Rectangle HitArea
46 public bool IsHit(Point p)
48 return this.Enabled && this.HitArea.IsHit(p);
51 public void Move(EditView view,TextPoint tp)
53 this.Rectangle = view.GetRectFromTextPoint(tp, Gripper.GripperWidth, Gripper.GripperWidth);
54 this.HitArea = view.GetRectFromTextPoint(tp, Gripper.HitAreaWidth, Gripper.HitAreaWidth);
57 public void MoveByIndex(EditView view, int index)
59 this.Rectangle = view.GetRectFromIndex(index, Gripper.GripperWidth, Gripper.GripperWidth);
60 this.HitArea = view.GetRectFromIndex(index, Gripper.HitAreaWidth, Gripper.HitAreaWidth);
63 public Point AdjustPoint(Point p)
65 Rectangle gripperRect = this.HitArea;
67 if (gripperRect.IsHit(p))
68 p.Y = gripperRect.Y - 1;
70 p.Y -= gripperRect.Height;
72 //if (p.Y < this.Render.TextArea.Y)
73 // p.Y = this.Render.TextArea.Y;
77 public void Draw(ITextRender render)
81 Rectangle gripperRect = this.Rectangle;
82 double radius = gripperRect.Width / 2;
84 point = new Point(gripperRect.X + radius, gripperRect.Y + radius);
85 render.DrawGripper(point, radius);
89 public bool Equals(Gripper other)
91 return this.Rectangle == other.Rectangle;