2 using System.Collections.Generic;
5 namespace FooEditEngine
9 public const int GripperWidth = 10;
10 public const int HitAreaWidth = 48;
13 public GripperView(ITextRender render)
23 public Rectangle Rectangle
28 public Rectangle HitArea
33 public bool IsHit(Point p)
35 return this.Enabled && this.HitArea.IsHit(p);
38 public void Move(EditView view,TextPoint tp)
40 this.Rectangle = view.GetRectFromTextPoint(tp, GripperView.GripperWidth, GripperView.GripperWidth);
41 this.HitArea = view.GetRectFromTextPoint(tp, GripperView.HitAreaWidth, GripperView.HitAreaWidth);
44 public void MoveByIndex(EditView view, int index)
46 this.Rectangle = view.GetRectFromIndex(index, GripperView.GripperWidth, GripperView.GripperWidth);
47 this.HitArea = view.GetRectFromIndex(index, GripperView.HitAreaWidth, GripperView.HitAreaWidth);
50 public Point AdjustPoint(Point p)
52 Rectangle gripperRect = this.HitArea;
54 if (gripperRect.IsHit(p))
55 p.Y = gripperRect.Y - 1;
57 p.Y -= gripperRect.Height;
59 if (p.Y < this.Render.TextArea.Y)
60 p.Y = this.Render.TextArea.Y;
68 Rectangle gripperRect = this.Rectangle;
69 double radius = gripperRect.Width / 2;
71 point = new Point(gripperRect.X + radius, gripperRect.Y + radius);
72 this.Render.DrawGripper(point, radius);
76 public bool Equals(GripperView other)
78 return this.Rectangle == other.Rectangle;