this.View.AdjustCaretAndSrc();
}
+ /// <summary>
+ /// グリッパーとキャレットを同時に移動する
+ /// </summary>
+ /// <param name="p">ポインターの座標</param>
+ /// <param name="hittedGripper">動かす対象となるグリッパー</param>
+ /// <returns>移動できた場合は真を返す。そうでなければ偽を返す</returns>
+ /// <remarks>グリッパー内にポインターが存在しない場合、グリッパーはポインターの座標近くの行に移動する</remarks>
+ public bool MoveCaretAndGripper(Point p, GripperView hittedGripper)
+ {
+ bool HittedCaret = false;
+ TextPoint tp = this.View.GetTextPointFromPostion(p);
+ if (tp == this.View.CaretPostion)
+ {
+ HittedCaret = true;
+ }
+
+ if (HittedCaret || hittedGripper != null)
+ {
+ if (hittedGripper != null)
+ {
+ tp = this.View.GetTextPointFromPostion(hittedGripper.AdjustPoint(p));
+ if (this.IsReverseSelect())
+ {
+ if (Object.ReferenceEquals(hittedGripper, this.View.SelectGrippers.BottomRight))
+ this.MoveSelectBefore(tp);
+ else
+ this.MoveCaretAndSelect(tp);
+ }
+ else
+ {
+ if (Object.ReferenceEquals(hittedGripper, this.View.SelectGrippers.BottomLeft))
+ this.MoveSelectBefore(tp);
+ else
+ this.MoveCaretAndSelect(tp);
+ }
+ hittedGripper.Move(this.View, tp);
+ }
+ else
+ {
+ tp = this.View.GetTextPointFromPostion(p);
+ if (tp != TextPoint.Null)
+ this.MoveCaretAndSelect(tp);
+ }
+ this.View.SelectGrippers.BottomLeft.Enabled = this.SelectionLength != 0;
+ return true;
+ }
+ return false;
+ }
+
public void MoveSelectBefore(TextPoint tp)
{
int NewAnchorIndex;
this.textStore.NotifySelectionChanged();
}
- bool HittedCaret;
- GripperView hittedGripper;
private void gestureRecongnizer_ManipulationInertiaStarting(GestureRecognizer sender, ManipulationInertiaStartingEventArgs e)
{
//sender.InertiaTranslationDeceleration = 0.001f;
//sender.InertiaRotationDeceleration = 720.0f / (1000.0f * 1000.0f);
}
+ GripperView hittedGripper;
void gestureRecongnizer_ManipulationStarted(GestureRecognizer sender, ManipulationStartedEventArgs e)
{
- this.HittedCaret = false;
-
- Point p = e.Position;
- TextPoint tp = this.View.GetTextPointFromPostion(p);
- if (tp == this.View.CaretPostion)
- {
- HittedCaret = true;
- }
-
+ //Updateedの段階でヒットテストしてしまうとグリッパーを触ってもヒットしないことがある
this.hittedGripper = this.View.HitGripperFromPoint(e.Position);
- if (this.hittedGripper != null)
- {
- this.HittedCaret = true;
- }
}
const int WheelNoti = 120;
void gestureRecongnizer_ManipulationUpdated(GestureRecognizer sender, ManipulationUpdatedEventArgs e)
{
- if (HittedCaret)
+ if (this._Controller.MoveCaretAndGripper(e.Position, this.hittedGripper))
{
- Point p;
- if (this.hittedGripper == null)
- p = e.Position;
- else
- p = this.hittedGripper.AdjustPoint(e.Position);
-
- if (hittedGripper != null)
- {
- TextPoint tp = this.View.GetTextPointFromPostion(p);
- if (this._Controller.IsReverseSelect())
- {
- if (Object.ReferenceEquals(hittedGripper,this.View.SelectGrippers.BottomRight))
- this._Controller.MoveSelectBefore(tp);
- else
- this._Controller.MoveCaretAndSelect(tp);
- }
- else
- {
- if (Object.ReferenceEquals(hittedGripper, this.View.SelectGrippers.BottomLeft))
- this._Controller.MoveSelectBefore(tp);
- else
- this._Controller.MoveCaretAndSelect(tp);
- }
- this.hittedGripper.Move(this.View, tp);
- }
- else
- {
- TextPoint tp = this.View.GetTextPointFromPostion(p);
- if(tp != TextPoint.Null)
- this._Controller.MoveCaretAndSelect(tp);
- }
if (this.peer != null)
this.peer.OnNotifyCaretChanged();
- this.View.SelectGrippers.BottomLeft.Enabled = this._Controller.SelectionLength != 0;
-
- this.Refresh();
-
+ this.Refresh();
return;
}