this._Controller = new Controller(this.Document, this.View);\r
this._Controller.SelectionChanged += Controller_SelectionChanged;\r
\r
- this.FirstGripper = new Gripper(this._Controller, this.View, this.Render, GripperPostion.Upper);\r
- this.SecondGripper = new Gripper(this._Controller, this.View, this.Render, GripperPostion.Bottom);\r
+ this.FirstGripper = new Gripper(this._Controller, this.View, this.Render, GripperPostion.BottomLeft);\r
+ this.SecondGripper = new Gripper(this._Controller, this.View, this.Render, GripperPostion.BottomRight);\r
\r
this.gestureRecongnizer.GestureSettings = GestureSettings.Drag | \r
GestureSettings.RightTap | \r
{\r
hittedGripper = this.FirstGripper;\r
HittedCaret = true;\r
+ System.Diagnostics.Debug.WriteLine("first gripper hitted");\r
}\r
\r
else if (this.SecondGripper.IsHit(p))\r
{\r
hittedGripper = this.SecondGripper;\r
HittedCaret = true;\r
+ System.Diagnostics.Debug.WriteLine("second gripper hitted");\r
}\r
}\r
\r
}\r
if (this.peer != null)\r
this.peer.OnNotifyCaretChanged();\r
+ if (this._Controller.SelectionLength != 0)\r
+ this.FirstGripper.Enabled = true;\r
+ else\r
+ this.FirstGripper.Enabled = false;\r
+\r
this.Refresh();\r
+ \r
return;\r
}\r
if (e.Delta.Scale < 1)\r
void gestureRecongnizer_Tapped(GestureRecognizer sender, TappedEventArgs e)\r
{\r
bool touched = e.PointerDeviceType == PointerDeviceType.Touch;\r
- this.FirstGripper.Enabled = touched;\r
this.SecondGripper.Enabled = touched;\r
this.JumpCaret(e.Position);\r
}\r
{
enum GripperPostion
{
- Upper,
- Bottom,
+ BottomLeft,
+ BottomRight,
}
class Gripper : IEquatable<Gripper>
{
public Point AdjustPoint(Point p)
{
Rectangle gripperRect = this.GetGripperRect(type, HitAreaWidth, HitAreaWidth);
- if (this.type == GripperPostion.Upper)
- {
- if (gripperRect.IsHit(p))
- p.Y = gripperRect.Bottom + 1;
- else
- p.Y += gripperRect.Height;
- }
+
+ if (gripperRect.IsHit(p))
+ p.Y = gripperRect.Y - 1;
else
- {
- if (gripperRect.IsHit(p))
- p.Y = gripperRect.Y - 1;
- else
- p.Y -= gripperRect.Height;
- }
+ p.Y -= gripperRect.Height;
+
if (p.Y < this.Render.TextArea.Y)
p.Y = this.Render.TextArea.Y;
return p;
TextPoint tp;
Point point;
double radius = width / 2;
- if (type == GripperPostion.Bottom)
- {
+ if (type == GripperPostion.BottomRight)
tp = this.View.LayoutLines.GetTextPointFromIndex(this.Controller.SelectionStart + this.Controller.SelectionLength);
- point = this.View.GetPostionFromTextPoint(tp);
- double lineHeight = this.View.LayoutLines.GetLayout(tp.row).Height;
- return new Rectangle(point.X - radius, point.Y + lineHeight, width, height);
- }
- else if (type == GripperPostion.Upper)
- {
+ else if (type == GripperPostion.BottomLeft)
tp = this.View.LayoutLines.GetTextPointFromIndex(this.Controller.SelectionStart);
- point = this.View.GetPostionFromTextPoint(tp);
- return new Rectangle(point.X - radius, point.Y - height, width, height);
- }
else
- {
throw new ArgumentOutOfRangeException();
- }
+
+ point = this.View.GetPostionFromTextPoint(tp);
+ double lineHeight = this.View.LayoutLines.GetLayout(tp.row).Height;
+
+ return new Rectangle(point.X - radius, point.Y + lineHeight, width, height);
}
public bool Equals(Gripper other)