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 if (this.textServiceManager != null)
449 this.textServiceManager.InputLanguageChanged -= TextServiceManager_InputLanguageChanged;
450 this.textServiceManager = null;
453 System.Diagnostics.Debug.WriteLine("losing focus");
456 private async void FooTextBox_GettingFocus(UIElement sender, GettingFocusEventArgs args)
458 System.Diagnostics.Debug.WriteLine("getting focus");
459 if (this.textServiceManager == null)
461 await Task.Delay(500);
462 this.textServiceManager = CoreTextServicesManager.GetForCurrentView();
463 this.textServiceManager.InputLanguageChanged += TextServiceManager_InputLanguageChanged;
466 this.CreateTextContext();
470 protected override void OnGotFocus(RoutedEventArgs e)
474 System.Diagnostics.Debug.WriteLine("got focus");
476 this.View.IsFocused = true;
477 this.timer.Interval = new TimeSpan(0, 0, 0, 0, Interval);
481 private void TextServiceManager_InputLanguageChanged(CoreTextServicesManager sender, object args)
483 System.Diagnostics.Debug.WriteLine("input language changed input script:"+ this.textServiceManager.InputLanguage.Script);
484 this.RemoveTextContext();
485 this.CreateTextContext();
489 protected override void OnLostFocus(RoutedEventArgs e)
493 System.Diagnostics.Debug.WriteLine("lost focus");
495 this.View.IsFocused = false;
496 this.Refresh(this.View.PageBound);
497 this.timer.Interval = new TimeSpan(0, 0, 0, 0, IntervalWhenLostFocus);
500 private void CreateTextContext()
502 if(this.textServiceManager != null)
504 this.textEditContext = this.textServiceManager.CreateEditContext();
505 this.textEditContext.InputScope = CoreTextInputScope.Text;
506 this.textEditContext.CompositionStarted += TextEditContext_CompositionStarted;
507 this.textEditContext.CompositionCompleted += TextEditContext_CompositionCompleted;
508 this.textEditContext.LayoutRequested += TextEditContext_LayoutRequested;
509 this.textEditContext.TextUpdating += TextEditContext_TextUpdating;
510 this.textEditContext.TextRequested += TextEditContext_TextRequested;
511 this.textEditContext.SelectionRequested += TextEditContext_SelectionRequested;
512 this.textEditContext.SelectionUpdating += TextEditContext_SelectionUpdating;
513 this.textEditContext.FormatUpdating += TextEditContext_FormatUpdating;
514 this.textEditContext.FocusRemoved += TextEditContext_FocusRemoved;
515 this.textEditContext.NotifyFocusLeaveCompleted += TextEditContext_NotifyFocusLeaveCompleted;
516 this.textEditContext.NotifyFocusEnter();
520 private void RemoveTextContext()
522 if(this.textEditContext != null)
524 this.textEditContext.NotifyFocusLeave();
525 this.textEditContext.CompositionStarted -= TextEditContext_CompositionStarted;
526 this.textEditContext.CompositionCompleted -= TextEditContext_CompositionCompleted;
527 this.textEditContext.LayoutRequested -= TextEditContext_LayoutRequested;
528 this.textEditContext.TextUpdating -= TextEditContext_TextUpdating;
529 this.textEditContext.TextRequested -= TextEditContext_TextRequested;
530 this.textEditContext.SelectionRequested -= TextEditContext_SelectionRequested;
531 this.textEditContext.SelectionUpdating -= TextEditContext_SelectionUpdating;
532 this.textEditContext.FormatUpdating -= TextEditContext_FormatUpdating;
533 this.textEditContext.FocusRemoved -= TextEditContext_FocusRemoved;
534 this.textEditContext.NotifyFocusLeaveCompleted -= TextEditContext_NotifyFocusLeaveCompleted;
535 this.textEditContext = null;
540 protected override async void OnKeyDown(KeyRoutedEventArgs e)
542 bool isControlPressed = this.IsModiferKeyPressed(VirtualKey.Control);
543 bool isShiftPressed = this.IsModiferKeyPressed(VirtualKey.Shift);
544 bool isMovedCaret = false;
546 var autocomplete = this.Document.AutoComplete as AutoCompleteBox;
547 if (autocomplete != null && autocomplete.ProcessKeyDown(this, e, isControlPressed, isShiftPressed))
553 this._Controller.MoveCaretVertical(-1, isShiftPressed);
558 case VirtualKey.Down:
559 this._Controller.MoveCaretVertical(+1, isShiftPressed);
564 case VirtualKey.Left:
565 this._Controller.MoveCaretHorizontical(-1, isShiftPressed, isControlPressed);
570 case VirtualKey.Right:
571 this._Controller.MoveCaretHorizontical(1, isShiftPressed, isControlPressed);
576 case VirtualKey.PageUp:
577 this._Controller.Scroll(ScrollDirection.Up, this.View.LineCountOnScreen, isShiftPressed, true);
581 case VirtualKey.PageDown:
582 this._Controller.Scroll(ScrollDirection.Down, this.View.LineCountOnScreen, isShiftPressed, true);
586 case VirtualKey.Home:
587 if (isControlPressed)
588 this._Controller.JumpToHead(isShiftPressed);
590 this.Controller.JumpToLineHead(this.Document.CaretPostion.row,isShiftPressed);
595 if (isControlPressed)
596 this._Controller.JumpToEnd(isShiftPressed);
598 this.Controller.JumpToLineEnd(this.Document.CaretPostion.row,isShiftPressed);
603 if (!isControlPressed)
605 if (this._Controller.SelectionLength == 0)
606 this._Controller.DoInputChar('\t');
607 else if (isShiftPressed)
608 this._Controller.DownIndent();
610 this._Controller.UpIndent();
615 case VirtualKey.Enter:
616 this._Controller.DoEnterAction();
620 case VirtualKey.Insert:
621 if(this.View.InsertMode)
622 this.View.InsertMode = false;
624 this.View.InsertMode = true;
629 if (isControlPressed)
637 if (isControlPressed)
639 if (this._Controller.RectSelection)
640 this._Controller.RectSelection = false;
642 this._Controller.RectSelection = true;
648 if (isControlPressed)
655 if (isControlPressed)
662 if (isControlPressed)
664 await this.PasteCommand();
669 if (isControlPressed)
671 this.Document.UndoManager.redo();
677 if (isControlPressed)
679 this.Document.UndoManager.undo();
684 case VirtualKey.Back:
685 this._Controller.DoBackSpaceAction();
689 case VirtualKey.Delete:
690 this._Controller.DoDeleteAction();
696 if (isMovedCaret && this.peer != null)
697 this.peer.OnNotifyCaretChanged();
703 protected override void OnPointerPressed(PointerRoutedEventArgs e)
705 System.Diagnostics.Debug.WriteLine("pointer pressed");
706 this.CapturePointer(e.Pointer);
707 this.gestureRecongnizer.ProcessDownEvent(e.GetCurrentPoint(this));
712 protected override void OnPointerMoved(PointerRoutedEventArgs e)
714 System.Diagnostics.Debug.WriteLine("pointer moved");
717 this.gestureRecongnizer.ProcessMoveEvents(e.GetIntermediatePoints(this));
718 }catch(System.Runtime.InteropServices.COMException ex)
720 //ピンチズームでこの例外が発生するが、回避できない
721 System.Diagnostics.Debug.WriteLine("expection:" + ex);
725 if (e.Pointer.PointerDeviceType == PointerDeviceType.Mouse)
727 Point p = e.GetCurrentPoint(this).Position;
728 if (this.View.HitTextArea(p.X, p.Y))
730 TextPoint tp = this.View.GetTextPointFromPostion(p);
731 if (this._Controller.IsMarker(tp, HilightType.Url))
732 Window.Current.CoreWindow.PointerCursor = new CoreCursor(CoreCursorType.Hand, 101);
734 Window.Current.CoreWindow.PointerCursor = new CoreCursor(CoreCursorType.IBeam, 101);
738 Window.Current.CoreWindow.PointerCursor = new CoreCursor(CoreCursorType.Arrow, 101);
744 protected override void OnPointerReleased(PointerRoutedEventArgs e)
746 System.Diagnostics.Debug.WriteLine("pointer released");
747 this.gestureRecongnizer.ProcessUpEvent(e.GetCurrentPoint(this));
752 protected override void OnPointerCanceled(PointerRoutedEventArgs e)
754 System.Diagnostics.Debug.WriteLine("pointer canceled");
755 this.gestureRecongnizer.CompleteGesture();
760 protected override void OnPointerWheelChanged(PointerRoutedEventArgs e)
762 System.Diagnostics.Debug.WriteLine("pointer wheelchanged");
763 bool shift = (e.KeyModifiers & Windows.System.VirtualKeyModifiers.Shift) ==
764 Windows.System.VirtualKeyModifiers.Shift;
765 bool ctrl = (e.KeyModifiers & Windows.System.VirtualKeyModifiers.Control) ==
766 Windows.System.VirtualKeyModifiers.Control;
767 this.gestureRecongnizer.ProcessMouseWheelEvent(e.GetCurrentPoint(this), shift, ctrl);
771 private void TextEditContext_FormatUpdating(CoreTextEditContext sender, CoreTextFormatUpdatingEventArgs args)
773 if (this.Document.Length == 0 || args.IsCanceled)
775 args.Result = CoreTextFormatUpdatingResult.Failed;
778 System.Diagnostics.Debug.WriteLine("core text format updating range({0}-{1}) underline type:{2} underline color:{3} reason:{4} textcolor:{5} background:{6}",
779 args.Range.StartCaretPosition,
780 args.Range.EndCaretPosition,
787 HilightType type = HilightType.None;
788 Color color = new Color(this.Foreground.A,this.Foreground.R,this.Foreground.G,this.Foreground.R);
789 bool isBoldLine = false;
790 switch (args.UnderlineType)
792 case UnderlineType.Dotted:
793 type = HilightType.Dot;
795 case UnderlineType.Single:
796 type = HilightType.Sold;
798 case UnderlineType.Dash:
799 type = HilightType.Dash;
801 case UnderlineType.Wave:
802 type = HilightType.Squiggle;
804 case UnderlineType.Thin:
805 type = HilightType.Sold;
807 case UnderlineType.Thick:
808 type = HilightType.Sold;
812 int start = args.Range.StartCaretPosition;
813 int lengt = args.Range.EndCaretPosition - args.Range.StartCaretPosition;
814 this.Document.SetMarker(MarkerIDs.IME, Marker.Create(start, lengt, type, color, isBoldLine));
816 if (args.Reason == CoreTextFormatUpdatingReason.CompositionTargetConverted)
818 this.View.AdjustSrc(args.Range.StartCaretPosition);
822 args.Result = CoreTextFormatUpdatingResult.Succeeded;
825 private void TextEditContext_TextRequested(CoreTextEditContext sender, CoreTextTextRequestedEventArgs args)
827 CoreTextTextRequest req = args.Request;
829 if (this.Document.Length == 0 || req.IsCanceled)
834 int start = req.Range.StartCaretPosition;
835 int end = req.Range.EndCaretPosition;
836 if (end > this.Document.Length)
837 end = this.Document.Length;
839 int length = end - start;
841 System.Diagnostics.Debug.WriteLine("req text start:{0} length:{1}", start, length);
843 //キャレット位置も含むので+1する必要はない
844 req.Text = this.Document.ToString(start,length);
847 private void TextEditContext_LayoutRequested(CoreTextEditContext sender, CoreTextLayoutRequestedEventArgs args)
850 Point startPos, endPos;
851 int i_startIndex = args.Request.Range.StartCaretPosition;
852 int i_endIndex = args.Request.Range.EndCaretPosition;
854 if(args.Request.IsCanceled)
859 System.Diagnostics.Debug.WriteLine("core text layoutreq range({0}-{1})",i_startIndex,i_endIndex);
861 if (i_startIndex != -1 && i_endIndex != -1)
863 TextStoreHelper.GetStringExtent(this.Document, this.View, i_startIndex, i_endIndex, out startPos, out endPos);
865 double scale = Util.GetScale();
867 //Core.Textはスクリーン座標に変換してくれないので自前で変換する(しかも、デバイス依存の座標で返さないといけない)
868 var screenStartPos = Util.GetScreentPoint(startPos, this).Scale(scale);
869 var screenEndPos = Util.GetScreentPoint(endPos, this).Scale(scale);
870 args.Request.LayoutBounds.TextBounds = new Rect(
873 Math.Max(0,screenEndPos.X - screenStartPos.X), //折り返されている場合、負になることがある
874 screenEndPos.Y - screenStartPos.Y);
878 var controlTopLeft = new Point(0, 0);
879 var controlBottomRight = new Point(this.RenderSize.Width, this.RenderSize.Height);
881 var gt = this.TransformToVisual(Window.Current.Content);
882 controlTopLeft = gt.TransformPoint(controlTopLeft);
883 controlBottomRight = gt.TransformPoint(controlBottomRight);
885 args.Request.LayoutBounds.ControlBounds = new Rect(
888 controlBottomRight.X - controlTopLeft.X,
889 controlBottomRight.Y - controlTopLeft.Y
893 private void TextEditContext_SelectionRequested(CoreTextEditContext sender, CoreTextSelectionRequestedEventArgs args)
895 if(args.Request.IsCanceled || this.Document.Length == 0)
899 TextRange currentSelection = new TextRange();
900 TextStoreHelper.GetSelection(this._Controller, this.View.Selections, out currentSelection);
902 CoreTextRange currentSelectionRange = new CoreTextRange();
903 currentSelectionRange.StartCaretPosition = currentSelection.Index;
904 currentSelectionRange.EndCaretPosition = currentSelection.Index + currentSelection.Length;
905 args.Request.Selection = currentSelectionRange;
906 System.Diagnostics.Debug.WriteLine("req selection start:{0} end:{1}", currentSelectionRange.StartCaretPosition, currentSelectionRange.EndCaretPosition);
909 private void TextEditContext_SelectionUpdating(CoreTextEditContext sender, CoreTextSelectionUpdatingEventArgs args)
911 if(this.Document.Length == 0 || args.IsCanceled)
913 args.Result = CoreTextSelectionUpdatingResult.Failed;
916 CoreTextRange sel = args.Selection;
917 System.Diagnostics.Debug.WriteLine("update selection start:{0} end:{1}", sel.StartCaretPosition, sel.EndCaretPosition);
918 TextStoreHelper.SetSelectionIndex(this.Controller, this.View, sel.StartCaretPosition, sel.EndCaretPosition);
919 args.Result = CoreTextSelectionUpdatingResult.Succeeded;
923 private void TextEditContext_TextUpdating(CoreTextEditContext sender, CoreTextTextUpdatingEventArgs args)
925 this.nowCompstion = true;
927 System.Diagnostics.Debug.WriteLine("update text (modify start:{0} end:{1}) text:{2} (new sel start:{0} end:{1})",
928 args.Range.StartCaretPosition,
929 args.Range.EndCaretPosition,
931 args.NewSelection.StartCaretPosition,
932 args.NewSelection.EndCaretPosition);
933 bool isTip = args.InputLanguage.Script == "Latan";
934 CoreTextRange sel = args.Range;
935 TextStoreHelper.SetSelectionIndex(this.Controller, this.View, sel.StartCaretPosition, sel.EndCaretPosition);
936 TextStoreHelper.InsertTextAtSelection(this._Controller, args.Text, isTip);
938 args.Result = CoreTextTextUpdatingResult.Succeeded;
940 this.nowCompstion = false;
943 private void TextEditContext_CompositionCompleted(CoreTextEditContext sender, CoreTextCompositionCompletedEventArgs args)
945 System.Diagnostics.Debug.WriteLine("end compostion");
946 TextStoreHelper.EndCompostion(this.Document);
947 this.Document.RemoveAllMarker(MarkerIDs.IME);
951 private void TextEditContext_CompositionStarted(CoreTextEditContext sender, CoreTextCompositionStartedEventArgs args)
953 System.Diagnostics.Debug.WriteLine("start compstion");
954 TextStoreHelper.StartCompstion(this.Document);
957 private void TextEditContext_NotifyFocusLeaveCompleted(CoreTextEditContext sender, object args)
959 System.Diagnostics.Debug.WriteLine("notify focus leaved");
962 private void TextEditContext_FocusRemoved(CoreTextEditContext sender, object args)
964 System.Diagnostics.Debug.WriteLine("focus leaved");
967 void Controller_SelectionChanged(object sender, EventArgs e)
969 if (this._Controller == null)
973 this.nowCaretMove = true;
974 SetValue(SelectedTextProperty, this._Controller.SelectedText);
975 SetValue(CaretPostionPropertyKey, this.Document.CaretPostion);
976 this.nowCaretMove = false;
978 if(!this.nowCompstion)
980 TextRange currentSelection = new TextRange();
981 TextStoreHelper.GetSelection(this._Controller, this.View.Selections, out currentSelection);
983 CoreTextRange currentSelectionRange = new CoreTextRange();
984 currentSelectionRange.StartCaretPosition = currentSelection.Index;
985 currentSelectionRange.EndCaretPosition = currentSelection.Index + currentSelection.Length;
987 System.Diagnostics.Debug.WriteLine("notify selection start:{0} end:{1}", currentSelectionRange.StartCaretPosition, currentSelectionRange.EndCaretPosition);
989 if (this.textEditContext != null)
990 this.textEditContext.NotifySelectionChanged(currentSelectionRange);
994 Gripper hittedGripper;
995 void gestureRecongnizer_ManipulationStarted(GestureRecognizer sender, ManipulationStartedEventArgs e)
997 //Updateedの段階でヒットテストしてしまうとグリッパーを触ってもヒットしないことがある
998 this.hittedGripper = this.View.HitGripperFromPoint(e.Position);
1001 private void GestureRecongnizer_ManipulationInertiaStarting(GestureRecognizer sender, ManipulationInertiaStartingEventArgs args)
1003 //sender.InertiaTranslationDeceleration = 0.001f;
1004 //sender.InertiaExpansionDeceleration = 100.0f * 96.0f / 1000.0f;
1005 //sender.InertiaRotationDeceleration = 720.0f / (1000.0f * 1000.0f);
1008 void gestureRecongnizer_ManipulationUpdated(GestureRecognizer sender, ManipulationUpdatedEventArgs e)
1010 if (e.Delta.Scale < 1)
1012 double newSize = this.Render.FontSize - 1;
1015 this.Render.FontSize = newSize;
1017 SetValue(MagnificationPowerPropertyKey, this.Render.FontSize / this.FontSize);
1021 if (e.Delta.Scale > 1)
1023 double newSize = this.Render.FontSize + 1;
1026 this.Render.FontSize = newSize;
1028 SetValue(MagnificationPowerPropertyKey, this.Render.FontSize / this.FontSize);
1032 if (this._Controller.MoveCaretAndGripper(e.Position, this.hittedGripper))
1034 #if ENABLE_AUTMATION
1035 if (this.peer != null)
1036 this.peer.OnNotifyCaretChanged();
1042 Point translation = e.Delta.Translation;
1044 //Xの絶対値が大きければ横方向のスクロールで、そうでなければ縦方向らしい
1045 if (Math.Abs(e.Cumulative.Translation.X) < Math.Abs(e.Cumulative.Translation.Y))
1047 int deltay = (int)Math.Abs(Math.Ceiling(translation.Y));
1048 if (translation.Y < 0)
1049 this._Controller.ScrollByPixel(ScrollDirection.Down, deltay, false, false);
1051 this._Controller.ScrollByPixel(ScrollDirection.Up, deltay, false, false);
1056 int deltax = (int)Math.Abs(Math.Ceiling(translation.X));
1059 if (translation.X < 0)
1060 this._Controller.Scroll(ScrollDirection.Left, deltax, false, false);
1062 this._Controller.Scroll(ScrollDirection.Right, deltax, false, false);
1067 void gestureRecongnizer_ManipulationCompleted(GestureRecognizer sender, ManipulationCompletedEventArgs e)
1071 async void gestureRecongnizer_RightTapped(GestureRecognizer sender, RightTappedEventArgs e)
1073 ResourceMap map = ResourceManager.Current.MainResourceMap.GetSubtree("FooEditEngine.UWP/Resources");
1074 ResourceContext context = ResourceContext.GetForCurrentView();
1075 if (this.View.HitTextArea(e.Position.X, e.Position.Y))
1077 FooContextMenuEventArgs args = new FooContextMenuEventArgs(e.Position);
1078 if (this.ContextMenuOpening != null)
1079 this.ContextMenuOpening(this, args);
1082 PopupMenu ContextMenu = new PopupMenu();
1083 ContextMenu.Commands.Add(new UICommand(map.GetValue("CopyMenuName", context).ValueAsString, (command) =>
1087 ContextMenu.Commands.Add(new UICommand(map.GetValue("CutMenuName", context).ValueAsString, (command) =>
1091 ContextMenu.Commands.Add(new UICommand(map.GetValue("PasteMenuName", context).ValueAsString, async (command) =>
1093 await this.PasteCommand();
1095 if (this._Controller.RectSelection)
1097 ContextMenu.Commands.Add(new UICommand(map.GetValue("LineSelectMenuName", context).ValueAsString, (command) =>
1099 this._Controller.RectSelection = false;
1104 ContextMenu.Commands.Add(new UICommand(map.GetValue("RectSelectMenuName", context).ValueAsString, (command) =>
1106 this._Controller.RectSelection = true;
1109 var windowStartPos = Util.GetPointInWindow(e.Position, this);
1110 await ContextMenu.ShowAsync(windowStartPos);
1115 long lastDouleTapTick;
1116 const long allowTripleTapTimeSpan = 500;
1117 void gestureRecongnizer_Tapped(GestureRecognizer sender, TappedEventArgs e)
1119 bool touched = e.PointerDeviceType == PointerDeviceType.Touch;
1120 this.Document.SelectGrippers.BottomLeft.Enabled = false;
1121 this.Document.SelectGrippers.BottomRight.Enabled = touched;
1122 this.JumpCaret(e.Position);
1123 if(e.TapCount == 1 && System.DateTime.Now.Ticks - lastDouleTapTick < allowTripleTapTimeSpan * 10000) //トリプルタップ
1125 //タッチスクリーンで行選択した場合、アンカーインデックスを単語の先頭にしないとバグる
1126 this.Document.SelectGrippers.BottomLeft.Enabled = touched;
1127 this.Document.SelectLine(this.Controller.SelectionStart, touched);
1130 else if(e.TapCount == 2) //ダブルタップ
1132 //タッチスクリーンで単語選択した場合、アンカーインデックスを単語の先頭にしないとバグる
1133 this.Document.SelectGrippers.BottomLeft.Enabled = touched;
1134 if (e.Position.X < this.Render.TextArea.X)
1135 this.Document.SelectLine(this.Controller.SelectionStart, touched);
1137 this.Document.SelectWord(this.Controller.SelectionStart, touched);
1138 this.lastDouleTapTick = System.DateTime.Now.Ticks;
1143 void JumpCaret(Point p)
1145 TextPoint tp = this.View.GetTextPointFromPostion(p);
1146 if (tp == TextPoint.Null)
1149 int index = this.View.LayoutLines.GetIndexFromTextPoint(tp);
1151 FoldingItem foldingData = this.View.HitFoldingData(p.X, tp.row);
1152 if (foldingData != null)
1154 if (foldingData.Expand)
1155 this.View.LayoutLines.FoldingCollection.Collapse(foldingData);
1157 this.View.LayoutLines.FoldingCollection.Expand(foldingData);
1158 this._Controller.JumpCaret(foldingData.Start, false);
1162 this._Controller.JumpCaret(tp.row, tp.col, false);
1164 #if ENABLE_AUTMATION
1165 if (this.peer != null)
1166 this.peer.OnNotifyCaretChanged();
1168 this.View.IsFocused = true;
1169 this.Focus(FocusState.Programmatic);
1173 void gestureRecongnizer_Dragging(GestureRecognizer sender, DraggingEventArgs e)
1175 Point p = e.Position;
1176 TextPointSearchRange searchRange;
1177 if (this.View.HitTextArea(p.X, p.Y))
1178 searchRange = TextPointSearchRange.TextAreaOnly;
1179 else if (this._Controller.SelectionLength > 0)
1180 searchRange = TextPointSearchRange.Full;
1183 TextPoint tp = this.View.GetTextPointFromPostion(p, searchRange);
1184 this._Controller.MoveCaretAndSelect(tp, this.IsModiferKeyPressed(VirtualKey.LeftControl));
1185 #if ENABLE_AUTMATION
1186 if (this.peer != null)
1187 this.peer.OnNotifyCaretChanged();
1192 bool IsModiferKeyPressed(VirtualKey key)
1194 CoreVirtualKeyStates state = Window.Current.CoreWindow.GetKeyState(key);
1195 return (state & CoreVirtualKeyStates.Down) == CoreVirtualKeyStates.Down;
1197 void Refresh(Rectangle updateRect)
1199 if (this.rectangle.ActualWidth == 0 || this.rectangle.ActualHeight == 0 || this.Visibility == Windows.UI.Xaml.Visibility.Collapsed)
1202 this.Render.DrawContent(this.View, this.IsEnabled, updateRect);
1204 this.Document.IsRequestRedraw = false;
1208 bool Resize(double width, double height)
1210 if (width == 0 || height == 0)
1211 throw new ArgumentOutOfRangeException();
1212 if (this.Render.Resize(this.rectangle, width, height))
1214 this.View.PageBound = new Rectangle(0, 0, width, height);
1216 if (this.horizontalScrollBar != null)
1218 this.horizontalScrollBar.LargeChange = this.View.PageBound.Width;
1219 this.horizontalScrollBar.Maximum = this.View.LongestWidth + this.horizontalScrollBar.LargeChange + 1;
1221 if (this.verticalScrollBar != null)
1223 this.verticalScrollBar.LargeChange = this.View.LineCountOnScreen;
1224 this.verticalScrollBar.Maximum = this.View.LayoutLines.Count + this.verticalScrollBar.LargeChange + 1;
1231 void View_SrcChanged(object sender, EventArgs e)
1233 if (this.horizontalScrollBar == null || this.verticalScrollBar == null)
1235 EditView view = this.View;
1236 if (view.Src.Row > this.verticalScrollBar.Maximum)
1237 this.verticalScrollBar.Maximum = view.Src.Row + view.LineCountOnScreen + 1;
1238 double absoulteX = Math.Abs(view.Src.X);
1239 if (absoulteX > this.horizontalScrollBar.Maximum)
1240 this.horizontalScrollBar.Maximum = absoulteX + view.PageBound.Width + 1;
1241 if (view.Src.Row != this.verticalScrollBar.Value)
1242 this.verticalScrollBar.Value = view.Src.Row;
1243 if (view.Src.X != this.horizontalScrollBar.Value)
1244 this.horizontalScrollBar.Value = Math.Abs(view.Src.X);
1247 void FooTextBox_SizeChanged(object sender, SizeChangedEventArgs e)
1249 if (this.Resize(this.rectangle.ActualWidth, this.rectangle.ActualHeight))
1252 this.Refresh(this.View.PageBound);
1256 void horizontalScrollBar_Scroll(object sender, ScrollEventArgs e)
1258 if (this.horizontalScrollBar == null)
1261 if (this.FlowDirection == FlowDirection.LeftToRight)
1262 toX = this.horizontalScrollBar.Value;
1264 toX = -this.horizontalScrollBar.Value;
1265 this._Controller.Scroll(toX, this.View.Src.Row, false, false);
1269 void verticalScrollBar_Scroll(object sender, ScrollEventArgs e)
1271 if (this.verticalScrollBar == null)
1273 int newRow = (int)this.verticalScrollBar.Value;
1274 if (newRow >= this.View.LayoutLines.Count)
1276 this._Controller.Scroll(this.View.Src.X, newRow, false, false);
1280 void Document_Update(object sender, DocumentUpdateEventArgs e)
1282 if (e.type == UpdateType.Replace && !this.nowCompstion)
1284 CoreTextRange oldTextRange = new CoreTextRange();
1285 oldTextRange.StartCaretPosition = e.startIndex;
1286 oldTextRange.EndCaretPosition = e.startIndex;
1287 //削除する範囲が1以上の場合、ドキュメントを飛び越えることはできない
1288 //https://msdn.microsoft.com/en-us/windows/uwp/input-and-devices/custom-text-input
1289 if (e.removeLength > 0)
1290 oldTextRange.EndCaretPosition += e.removeLength;
1292 TextRange currentSelection = new TextRange();
1293 TextStoreHelper.GetSelection(this._Controller, this.View.Selections, out currentSelection);
1295 CoreTextRange newSelection = new CoreTextRange();
1296 newSelection.StartCaretPosition = e.startIndex;
1297 newSelection.EndCaretPosition = e.startIndex;
1300 //(注意:削除された文字数のほうが多い場合は0を指定しないいけない)
1301 int newTextLength = e.insertLength;
1303 System.Diagnostics.Debug.WriteLine("notify text change (modify start:{0} end:{1}) newlength:{2} (new sel start:{3} end:{4})",
1304 oldTextRange.StartCaretPosition, oldTextRange.EndCaretPosition, newTextLength, newSelection.StartCaretPosition, newSelection.EndCaretPosition);
1306 if(this.textEditContext != null)
1307 this.textEditContext.NotifyTextChanged(oldTextRange, newTextLength, newSelection);
1309 #if ENABLE_AUTMATION
1310 if (this.peer != null)
1311 this.peer.OnNotifyTextChanged();
1315 void FooTextBox_Loaded(object sender, RoutedEventArgs e)
1317 this.Focus(FocusState.Programmatic);
1320 void timer_Tick(object sender, object e)
1322 if (this.View.LayoutLines.HilightAll() || this.View.LayoutLines.GenerateFolding() || this.Document.IsRequestRedraw)
1324 this.Refresh(this.View.PageBound);
1328 private void SetDocument(Document value)
1333 Document old_doc = this._Document;
1335 if (this._Document != null)
1337 old_doc.Update -= new DocumentUpdateEventHandler(Document_Update);
1338 this._Document.SelectionChanged -= Controller_SelectionChanged;
1339 this._Document.LoadProgress -= Document_LoadProgress;
1340 this._Document.AutoCompleteChanged -= _Document_AutoCompleteChanged;
1341 if (this._Document.AutoComplete != null)
1343 this._Document.AutoComplete.GetPostion = null;
1344 this._Document.AutoComplete = null;
1347 //NotifyTextChanged()を呼び出すと落ちるのでTextConextをごっそり作り替える
1348 this.RemoveTextContext();
1351 System.Diagnostics.Debug.WriteLine("document switched");
1353 this._Document = value;
1354 this._Document.LayoutLines.Render = this.Render;
1355 this._Document.Update += new DocumentUpdateEventHandler(Document_Update);
1356 this._Document.LoadProgress += Document_LoadProgress;
1357 this._Document.AutoCompleteChanged += _Document_AutoCompleteChanged;
1358 if (this._Document.AutoComplete != null && this._Document.AutoComplete.GetPostion == null)
1359 this._Document_AutoCompleteChanged(this._Document, null);
1360 //初期化が終わっていればすべて存在する
1361 if (this.Controller != null && this.View != null)
1363 this.Controller.Document = value;
1364 this.View.Document = value;
1366 this.Controller.AdjustCaret();
1368 this.CreateTextContext();
1370 //依存プロパティとドキュメント内容が食い違っているので再設定する
1371 this.ShowFullSpace = value.ShowFullSpace;
1372 this.ShowHalfSpace = value.ShowHalfSpace;
1373 this.ShowLineBreak = value.ShowLineBreak;
1374 this.ShowTab = value.ShowTab;
1375 this.FlowDirection = value.RightToLeft ? FlowDirection.RightToLeft : FlowDirection.LeftToRight;
1376 this.IndentMode = value.IndentMode;
1377 this.DrawCaretLine = !value.HideLineMarker;
1378 this.InsertMode = value.InsertMode;
1379 this.DrawRuler = !value.HideRuler;
1380 this.DrawLineNumber = value.DrawLineNumber;
1381 this.MarkURL = value.UrlMark;
1382 this.LineBreakMethod = value.LineBreak;
1383 this.LineBreakCharCount = value.LineBreakCharCount;
1384 this.TabChars = value.TabStops;
1388 //TextEditContext作成後に設定しないと落ちることがある
1389 this._Document.SelectionChanged += Controller_SelectionChanged;
1392 private void _Document_AutoCompleteChanged(object sender, EventArgs e)
1394 Document doc = (Document)sender;
1395 doc.AutoComplete.GetPostion = (tp, e_doc) =>
1397 var p = this.View.GetPostionFromTextPoint(tp);
1398 int height = (int)e_doc.LayoutLines.GetLayout(e_doc.CaretPostion.row).Height;
1400 if (p.Y + AutoCompleteBox.CompleteListBoxHeight + height > e_doc.LayoutLines.Render.TextArea.Height)
1401 p.Y -= AutoCompleteBox.CompleteListBoxHeight;
1404 //AutoCompleteBox内ではCanvasで位置を指定しているので変換する必要がある
1405 var pointInWindow = Util.GetPointInWindow(p, this);
1406 return pointInWindow;
1411 public static void OnPropertyChanged(object sender, DependencyPropertyChangedEventArgs e)
1413 FooTextBox source = (FooTextBox)sender;
1414 if(e.Property.Equals(SelectedTextProperty) && !source.nowCaretMove)
1415 source._Controller.SelectedText = source.SelectedText;
1416 if (e.Property.Equals(DocumentProperty))
1417 source.SetDocument(source.Document);
1418 if(e.Property.Equals(HilighterProperty))
1419 source.View.Hilighter = source.Hilighter;
1420 if (e.Property.Equals(FoldingStrategyProperty))
1421 source.View.LayoutLines.FoldingStrategy = source.FoldingStrategy;
1422 if (e.Property.Equals(IndentModeProperty))
1423 source.Controller.IndentMode = source.IndentMode;
1424 if (e.Property.Equals(SelectionProperty) && !source.nowCaretMove)
1425 source.Document.Select(source.Selection.Index,source.Selection.Length);
1426 if (e.Property.Equals(CaretPostionPropertyKey) && !source.nowCaretMove)
1427 source.JumpCaret(source.CaretPostion.row, source.CaretPostion.col);
1428 if (e.Property.Equals(InsertModeProperty))
1429 source.View.InsertMode = source.InsertMode;
1430 if (e.Property.Equals(TabCharsProperty))
1431 source.Document.TabStops = source.TabChars;
1432 if (e.Property.Equals(RectSelectModeProperty))
1433 source._Controller.RectSelection = source.RectSelectMode;
1434 if (e.Property.Equals(DrawCaretProperty))
1435 source.View.HideCaret = !source.DrawCaret;
1436 if (e.Property.Equals(DrawCaretLineProperty))
1437 source.View.HideLineMarker = !source.DrawCaretLine;
1438 if (e.Property.Equals(DrawLineNumberProperty))
1439 source.Document.DrawLineNumber = source.DrawLineNumber;
1440 if (e.Property.Equals(MarkURLProperty))
1441 source.Document.UrlMark = source.MarkURL;
1442 if (e.Property.Equals(LineBreakProperty))
1443 source.Document.LineBreak = source.LineBreakMethod;
1444 if (e.Property.Equals(LineBreakCharCountProperty))
1445 source.Document.LineBreakCharCount = source.LineBreakCharCount;
1446 if (e.Property.Equals(FlowDirectionProperty))
1448 source.Document.RightToLeft = source.FlowDirection == Windows.UI.Xaml.FlowDirection.RightToLeft;
1449 if (source.horizontalScrollBar != null)
1450 source.horizontalScrollBar.FlowDirection = source.FlowDirection;
1452 if (e.Property.Equals(DrawRulerProperty))
1454 source.Document.HideRuler = !source.DrawRuler;
1455 source._Controller.JumpCaret(source.Document.CaretPostion.row, source.Document.CaretPostion.col);
1458 if (e.Property.Equals(TextAntialiasModeProperty))
1459 source.Render.TextAntialiasMode = source.TextAntialiasMode;
1460 if(e.Property.Equals(MagnificationPowerPropertyKey))
1461 source.Render.FontSize = source.FontSize * source.MagnificationPower;
1462 if (e.Property.Equals(FontFamilyProperty))
1463 source.Render.FontFamily = source.FontFamily;
1464 if (e.Property.Equals(FontStyleProperty))
1465 source.Render.FontStyle = source.FontStyle;
1466 if (e.Property.Equals(FontWeightProperty))
1467 source.Render.FontWeigth = source.FontWeight;
1468 if (e.Property.Equals(FontSizeProperty))
1469 source.Render.FontSize = source.FontSize;
1470 if (e.Property.Equals(ForegroundProperty))
1471 source.Render.Foreground = D2DRenderBase.ToColor4(source.Foreground);
1472 if (e.Property.Equals(HilightForegroundProperty))
1473 source.Render.HilightForeground = D2DRenderBase.ToColor4(source.HilightForeground);
1474 if (e.Property.Equals(BackgroundProperty))
1475 source.Render.Background = D2DRenderBase.ToColor4(source.Background);
1476 if (e.Property.Equals(ControlCharProperty))
1477 source.Render.ControlChar = D2DRenderBase.ToColor4(source.ControlChar);
1478 if (e.Property.Equals(HilightProperty))
1479 source.Render.Hilight = D2DRenderBase.ToColor4(source.Hilight);
1480 if (e.Property.Equals(Keyword1Property))
1481 source.Render.Keyword1 = D2DRenderBase.ToColor4(source.Keyword1);
1482 if (e.Property.Equals(Keyword2Property))
1483 source.Render.Keyword2 = D2DRenderBase.ToColor4(source.Keyword2);
1484 if (e.Property.Equals(CommentProperty))
1485 source.Render.Comment = D2DRenderBase.ToColor4(source.Comment);
1486 if (e.Property.Equals(LiteralProperty))
1487 source.Render.Literal = D2DRenderBase.ToColor4(source.Literal);
1488 if (e.Property.Equals(URLProperty))
1489 source.Render.Url = D2DRenderBase.ToColor4(source.URL);
1490 if (e.Property.Equals(InsertCaretProperty))
1491 source.Render.InsertCaret = D2DRenderBase.ToColor4(source.InsertCaret);
1492 if (e.Property.Equals(OverwriteCaretProperty))
1493 source.Render.OverwriteCaret = D2DRenderBase.ToColor4(source.OverwriteCaret);
1494 if (e.Property.Equals(PaddingProperty))
1495 source.View.Padding = new Padding((int)source.Padding.Left, (int)source.Padding.Top, (int)source.Padding.Right, (int)source.Padding.Bottom);
1496 if (e.Property.Equals(LineMarkerProperty))
1497 source.Render.LineMarker = D2DRenderBase.ToColor4(source.LineMarker);
1498 if (e.Property.Equals(ShowFullSpaceProperty))
1499 source.Render.ShowFullSpace = source.ShowFullSpace;
1500 if (e.Property.Equals(ShowHalfSpaceProperty))
1501 source.Render.ShowHalfSpace = source.ShowHalfSpace;
1502 if (e.Property.Equals(ShowTabProperty))
1503 source.Render.ShowTab = source.ShowTab;
1504 if (e.Property.Equals(ShowLineBreakProperty))
1505 source.Render.ShowLineBreak = source.ShowLineBreak;
1506 if (e.Property.Equals(UpdateAreaProperty))
1507 source.Render.UpdateArea = D2DRenderBase.ToColor4(source.UpdateArea);
1508 if (e.Property.Equals(LineNumberProperty))
1509 source.Render.LineNumber = D2DRenderBase.ToColor4(source.LineNumber);
1517 /// コンテキストメニューが表示されるときに呼び出されます
1519 public event EventHandler<FooContextMenuEventArgs> ContextMenuOpening;
1525 internal Controller Controller
1529 return this._Controller;
1534 /// 文字列の描写に使用されるアンチエイリアシング モードを表します
1536 public TextAntialiasMode TextAntialiasMode
1538 get { return (TextAntialiasMode)GetValue(TextAntialiasModeProperty); }
1539 set { SetValue(TextAntialiasModeProperty, value); }
1543 /// TextAntialiasModeの依存プロパティを表す
1545 public static readonly DependencyProperty TextAntialiasModeProperty =
1546 DependencyProperty.Register("TextAntialiasMode", typeof(TextAntialiasMode), typeof(FooTextBox), new PropertyMetadata(TextAntialiasMode.Default, OnPropertyChanged));
1551 public IHilighter Hilighter
1553 get { return (IHilighter)GetValue(HilighterProperty); }
1554 set { SetValue(HilighterProperty, value); }
1558 /// Hilighterの依存プロパティを表す
1560 public static readonly DependencyProperty HilighterProperty =
1561 DependencyProperty.Register("Hilighter", typeof(IHilighter), typeof(FooTextBox), new PropertyMetadata(null, OnPropertyChanged));
1564 /// フォールティングを作成するインターフェイスを表す
1566 public IFoldingStrategy FoldingStrategy
1568 get { return (IFoldingStrategy)GetValue(FoldingStrategyProperty); }
1569 set { SetValue(FoldingStrategyProperty, value); }
1573 /// FoldingStrategyの依存プロパティ
1575 public static readonly DependencyProperty FoldingStrategyProperty =
1576 DependencyProperty.Register("FoldingStrategy", typeof(IFoldingStrategy), typeof(FooTextBox), new PropertyMetadata(null,OnPropertyChanged));
1581 public MarkerPatternSet MarkerPatternSet
1585 return this.Document.MarkerPatternSet;
1592 /// <remarks>切り替え後に再描写が行われます</remarks>
1593 public Document Document
1595 get { return (Document)GetValue(DocumentProperty); }
1596 set { SetValue(DocumentProperty, value); }
1599 // Using a DependencyProperty as the backing store for Document. This enables animation, styling, binding, etc...
1600 public static readonly DependencyProperty DocumentProperty =
1601 DependencyProperty.Register("Document", typeof(Document), typeof(FooTextBox), new PropertyMetadata(null, OnPropertyChanged));
1608 public LineToIndexTable LayoutLineCollection
1610 get { return this.View.LayoutLines; }
1616 public string SelectedText
1618 get { return (string)GetValue(SelectedTextProperty); }
1619 set { SetValue(SelectedTextProperty, value); }
1623 /// SelectedTextの依存プロパティを表す
1625 public static readonly DependencyProperty SelectedTextProperty =
1626 DependencyProperty.Register("SelectedText", typeof(string), typeof(FooTextBox), new PropertyMetadata(null, OnPropertyChanged));
1631 public IndentMode IndentMode
1633 get { return (IndentMode)GetValue(IndentModeProperty); }
1634 set { SetValue(IndentModeProperty, value); }
1638 /// IndentModeの依存プロパティを表す
1640 public static readonly DependencyProperty IndentModeProperty =
1641 DependencyProperty.Register("IndentMode", typeof(IndentMode), typeof(FooTextBox), new PropertyMetadata(IndentMode.Tab,OnPropertyChanged));
1647 /// Lengthが0の場合はキャレット位置を表します。
1648 /// 矩形選択モードの場合、選択範囲の文字数ではなく、開始位置から終了位置までの長さとなります
1650 public TextRange Selection
1652 get { return (TextRange)GetValue(SelectionProperty); }
1653 set { SetValue(SelectionProperty, value); }
1657 /// Selectionの依存プロパティを表す
1659 public static readonly DependencyProperty SelectionProperty =
1660 DependencyProperty.Register("Selection", typeof(TextRange), typeof(FooTextBox), new PropertyMetadata(TextRange.Null, OnPropertyChanged));
1665 public double MagnificationPower
1667 get { return (double)GetValue(MagnificationPowerPropertyKey); }
1668 set { SetValue(MagnificationPowerPropertyKey, value); }
1674 public static readonly DependencyProperty MagnificationPowerPropertyKey =
1675 DependencyProperty.Register("MagnificationPower", typeof(double), typeof(FooTextBox), new PropertyMetadata(1.0, OnPropertyChanged));
1680 public TextPoint CaretPostion
1682 get { return (TextPoint)GetValue(CaretPostionPropertyKey); }
1683 set { SetValue(CaretPostionPropertyKey, value); }
1686 static readonly DependencyProperty CaretPostionPropertyKey =
1687 DependencyProperty.Register("CaretPostion", typeof(TextPoint), typeof(FooTextBox), new PropertyMetadata(new TextPoint(), OnPropertyChanged));
1692 public new FlowDirection FlowDirection
1694 get { return (FlowDirection)GetValue(FlowDirectionProperty); }
1695 set { SetValue(FlowDirectionProperty, value); }
1699 /// レタリング方向を表す。これは依存プロパティです
1701 public new static readonly DependencyProperty FlowDirectionProperty =
1702 DependencyProperty.Register("FlowDirection", typeof(FlowDirection), typeof(FooTextBox), new PropertyMetadata(FlowDirection.LeftToRight,OnPropertyChanged));
1707 public new FontFamily FontFamily
1709 get { return (FontFamily)GetValue(FontFamilyProperty); }
1710 set { SetValue(FontFamilyProperty, value); }
1714 /// FontFamilyの依存プロパティを表す
1716 public new static readonly DependencyProperty FontFamilyProperty =
1717 DependencyProperty.Register("FontFamily", typeof(FontFamily), typeof(FooTextBox), new PropertyMetadata(new FontFamily("Cambria"), OnPropertyChanged));
1722 public new double FontSize
1724 get { return (double)GetValue(FontSizeProperty); }
1725 set { SetValue(FontSizeProperty, value); }
1729 /// FontSizeの依存プロパティを表す
1731 public new static readonly DependencyProperty FontSizeProperty =
1732 DependencyProperty.Register("FontSize", typeof(double), typeof(FooTextBox), new PropertyMetadata(12.0,OnPropertyChanged));
1737 public new FontStyle FontStyle
1739 get { return (FontStyle)GetValue(FontStyleProperty); }
1740 set { SetValue(FontStyleProperty, value); }
1744 /// FontStyleの依存プロパティを表す
1746 public new static readonly DependencyProperty FontStyleProperty =
1747 DependencyProperty.Register("FontStyle", typeof(FontStyle), typeof(FooTextBox), new PropertyMetadata(FontStyle.Normal,OnPropertyChanged));
1752 public new FontWeight FontWeight
1754 get { return (FontWeight)GetValue(FontWeightProperty); }
1755 set { SetValue(FontWeightProperty, value); }
1759 /// FontWeigthの依存プロパティを表す
1761 public new static readonly DependencyProperty FontWeightProperty =
1762 DependencyProperty.Register("FontWeigth", typeof(FontWeight), typeof(FooTextBox), new PropertyMetadata(FontWeights.Normal,OnPropertyChanged));
1765 /// デフォルトの文字色を表す。これは依存プロパティです
1767 public new Windows.UI.Color Foreground
1769 get { return (Windows.UI.Color)GetValue(ForegroundProperty); }
1770 set { SetValue(ForegroundProperty, value); }
1774 /// Foregroundの依存プロパティを表す
1776 public new static readonly DependencyProperty ForegroundProperty =
1777 DependencyProperty.Register("Foreground", typeof(Windows.UI.Color), typeof(FooTextBox), new PropertyMetadata(Colors.Black, OnPropertyChanged));
1780 /// 選択時の文字色を表す。これは依存プロパティです
1782 public Windows.UI.Color HilightForeground
1784 get { return (Windows.UI.Color)GetValue(HilightForegroundProperty); }
1785 set { SetValue(HilightForegroundProperty, value); }
1789 /// HilightForegroundForegroundの依存プロパティを表す
1791 public static readonly DependencyProperty HilightForegroundProperty =
1792 DependencyProperty.Register("HilightForeground", typeof(Windows.UI.Color), typeof(FooTextBox), new PropertyMetadata(Colors.White, OnPropertyChanged));
1795 /// 背景色を表す。これは依存プロパティです
1797 public new Windows.UI.Color Background
1799 get { return (Windows.UI.Color)GetValue(BackgroundProperty); }
1800 set { SetValue(BackgroundProperty, value); }
1804 /// Backgroundの依存プロパティを表す
1806 public new static readonly DependencyProperty BackgroundProperty =
1807 DependencyProperty.Register("Background", typeof(Windows.UI.Color), typeof(FooTextBox), new PropertyMetadata(Colors.White, OnPropertyChanged));
1810 /// コントロールコードの文字色を表す。これは依存プロパティです
1812 public Windows.UI.Color ControlChar
1814 get { return (Windows.UI.Color)GetValue(ControlCharProperty); }
1815 set { SetValue(ControlCharProperty, value); }
1819 /// ControlCharの依存プロパティを表す
1821 public static readonly DependencyProperty ControlCharProperty =
1822 DependencyProperty.Register("ControlChar", typeof(Windows.UI.Color), typeof(FooTextBox), new PropertyMetadata(Colors.Gray, OnPropertyChanged));
1825 /// 選択時の背景色を表す。これは依存プロパティです
1827 public Windows.UI.Color Hilight
1829 get { return (Windows.UI.Color)GetValue(HilightProperty); }
1830 set { SetValue(HilightProperty, value); }
1834 /// Hilightの依存プロパティを表す
1836 public static readonly DependencyProperty HilightProperty =
1837 DependencyProperty.Register("Hilight", typeof(Windows.UI.Color), typeof(FooTextBox), new PropertyMetadata(Colors.DodgerBlue, OnPropertyChanged));
1840 /// キーワード1の文字色を表す。これは依存プロパティです
1842 public Windows.UI.Color Keyword1
1844 get { return (Windows.UI.Color)GetValue(Keyword1Property); }
1845 set { SetValue(Keyword1Property, value); }
1849 /// Keyword1の依存プロパティを表す
1851 public static readonly DependencyProperty Keyword1Property =
1852 DependencyProperty.Register("Keyword1", typeof(Windows.UI.Color), typeof(FooTextBox), new PropertyMetadata(Colors.Blue, OnPropertyChanged));
1855 /// キーワード2の文字色を表す。これは依存プロパティです
1857 public Windows.UI.Color Keyword2
1859 get { return (Windows.UI.Color)GetValue(Keyword2Property); }
1860 set { SetValue(Keyword2Property, value); }
1864 /// Keyword2の依存プロパティを表す
1866 public static readonly DependencyProperty Keyword2Property =
1867 DependencyProperty.Register("Keyword2", typeof(Windows.UI.Color), typeof(FooTextBox), new PropertyMetadata(Colors.DarkCyan, OnPropertyChanged));
1870 /// コメントの文字色を表す。これは依存プロパティです
1872 public Windows.UI.Color Comment
1874 get { return (Windows.UI.Color)GetValue(CommentProperty); }
1875 set { SetValue(CommentProperty, value); }
1879 /// Commentの依存プロパティを表す
1881 public static readonly DependencyProperty CommentProperty =
1882 DependencyProperty.Register("Comment", typeof(Windows.UI.Color), typeof(FooTextBox), new PropertyMetadata(Colors.Green, OnPropertyChanged));
1885 /// 文字リテラルの文字色を表す。これは依存プロパティです
1887 public Windows.UI.Color Literal
1889 get { return (Windows.UI.Color)GetValue(LiteralProperty); }
1890 set { SetValue(LiteralProperty, value); }
1894 /// Literalの依存プロパティを表す
1896 public static readonly DependencyProperty LiteralProperty =
1897 DependencyProperty.Register("Literal", typeof(Windows.UI.Color), typeof(FooTextBox), new PropertyMetadata(Colors.Brown, OnPropertyChanged));
1900 /// URLの文字色を表す。これは依存プロパティです
1902 public Windows.UI.Color URL
1904 get { return (Windows.UI.Color)GetValue(URLProperty); }
1905 set { SetValue(URLProperty, value); }
1911 public static readonly DependencyProperty URLProperty =
1912 DependencyProperty.Register("URL", typeof(Windows.UI.Color), typeof(FooTextBox), new PropertyMetadata(Colors.Blue, OnPropertyChanged));
1917 public Windows.UI.Color UpdateArea
1919 get { return (Windows.UI.Color)GetValue(UpdateAreaProperty); }
1920 set { SetValue(UpdateAreaProperty, value); }
1924 /// UpdateAreaの依存プロパティを表す
1926 public static readonly DependencyProperty UpdateAreaProperty =
1927 DependencyProperty.Register("UpdateArea", typeof(Windows.UI.Color), typeof(FooTextBox), new PropertyMetadata(Colors.MediumSeaGreen, OnPropertyChanged));
1932 public Windows.UI.Color LineMarker
1934 get { return (Windows.UI.Color)GetValue(LineMarkerProperty); }
1935 set { SetValue(LineMarkerProperty, value); }
1939 /// LineMarkerの依存プロパティを表す
1941 public static readonly DependencyProperty LineMarkerProperty =
1942 DependencyProperty.Register("LineMarker", typeof(Windows.UI.Color), typeof(FooTextBox), new PropertyMetadata(Colors.Gray, OnPropertyChanged));
1945 /// 挿入モード時のキャレットの色を表す
1947 public Windows.UI.Color InsertCaret
1949 get { return (Windows.UI.Color)GetValue(InsertCaretProperty); }
1950 set { SetValue(InsertCaretProperty, value); }
1954 /// InsertCaretの依存プロパティを表す
1956 public static readonly DependencyProperty InsertCaretProperty =
1957 DependencyProperty.Register("InsertCaret", typeof(Windows.UI.Color), typeof(FooTextBox), new PropertyMetadata(Colors.Black, OnPropertyChanged));
1960 /// 上書きモード時のキャレット職を表す
1962 public Windows.UI.Color OverwriteCaret
1964 get { return (Windows.UI.Color)GetValue(OverwriteCaretProperty); }
1965 set { SetValue(OverwriteCaretProperty, value); }
1969 /// OverwriteCaretの依存プロパティを表す
1971 public static readonly DependencyProperty OverwriteCaretProperty =
1972 DependencyProperty.Register("OverwriteCaret", typeof(Windows.UI.Color), typeof(FooTextBox), new PropertyMetadata(Colors.Black, OnPropertyChanged));
1977 public Windows.UI.Color LineNumber
1979 get { return (Windows.UI.Color)GetValue(LineNumberProperty); }
1980 set { SetValue(LineNumberProperty, value); }
1984 /// Using a DependencyProperty as the backing store for LineNumber. This enables animation, styling, binding, etc...
1986 public static readonly DependencyProperty LineNumberProperty =
1987 DependencyProperty.Register("LineNumber", typeof(Windows.UI.Color), typeof(FooTextBox), new PropertyMetadata(Colors.DimGray,OnPropertyChanged));
1992 public new Thickness Padding
1994 get { return (Thickness)GetValue(PaddingProperty); }
1995 set { SetValue(PaddingProperty, value); }
1999 /// Paddingの依存プロパティを表す
2001 public new static readonly DependencyProperty PaddingProperty =
2002 DependencyProperty.Register("Padding", typeof(Thickness), typeof(FooTextBox), new PropertyMetadata(new Thickness(),OnPropertyChanged));
2005 /// 挿入モードなら真を返し、そうでないなら、偽を返す。これは依存プロパティです
2007 public bool InsertMode
2009 get { return (bool)GetValue(InsertModeProperty); }
2010 set { SetValue(InsertModeProperty, value); }
2014 /// InsertModeの依存プロパティを表す
2016 public static readonly DependencyProperty InsertModeProperty =
2017 DependencyProperty.Register("InsertMode",
2020 new PropertyMetadata(true, OnPropertyChanged));
2023 /// タブの文字数を表す。これは依存プロパティです
2027 get { return (int)GetValue(TabCharsProperty); }
2028 set { SetValue(TabCharsProperty, value); }
2032 /// TabCharsの依存プロパティを表す
2034 public static readonly DependencyProperty TabCharsProperty =
2035 DependencyProperty.Register("TabChars",
2038 new PropertyMetadata(4, OnPropertyChanged));
2041 /// 矩形選択モードなら真を返し、そうでないなら偽を返す。これは依存プロパティです
2043 public bool RectSelectMode
2045 get { return (bool)GetValue(RectSelectModeProperty); }
2046 set { SetValue(RectSelectModeProperty, value); }
2050 /// RectSelectModeの依存プロパティを表す
2052 public static readonly DependencyProperty RectSelectModeProperty =
2053 DependencyProperty.Register("RectSelectMode", typeof(bool), typeof(FooTextBox), new PropertyMetadata(false, OnPropertyChanged));
2059 /// 変更した場合、レイアウトの再構築を行う必要があります
2061 public LineBreakMethod LineBreakMethod
2063 get { return (LineBreakMethod)GetValue(LineBreakProperty); }
2064 set { SetValue(LineBreakProperty, value); }
2068 /// LineBreakMethodの依存プロパティを表す
2070 public static readonly DependencyProperty LineBreakProperty =
2071 DependencyProperty.Register("LineBreakMethod", typeof(LineBreakMethod), typeof(FooTextBox), new PropertyMetadata(LineBreakMethod.None, OnPropertyChanged));
2075 /// 折り返しの幅を指定する。LineBreakMethod.CharUnit以外の時は無視されます
2078 /// 変更した場合、レイアウトの再構築を行う必要があります
2080 public int LineBreakCharCount
2082 get { return (int)GetValue(LineBreakCharCountProperty); }
2083 set { SetValue(LineBreakCharCountProperty, value); }
2087 /// LineBreakCharCountの依存プロパティを表す
2089 public static readonly DependencyProperty LineBreakCharCountProperty =
2090 DependencyProperty.Register("LineBreakCharCount", typeof(int), typeof(FooTextBox), new PropertyMetadata(80, OnPropertyChanged));
2093 /// キャレットを描くなら真。そうでないなら偽を返す。これは依存プロパティです
2095 public bool DrawCaret
2097 get { return (bool)GetValue(DrawCaretProperty); }
2098 set { SetValue(DrawCaretProperty, value); }
2102 /// DrawCaretの依存プロパティを表す
2104 public static readonly DependencyProperty DrawCaretProperty =
2105 DependencyProperty.Register("DrawCaret", typeof(bool), typeof(FooTextBox), new PropertyMetadata(true, OnPropertyChanged));
2109 /// キャレットラインを描くなら真。そうでないなら偽を返す。これは依存プロパティです
2111 public bool DrawCaretLine
2113 get { return (bool)GetValue(DrawCaretLineProperty); }
2114 set { SetValue(DrawCaretLineProperty, value); }
2118 /// DrawCaretLineの依存プロパティを表す
2120 public static readonly DependencyProperty DrawCaretLineProperty =
2121 DependencyProperty.Register("DrawCaretLine", typeof(bool), typeof(FooTextBox), new PropertyMetadata(false, OnPropertyChanged));
2124 /// 行番号を描くなら真。そうでなければ偽。これは依存プロパティです
2126 public bool DrawLineNumber
2128 get { return (bool)GetValue(DrawLineNumberProperty); }
2129 set { SetValue(DrawLineNumberProperty, value); }
2133 /// ルーラーを描くなら真。そうでなければ偽。これは依存プロパティです
2135 public bool DrawRuler
2137 get { return (bool)GetValue(DrawRulerProperty); }
2138 set { SetValue(DrawRulerProperty, value); }
2142 /// DrawRulerの依存プロパティを表す
2144 public static readonly DependencyProperty DrawRulerProperty =
2145 DependencyProperty.Register("DrawRuler", typeof(bool), typeof(FooTextBox), new PropertyMetadata(false, OnPropertyChanged));
2149 /// DrawLineNumberの依存プロパティを表す
2151 public static readonly DependencyProperty DrawLineNumberProperty =
2152 DependencyProperty.Register("DrawLineNumber", typeof(bool), typeof(FooTextBox), new PropertyMetadata(false, OnPropertyChanged));
2155 /// URLに下線を引くなら真。そうでないなら偽を表す。これは依存プロパティです
2159 get { return (bool)GetValue(MarkURLProperty); }
2160 set { SetValue(MarkURLProperty, value); }
2164 /// MarkURLの依存プロパティを表す
2166 public static readonly DependencyProperty MarkURLProperty =
2167 DependencyProperty.Register("MarkURL", typeof(bool), typeof(FooTextBox), new PropertyMetadata(false, OnPropertyChanged));
2170 /// 全角スペースを表示するなら真。そうでないなら偽
2172 public bool ShowFullSpace
2174 get { return (bool)GetValue(ShowFullSpaceProperty); }
2175 set { SetValue(ShowFullSpaceProperty, value); }
2179 /// ShowFullSpaceの依存プロパティを表す
2181 public static readonly DependencyProperty ShowFullSpaceProperty =
2182 DependencyProperty.Register("ShowFullSpace", typeof(bool), typeof(FooTextBox), new PropertyMetadata(false, OnPropertyChanged));
2185 /// 半角スペースを表示するなら真。そうでないなら偽
2187 public bool ShowHalfSpace
2189 get { return (bool)GetValue(ShowHalfSpaceProperty); }
2190 set { SetValue(ShowHalfSpaceProperty, value); }
2194 /// ShowHalfSpaceの依存プロパティを表す
2196 public static readonly DependencyProperty ShowHalfSpaceProperty =
2197 DependencyProperty.Register("ShowHalfSpace", typeof(bool), typeof(FooTextBox), new PropertyMetadata(false, OnPropertyChanged));
2200 /// タブを表示するなら真。そうでないなら偽
2204 get { return (bool)GetValue(ShowTabProperty); }
2205 set { SetValue(ShowTabProperty, value); }
2209 /// ShowTabの依存プロパティを表す
2211 public static readonly DependencyProperty ShowTabProperty =
2212 DependencyProperty.Register("ShowTab", typeof(bool), typeof(FooTextBox), new PropertyMetadata(false, OnPropertyChanged));
2215 /// 改行マークを表示するなら真。そうでないなら偽
2217 public bool ShowLineBreak
2219 get { return (bool)GetValue(ShowLineBreakProperty); }
2220 set { SetValue(ShowLineBreakProperty, value); }
2224 /// ShowLineBreakの依存プロパティを表す
2226 public static readonly DependencyProperty ShowLineBreakProperty =
2227 DependencyProperty.Register("ShowLineBreak", typeof(bool), typeof(FooTextBox), new PropertyMetadata(false,OnPropertyChanged));
2233 /// コンテキストメニューのイベントデーターを表す
2235 public class FooContextMenuEventArgs
2238 /// 処理済みなら真。そうでないなら偽
2240 public bool Handled = false;
2242 /// コンテキストメニューを表示すべき座標を表す
2244 public Windows.Foundation.Point Postion;
2248 /// <param name="pos"></param>
2249 public FooContextMenuEventArgs(Windows.Foundation.Point pos)