2 * Copyright (C) 2013 FooProject
3 * * This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by
4 * the Free Software Foundation; either version 3 of the License, or (at your option) any later version.
6 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
7 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
9 You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
14 using System.ComponentModel;
15 using System.Threading.Tasks;
16 using Windows.ApplicationModel.Resources.Core;
17 using Windows.Devices.Input;
19 using Windows.ApplicationModel.DataTransfer;
20 using Windows.Foundation;
22 using Windows.UI.Input;
23 using Windows.UI.Core;
24 using Windows.UI.Popups;
25 using Windows.UI.Text;
26 using Windows.UI.Xaml.Media;
27 using Windows.UI.Xaml;
28 using Windows.UI.Xaml.Controls;
29 using Windows.UI.Xaml.Controls.Primitives;
30 using Windows.UI.Xaml.Input;
31 using Windows.UI.Text.Core;
33 // テンプレート コントロールのアイテム テンプレートについては、http://go.microsoft.com/fwlink/?LinkId=234235 を参照してください
34 namespace FooEditEngine.UWP
39 public sealed class FooTextBox : Control,IDisposable
42 Controller _Controller;
48 ScrollBar horizontalScrollBar, verticalScrollBar;
49 Windows.UI.Xaml.Shapes.Rectangle rectangle;
50 GestureRecognizer gestureRecongnizer = new GestureRecognizer();
51 CoreTextEditContext textEditContext;
52 CoreTextServicesManager textServiceManager;
54 FooTextBoxAutomationPeer peer;
56 bool nowCaretMove = false;
57 bool nowCompstion = false;
59 DispatcherTimer timer = new DispatcherTimer();
61 const int Interval = 96;
62 const int IntervalWhenLostFocus = 160;
69 this.DefaultStyleKey = typeof(FooTextBox);
71 this.rectangle = new Windows.UI.Xaml.Shapes.Rectangle();
72 this.rectangle.Margin = this.Padding;
74 this.Render = new D2DRender(this,this.rectangle);
76 this.Render = new DummyRender();
79 this.Document = new Document();
81 this.View = new EditView(this.Document, this.Render, new Padding(5, 5, Gripper.HitAreaWidth / 2, Gripper.HitAreaWidth));
82 this.View.SrcChanged += View_SrcChanged;
83 this.View.InsertMode = this.InsertMode;
84 this.Document.DrawLineNumber = this.DrawLineNumber;
85 this.View.HideCaret = !this.DrawCaret;
86 this.View.HideLineMarker = !this.DrawCaretLine;
87 this.Document.HideRuler = !this.DrawRuler;
88 this.Document.UrlMark = this.MarkURL;
89 this.Document.TabStops = this.TabChars;
91 this._Controller = new Controller(this.Document, this.View);
93 this.gestureRecongnizer.GestureSettings = GestureSettings.Drag |
94 GestureSettings.RightTap |
96 GestureSettings.DoubleTap |
97 GestureSettings.ManipulationTranslateX |
98 GestureSettings.ManipulationTranslateY |
99 GestureSettings.ManipulationScale |
100 GestureSettings.ManipulationTranslateInertia |
101 GestureSettings.ManipulationScaleInertia;
102 this.gestureRecongnizer.RightTapped += gestureRecongnizer_RightTapped;
103 this.gestureRecongnizer.Tapped += gestureRecongnizer_Tapped;
104 this.gestureRecongnizer.Dragging += gestureRecongnizer_Dragging;
105 this.gestureRecongnizer.ManipulationInertiaStarting += GestureRecongnizer_ManipulationInertiaStarting; ;
106 this.gestureRecongnizer.ManipulationStarted += gestureRecongnizer_ManipulationStarted;
107 this.gestureRecongnizer.ManipulationUpdated += gestureRecongnizer_ManipulationUpdated;
108 this.gestureRecongnizer.ManipulationCompleted += gestureRecongnizer_ManipulationCompleted;
110 this.timer.Interval = new TimeSpan(0, 0, 0, 0, Interval);
111 this.timer.Tick += this.timer_Tick;
114 this.GettingFocus += FooTextBox_GettingFocus;
115 this.LosingFocus += FooTextBox_LosingFocus;
117 this.SizeChanged += FooTextBox_SizeChanged;
119 this.Loaded += FooTextBox_Loaded;
133 public void Dispose()
136 GC.SuppressFinalize(this);
139 bool Disposed = false;
140 private void Dispose(bool disposing)
147 this.Render.Dispose();
154 /// <param name="start">開始インデックス</param>
155 /// <param name="length">長さ</param>
156 public void Select(int start, int length)
158 this.Document.Select(start, length);
162 /// キャレットを指定した行に移動させます
164 /// <param name="index">インデックス</param>
165 /// <remarks>このメソッドを呼び出すと選択状態は解除されます</remarks>
166 public void JumpCaret(int index)
168 this._Controller.JumpCaret(index);
171 /// キャレットを指定した行と桁に移動させます
173 /// <param name="row">行番号</param>
174 /// <param name="col">桁</param>
175 /// <remarks>このメソッドを呼び出すと選択状態は解除されます</remarks>
176 public void JumpCaret(int row, int col)
178 this._Controller.JumpCaret(row, col);
182 /// 選択中のテキストをクリップボードにコピーします
186 string text = this._Controller.SelectedText;
187 if (text != null && text != string.Empty)
189 DataPackage dataPackage = new DataPackage();
190 dataPackage.RequestedOperation = DataPackageOperation.Copy;
191 dataPackage.SetText(text);
193 Clipboard.SetContent(dataPackage);
198 /// 選択中のテキストをクリップボードに切り取ります
202 string text = this._Controller.SelectedText;
203 if (text != null && text != string.Empty)
205 DataPackage dataPackage = new DataPackage();
206 dataPackage.RequestedOperation = DataPackageOperation.Copy;
207 dataPackage.SetText(text);
209 Clipboard.SetContent(dataPackage);
211 this._Controller.SelectedText = "";
218 public async Task PasteAsync()
220 var dataPackageView = Clipboard.GetContent();
221 if (dataPackageView.Contains(StandardDataFormats.Text))
225 this._Controller.SelectedText = await dataPackageView.GetTextAsync();
228 System.Diagnostics.Debug.WriteLine("past error:" + e.Message);
236 public void SelectAll()
238 this.Document.Select(0, this.Document.Length);
244 public void DeSelectAll()
246 this._Controller.DeSelectAll();
252 /// <param name="tp">テキストポイント</param>
253 /// <returns>座標</returns>
254 /// <remarks>テキストポイントがクライアント領域の原点より外にある場合、返される値は原点に丸められます</remarks>
255 public Windows.Foundation.Point GetPostionFromTextPoint(TextPoint tp)
257 if (this.Document.FireUpdateEvent == false)
258 throw new InvalidOperationException("");
259 return this.View.GetPostionFromTextPoint(tp);
263 /// 対応するテキストポイントを返します
265 /// <param name="p">クライアント領域の原点を左上とする座標</param>
266 /// <returns>テキストポイント</returns>
267 public TextPoint GetTextPointFromPostion(Windows.Foundation.Point p)
269 if (this.Document.FireUpdateEvent == false)
270 throw new InvalidOperationException("");
271 return this.View.GetTextPointFromPostion(p);
277 /// <param name="row">レイアウト行</param>
278 /// <returns>行の高さ</returns>
279 public double GetLineHeight(int row)
281 if (this.Document.FireUpdateEvent == false)
282 throw new InvalidOperationException("");
283 return this.View.LayoutLines.GetLayout(row).Height; ;
287 /// インデックスに対応する座標を得ます
289 /// <param name="index">インデックス</param>
290 /// <returns>座標を返す</returns>
291 public Windows.Foundation.Point GetPostionFromIndex(int index)
293 if (this.Document.FireUpdateEvent == false)
294 throw new InvalidOperationException("");
295 TextPoint tp = this.View.GetLayoutLineFromIndex(index);
296 return this.View.GetPostionFromTextPoint(tp);
302 /// <param name="p">座標</param>
303 /// <returns>インデックスを返す</returns>
304 public int GetIndexFromPostion(Windows.Foundation.Point p)
306 if (this.Document.FireUpdateEvent == false)
307 throw new InvalidOperationException("");
308 TextPoint tp = this.View.GetTextPointFromPostion(p);
309 return this.View.GetIndexFromLayoutLine(tp);
316 public void Refresh()
318 this.Refresh(this.View.PageBound);
322 /// レイアウト行をすべて破棄し、再度レイアウトを行う
324 public void PerfomLayouts()
326 this.Document.PerformLayout();
332 /// <param name="row">行</param>
333 /// <param name="alignTop">指定行を画面上に置くなら真。そうでないなら偽</param>
334 public void ScrollIntoView(int row, bool alignTop)
336 this.View.ScrollIntoView(row, alignTop);
340 /// ファイルからドキュメントを構築する
342 /// <param name="sr">StremReader</param>
343 /// <returns>Taskオブジェクト</returns>
344 public async Task LoadFileAsync(System.IO.StreamReader sr, System.Threading.CancellationTokenSource token)
346 await this.Document.LoadAsync(sr, token);
349 private void Document_LoadProgress(object sender, ProgressEventArgs e)
351 if(e.state == ProgressState.Start)
353 this.IsEnabled = false;
355 else if(e.state == ProgressState.Complete)
357 CoreTextRange modified_range = new CoreTextRange();
358 modified_range.StartCaretPosition = 0;
359 modified_range.EndCaretPosition = 0;
360 //キャレット位置はロード前と同じにしないと違和感を感じる
361 if (this.textEditContext != null)
362 this.textEditContext.NotifyTextChanged(modified_range, this.Document.Length, modified_range);
364 if (this.verticalScrollBar != null)
365 this.verticalScrollBar.Maximum = this.View.LayoutLines.Count;
366 this.IsEnabled = true;
367 this.Refresh(this.View.PageBound);
372 /// ドキュメントの内容をファイルに保存する
374 /// <param name="sw">StreamWriter</param>
375 /// <param name="enc">エンコード</param>
376 /// <returns>Taskオブジェクト</returns>
377 public async Task SaveFile(System.IO.StreamWriter sw, System.Threading.CancellationTokenSource token)
379 await this.Document.SaveAsync(sw, token);
394 async Task PasteCommand()
396 await this.PasteAsync();
406 protected override Windows.UI.Xaml.Automation.Peers.AutomationPeer OnCreateAutomationPeer()
408 this.peer = new FooTextBoxAutomationPeer(this);
413 protected override void OnApplyTemplate()
415 base.OnApplyTemplate();
417 Grid grid = this.GetTemplateChild("PART_Grid") as Grid;
420 Grid.SetRow(this.rectangle, 0);
421 Grid.SetColumn(this.rectangle, 0);
422 grid.Children.Add(this.rectangle);
425 this.horizontalScrollBar = this.GetTemplateChild("PART_HorizontalScrollBar") as ScrollBar;
426 if (this.horizontalScrollBar != null)
428 this.horizontalScrollBar.SmallChange = 10;
429 this.horizontalScrollBar.LargeChange = 100;
430 this.horizontalScrollBar.Maximum = this.horizontalScrollBar.LargeChange + 1;
431 this.horizontalScrollBar.Scroll += new ScrollEventHandler(horizontalScrollBar_Scroll);
433 this.verticalScrollBar = this.GetTemplateChild("PART_VerticalScrollBar") as ScrollBar;
434 if (this.verticalScrollBar != null)
436 this.verticalScrollBar.SmallChange = 1;
437 this.verticalScrollBar.LargeChange = 10;
438 this.verticalScrollBar.Maximum = this.View.LayoutLines.Count;
439 this.verticalScrollBar.Scroll += new ScrollEventHandler(verticalScrollBar_Scroll);
443 private void FooTextBox_LosingFocus(UIElement sender, LosingFocusEventArgs args)
445 this.RemoveTextContext();
447 this.textServiceManager.InputLanguageChanged -= TextServiceManager_InputLanguageChanged;
448 this.textServiceManager = null;
450 System.Diagnostics.Debug.WriteLine("losing focus");
453 private async void FooTextBox_GettingFocus(UIElement sender, GettingFocusEventArgs args)
455 System.Diagnostics.Debug.WriteLine("getting focus");
456 if (this.textServiceManager == null)
458 await Task.Delay(500);
459 this.textServiceManager = CoreTextServicesManager.GetForCurrentView();
460 this.textServiceManager.InputLanguageChanged += TextServiceManager_InputLanguageChanged;
463 this.CreateTextContext();
467 protected override void OnGotFocus(RoutedEventArgs e)
471 System.Diagnostics.Debug.WriteLine("got focus");
473 this.View.IsFocused = true;
474 this.timer.Interval = new TimeSpan(0, 0, 0, 0, Interval);
478 private void TextServiceManager_InputLanguageChanged(CoreTextServicesManager sender, object args)
480 System.Diagnostics.Debug.WriteLine("input language changed input script:"+ this.textServiceManager.InputLanguage.Script);
481 this.RemoveTextContext();
482 this.CreateTextContext();
486 protected override void OnLostFocus(RoutedEventArgs e)
490 System.Diagnostics.Debug.WriteLine("lost focus");
492 this.View.IsFocused = false;
493 this.Refresh(this.View.PageBound);
494 this.timer.Interval = new TimeSpan(0, 0, 0, 0, IntervalWhenLostFocus);
497 private void CreateTextContext()
499 if(this.textServiceManager != null)
501 this.textEditContext = this.textServiceManager.CreateEditContext();
502 this.textEditContext.InputScope = CoreTextInputScope.Text;
503 this.textEditContext.CompositionStarted += TextEditContext_CompositionStarted;
504 this.textEditContext.CompositionCompleted += TextEditContext_CompositionCompleted;
505 this.textEditContext.LayoutRequested += TextEditContext_LayoutRequested;
506 this.textEditContext.TextUpdating += TextEditContext_TextUpdating;
507 this.textEditContext.TextRequested += TextEditContext_TextRequested;
508 this.textEditContext.SelectionRequested += TextEditContext_SelectionRequested;
509 this.textEditContext.SelectionUpdating += TextEditContext_SelectionUpdating;
510 this.textEditContext.FormatUpdating += TextEditContext_FormatUpdating;
511 this.textEditContext.FocusRemoved += TextEditContext_FocusRemoved;
512 this.textEditContext.NotifyFocusLeaveCompleted += TextEditContext_NotifyFocusLeaveCompleted;
513 this.textEditContext.NotifyFocusEnter();
517 private void RemoveTextContext()
519 if(this.textEditContext != null)
521 this.textEditContext.NotifyFocusLeave();
522 this.textEditContext.CompositionStarted -= TextEditContext_CompositionStarted;
523 this.textEditContext.CompositionCompleted -= TextEditContext_CompositionCompleted;
524 this.textEditContext.LayoutRequested -= TextEditContext_LayoutRequested;
525 this.textEditContext.TextUpdating -= TextEditContext_TextUpdating;
526 this.textEditContext.TextRequested -= TextEditContext_TextRequested;
527 this.textEditContext.SelectionRequested -= TextEditContext_SelectionRequested;
528 this.textEditContext.SelectionUpdating -= TextEditContext_SelectionUpdating;
529 this.textEditContext.FormatUpdating -= TextEditContext_FormatUpdating;
530 this.textEditContext.FocusRemoved -= TextEditContext_FocusRemoved;
531 this.textEditContext.NotifyFocusLeaveCompleted -= TextEditContext_NotifyFocusLeaveCompleted;
532 this.textEditContext = null;
537 protected override async void OnKeyDown(KeyRoutedEventArgs e)
539 bool isControlPressed = this.IsModiferKeyPressed(VirtualKey.Control);
540 bool isShiftPressed = this.IsModiferKeyPressed(VirtualKey.Shift);
541 bool isMovedCaret = false;
543 var autocomplete = this.Document.AutoComplete as AutoCompleteBox;
544 if (autocomplete != null && autocomplete.ProcessKeyDown(this, e, isControlPressed, isShiftPressed))
550 this._Controller.MoveCaretVertical(-1, isShiftPressed);
555 case VirtualKey.Down:
556 this._Controller.MoveCaretVertical(+1, isShiftPressed);
561 case VirtualKey.Left:
562 this._Controller.MoveCaretHorizontical(-1, isShiftPressed, isControlPressed);
567 case VirtualKey.Right:
568 this._Controller.MoveCaretHorizontical(1, isShiftPressed, isControlPressed);
573 case VirtualKey.PageUp:
574 this._Controller.Scroll(ScrollDirection.Up, this.View.LineCountOnScreen, isShiftPressed, true);
578 case VirtualKey.PageDown:
579 this._Controller.Scroll(ScrollDirection.Down, this.View.LineCountOnScreen, isShiftPressed, true);
583 case VirtualKey.Home:
584 if (isControlPressed)
585 this._Controller.JumpToHead(isShiftPressed);
587 this.Controller.JumpToLineHead(this.Document.CaretPostion.row,isShiftPressed);
592 if (isControlPressed)
593 this._Controller.JumpToEnd(isShiftPressed);
595 this.Controller.JumpToLineEnd(this.Document.CaretPostion.row,isShiftPressed);
600 if (!isControlPressed)
602 if (this._Controller.SelectionLength == 0)
603 this._Controller.DoInputChar('\t');
604 else if (isShiftPressed)
605 this._Controller.DownIndent();
607 this._Controller.UpIndent();
612 case VirtualKey.Enter:
613 this._Controller.DoEnterAction();
617 case VirtualKey.Insert:
618 if(this.View.InsertMode)
619 this.View.InsertMode = false;
621 this.View.InsertMode = true;
626 if (isControlPressed)
634 if (isControlPressed)
636 if (this._Controller.RectSelection)
637 this._Controller.RectSelection = false;
639 this._Controller.RectSelection = true;
645 if (isControlPressed)
652 if (isControlPressed)
659 if (isControlPressed)
661 await this.PasteCommand();
666 if (isControlPressed)
668 this.Document.UndoManager.redo();
674 if (isControlPressed)
676 this.Document.UndoManager.undo();
681 case VirtualKey.Back:
682 this._Controller.DoBackSpaceAction();
686 case VirtualKey.Delete:
687 this._Controller.DoDeleteAction();
693 if (isMovedCaret && this.peer != null)
694 this.peer.OnNotifyCaretChanged();
700 protected override void OnPointerPressed(PointerRoutedEventArgs e)
702 System.Diagnostics.Debug.WriteLine("pointer pressed");
703 this.CapturePointer(e.Pointer);
704 this.gestureRecongnizer.ProcessDownEvent(e.GetCurrentPoint(this));
709 protected override void OnPointerMoved(PointerRoutedEventArgs e)
711 System.Diagnostics.Debug.WriteLine("pointer moved");
714 this.gestureRecongnizer.ProcessMoveEvents(e.GetIntermediatePoints(this));
715 }catch(System.Runtime.InteropServices.COMException ex)
717 //ピンチズームでこの例外が発生するが、回避できない
718 System.Diagnostics.Debug.WriteLine("expection:" + ex);
722 if (e.Pointer.PointerDeviceType == PointerDeviceType.Mouse)
724 Point p = e.GetCurrentPoint(this).Position;
725 if (this.View.HitTextArea(p.X, p.Y))
727 TextPoint tp = this.View.GetTextPointFromPostion(p);
728 if (this._Controller.IsMarker(tp, HilightType.Url))
729 Window.Current.CoreWindow.PointerCursor = new CoreCursor(CoreCursorType.Hand, 101);
731 Window.Current.CoreWindow.PointerCursor = new CoreCursor(CoreCursorType.IBeam, 101);
735 Window.Current.CoreWindow.PointerCursor = new CoreCursor(CoreCursorType.Arrow, 101);
741 protected override void OnPointerReleased(PointerRoutedEventArgs e)
743 System.Diagnostics.Debug.WriteLine("pointer released");
744 this.gestureRecongnizer.ProcessUpEvent(e.GetCurrentPoint(this));
749 protected override void OnPointerCanceled(PointerRoutedEventArgs e)
751 System.Diagnostics.Debug.WriteLine("pointer canceled");
752 this.gestureRecongnizer.CompleteGesture();
757 protected override void OnPointerWheelChanged(PointerRoutedEventArgs e)
759 System.Diagnostics.Debug.WriteLine("pointer wheelchanged");
760 bool shift = (e.KeyModifiers & Windows.System.VirtualKeyModifiers.Shift) ==
761 Windows.System.VirtualKeyModifiers.Shift;
762 bool ctrl = (e.KeyModifiers & Windows.System.VirtualKeyModifiers.Control) ==
763 Windows.System.VirtualKeyModifiers.Control;
764 this.gestureRecongnizer.ProcessMouseWheelEvent(e.GetCurrentPoint(this), shift, ctrl);
768 private void TextEditContext_FormatUpdating(CoreTextEditContext sender, CoreTextFormatUpdatingEventArgs args)
770 if (this.Document.Length == 0 || args.IsCanceled)
772 args.Result = CoreTextFormatUpdatingResult.Failed;
775 System.Diagnostics.Debug.WriteLine("core text format updating range({0}-{1}) underline type:{2} underline color:{3} reason:{4} textcolor:{5} background:{6}",
776 args.Range.StartCaretPosition,
777 args.Range.EndCaretPosition,
784 HilightType type = HilightType.None;
785 Color color = new Color(this.Foreground.A,this.Foreground.R,this.Foreground.G,this.Foreground.R);
786 bool isBoldLine = false;
787 switch (args.UnderlineType)
789 case UnderlineType.Dotted:
790 type = HilightType.Dot;
792 case UnderlineType.Single:
793 type = HilightType.Sold;
795 case UnderlineType.Dash:
796 type = HilightType.Dash;
798 case UnderlineType.Wave:
799 type = HilightType.Squiggle;
801 case UnderlineType.Thin:
802 type = HilightType.Sold;
804 case UnderlineType.Thick:
805 type = HilightType.Sold;
809 int start = args.Range.StartCaretPosition;
810 int lengt = args.Range.EndCaretPosition - args.Range.StartCaretPosition;
811 this.Document.SetMarker(MarkerIDs.IME, Marker.Create(start, lengt, type, color, isBoldLine));
813 if (args.Reason == CoreTextFormatUpdatingReason.CompositionTargetConverted)
815 this.View.AdjustSrc(args.Range.StartCaretPosition);
819 args.Result = CoreTextFormatUpdatingResult.Succeeded;
822 private void TextEditContext_TextRequested(CoreTextEditContext sender, CoreTextTextRequestedEventArgs args)
824 CoreTextTextRequest req = args.Request;
826 if (this.Document.Length == 0 || req.IsCanceled)
831 int start = req.Range.StartCaretPosition;
832 int end = req.Range.EndCaretPosition;
833 if (end > this.Document.Length)
834 end = this.Document.Length;
836 int length = end - start;
838 System.Diagnostics.Debug.WriteLine("req text start:{0} length:{1}", start, length);
840 //キャレット位置も含むので+1する必要はない
841 req.Text = this.Document.ToString(start,length);
844 private void TextEditContext_LayoutRequested(CoreTextEditContext sender, CoreTextLayoutRequestedEventArgs args)
847 Point startPos, endPos;
848 int i_startIndex = args.Request.Range.StartCaretPosition;
849 int i_endIndex = args.Request.Range.EndCaretPosition;
851 if(args.Request.IsCanceled)
856 System.Diagnostics.Debug.WriteLine("core text layoutreq range({0}-{1})",i_startIndex,i_endIndex);
858 if (i_startIndex != -1 && i_endIndex != -1)
860 TextStoreHelper.GetStringExtent(this.Document, this.View, i_startIndex, i_endIndex, out startPos, out endPos);
862 double scale = Util.GetScale();
864 //Core.Textはスクリーン座標に変換してくれないので自前で変換する(しかも、デバイス依存の座標で返さないといけない)
865 var screenStartPos = Util.GetScreentPoint(startPos, this).Scale(scale);
866 var screenEndPos = Util.GetScreentPoint(endPos, this).Scale(scale);
867 args.Request.LayoutBounds.TextBounds = new Rect(
870 Math.Max(0,screenEndPos.X - screenStartPos.X), //折り返されている場合、負になることがある
871 screenEndPos.Y - screenStartPos.Y);
875 var controlTopLeft = new Point(0, 0);
876 var controlBottomRight = new Point(this.RenderSize.Width, this.RenderSize.Height);
878 var gt = this.TransformToVisual(Window.Current.Content);
879 controlTopLeft = gt.TransformPoint(controlTopLeft);
880 controlBottomRight = gt.TransformPoint(controlBottomRight);
882 args.Request.LayoutBounds.ControlBounds = new Rect(
885 controlBottomRight.X - controlTopLeft.X,
886 controlBottomRight.Y - controlTopLeft.Y
890 private void TextEditContext_SelectionRequested(CoreTextEditContext sender, CoreTextSelectionRequestedEventArgs args)
892 if(args.Request.IsCanceled || this.Document.Length == 0)
896 TextRange currentSelection = new TextRange();
897 TextStoreHelper.GetSelection(this._Controller, this.View.Selections, out currentSelection);
899 CoreTextRange currentSelectionRange = new CoreTextRange();
900 currentSelectionRange.StartCaretPosition = currentSelection.Index;
901 currentSelectionRange.EndCaretPosition = currentSelection.Index + currentSelection.Length;
902 args.Request.Selection = currentSelectionRange;
903 System.Diagnostics.Debug.WriteLine("req selection start:{0} end:{1}", currentSelectionRange.StartCaretPosition, currentSelectionRange.EndCaretPosition);
906 private void TextEditContext_SelectionUpdating(CoreTextEditContext sender, CoreTextSelectionUpdatingEventArgs args)
908 if(this.Document.Length == 0 || args.IsCanceled)
910 args.Result = CoreTextSelectionUpdatingResult.Failed;
913 CoreTextRange sel = args.Selection;
914 System.Diagnostics.Debug.WriteLine("update selection start:{0} end:{1}", sel.StartCaretPosition, sel.EndCaretPosition);
915 TextStoreHelper.SetSelectionIndex(this.Controller, this.View, sel.StartCaretPosition, sel.EndCaretPosition);
916 args.Result = CoreTextSelectionUpdatingResult.Succeeded;
920 private void TextEditContext_TextUpdating(CoreTextEditContext sender, CoreTextTextUpdatingEventArgs args)
922 this.nowCompstion = true;
924 System.Diagnostics.Debug.WriteLine("update text (modify start:{0} end:{1}) text:{2} (new sel start:{0} end:{1})",
925 args.Range.StartCaretPosition,
926 args.Range.EndCaretPosition,
928 args.NewSelection.StartCaretPosition,
929 args.NewSelection.EndCaretPosition);
930 bool isTip = args.InputLanguage.Script == "Latan";
931 CoreTextRange sel = args.Range;
932 TextStoreHelper.SetSelectionIndex(this.Controller, this.View, sel.StartCaretPosition, sel.EndCaretPosition);
933 TextStoreHelper.InsertTextAtSelection(this._Controller, args.Text, isTip);
935 args.Result = CoreTextTextUpdatingResult.Succeeded;
937 this.nowCompstion = false;
940 private void TextEditContext_CompositionCompleted(CoreTextEditContext sender, CoreTextCompositionCompletedEventArgs args)
942 System.Diagnostics.Debug.WriteLine("end compostion");
943 TextStoreHelper.EndCompostion(this.Document);
944 this.Document.RemoveAllMarker(MarkerIDs.IME);
948 private void TextEditContext_CompositionStarted(CoreTextEditContext sender, CoreTextCompositionStartedEventArgs args)
950 System.Diagnostics.Debug.WriteLine("start compstion");
951 TextStoreHelper.StartCompstion(this.Document);
954 private void TextEditContext_NotifyFocusLeaveCompleted(CoreTextEditContext sender, object args)
956 System.Diagnostics.Debug.WriteLine("notify focus leaved");
959 private void TextEditContext_FocusRemoved(CoreTextEditContext sender, object args)
961 System.Diagnostics.Debug.WriteLine("focus leaved");
964 void Controller_SelectionChanged(object sender, EventArgs e)
966 if (this._Controller == null)
970 this.nowCaretMove = true;
971 SetValue(SelectedTextProperty, this._Controller.SelectedText);
972 SetValue(CaretPostionPropertyKey, this.Document.CaretPostion);
973 this.nowCaretMove = false;
975 if(!this.nowCompstion)
977 TextRange currentSelection = new TextRange();
978 TextStoreHelper.GetSelection(this._Controller, this.View.Selections, out currentSelection);
980 CoreTextRange currentSelectionRange = new CoreTextRange();
981 currentSelectionRange.StartCaretPosition = currentSelection.Index;
982 currentSelectionRange.EndCaretPosition = currentSelection.Index + currentSelection.Length;
984 System.Diagnostics.Debug.WriteLine("notify selection start:{0} end:{1}", currentSelectionRange.StartCaretPosition, currentSelectionRange.EndCaretPosition);
986 if (this.textEditContext != null)
987 this.textEditContext.NotifySelectionChanged(currentSelectionRange);
991 Gripper hittedGripper;
992 void gestureRecongnizer_ManipulationStarted(GestureRecognizer sender, ManipulationStartedEventArgs e)
994 //Updateedの段階でヒットテストしてしまうとグリッパーを触ってもヒットしないことがある
995 this.hittedGripper = this.View.HitGripperFromPoint(e.Position);
998 private void GestureRecongnizer_ManipulationInertiaStarting(GestureRecognizer sender, ManipulationInertiaStartingEventArgs args)
1000 //sender.InertiaTranslationDeceleration = 0.001f;
1001 //sender.InertiaExpansionDeceleration = 100.0f * 96.0f / 1000.0f;
1002 //sender.InertiaRotationDeceleration = 720.0f / (1000.0f * 1000.0f);
1005 void gestureRecongnizer_ManipulationUpdated(GestureRecognizer sender, ManipulationUpdatedEventArgs e)
1007 if (e.Delta.Scale < 1)
1009 double newSize = this.Render.FontSize - 1;
1012 this.Render.FontSize = newSize;
1014 SetValue(MagnificationPowerPropertyKey, this.Render.FontSize / this.FontSize);
1018 if (e.Delta.Scale > 1)
1020 double newSize = this.Render.FontSize + 1;
1023 this.Render.FontSize = newSize;
1025 SetValue(MagnificationPowerPropertyKey, this.Render.FontSize / this.FontSize);
1029 if (this._Controller.MoveCaretAndGripper(e.Position, this.hittedGripper))
1031 #if ENABLE_AUTMATION
1032 if (this.peer != null)
1033 this.peer.OnNotifyCaretChanged();
1039 Point translation = e.Delta.Translation;
1041 //Xの絶対値が大きければ横方向のスクロールで、そうでなければ縦方向らしい
1042 if (Math.Abs(e.Cumulative.Translation.X) < Math.Abs(e.Cumulative.Translation.Y))
1044 int deltay = (int)Math.Abs(Math.Ceiling(translation.Y));
1045 if (translation.Y < 0)
1046 this._Controller.ScrollByPixel(ScrollDirection.Down, deltay, false, false);
1048 this._Controller.ScrollByPixel(ScrollDirection.Up, deltay, false, false);
1053 int deltax = (int)Math.Abs(Math.Ceiling(translation.X));
1056 if (translation.X < 0)
1057 this._Controller.Scroll(ScrollDirection.Left, deltax, false, false);
1059 this._Controller.Scroll(ScrollDirection.Right, deltax, false, false);
1064 void gestureRecongnizer_ManipulationCompleted(GestureRecognizer sender, ManipulationCompletedEventArgs e)
1068 async void gestureRecongnizer_RightTapped(GestureRecognizer sender, RightTappedEventArgs e)
1070 ResourceMap map = ResourceManager.Current.MainResourceMap.GetSubtree("FooEditEngine.UWP/Resources");
1071 ResourceContext context = ResourceContext.GetForCurrentView();
1072 if (this.View.HitTextArea(e.Position.X, e.Position.Y))
1074 FooContextMenuEventArgs args = new FooContextMenuEventArgs(e.Position);
1075 if (this.ContextMenuOpening != null)
1076 this.ContextMenuOpening(this, args);
1079 PopupMenu ContextMenu = new PopupMenu();
1080 ContextMenu.Commands.Add(new UICommand(map.GetValue("CopyMenuName", context).ValueAsString, (command) =>
1084 ContextMenu.Commands.Add(new UICommand(map.GetValue("CutMenuName", context).ValueAsString, (command) =>
1088 ContextMenu.Commands.Add(new UICommand(map.GetValue("PasteMenuName", context).ValueAsString, async (command) =>
1090 await this.PasteCommand();
1092 if (this._Controller.RectSelection)
1094 ContextMenu.Commands.Add(new UICommand(map.GetValue("LineSelectMenuName", context).ValueAsString, (command) =>
1096 this._Controller.RectSelection = false;
1101 ContextMenu.Commands.Add(new UICommand(map.GetValue("RectSelectMenuName", context).ValueAsString, (command) =>
1103 this._Controller.RectSelection = true;
1106 var windowStartPos = Util.GetPointInWindow(e.Position, this);
1107 await ContextMenu.ShowAsync(windowStartPos);
1112 long lastDouleTapTick;
1113 const long allowTripleTapTimeSpan = 500;
1114 void gestureRecongnizer_Tapped(GestureRecognizer sender, TappedEventArgs e)
1116 bool touched = e.PointerDeviceType == PointerDeviceType.Touch;
1117 this.Document.SelectGrippers.BottomLeft.Enabled = false;
1118 this.Document.SelectGrippers.BottomRight.Enabled = touched;
1119 this.JumpCaret(e.Position);
1120 if(e.TapCount == 1 && System.DateTime.Now.Ticks - lastDouleTapTick < allowTripleTapTimeSpan * 10000) //トリプルタップ
1122 //タッチスクリーンで行選択した場合、アンカーインデックスを単語の先頭にしないとバグる
1123 this.Document.SelectGrippers.BottomLeft.Enabled = touched;
1124 this.Document.SelectLine(this.Controller.SelectionStart, touched);
1127 else if(e.TapCount == 2) //ダブルタップ
1129 //タッチスクリーンで単語選択した場合、アンカーインデックスを単語の先頭にしないとバグる
1130 this.Document.SelectGrippers.BottomLeft.Enabled = touched;
1131 if (e.Position.X < this.Render.TextArea.X)
1132 this.Document.SelectLine(this.Controller.SelectionStart, touched);
1134 this.Document.SelectWord(this.Controller.SelectionStart, touched);
1135 this.lastDouleTapTick = System.DateTime.Now.Ticks;
1140 void JumpCaret(Point p)
1142 TextPoint tp = this.View.GetTextPointFromPostion(p);
1143 if (tp == TextPoint.Null)
1146 int index = this.View.LayoutLines.GetIndexFromTextPoint(tp);
1148 FoldingItem foldingData = this.View.HitFoldingData(p.X, tp.row);
1149 if (foldingData != null)
1151 if (foldingData.Expand)
1152 this.View.LayoutLines.FoldingCollection.Collapse(foldingData);
1154 this.View.LayoutLines.FoldingCollection.Expand(foldingData);
1155 this._Controller.JumpCaret(foldingData.Start, false);
1159 this._Controller.JumpCaret(tp.row, tp.col, false);
1161 #if ENABLE_AUTMATION
1162 if (this.peer != null)
1163 this.peer.OnNotifyCaretChanged();
1165 this.View.IsFocused = true;
1166 this.Focus(FocusState.Programmatic);
1170 void gestureRecongnizer_Dragging(GestureRecognizer sender, DraggingEventArgs e)
1172 Point p = e.Position;
1173 TextPointSearchRange searchRange;
1174 if (this.View.HitTextArea(p.X, p.Y))
1175 searchRange = TextPointSearchRange.TextAreaOnly;
1176 else if (this._Controller.SelectionLength > 0)
1177 searchRange = TextPointSearchRange.Full;
1180 TextPoint tp = this.View.GetTextPointFromPostion(p, searchRange);
1181 this._Controller.MoveCaretAndSelect(tp, this.IsModiferKeyPressed(VirtualKey.LeftControl));
1182 #if ENABLE_AUTMATION
1183 if (this.peer != null)
1184 this.peer.OnNotifyCaretChanged();
1189 bool IsModiferKeyPressed(VirtualKey key)
1191 CoreVirtualKeyStates state = Window.Current.CoreWindow.GetKeyState(key);
1192 return (state & CoreVirtualKeyStates.Down) == CoreVirtualKeyStates.Down;
1194 void Refresh(Rectangle updateRect)
1196 if (this.rectangle.ActualWidth == 0 || this.rectangle.ActualHeight == 0 || this.Visibility == Windows.UI.Xaml.Visibility.Collapsed)
1199 this.Render.DrawContent(this.View, this.IsEnabled, updateRect);
1201 this.Document.IsRequestRedraw = false;
1205 bool Resize(double width, double height)
1207 if (width == 0 || height == 0)
1208 throw new ArgumentOutOfRangeException();
1209 if (this.Render.Resize(this.rectangle, width, height))
1211 this.View.PageBound = new Rectangle(0, 0, width, height);
1213 if (this.horizontalScrollBar != null)
1215 this.horizontalScrollBar.LargeChange = this.View.PageBound.Width;
1216 this.horizontalScrollBar.Maximum = this.View.LongestWidth + this.horizontalScrollBar.LargeChange + 1;
1218 if (this.verticalScrollBar != null)
1220 this.verticalScrollBar.LargeChange = this.View.LineCountOnScreen;
1221 this.verticalScrollBar.Maximum = this.View.LayoutLines.Count + this.verticalScrollBar.LargeChange + 1;
1228 void View_SrcChanged(object sender, EventArgs e)
1230 if (this.horizontalScrollBar == null || this.verticalScrollBar == null)
1232 EditView view = this.View;
1233 if (view.Src.Row > this.verticalScrollBar.Maximum)
1234 this.verticalScrollBar.Maximum = view.Src.Row + view.LineCountOnScreen + 1;
1235 double absoulteX = Math.Abs(view.Src.X);
1236 if (absoulteX > this.horizontalScrollBar.Maximum)
1237 this.horizontalScrollBar.Maximum = absoulteX + view.PageBound.Width + 1;
1238 if (view.Src.Row != this.verticalScrollBar.Value)
1239 this.verticalScrollBar.Value = view.Src.Row;
1240 if (view.Src.X != this.horizontalScrollBar.Value)
1241 this.horizontalScrollBar.Value = Math.Abs(view.Src.X);
1244 void FooTextBox_SizeChanged(object sender, SizeChangedEventArgs e)
1246 if (this.Resize(this.rectangle.ActualWidth, this.rectangle.ActualHeight))
1249 this.Refresh(this.View.PageBound);
1253 void horizontalScrollBar_Scroll(object sender, ScrollEventArgs e)
1255 if (this.horizontalScrollBar == null)
1258 if (this.FlowDirection == FlowDirection.LeftToRight)
1259 toX = this.horizontalScrollBar.Value;
1261 toX = -this.horizontalScrollBar.Value;
1262 this._Controller.Scroll(toX, this.View.Src.Row, false, false);
1266 void verticalScrollBar_Scroll(object sender, ScrollEventArgs e)
1268 if (this.verticalScrollBar == null)
1270 int newRow = (int)this.verticalScrollBar.Value;
1271 if (newRow >= this.View.LayoutLines.Count)
1273 this._Controller.Scroll(this.View.Src.X, newRow, false, false);
1277 void Document_Update(object sender, DocumentUpdateEventArgs e)
1279 if (e.type == UpdateType.Replace && !this.nowCompstion)
1281 CoreTextRange oldTextRange = new CoreTextRange();
1282 oldTextRange.StartCaretPosition = e.startIndex;
1283 oldTextRange.EndCaretPosition = e.startIndex;
1284 //削除する範囲が1以上の場合、ドキュメントを飛び越えることはできない
1285 //https://msdn.microsoft.com/en-us/windows/uwp/input-and-devices/custom-text-input
1286 if (e.removeLength > 0)
1287 oldTextRange.EndCaretPosition += e.removeLength;
1289 TextRange currentSelection = new TextRange();
1290 TextStoreHelper.GetSelection(this._Controller, this.View.Selections, out currentSelection);
1292 CoreTextRange newSelection = new CoreTextRange();
1293 newSelection.StartCaretPosition = e.startIndex;
1294 newSelection.EndCaretPosition = e.startIndex;
1297 //(注意:削除された文字数のほうが多い場合は0を指定しないいけない)
1298 int newTextLength = e.insertLength;
1300 System.Diagnostics.Debug.WriteLine("notify text change (modify start:{0} end:{1}) newlength:{2} (new sel start:{3} end:{4})",
1301 oldTextRange.StartCaretPosition, oldTextRange.EndCaretPosition, newTextLength, newSelection.StartCaretPosition, newSelection.EndCaretPosition);
1303 if(this.textEditContext != null)
1304 this.textEditContext.NotifyTextChanged(oldTextRange, newTextLength, newSelection);
1306 #if ENABLE_AUTMATION
1307 if (this.peer != null)
1308 this.peer.OnNotifyTextChanged();
1312 void FooTextBox_Loaded(object sender, RoutedEventArgs e)
1314 this.Focus(FocusState.Programmatic);
1317 void timer_Tick(object sender, object e)
1319 if (this.View.LayoutLines.HilightAll() || this.View.LayoutLines.GenerateFolding() || this.Document.IsRequestRedraw)
1321 this.Refresh(this.View.PageBound);
1325 private void SetDocument(Document value)
1330 Document old_doc = this._Document;
1332 if (this._Document != null)
1334 old_doc.Update -= new DocumentUpdateEventHandler(Document_Update);
1335 this._Document.SelectionChanged -= Controller_SelectionChanged;
1336 this._Document.LoadProgress -= Document_LoadProgress;
1337 this._Document.AutoCompleteChanged -= _Document_AutoCompleteChanged;
1338 if (this._Document.AutoComplete != null)
1340 this._Document.AutoComplete.GetPostion = null;
1341 this._Document.AutoComplete = null;
1344 //NotifyTextChanged()を呼び出すと落ちるのでTextConextをごっそり作り替える
1345 this.RemoveTextContext();
1348 System.Diagnostics.Debug.WriteLine("document switched");
1350 this._Document = value;
1351 this._Document.LayoutLines.Render = this.Render;
1352 this._Document.Update += new DocumentUpdateEventHandler(Document_Update);
1353 this._Document.LoadProgress += Document_LoadProgress;
1354 this._Document.AutoCompleteChanged += _Document_AutoCompleteChanged;
1355 if (this._Document.AutoComplete != null && this._Document.AutoComplete.GetPostion == null)
1356 this._Document_AutoCompleteChanged(this._Document, null);
1357 //初期化が終わっていればすべて存在する
1358 if (this.Controller != null && this.View != null)
1360 this.Controller.Document = value;
1361 this.View.Document = value;
1363 this.Controller.AdjustCaret();
1365 this.CreateTextContext();
1367 //依存プロパティとドキュメント内容が食い違っているので再設定する
1368 this.ShowFullSpace = value.ShowFullSpace;
1369 this.ShowHalfSpace = value.ShowHalfSpace;
1370 this.ShowLineBreak = value.ShowLineBreak;
1371 this.ShowTab = value.ShowTab;
1372 this.FlowDirection = value.RightToLeft ? FlowDirection.RightToLeft : FlowDirection.LeftToRight;
1373 this.IndentMode = value.IndentMode;
1374 this.DrawCaretLine = !value.HideLineMarker;
1375 this.InsertMode = value.InsertMode;
1376 this.DrawRuler = !value.HideRuler;
1377 this.DrawLineNumber = value.DrawLineNumber;
1378 this.MarkURL = value.UrlMark;
1379 this.LineBreakMethod = value.LineBreak;
1380 this.LineBreakCharCount = value.LineBreakCharCount;
1381 this.TabChars = value.TabStops;
1385 //TextEditContext作成後に設定しないと落ちることがある
1386 this._Document.SelectionChanged += Controller_SelectionChanged;
1389 private void _Document_AutoCompleteChanged(object sender, EventArgs e)
1391 Document doc = (Document)sender;
1392 doc.AutoComplete.GetPostion = (tp, e_doc) =>
1394 var p = this.View.GetPostionFromTextPoint(tp);
1395 int height = (int)e_doc.LayoutLines.GetLayout(e_doc.CaretPostion.row).Height;
1397 if (p.Y + AutoCompleteBox.CompleteListBoxHeight + height > e_doc.LayoutLines.Render.TextArea.Height)
1398 p.Y -= AutoCompleteBox.CompleteListBoxHeight;
1401 //AutoCompleteBox内ではCanvasで位置を指定しているので変換する必要がある
1402 var pointInWindow = Util.GetPointInWindow(p, this);
1403 return pointInWindow;
1408 public static void OnPropertyChanged(object sender, DependencyPropertyChangedEventArgs e)
1410 FooTextBox source = (FooTextBox)sender;
1411 if(e.Property.Equals(SelectedTextProperty) && !source.nowCaretMove)
1412 source._Controller.SelectedText = source.SelectedText;
1413 if (e.Property.Equals(DocumentProperty))
1414 source.SetDocument(source.Document);
1415 if(e.Property.Equals(HilighterProperty))
1416 source.View.Hilighter = source.Hilighter;
1417 if (e.Property.Equals(FoldingStrategyProperty))
1418 source.View.LayoutLines.FoldingStrategy = source.FoldingStrategy;
1419 if (e.Property.Equals(IndentModeProperty))
1420 source.Controller.IndentMode = source.IndentMode;
1421 if (e.Property.Equals(SelectionProperty) && !source.nowCaretMove)
1422 source.Document.Select(source.Selection.Index,source.Selection.Length);
1423 if (e.Property.Equals(CaretPostionPropertyKey) && !source.nowCaretMove)
1424 source.JumpCaret(source.CaretPostion.row, source.CaretPostion.col);
1425 if (e.Property.Equals(InsertModeProperty))
1426 source.View.InsertMode = source.InsertMode;
1427 if (e.Property.Equals(TabCharsProperty))
1428 source.Document.TabStops = source.TabChars;
1429 if (e.Property.Equals(RectSelectModeProperty))
1430 source._Controller.RectSelection = source.RectSelectMode;
1431 if (e.Property.Equals(DrawCaretProperty))
1432 source.View.HideCaret = !source.DrawCaret;
1433 if (e.Property.Equals(DrawCaretLineProperty))
1434 source.View.HideLineMarker = !source.DrawCaretLine;
1435 if (e.Property.Equals(DrawLineNumberProperty))
1436 source.Document.DrawLineNumber = source.DrawLineNumber;
1437 if (e.Property.Equals(MarkURLProperty))
1438 source.Document.UrlMark = source.MarkURL;
1439 if (e.Property.Equals(LineBreakProperty))
1440 source.Document.LineBreak = source.LineBreakMethod;
1441 if (e.Property.Equals(LineBreakCharCountProperty))
1442 source.Document.LineBreakCharCount = source.LineBreakCharCount;
1443 if (e.Property.Equals(FlowDirectionProperty))
1445 source.Document.RightToLeft = source.FlowDirection == Windows.UI.Xaml.FlowDirection.RightToLeft;
1446 if (source.horizontalScrollBar != null)
1447 source.horizontalScrollBar.FlowDirection = source.FlowDirection;
1449 if (e.Property.Equals(DrawRulerProperty))
1451 source.Document.HideRuler = !source.DrawRuler;
1452 source._Controller.JumpCaret(source.Document.CaretPostion.row, source.Document.CaretPostion.col);
1455 if (e.Property.Equals(TextAntialiasModeProperty))
1456 source.Render.TextAntialiasMode = source.TextAntialiasMode;
1457 if(e.Property.Equals(MagnificationPowerPropertyKey))
1458 source.Render.FontSize = source.FontSize * source.MagnificationPower;
1459 if (e.Property.Equals(FontFamilyProperty))
1460 source.Render.FontFamily = source.FontFamily;
1461 if (e.Property.Equals(FontStyleProperty))
1462 source.Render.FontStyle = source.FontStyle;
1463 if (e.Property.Equals(FontWeightProperty))
1464 source.Render.FontWeigth = source.FontWeight;
1465 if (e.Property.Equals(FontSizeProperty))
1466 source.Render.FontSize = source.FontSize;
1467 if (e.Property.Equals(ForegroundProperty))
1468 source.Render.Foreground = D2DRenderBase.ToColor4(source.Foreground);
1469 if (e.Property.Equals(HilightForegroundProperty))
1470 source.Render.HilightForeground = D2DRenderBase.ToColor4(source.HilightForeground);
1471 if (e.Property.Equals(BackgroundProperty))
1472 source.Render.Background = D2DRenderBase.ToColor4(source.Background);
1473 if (e.Property.Equals(ControlCharProperty))
1474 source.Render.ControlChar = D2DRenderBase.ToColor4(source.ControlChar);
1475 if (e.Property.Equals(HilightProperty))
1476 source.Render.Hilight = D2DRenderBase.ToColor4(source.Hilight);
1477 if (e.Property.Equals(Keyword1Property))
1478 source.Render.Keyword1 = D2DRenderBase.ToColor4(source.Keyword1);
1479 if (e.Property.Equals(Keyword2Property))
1480 source.Render.Keyword2 = D2DRenderBase.ToColor4(source.Keyword2);
1481 if (e.Property.Equals(CommentProperty))
1482 source.Render.Comment = D2DRenderBase.ToColor4(source.Comment);
1483 if (e.Property.Equals(LiteralProperty))
1484 source.Render.Literal = D2DRenderBase.ToColor4(source.Literal);
1485 if (e.Property.Equals(URLProperty))
1486 source.Render.Url = D2DRenderBase.ToColor4(source.URL);
1487 if (e.Property.Equals(InsertCaretProperty))
1488 source.Render.InsertCaret = D2DRenderBase.ToColor4(source.InsertCaret);
1489 if (e.Property.Equals(OverwriteCaretProperty))
1490 source.Render.OverwriteCaret = D2DRenderBase.ToColor4(source.OverwriteCaret);
1491 if (e.Property.Equals(PaddingProperty))
1492 source.View.Padding = new Padding((int)source.Padding.Left, (int)source.Padding.Top, (int)source.Padding.Right, (int)source.Padding.Bottom);
1493 if (e.Property.Equals(LineMarkerProperty))
1494 source.Render.LineMarker = D2DRenderBase.ToColor4(source.LineMarker);
1495 if (e.Property.Equals(ShowFullSpaceProperty))
1496 source.Render.ShowFullSpace = source.ShowFullSpace;
1497 if (e.Property.Equals(ShowHalfSpaceProperty))
1498 source.Render.ShowHalfSpace = source.ShowHalfSpace;
1499 if (e.Property.Equals(ShowTabProperty))
1500 source.Render.ShowTab = source.ShowTab;
1501 if (e.Property.Equals(ShowLineBreakProperty))
1502 source.Render.ShowLineBreak = source.ShowLineBreak;
1503 if (e.Property.Equals(UpdateAreaProperty))
1504 source.Render.UpdateArea = D2DRenderBase.ToColor4(source.UpdateArea);
1505 if (e.Property.Equals(LineNumberProperty))
1506 source.Render.LineNumber = D2DRenderBase.ToColor4(source.LineNumber);
1514 /// コンテキストメニューが表示されるときに呼び出されます
1516 public event EventHandler<FooContextMenuEventArgs> ContextMenuOpening;
1522 internal Controller Controller
1526 return this._Controller;
1531 /// 文字列の描写に使用されるアンチエイリアシング モードを表します
1533 public TextAntialiasMode TextAntialiasMode
1535 get { return (TextAntialiasMode)GetValue(TextAntialiasModeProperty); }
1536 set { SetValue(TextAntialiasModeProperty, value); }
1540 /// TextAntialiasModeの依存プロパティを表す
1542 public static readonly DependencyProperty TextAntialiasModeProperty =
1543 DependencyProperty.Register("TextAntialiasMode", typeof(TextAntialiasMode), typeof(FooTextBox), new PropertyMetadata(TextAntialiasMode.Default, OnPropertyChanged));
1548 public IHilighter Hilighter
1550 get { return (IHilighter)GetValue(HilighterProperty); }
1551 set { SetValue(HilighterProperty, value); }
1555 /// Hilighterの依存プロパティを表す
1557 public static readonly DependencyProperty HilighterProperty =
1558 DependencyProperty.Register("Hilighter", typeof(IHilighter), typeof(FooTextBox), new PropertyMetadata(null, OnPropertyChanged));
1561 /// フォールティングを作成するインターフェイスを表す
1563 public IFoldingStrategy FoldingStrategy
1565 get { return (IFoldingStrategy)GetValue(FoldingStrategyProperty); }
1566 set { SetValue(FoldingStrategyProperty, value); }
1570 /// FoldingStrategyの依存プロパティ
1572 public static readonly DependencyProperty FoldingStrategyProperty =
1573 DependencyProperty.Register("FoldingStrategy", typeof(IFoldingStrategy), typeof(FooTextBox), new PropertyMetadata(null,OnPropertyChanged));
1578 public MarkerPatternSet MarkerPatternSet
1582 return this.Document.MarkerPatternSet;
1589 /// <remarks>切り替え後に再描写が行われます</remarks>
1590 public Document Document
1592 get { return (Document)GetValue(DocumentProperty); }
1593 set { SetValue(DocumentProperty, value); }
1596 // Using a DependencyProperty as the backing store for Document. This enables animation, styling, binding, etc...
1597 public static readonly DependencyProperty DocumentProperty =
1598 DependencyProperty.Register("Document", typeof(Document), typeof(FooTextBox), new PropertyMetadata(null, OnPropertyChanged));
1605 public LineToIndexTable LayoutLineCollection
1607 get { return this.View.LayoutLines; }
1613 public string SelectedText
1615 get { return (string)GetValue(SelectedTextProperty); }
1616 set { SetValue(SelectedTextProperty, value); }
1620 /// SelectedTextの依存プロパティを表す
1622 public static readonly DependencyProperty SelectedTextProperty =
1623 DependencyProperty.Register("SelectedText", typeof(string), typeof(FooTextBox), new PropertyMetadata(null, OnPropertyChanged));
1628 public IndentMode IndentMode
1630 get { return (IndentMode)GetValue(IndentModeProperty); }
1631 set { SetValue(IndentModeProperty, value); }
1635 /// IndentModeの依存プロパティを表す
1637 public static readonly DependencyProperty IndentModeProperty =
1638 DependencyProperty.Register("IndentMode", typeof(IndentMode), typeof(FooTextBox), new PropertyMetadata(IndentMode.Tab,OnPropertyChanged));
1644 /// Lengthが0の場合はキャレット位置を表します。
1645 /// 矩形選択モードの場合、選択範囲の文字数ではなく、開始位置から終了位置までの長さとなります
1647 public TextRange Selection
1649 get { return (TextRange)GetValue(SelectionProperty); }
1650 set { SetValue(SelectionProperty, value); }
1654 /// Selectionの依存プロパティを表す
1656 public static readonly DependencyProperty SelectionProperty =
1657 DependencyProperty.Register("Selection", typeof(TextRange), typeof(FooTextBox), new PropertyMetadata(TextRange.Null, OnPropertyChanged));
1662 public double MagnificationPower
1664 get { return (double)GetValue(MagnificationPowerPropertyKey); }
1665 set { SetValue(MagnificationPowerPropertyKey, value); }
1671 public static readonly DependencyProperty MagnificationPowerPropertyKey =
1672 DependencyProperty.Register("MagnificationPower", typeof(double), typeof(FooTextBox), new PropertyMetadata(1.0, OnPropertyChanged));
1677 public TextPoint CaretPostion
1679 get { return (TextPoint)GetValue(CaretPostionPropertyKey); }
1680 set { SetValue(CaretPostionPropertyKey, value); }
1683 static readonly DependencyProperty CaretPostionPropertyKey =
1684 DependencyProperty.Register("CaretPostion", typeof(TextPoint), typeof(FooTextBox), new PropertyMetadata(new TextPoint(), OnPropertyChanged));
1689 public new FlowDirection FlowDirection
1691 get { return (FlowDirection)GetValue(FlowDirectionProperty); }
1692 set { SetValue(FlowDirectionProperty, value); }
1696 /// レタリング方向を表す。これは依存プロパティです
1698 public new static readonly DependencyProperty FlowDirectionProperty =
1699 DependencyProperty.Register("FlowDirection", typeof(FlowDirection), typeof(FooTextBox), new PropertyMetadata(FlowDirection.LeftToRight,OnPropertyChanged));
1704 public new FontFamily FontFamily
1706 get { return (FontFamily)GetValue(FontFamilyProperty); }
1707 set { SetValue(FontFamilyProperty, value); }
1711 /// FontFamilyの依存プロパティを表す
1713 public new static readonly DependencyProperty FontFamilyProperty =
1714 DependencyProperty.Register("FontFamily", typeof(FontFamily), typeof(FooTextBox), new PropertyMetadata(new FontFamily("Cambria"), OnPropertyChanged));
1719 public new double FontSize
1721 get { return (double)GetValue(FontSizeProperty); }
1722 set { SetValue(FontSizeProperty, value); }
1726 /// FontSizeの依存プロパティを表す
1728 public new static readonly DependencyProperty FontSizeProperty =
1729 DependencyProperty.Register("FontSize", typeof(double), typeof(FooTextBox), new PropertyMetadata(12.0,OnPropertyChanged));
1734 public new FontStyle FontStyle
1736 get { return (FontStyle)GetValue(FontStyleProperty); }
1737 set { SetValue(FontStyleProperty, value); }
1741 /// FontStyleの依存プロパティを表す
1743 public new static readonly DependencyProperty FontStyleProperty =
1744 DependencyProperty.Register("FontStyle", typeof(FontStyle), typeof(FooTextBox), new PropertyMetadata(FontStyle.Normal,OnPropertyChanged));
1749 public new FontWeight FontWeight
1751 get { return (FontWeight)GetValue(FontWeightProperty); }
1752 set { SetValue(FontWeightProperty, value); }
1756 /// FontWeigthの依存プロパティを表す
1758 public new static readonly DependencyProperty FontWeightProperty =
1759 DependencyProperty.Register("FontWeigth", typeof(FontWeight), typeof(FooTextBox), new PropertyMetadata(FontWeights.Normal,OnPropertyChanged));
1762 /// デフォルトの文字色を表す。これは依存プロパティです
1764 public new Windows.UI.Color Foreground
1766 get { return (Windows.UI.Color)GetValue(ForegroundProperty); }
1767 set { SetValue(ForegroundProperty, value); }
1771 /// Foregroundの依存プロパティを表す
1773 public new static readonly DependencyProperty ForegroundProperty =
1774 DependencyProperty.Register("Foreground", typeof(Windows.UI.Color), typeof(FooTextBox), new PropertyMetadata(Colors.Black, OnPropertyChanged));
1777 /// 選択時の文字色を表す。これは依存プロパティです
1779 public Windows.UI.Color HilightForeground
1781 get { return (Windows.UI.Color)GetValue(HilightForegroundProperty); }
1782 set { SetValue(HilightForegroundProperty, value); }
1786 /// HilightForegroundForegroundの依存プロパティを表す
1788 public static readonly DependencyProperty HilightForegroundProperty =
1789 DependencyProperty.Register("HilightForeground", typeof(Windows.UI.Color), typeof(FooTextBox), new PropertyMetadata(Colors.White, OnPropertyChanged));
1792 /// 背景色を表す。これは依存プロパティです
1794 public new Windows.UI.Color Background
1796 get { return (Windows.UI.Color)GetValue(BackgroundProperty); }
1797 set { SetValue(BackgroundProperty, value); }
1801 /// Backgroundの依存プロパティを表す
1803 public new static readonly DependencyProperty BackgroundProperty =
1804 DependencyProperty.Register("Background", typeof(Windows.UI.Color), typeof(FooTextBox), new PropertyMetadata(Colors.White, OnPropertyChanged));
1807 /// コントロールコードの文字色を表す。これは依存プロパティです
1809 public Windows.UI.Color ControlChar
1811 get { return (Windows.UI.Color)GetValue(ControlCharProperty); }
1812 set { SetValue(ControlCharProperty, value); }
1816 /// ControlCharの依存プロパティを表す
1818 public static readonly DependencyProperty ControlCharProperty =
1819 DependencyProperty.Register("ControlChar", typeof(Windows.UI.Color), typeof(FooTextBox), new PropertyMetadata(Colors.Gray, OnPropertyChanged));
1822 /// 選択時の背景色を表す。これは依存プロパティです
1824 public Windows.UI.Color Hilight
1826 get { return (Windows.UI.Color)GetValue(HilightProperty); }
1827 set { SetValue(HilightProperty, value); }
1831 /// Hilightの依存プロパティを表す
1833 public static readonly DependencyProperty HilightProperty =
1834 DependencyProperty.Register("Hilight", typeof(Windows.UI.Color), typeof(FooTextBox), new PropertyMetadata(Colors.DodgerBlue, OnPropertyChanged));
1837 /// キーワード1の文字色を表す。これは依存プロパティです
1839 public Windows.UI.Color Keyword1
1841 get { return (Windows.UI.Color)GetValue(Keyword1Property); }
1842 set { SetValue(Keyword1Property, value); }
1846 /// Keyword1の依存プロパティを表す
1848 public static readonly DependencyProperty Keyword1Property =
1849 DependencyProperty.Register("Keyword1", typeof(Windows.UI.Color), typeof(FooTextBox), new PropertyMetadata(Colors.Blue, OnPropertyChanged));
1852 /// キーワード2の文字色を表す。これは依存プロパティです
1854 public Windows.UI.Color Keyword2
1856 get { return (Windows.UI.Color)GetValue(Keyword2Property); }
1857 set { SetValue(Keyword2Property, value); }
1861 /// Keyword2の依存プロパティを表す
1863 public static readonly DependencyProperty Keyword2Property =
1864 DependencyProperty.Register("Keyword2", typeof(Windows.UI.Color), typeof(FooTextBox), new PropertyMetadata(Colors.DarkCyan, OnPropertyChanged));
1867 /// コメントの文字色を表す。これは依存プロパティです
1869 public Windows.UI.Color Comment
1871 get { return (Windows.UI.Color)GetValue(CommentProperty); }
1872 set { SetValue(CommentProperty, value); }
1876 /// Commentの依存プロパティを表す
1878 public static readonly DependencyProperty CommentProperty =
1879 DependencyProperty.Register("Comment", typeof(Windows.UI.Color), typeof(FooTextBox), new PropertyMetadata(Colors.Green, OnPropertyChanged));
1882 /// 文字リテラルの文字色を表す。これは依存プロパティです
1884 public Windows.UI.Color Literal
1886 get { return (Windows.UI.Color)GetValue(LiteralProperty); }
1887 set { SetValue(LiteralProperty, value); }
1891 /// Literalの依存プロパティを表す
1893 public static readonly DependencyProperty LiteralProperty =
1894 DependencyProperty.Register("Literal", typeof(Windows.UI.Color), typeof(FooTextBox), new PropertyMetadata(Colors.Brown, OnPropertyChanged));
1897 /// URLの文字色を表す。これは依存プロパティです
1899 public Windows.UI.Color URL
1901 get { return (Windows.UI.Color)GetValue(URLProperty); }
1902 set { SetValue(URLProperty, value); }
1908 public static readonly DependencyProperty URLProperty =
1909 DependencyProperty.Register("URL", typeof(Windows.UI.Color), typeof(FooTextBox), new PropertyMetadata(Colors.Blue, OnPropertyChanged));
1914 public Windows.UI.Color UpdateArea
1916 get { return (Windows.UI.Color)GetValue(UpdateAreaProperty); }
1917 set { SetValue(UpdateAreaProperty, value); }
1921 /// UpdateAreaの依存プロパティを表す
1923 public static readonly DependencyProperty UpdateAreaProperty =
1924 DependencyProperty.Register("UpdateArea", typeof(Windows.UI.Color), typeof(FooTextBox), new PropertyMetadata(Colors.MediumSeaGreen, OnPropertyChanged));
1929 public Windows.UI.Color LineMarker
1931 get { return (Windows.UI.Color)GetValue(LineMarkerProperty); }
1932 set { SetValue(LineMarkerProperty, value); }
1936 /// LineMarkerの依存プロパティを表す
1938 public static readonly DependencyProperty LineMarkerProperty =
1939 DependencyProperty.Register("LineMarker", typeof(Windows.UI.Color), typeof(FooTextBox), new PropertyMetadata(Colors.Gray, OnPropertyChanged));
1942 /// 挿入モード時のキャレットの色を表す
1944 public Windows.UI.Color InsertCaret
1946 get { return (Windows.UI.Color)GetValue(InsertCaretProperty); }
1947 set { SetValue(InsertCaretProperty, value); }
1951 /// InsertCaretの依存プロパティを表す
1953 public static readonly DependencyProperty InsertCaretProperty =
1954 DependencyProperty.Register("InsertCaret", typeof(Windows.UI.Color), typeof(FooTextBox), new PropertyMetadata(Colors.Black, OnPropertyChanged));
1957 /// 上書きモード時のキャレット職を表す
1959 public Windows.UI.Color OverwriteCaret
1961 get { return (Windows.UI.Color)GetValue(OverwriteCaretProperty); }
1962 set { SetValue(OverwriteCaretProperty, value); }
1966 /// OverwriteCaretの依存プロパティを表す
1968 public static readonly DependencyProperty OverwriteCaretProperty =
1969 DependencyProperty.Register("OverwriteCaret", typeof(Windows.UI.Color), typeof(FooTextBox), new PropertyMetadata(Colors.Black, OnPropertyChanged));
1974 public Windows.UI.Color LineNumber
1976 get { return (Windows.UI.Color)GetValue(LineNumberProperty); }
1977 set { SetValue(LineNumberProperty, value); }
1981 /// Using a DependencyProperty as the backing store for LineNumber. This enables animation, styling, binding, etc...
1983 public static readonly DependencyProperty LineNumberProperty =
1984 DependencyProperty.Register("LineNumber", typeof(Windows.UI.Color), typeof(FooTextBox), new PropertyMetadata(Colors.DimGray,OnPropertyChanged));
1989 public new Thickness Padding
1991 get { return (Thickness)GetValue(PaddingProperty); }
1992 set { SetValue(PaddingProperty, value); }
1996 /// Paddingの依存プロパティを表す
1998 public new static readonly DependencyProperty PaddingProperty =
1999 DependencyProperty.Register("Padding", typeof(Thickness), typeof(FooTextBox), new PropertyMetadata(new Thickness(),OnPropertyChanged));
2002 /// 挿入モードなら真を返し、そうでないなら、偽を返す。これは依存プロパティです
2004 public bool InsertMode
2006 get { return (bool)GetValue(InsertModeProperty); }
2007 set { SetValue(InsertModeProperty, value); }
2011 /// InsertModeの依存プロパティを表す
2013 public static readonly DependencyProperty InsertModeProperty =
2014 DependencyProperty.Register("InsertMode",
2017 new PropertyMetadata(true, OnPropertyChanged));
2020 /// タブの文字数を表す。これは依存プロパティです
2024 get { return (int)GetValue(TabCharsProperty); }
2025 set { SetValue(TabCharsProperty, value); }
2029 /// TabCharsの依存プロパティを表す
2031 public static readonly DependencyProperty TabCharsProperty =
2032 DependencyProperty.Register("TabChars",
2035 new PropertyMetadata(4, OnPropertyChanged));
2038 /// 矩形選択モードなら真を返し、そうでないなら偽を返す。これは依存プロパティです
2040 public bool RectSelectMode
2042 get { return (bool)GetValue(RectSelectModeProperty); }
2043 set { SetValue(RectSelectModeProperty, value); }
2047 /// RectSelectModeの依存プロパティを表す
2049 public static readonly DependencyProperty RectSelectModeProperty =
2050 DependencyProperty.Register("RectSelectMode", typeof(bool), typeof(FooTextBox), new PropertyMetadata(false, OnPropertyChanged));
2056 /// 変更した場合、レイアウトの再構築を行う必要があります
2058 public LineBreakMethod LineBreakMethod
2060 get { return (LineBreakMethod)GetValue(LineBreakProperty); }
2061 set { SetValue(LineBreakProperty, value); }
2065 /// LineBreakMethodの依存プロパティを表す
2067 public static readonly DependencyProperty LineBreakProperty =
2068 DependencyProperty.Register("LineBreakMethod", typeof(LineBreakMethod), typeof(FooTextBox), new PropertyMetadata(LineBreakMethod.None, OnPropertyChanged));
2072 /// 折り返しの幅を指定する。LineBreakMethod.CharUnit以外の時は無視されます
2075 /// 変更した場合、レイアウトの再構築を行う必要があります
2077 public int LineBreakCharCount
2079 get { return (int)GetValue(LineBreakCharCountProperty); }
2080 set { SetValue(LineBreakCharCountProperty, value); }
2084 /// LineBreakCharCountの依存プロパティを表す
2086 public static readonly DependencyProperty LineBreakCharCountProperty =
2087 DependencyProperty.Register("LineBreakCharCount", typeof(int), typeof(FooTextBox), new PropertyMetadata(80, OnPropertyChanged));
2090 /// キャレットを描くなら真。そうでないなら偽を返す。これは依存プロパティです
2092 public bool DrawCaret
2094 get { return (bool)GetValue(DrawCaretProperty); }
2095 set { SetValue(DrawCaretProperty, value); }
2099 /// DrawCaretの依存プロパティを表す
2101 public static readonly DependencyProperty DrawCaretProperty =
2102 DependencyProperty.Register("DrawCaret", typeof(bool), typeof(FooTextBox), new PropertyMetadata(true, OnPropertyChanged));
2106 /// キャレットラインを描くなら真。そうでないなら偽を返す。これは依存プロパティです
2108 public bool DrawCaretLine
2110 get { return (bool)GetValue(DrawCaretLineProperty); }
2111 set { SetValue(DrawCaretLineProperty, value); }
2115 /// DrawCaretLineの依存プロパティを表す
2117 public static readonly DependencyProperty DrawCaretLineProperty =
2118 DependencyProperty.Register("DrawCaretLine", typeof(bool), typeof(FooTextBox), new PropertyMetadata(false, OnPropertyChanged));
2121 /// 行番号を描くなら真。そうでなければ偽。これは依存プロパティです
2123 public bool DrawLineNumber
2125 get { return (bool)GetValue(DrawLineNumberProperty); }
2126 set { SetValue(DrawLineNumberProperty, value); }
2130 /// ルーラーを描くなら真。そうでなければ偽。これは依存プロパティです
2132 public bool DrawRuler
2134 get { return (bool)GetValue(DrawRulerProperty); }
2135 set { SetValue(DrawRulerProperty, value); }
2139 /// DrawRulerの依存プロパティを表す
2141 public static readonly DependencyProperty DrawRulerProperty =
2142 DependencyProperty.Register("DrawRuler", typeof(bool), typeof(FooTextBox), new PropertyMetadata(false, OnPropertyChanged));
2146 /// DrawLineNumberの依存プロパティを表す
2148 public static readonly DependencyProperty DrawLineNumberProperty =
2149 DependencyProperty.Register("DrawLineNumber", typeof(bool), typeof(FooTextBox), new PropertyMetadata(false, OnPropertyChanged));
2152 /// URLに下線を引くなら真。そうでないなら偽を表す。これは依存プロパティです
2156 get { return (bool)GetValue(MarkURLProperty); }
2157 set { SetValue(MarkURLProperty, value); }
2161 /// MarkURLの依存プロパティを表す
2163 public static readonly DependencyProperty MarkURLProperty =
2164 DependencyProperty.Register("MarkURL", typeof(bool), typeof(FooTextBox), new PropertyMetadata(false, OnPropertyChanged));
2167 /// 全角スペースを表示するなら真。そうでないなら偽
2169 public bool ShowFullSpace
2171 get { return (bool)GetValue(ShowFullSpaceProperty); }
2172 set { SetValue(ShowFullSpaceProperty, value); }
2176 /// ShowFullSpaceの依存プロパティを表す
2178 public static readonly DependencyProperty ShowFullSpaceProperty =
2179 DependencyProperty.Register("ShowFullSpace", typeof(bool), typeof(FooTextBox), new PropertyMetadata(false, OnPropertyChanged));
2182 /// 半角スペースを表示するなら真。そうでないなら偽
2184 public bool ShowHalfSpace
2186 get { return (bool)GetValue(ShowHalfSpaceProperty); }
2187 set { SetValue(ShowHalfSpaceProperty, value); }
2191 /// ShowHalfSpaceの依存プロパティを表す
2193 public static readonly DependencyProperty ShowHalfSpaceProperty =
2194 DependencyProperty.Register("ShowHalfSpace", typeof(bool), typeof(FooTextBox), new PropertyMetadata(false, OnPropertyChanged));
2197 /// タブを表示するなら真。そうでないなら偽
2201 get { return (bool)GetValue(ShowTabProperty); }
2202 set { SetValue(ShowTabProperty, value); }
2206 /// ShowTabの依存プロパティを表す
2208 public static readonly DependencyProperty ShowTabProperty =
2209 DependencyProperty.Register("ShowTab", typeof(bool), typeof(FooTextBox), new PropertyMetadata(false, OnPropertyChanged));
2212 /// 改行マークを表示するなら真。そうでないなら偽
2214 public bool ShowLineBreak
2216 get { return (bool)GetValue(ShowLineBreakProperty); }
2217 set { SetValue(ShowLineBreakProperty, value); }
2221 /// ShowLineBreakの依存プロパティを表す
2223 public static readonly DependencyProperty ShowLineBreakProperty =
2224 DependencyProperty.Register("ShowLineBreak", typeof(bool), typeof(FooTextBox), new PropertyMetadata(false,OnPropertyChanged));
2230 /// コンテキストメニューのイベントデーターを表す
2232 public class FooContextMenuEventArgs
2235 /// 処理済みなら真。そうでないなら偽
2237 public bool Handled = false;
2239 /// コンテキストメニューを表示すべき座標を表す
2241 public Windows.Foundation.Point Postion;
2245 /// <param name="pos"></param>
2246 public FooContextMenuEventArgs(Windows.Foundation.Point pos)