this.View = new EditView(this.Document, this.Render, new Padding(5, Gripper.HitAreaWidth, Gripper.HitAreaWidth / 2, Gripper.HitAreaWidth));
this.View.SrcChanged += View_SrcChanged;
this.View.InsertMode = this.InsertMode;
- this.View.DrawLineNumber = this.DrawLineNumber;
+ this.Document.DrawLineNumber = this.DrawLineNumber;
this.View.HideCaret = !this.DrawCaret;
this.View.HideLineMarker = !this.DrawCaretLine;
- this.View.HideRuler = !this.DrawRuler;
- this.View.UrlMark = this.MarkURL;
- this.View.TabStops = this.TabChars;
+ this.Document.HideRuler = !this.DrawRuler;
+ this.Document.UrlMark = this.MarkURL;
+ this.Document.TabStops = this.TabChars;
this._Controller = new Controller(this.Document, this.View);
this._Controller.SelectionChanged += Controller_SelectionChanged;
- this.FirstGripper = new Gripper(this._Controller, this.View, this.Render, GripperPostion.BottomLeft);
- this.SecondGripper = new Gripper(this._Controller, this.View, this.Render, GripperPostion.BottomRight);
-
this.gestureRecongnizer.GestureSettings = GestureSettings.Drag |
GestureSettings.RightTap |
GestureSettings.Tap |
if (isControlPressed)
this._Controller.JumpToHead(isShiftPressed);
else
- this.Controller.JumpToLineHead(this.View.CaretPostion.row,isShiftPressed);
+ this.Controller.JumpToLineHead(this.Document.CaretPostion.row,isShiftPressed);
this.Refresh();
isMovedCaret = true;
break;
if (isControlPressed)
this._Controller.JumpToEnd(isShiftPressed);
else
- this.Controller.JumpToLineEnd(this.View.CaretPostion.row,isShiftPressed);
+ this.Controller.JumpToLineEnd(this.Document.CaretPostion.row,isShiftPressed);
this.Refresh();
isMovedCaret = true;
break;
/// <inheritdoc/>
protected override void OnPointerPressed(PointerRoutedEventArgs e)
{
+ //マウスでは慣性移動自体必要じゃない
+ this.gestureRecongnizer.AutoProcessInertia = e.Pointer.PointerDeviceType != PointerDeviceType.Mouse;
+
this.CapturePointer(e.Pointer);
this.gestureRecongnizer.ProcessDownEvent(e.GetCurrentPoint(this));
e.Handled = true;
/// <inheritdoc/>
protected override void OnPointerMoved(PointerRoutedEventArgs e)
{
+ //マウスでは慣性移動自体必要じゃない
+ this.gestureRecongnizer.AutoProcessInertia = e.Pointer.PointerDeviceType != PointerDeviceType.Mouse;
+
this.gestureRecongnizer.ProcessMoveEvents(e.GetIntermediatePoints(this));
e.Handled = true;
/// <inheritdoc/>
protected override void OnPointerWheelChanged(PointerRoutedEventArgs e)
{
+ //マウスでは慣性移動自体必要じゃない
+ this.gestureRecongnizer.AutoProcessInertia = e.Pointer.PointerDeviceType != PointerDeviceType.Mouse;
+
bool shift = (e.KeyModifiers & Windows.System.VirtualKeyModifiers.Shift) ==
Windows.System.VirtualKeyModifiers.Shift;
bool ctrl = (e.KeyModifiers & Windows.System.VirtualKeyModifiers.Control) ==
//こうしないと選択できなくなってしまう
this.nowCaretMove = true;
SetValue(SelectionProperty, new TextRange(this._Controller.SelectionStart, this._Controller.SelectionLength));
- SetValue(CaretPostionPropertyKey, this.View.CaretPostion);
+ SetValue(CaretPostionPropertyKey, this.Document.CaretPostion);
this.nowCaretMove = false;
+ this.Document.SelectGrippers.BottomLeft.MoveByIndex(this.View, this.Controller.SelectionStart);
+ this.Document.SelectGrippers.BottomRight.MoveByIndex(this.View, this.Controller.SelectionStart + this.Controller.SelectionLength);
if (this.textStore.IsLocked() == false)
this.textStore.NotifySelectionChanged();
}
- Gripper FirstGripper, SecondGripper;
- bool HittedCaret;
- Gripper hittedGripper;
private void gestureRecongnizer_ManipulationInertiaStarting(GestureRecognizer sender, ManipulationInertiaStartingEventArgs e)
{
//sender.InertiaTranslationDeceleration = 0.001f;
//sender.InertiaRotationDeceleration = 720.0f / (1000.0f * 1000.0f);
}
+ Gripper hittedGripper;
void gestureRecongnizer_ManipulationStarted(GestureRecognizer sender, ManipulationStartedEventArgs e)
{
- this.HittedCaret = false;
- this.hittedGripper = null;
-
- Point p = e.Position;
- TextPoint tp = this.View.GetTextPointFromPostion(p);
- if (tp == this.View.CaretPostion)
- {
- HittedCaret = true;
- }
-
- if (this.FirstGripper.IsHit(p))
- {
- hittedGripper = this.FirstGripper;
- HittedCaret = true;
- System.Diagnostics.Debug.WriteLine("first gripper hitted");
- }
-
- else if (this.SecondGripper.IsHit(p))
- {
- hittedGripper = this.SecondGripper;
- HittedCaret = true;
- System.Diagnostics.Debug.WriteLine("second gripper hitted");
- }
+ //Updateedの段階でヒットテストしてしまうとグリッパーを触ってもヒットしないことがある
+ this.hittedGripper = this.View.HitGripperFromPoint(e.Position);
}
+ const int WheelNoti = 120;
+ const int WheelScrollLines = 3;
+ double TotalWheelCount = 0;
+
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.SecondGripper))
- this._Controller.MoveSelectBefore(tp);
- else
- this._Controller.MoveCaretAndSelect(tp);
- }
- else
- {
- if (Object.ReferenceEquals(hittedGripper,this.FirstGripper))
- this._Controller.MoveSelectBefore(tp);
- else
- this._Controller.MoveCaretAndSelect(tp);
- }
- }
- else
- {
- TextPoint tp = this.View.GetTextPointFromPostion(p);
- this._Controller.MoveCaretAndSelect(tp);
- }
if (this.peer != null)
this.peer.OnNotifyCaretChanged();
- if (this._Controller.SelectionLength != 0)
- this.FirstGripper.Enabled = true;
- else
- this.FirstGripper.Enabled = false;
-
- this.Refresh();
-
+ this.Refresh();
return;
}
if (Math.Abs(e.Cumulative.Translation.X) < Math.Abs(e.Cumulative.Translation.Y))
{
int scrollCount = 0;
- if (e.PointerDeviceType == PointerDeviceType.Mouse) //ホイールを使っているので、スクロール行数を計算する
- scrollCount = (int)Math.Abs(translation.Y / sender.MouseWheelParameters.CharTranslation.Y);
+ if (e.PointerDeviceType == PointerDeviceType.Mouse) {
+ //テキストボックスはWheelNotiごとにWheelScrollLinesずつスクロールするらしい
+ scrollCount = (int)Math.Abs(this.TotalWheelCount / WheelNoti * WheelScrollLines);
+ if (scrollCount < 1)
+ scrollCount = 1;
+ else if (scrollCount > WheelScrollLines)
+ scrollCount = WheelScrollLines;
+ if (this.TotalWheelCount >= WheelNoti) //0にすると違和感を感じる
+ this.TotalWheelCount = this.TotalWheelCount % WheelNoti;
+ this.TotalWheelCount += Math.Abs(translation.Y);
+ }
else
- scrollCount = (int)Math.Abs(Math.Ceiling(translation.Y));
+ {
+ scrollCount = (int)Math.Abs(translation.Y + 0.5);
+ }
if (translation.Y > 0)
this._Controller.Scroll(ScrollDirection.Up, scrollCount, false, false);
else
this._Controller.Scroll(ScrollDirection.Down, scrollCount, false, false);
- this.FirstGripper.Enabled = false;
- this.SecondGripper.Enabled = false;
+ this.Document.SelectGrippers.BottomLeft.Enabled = false;
+ this.Document.SelectGrippers.BottomRight.Enabled = false;
this.Refresh();
return;
}
this._Controller.Scroll(ScrollDirection.Left, deltax, false, false);
else
this._Controller.Scroll(ScrollDirection.Right, deltax, false, false);
- this.FirstGripper.Enabled = false;
- this.SecondGripper.Enabled = false;
+ this.Document.SelectGrippers.BottomLeft.Enabled = false;
+ this.Document.SelectGrippers.BottomRight.Enabled = false;
this.Refresh();
}
}
void gestureRecongnizer_Tapped(GestureRecognizer sender, TappedEventArgs e)
{
bool touched = e.PointerDeviceType == PointerDeviceType.Touch;
- this.FirstGripper.Enabled = false;
- this.SecondGripper.Enabled = touched;
+ this.Document.SelectGrippers.BottomLeft.Enabled = false;
+ this.Document.SelectGrippers.BottomRight.Enabled = touched;
this.JumpCaret(e.Position);
System.Diagnostics.Debug.WriteLine(e.TapCount);
if (e.TapCount == 2)
{
- this.FirstGripper.Enabled = touched;
+ this.Document.SelectGrippers.BottomLeft.Enabled = touched;
//タッチスクリーンでダブルタップした場合、アンカーインデックスを単語の先頭にしないとバグる
this.Controller.SelectWord(this.Controller.SelectionStart, touched);
}
this.View.Draw(updateRect);
else
this.Render.FillBackground(updateRect);
- this.FirstGripper.Draw();
- this.SecondGripper.Draw();
this.Render.EndDraw();
}
else
toX = -this.horizontalScrollBar.Value;
this._Controller.Scroll(toX, this.View.Src.Row, false, false);
- this.FirstGripper.Enabled = false;
- this.SecondGripper.Enabled = false;
+ this.Document.SelectGrippers.BottomLeft.Enabled = false;
+ this.Document.SelectGrippers.BottomRight.Enabled = false;
this.Refresh();
}
if (newRow >= this.View.LayoutLines.Count)
return;
this._Controller.Scroll(this.View.Src.X, newRow, false, false);
- this.FirstGripper.Enabled = false;
- this.SecondGripper.Enabled = false;
+ this.Document.SelectGrippers.BottomLeft.Enabled = false;
+ this.Document.SelectGrippers.BottomRight.Enabled = false;
this.Refresh();
}
if (e.Property.Equals(InsertModeProperty))
source.View.InsertMode = source.InsertMode;
if (e.Property.Equals(TabCharsProperty))
- source.View.TabStops = source.TabChars;
+ source.Document.TabStops = source.TabChars;
if (e.Property.Equals(RectSelectModeProperty))
source._Controller.RectSelection = source.RectSelectMode;
if (e.Property.Equals(DrawCaretProperty))
if (e.Property.Equals(DrawCaretLineProperty))
source.View.HideLineMarker = !source.DrawCaretLine;
if (e.Property.Equals(DrawLineNumberProperty))
- {
- source.View.DrawLineNumber = source.DrawLineNumber;
- source._Controller.JumpCaret(source.View.CaretPostion.row, source.View.CaretPostion.col);
- }
+ source.Document.DrawLineNumber = source.DrawLineNumber;
if(e.Property.Equals(MagnificationPowerPropertyKey))
source.Render.FontSize = source.FontSize * source.MagnificationPower;
if (e.Property.Equals(FontFamilyProperty))
if (e.Property.Equals(LineMarkerProperty))
source.Render.LineMarker = D2DRenderBase.ToColor4(source.LineMarker);
if (e.Property.Equals(MarkURLProperty))
- source.View.UrlMark = source.MarkURL;
+ source.Document.UrlMark = source.MarkURL;
if (e.Property.Equals(ShowFullSpaceProperty))
source.Render.ShowFullSpace = source.ShowFullSpace;
if (e.Property.Equals(ShowHalfSpaceProperty))
if (e.Property.Equals(ShowLineBreakProperty))
source.Render.ShowLineBreak = source.ShowLineBreak;
if (e.Property.Equals(LineBreakProperty))
- source.View.LineBreak = source.LineBreakMethod;
+ source.Document.LineBreak = source.LineBreakMethod;
if (e.Property.Equals(LineBreakCharCountProperty))
- source.View.LineBreakCharCount = source.LineBreakCharCount;
+ source.Document.LineBreakCharCount = source.LineBreakCharCount;
if (e.Property.Equals(UpdateAreaProperty))
source.Render.UpdateArea = D2DRenderBase.ToColor4(source.UpdateArea);
if (e.Property.Equals(LineNumberProperty))
source.Render.LineNumber = D2DRenderBase.ToColor4(source.LineNumber);
if (e.Property.Equals(FlowDirectionProperty))
{
- source.Render.RightToLeft = source.FlowDirection == Windows.UI.Xaml.FlowDirection.RightToLeft;
+ source.Document.RightToLeft = source.FlowDirection == Windows.UI.Xaml.FlowDirection.RightToLeft;
if(source.horizontalScrollBar != null)
source.horizontalScrollBar.FlowDirection = source.FlowDirection;
}
if (e.Property.Equals(DrawRulerProperty))
{
- source.View.HideRuler = !source.DrawRuler;
- source._Controller.JumpCaret(source.View.CaretPostion.row, source.View.CaretPostion.col);
+ source.Document.HideRuler = !source.DrawRuler;
+ source._Controller.JumpCaret(source.Document.CaretPostion.row, source.Document.CaretPostion.col);
}
}
#endregion
{
get
{
- return this.View.MarkerPatternSet;
+ return this.Document.MarkerPatternSet;
}
}