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/>.
13 using System.ComponentModel;
14 using System.Threading.Tasks;
15 using Windows.ApplicationModel.Resources.Core;
16 using Windows.Devices.Input;
18 using Windows.ApplicationModel.DataTransfer;
19 using Windows.Foundation;
21 using Windows.UI.Input;
22 using Windows.UI.Core;
23 using Windows.UI.Popups;
24 using Windows.UI.Text;
25 using Windows.UI.Xaml.Media;
26 using Windows.UI.Xaml;
27 using Windows.UI.Xaml.Controls;
28 using Windows.UI.Xaml.Controls.Primitives;
29 using Windows.UI.Xaml.Input;
30 using DotNetTextStore;
31 using DotNetTextStore.UnmanagedAPI.TSF;
32 using DotNetTextStore.UnmanagedAPI.WinDef;
34 // テンプレート コントロールのアイテム テンプレートについては、http://go.microsoft.com/fwlink/?LinkId=234235 を参照してください
36 namespace FooEditEngine.Metro
41 public sealed class FooTextBox : Control,IDisposable
44 Controller _Controller;
46 ScrollBar horizontalScrollBar, verticalScrollBar;
47 Windows.UI.Xaml.Shapes.Rectangle rectangle;
48 GestureRecognizer gestureRecongnizer = new GestureRecognizer();
50 FooTextBoxAutomationPeer peer;
51 bool nowCaretMove = false;
52 DispatcherTimer timer;
59 this.DefaultStyleKey = typeof(FooTextBox);
61 this.textStore = new TextStore2();
62 this.textStore.IsLoading += textStore_IsLoading;
63 this.textStore.IsReadOnly += textStore_IsReadOnly;
64 this.textStore.GetStringLength += () => this.Document.Length;
65 this.textStore.GetString += _textStore_GetString;
66 this.textStore.GetSelectionIndex += _textStore_GetSelectionIndex;
67 this.textStore.SetSelectionIndex += _textStore_SetSelectionIndex;
68 this.textStore.InsertAtSelection += _textStore_InsertAtSelection;
69 this.textStore.GetScreenExtent += _textStore_GetScreenExtent;
70 this.textStore.GetStringExtent += _textStore_GetStringExtent;
71 this.textStore.CompositionStarted += textStore_CompositionStarted;
72 this.textStore.CompositionUpdated += textStore_CompositionUpdated;
73 this.textStore.CompositionEnded += textStore_CompositionEnded;
75 this.rectangle = new Windows.UI.Xaml.Shapes.Rectangle();
76 this.rectangle.Margin = this.Padding;
77 this.Render = new D2DRender(this,this.rectangle,this.textStore);
79 this.Document = new Document();
80 this.Document.LayoutLines.Render = this.Render;
82 this.View = new EditView(this.Document, this.Render, new Padding(5, Gripper.HitAreaWidth, Gripper.HitAreaWidth / 2, Gripper.HitAreaWidth));
83 this.View.SrcChanged += View_SrcChanged;
84 this.View.InsertMode = this.InsertMode;
85 this.View.DrawLineNumber = this.DrawLineNumber;
86 this.View.HideCaret = !this.DrawCaret;
87 this.View.HideLineMarker = !this.DrawCaretLine;
88 this.View.HideRuler = !this.DrawRuler;
89 this.View.UrlMark = this.MarkURL;
90 this.View.TabStops = this.TabChars;
92 this._Controller = new Controller(this.Document, this.View);
93 this._Controller.SelectionChanged += Controller_SelectionChanged;
95 this.FirstGripper = new Gripper(this._Controller, this.View, this.Render, GripperPostion.BottomLeft);
96 this.SecondGripper = new Gripper(this._Controller, this.View, this.Render, GripperPostion.BottomRight);
98 this.gestureRecongnizer.GestureSettings = GestureSettings.Drag |
99 GestureSettings.RightTap |
100 GestureSettings.Tap |
101 GestureSettings.DoubleTap |
102 GestureSettings.ManipulationTranslateX |
103 GestureSettings.ManipulationTranslateY |
104 GestureSettings.ManipulationScale |
105 GestureSettings.ManipulationTranslateInertia |
106 GestureSettings.ManipulationScaleInertia;
107 this.gestureRecongnizer.RightTapped += gestureRecongnizer_RightTapped;
108 this.gestureRecongnizer.Tapped += gestureRecongnizer_Tapped;
109 this.gestureRecongnizer.Dragging += gestureRecongnizer_Dragging;
110 this.gestureRecongnizer.ManipulationInertiaStarting += gestureRecongnizer_ManipulationInertiaStarting;
111 this.gestureRecongnizer.ManipulationStarted += gestureRecongnizer_ManipulationStarted;
112 this.gestureRecongnizer.ManipulationUpdated += gestureRecongnizer_ManipulationUpdated;
113 this.gestureRecongnizer.ManipulationCompleted += gestureRecongnizer_ManipulationCompleted;
115 this.timer = new DispatcherTimer();
116 this.timer.Interval = new TimeSpan(0, 0, 0, 0, 100);
117 this.timer.Tick += new EventHandler<object>(this.timer_Tick);
120 //Viewの初期化が終わった直後に置かないと例外が発生する
121 this.Document.Update += Document_Update;
123 Window.Current.CoreWindow.CharacterReceived += CoreWindow_CharacterReceived;
125 this.SizeChanged += FooTextBox_SizeChanged;
127 this.Loaded += FooTextBox_Loaded;
141 public void Dispose()
144 GC.SuppressFinalize(this);
147 bool Disposed = false;
148 private void Dispose(bool disposing)
154 this.textStore.Dispose();
156 this.Render.Dispose();
163 /// <param name="start">開始インデックス</param>
164 /// <param name="length">長さ</param>
165 public void Select(int start, int length)
167 this._Controller.Select(start, length);
171 /// キャレットを指定した行に移動させます
173 /// <param name="index">インデックス</param>
174 /// <remarks>このメソッドを呼び出すと選択状態は解除されます</remarks>
175 public void JumpCaret(int index)
177 this._Controller.JumpCaret(index);
180 /// キャレットを指定した行と桁に移動させます
182 /// <param name="row">行番号</param>
183 /// <param name="col">桁</param>
184 /// <remarks>このメソッドを呼び出すと選択状態は解除されます</remarks>
185 public void JumpCaret(int row, int col)
187 this._Controller.JumpCaret(row, col);
191 /// 選択中のテキストをクリップボードにコピーします
195 string text = this._Controller.SelectedText;
196 if (text != null && text != string.Empty)
198 DataPackage dataPackage = new DataPackage();
199 dataPackage.RequestedOperation = DataPackageOperation.Copy;
200 dataPackage.SetText(text);
202 Clipboard.SetContent(dataPackage);
207 /// 選択中のテキストをクリップボードに切り取ります
211 string text = this._Controller.SelectedText;
212 if (text != null && text != string.Empty)
214 DataPackage dataPackage = new DataPackage();
215 dataPackage.RequestedOperation = DataPackageOperation.Copy;
216 dataPackage.SetText(text);
218 Clipboard.SetContent(dataPackage);
220 this._Controller.SelectedText = "";
227 public async Task PasteAsync()
229 var dataPackageView = Clipboard.GetContent();
230 if (dataPackageView.Contains(StandardDataFormats.Text))
232 this._Controller.SelectedText = await dataPackageView.GetTextAsync();
239 public void SelectAll()
241 this._Controller.Select(0, this.Document.Length);
247 public void DeSelectAll()
249 this._Controller.DeSelectAll();
255 /// <param name="tp">テキストポイント</param>
256 /// <returns>座標</returns>
257 /// <remarks>テキストポイントがクライアント領域の原点より外にある場合、返される値は原点に丸められます</remarks>
258 public Windows.Foundation.Point GetPostionFromTextPoint(TextPoint tp)
260 if (this.Document.FireUpdateEvent == false)
261 throw new InvalidOperationException("");
262 return this.View.GetPostionFromTextPoint(tp);
266 /// 対応するテキストポイントを返します
268 /// <param name="p">クライアント領域の原点を左上とする座標</param>
269 /// <returns>テキストポイント</returns>
270 public TextPoint GetTextPointFromPostion(Windows.Foundation.Point p)
272 if (this.Document.FireUpdateEvent == false)
273 throw new InvalidOperationException("");
274 return this.View.GetTextPointFromPostion(p);
280 /// <param name="row">レイアウト行</param>
281 /// <returns>行の高さ</returns>
282 public double GetLineHeight(int row)
284 if (this.Document.FireUpdateEvent == false)
285 throw new InvalidOperationException("");
286 return this.View.LayoutLines.GetLayout(row).Height; ;
290 /// インデックスに対応する座標を得ます
292 /// <param name="index">インデックス</param>
293 /// <returns>座標を返す</returns>
294 public Windows.Foundation.Point GetPostionFromIndex(int index)
296 if (this.Document.FireUpdateEvent == false)
297 throw new InvalidOperationException("");
298 TextPoint tp = this.View.GetLayoutLineFromIndex(index);
299 return this.View.GetPostionFromTextPoint(tp);
305 /// <param name="p">座標</param>
306 /// <returns>インデックスを返す</returns>
307 public int GetIndexFromPostion(Windows.Foundation.Point p)
309 if (this.Document.FireUpdateEvent == false)
310 throw new InvalidOperationException("");
311 TextPoint tp = this.View.GetTextPointFromPostion(p);
312 return this.View.GetIndexFromLayoutLine(tp);
318 public void Refresh()
320 this.Refresh(this.View.PageBound);
324 /// レイアウト行をすべて破棄し、再度レイアウトを行う
326 public void PerfomLayouts()
328 this.View.PerfomLayouts();
334 /// <param name="row">行</param>
335 /// <param name="alignTop">指定行を画面上に置くなら真。そうでないなら偽</param>
336 public void ScrollIntoView(int row, bool alignTop)
338 this.View.ScrollIntoView(row, alignTop);
342 /// ファイルからドキュメントを構築する
344 /// <param name="sr">StremReader</param>
345 /// <returns>Taskオブジェクト</returns>
346 public async Task LoadFileAsync(System.IO.StreamReader sr, System.Threading.CancellationTokenSource token)
348 this.IsEnabled = false;
349 this.View.LayoutLines.IsFrozneDirtyFlag = true;
350 WinFileReader fs = new WinFileReader(sr);
351 await this.Document.LoadAsync(fs, token);
352 this.View.LayoutLines.IsFrozneDirtyFlag = false;
353 TextStoreHelper.NotifyTextChanged(this.textStore, 0, 0, this.Document.Length);
354 if (this.verticalScrollBar != null)
355 this.verticalScrollBar.Maximum = this.View.LayoutLines.Count;
356 this.View.CalculateLineCountOnScreen();
357 this.IsEnabled = true;
361 /// ドキュメントの内容をファイルに保存する
363 /// <param name="sw">StreamWriter</param>
364 /// <param name="enc">エンコード</param>
365 /// <returns>Taskオブジェクト</returns>
366 public async Task SaveFile(System.IO.StreamWriter sw, System.Threading.CancellationTokenSource token)
368 WinFileWriter fs = new WinFileWriter(sw);
369 await this.Document.SaveAsync(fs, token);
384 async Task PasteCommand()
386 await this.PasteAsync();
394 protected override Windows.UI.Xaml.Automation.Peers.AutomationPeer OnCreateAutomationPeer()
396 this.peer = new FooTextBoxAutomationPeer(this);
401 protected override void OnApplyTemplate()
403 base.OnApplyTemplate();
405 Grid grid = this.GetTemplateChild("PART_Grid") as Grid;
408 Grid.SetRow(this.rectangle, 0);
409 Grid.SetColumn(this.rectangle, 0);
410 grid.Children.Add(this.rectangle);
413 this.horizontalScrollBar = this.GetTemplateChild("PART_HorizontalScrollBar") as ScrollBar;
414 if (this.horizontalScrollBar != null)
416 this.horizontalScrollBar.SmallChange = 10;
417 this.horizontalScrollBar.LargeChange = 100;
418 this.horizontalScrollBar.Maximum = this.horizontalScrollBar.LargeChange + 1;
419 this.horizontalScrollBar.Scroll += new ScrollEventHandler(horizontalScrollBar_Scroll);
421 this.verticalScrollBar = this.GetTemplateChild("PART_VerticalScrollBar") as ScrollBar;
422 if (this.verticalScrollBar != null)
424 this.verticalScrollBar.SmallChange = 1;
425 this.verticalScrollBar.LargeChange = 10;
426 this.verticalScrollBar.Maximum = this.View.LayoutLines.Count;
427 this.verticalScrollBar.Scroll += new ScrollEventHandler(verticalScrollBar_Scroll);
432 protected override void OnGotFocus(RoutedEventArgs e)
435 this.textStore.SetFocus();
436 this.View.IsFocused = true;
441 protected override void OnLostFocus(RoutedEventArgs e)
444 this.View.IsFocused = false;
449 protected override async void OnKeyDown(KeyRoutedEventArgs e)
451 bool isControlPressed = this.IsModiferKeyPressed(VirtualKey.Control);
452 bool isShiftPressed = this.IsModiferKeyPressed(VirtualKey.Shift);
453 bool isMovedCaret = false;
457 this._Controller.MoveCaretVertical(-1, isShiftPressed);
462 case VirtualKey.Down:
463 this._Controller.MoveCaretVertical(+1, isShiftPressed);
468 case VirtualKey.Left:
469 this._Controller.MoveCaretHorizontical(-1, isShiftPressed, isControlPressed);
474 case VirtualKey.Right:
475 this._Controller.MoveCaretHorizontical(1, isShiftPressed, isControlPressed);
480 case VirtualKey.PageUp:
481 this._Controller.Scroll(ScrollDirection.Up, this.View.LineCountOnScreen, isShiftPressed, true);
485 case VirtualKey.PageDown:
486 this._Controller.Scroll(ScrollDirection.Down, this.View.LineCountOnScreen, isShiftPressed, true);
490 case VirtualKey.Home:
491 if (isControlPressed)
492 this._Controller.JumpToHead(isShiftPressed);
494 this.Controller.JumpToLineHead(this.View.CaretPostion.row,isShiftPressed);
499 if (isControlPressed)
500 this._Controller.JumpToEnd(isShiftPressed);
502 this.Controller.JumpToLineEnd(this.View.CaretPostion.row,isShiftPressed);
507 if (!isControlPressed)
509 if (this._Controller.SelectionLength == 0)
510 this._Controller.DoInputChar('\t');
511 else if (isShiftPressed)
512 this._Controller.DownIndent();
514 this._Controller.UpIndent();
519 case VirtualKey.Enter:
520 this._Controller.DoEnterAction();
524 case VirtualKey.Insert:
525 if(this.View.InsertMode)
526 this.View.InsertMode = false;
528 this.View.InsertMode = true;
533 if (isControlPressed)
541 if (isControlPressed)
543 if (this._Controller.RectSelection)
544 this._Controller.RectSelection = false;
546 this._Controller.RectSelection = true;
552 if (isControlPressed)
559 if (isControlPressed)
566 if (isControlPressed)
568 await this.PasteCommand();
573 if (isControlPressed)
575 this.Document.UndoManager.redo();
581 if (isControlPressed)
583 this.Document.UndoManager.undo();
588 case VirtualKey.Back:
589 this._Controller.DoBackSpaceAction();
593 case VirtualKey.Delete:
594 this._Controller.DoDeleteAction();
599 if (isMovedCaret && this.peer != null)
600 this.peer.OnNotifyCaretChanged();
605 protected override void OnPointerPressed(PointerRoutedEventArgs e)
608 this.gestureRecongnizer.AutoProcessInertia = e.Pointer.PointerDeviceType != PointerDeviceType.Mouse;
610 this.CapturePointer(e.Pointer);
611 this.gestureRecongnizer.ProcessDownEvent(e.GetCurrentPoint(this));
616 protected override void OnPointerMoved(PointerRoutedEventArgs e)
619 this.gestureRecongnizer.AutoProcessInertia = e.Pointer.PointerDeviceType != PointerDeviceType.Mouse;
621 this.gestureRecongnizer.ProcessMoveEvents(e.GetIntermediatePoints(this));
624 if (e.Pointer.PointerDeviceType == PointerDeviceType.Mouse)
626 Point p = e.GetCurrentPoint(this).Position;
627 if (this.View.HitTextArea(p.X, p.Y))
629 TextPoint tp = this.View.GetTextPointFromPostion(p);
630 if (this._Controller.IsMarker(tp, HilightType.Url))
631 Window.Current.CoreWindow.PointerCursor = new CoreCursor(CoreCursorType.Hand, 101);
633 Window.Current.CoreWindow.PointerCursor = new CoreCursor(CoreCursorType.IBeam, 101);
637 Window.Current.CoreWindow.PointerCursor = new CoreCursor(CoreCursorType.Arrow, 101);
643 protected override void OnPointerReleased(PointerRoutedEventArgs e)
645 this.gestureRecongnizer.ProcessUpEvent(e.GetCurrentPoint(this));
646 this.ReleasePointerCapture(e.Pointer);
651 protected override void OnPointerCanceled(PointerRoutedEventArgs e)
653 this.gestureRecongnizer.CompleteGesture();
654 this.ReleasePointerCapture(e.Pointer);
659 protected override void OnPointerCaptureLost(PointerRoutedEventArgs e)
661 this.gestureRecongnizer.CompleteGesture();
662 this.ReleasePointerCapture(e.Pointer);
667 protected override void OnPointerWheelChanged(PointerRoutedEventArgs e)
670 this.gestureRecongnizer.AutoProcessInertia = e.Pointer.PointerDeviceType != PointerDeviceType.Mouse;
672 bool shift = (e.KeyModifiers & Windows.System.VirtualKeyModifiers.Shift) ==
673 Windows.System.VirtualKeyModifiers.Shift;
674 bool ctrl = (e.KeyModifiers & Windows.System.VirtualKeyModifiers.Control) ==
675 Windows.System.VirtualKeyModifiers.Control;
676 this.gestureRecongnizer.ProcessMouseWheelEvent(e.GetCurrentPoint(this), shift, ctrl);
680 void CoreWindow_CharacterReceived(CoreWindow sender, CharacterReceivedEventArgs args)
682 if (this.FocusState == FocusState.Unfocused || !this.IsEnabled)
684 if (args.KeyCode >= 00 && args.KeyCode <= 0x1f)
686 this._Controller.DoInputString(Char.ConvertFromUtf32((int)args.KeyCode));
690 bool textStore_IsReadOnly()
695 bool textStore_IsLoading()
700 void textStore_CompositionEnded()
702 TextStoreHelper.EndCompostion(this.Document);
706 void textStore_CompositionUpdated(int start, int end)
708 if (TextStoreHelper.ScrollToCompstionUpdated(this.textStore, this.View, start, end))
711 bool textStore_CompositionStarted()
713 return TextStoreHelper.StartCompstion(this.Document);
716 string _textStore_GetString(int start, int length)
718 return this.Document.ToString(start, length);
721 void _textStore_GetStringExtent(
725 out POINT o_bottomRight
728 Point startPos, endPos;
729 TextStoreHelper.GetStringExtent(this.Document, this.View, i_startIndex, i_endIndex, out startPos, out endPos);
732 this.Render.GetDpi(out dpi, out dpi);
733 double scale = dpi / 96.0;
735 var gt = this.TransformToVisual(Window.Current.Content);
736 startPos = gt.TransformPoint(startPos.Scale(scale));
737 endPos = gt.TransformPoint(endPos.Scale(scale));
739 o_topLeft = new POINT((int)startPos.X, (int)startPos.Y);
740 o_bottomRight = new POINT((int)endPos.X, (int)endPos.Y);
743 void _textStore_GetScreenExtent(out POINT o_topLeft, out POINT o_bottomRight)
745 var pointTopLeft = new Point(0, 0);
746 var pointBottomRight = new Point(this.RenderSize.Width, this.RenderSize.Height);
748 var gt = this.TransformToVisual(Window.Current.Content);
749 pointTopLeft = gt.TransformPoint(pointTopLeft);
750 pointBottomRight = gt.TransformPoint(pointBottomRight);
752 o_topLeft = new POINT((int)pointTopLeft.X, (int)pointTopLeft.Y);
753 o_bottomRight = new POINT((int)pointBottomRight.X, (int)pointBottomRight.Y);
756 void _textStore_GetSelectionIndex(out int o_startIndex, out int o_endIndex)
758 TextStoreHelper.GetSelection(this._Controller, this.View.Selections, out o_startIndex, out o_endIndex);
761 void _textStore_SetSelectionIndex(int i_startIndex, int i_endIndex)
763 TextStoreHelper.SetSelectionIndex(this._Controller, this.View, i_startIndex, i_endIndex);
767 void _textStore_InsertAtSelection(string i_value,ref int o_stratIndex,ref int o_endIndex)
769 TextStoreHelper.InsertTextAtSelection(this._Controller, i_value);
773 void Controller_SelectionChanged(object sender, EventArgs e)
776 this.nowCaretMove = true;
777 SetValue(SelectionProperty, new TextRange(this._Controller.SelectionStart, this._Controller.SelectionLength));
778 SetValue(CaretPostionPropertyKey, this.View.CaretPostion);
779 this.nowCaretMove = false;
780 if (this.textStore.IsLocked() == false)
781 this.textStore.NotifySelectionChanged();
784 Gripper FirstGripper, SecondGripper;
786 Gripper hittedGripper;
787 private void gestureRecongnizer_ManipulationInertiaStarting(GestureRecognizer sender, ManipulationInertiaStartingEventArgs e)
789 //sender.InertiaTranslationDeceleration = 0.001f;
790 //sender.InertiaExpansionDeceleration = 100.0f * 96.0f / 1000.0f;
791 //sender.InertiaRotationDeceleration = 720.0f / (1000.0f * 1000.0f);
794 void gestureRecongnizer_ManipulationStarted(GestureRecognizer sender, ManipulationStartedEventArgs e)
796 this.HittedCaret = false;
797 this.hittedGripper = null;
799 Point p = e.Position;
800 TextPoint tp = this.View.GetTextPointFromPostion(p);
801 if (tp == this.View.CaretPostion)
806 if (this.FirstGripper.IsHit(p))
808 hittedGripper = this.FirstGripper;
810 System.Diagnostics.Debug.WriteLine("first gripper hitted");
813 else if (this.SecondGripper.IsHit(p))
815 hittedGripper = this.SecondGripper;
817 System.Diagnostics.Debug.WriteLine("second gripper hitted");
821 const int WheelNoti = 120;
822 const int WheelScrollLines = 3;
823 double TotalWheelCount = 0;
825 void gestureRecongnizer_ManipulationUpdated(GestureRecognizer sender, ManipulationUpdatedEventArgs e)
830 if (this.hittedGripper == null)
833 p = this.hittedGripper.AdjustPoint(e.Position);
835 if (hittedGripper != null)
837 TextPoint tp = this.View.GetTextPointFromPostion(p);
838 if (this._Controller.IsReverseSelect())
840 if (Object.ReferenceEquals(hittedGripper,this.SecondGripper))
841 this._Controller.MoveSelectBefore(tp);
843 this._Controller.MoveCaretAndSelect(tp);
847 if (Object.ReferenceEquals(hittedGripper,this.FirstGripper))
848 this._Controller.MoveSelectBefore(tp);
850 this._Controller.MoveCaretAndSelect(tp);
855 TextPoint tp = this.View.GetTextPointFromPostion(p);
856 this._Controller.MoveCaretAndSelect(tp);
858 if (this.peer != null)
859 this.peer.OnNotifyCaretChanged();
860 if (this._Controller.SelectionLength != 0)
861 this.FirstGripper.Enabled = true;
863 this.FirstGripper.Enabled = false;
870 if (e.Delta.Scale < 1)
872 double newSize = this.Render.FontSize - 1;
875 this.Render.FontSize = newSize;
877 SetValue(MagnificationPowerPropertyKey, this.Render.FontSize / this.FontSize);
881 if (e.Delta.Scale > 1)
883 double newSize = this.Render.FontSize + 1;
886 this.Render.FontSize = newSize;
888 SetValue(MagnificationPowerPropertyKey, this.Render.FontSize / this.FontSize);
892 Point translation = e.Delta.Translation;
894 //Xの絶対値が大きければ横方向のスクロールで、そうでなければ縦方向らしい
895 if (Math.Abs(e.Cumulative.Translation.X) < Math.Abs(e.Cumulative.Translation.Y))
898 if (e.PointerDeviceType == PointerDeviceType.Mouse) {
899 //テキストボックスはWheelNotiごとにWheelScrollLinesずつスクロールするらしい
900 scrollCount = (int)Math.Abs(this.TotalWheelCount / WheelNoti * WheelScrollLines);
903 else if (scrollCount > WheelScrollLines)
904 scrollCount = WheelScrollLines;
905 if (this.TotalWheelCount >= WheelNoti) //0にすると違和感を感じる
906 this.TotalWheelCount = this.TotalWheelCount % WheelNoti;
907 this.TotalWheelCount += Math.Abs(translation.Y);
911 scrollCount = (int)Math.Abs(translation.Y + 0.5);
914 if (translation.Y > 0)
915 this._Controller.Scroll(ScrollDirection.Up, scrollCount, false, false);
917 this._Controller.Scroll(ScrollDirection.Down, scrollCount, false, false);
918 this.FirstGripper.Enabled = false;
919 this.SecondGripper.Enabled = false;
924 int deltax = (int)Math.Abs(Math.Ceiling(translation.X));
927 if (translation.X < 0)
928 this._Controller.Scroll(ScrollDirection.Left, deltax, false, false);
930 this._Controller.Scroll(ScrollDirection.Right, deltax, false, false);
931 this.FirstGripper.Enabled = false;
932 this.SecondGripper.Enabled = false;
937 void gestureRecongnizer_ManipulationCompleted(GestureRecognizer sender, ManipulationCompletedEventArgs e)
941 async void gestureRecongnizer_RightTapped(GestureRecognizer sender, RightTappedEventArgs e)
943 ResourceMap map = ResourceManager.Current.MainResourceMap.GetSubtree("FooEditEngine.Metro/Resources");
944 ResourceContext context = ResourceContext.GetForCurrentView();
945 if (this.View.HitTextArea(e.Position.X, e.Position.Y))
947 FooContextMenuEventArgs args = new FooContextMenuEventArgs(e.Position);
948 if (this.ContextMenuOpening != null)
949 this.ContextMenuOpening(this, args);
952 PopupMenu ContextMenu = new PopupMenu();
953 ContextMenu.Commands.Add(new UICommand(map.GetValue("CopyMenuName", context).ValueAsString, (command) =>
957 ContextMenu.Commands.Add(new UICommand(map.GetValue("CutMenuName", context).ValueAsString, (command) =>
961 ContextMenu.Commands.Add(new UICommand(map.GetValue("PasteMenuName", context).ValueAsString, async (command) =>
963 await this.PasteCommand();
965 if (this._Controller.RectSelection)
967 ContextMenu.Commands.Add(new UICommand(map.GetValue("LineSelectMenuName", context).ValueAsString, (command) =>
969 this._Controller.RectSelection = false;
974 ContextMenu.Commands.Add(new UICommand(map.GetValue("RectSelectMenuName", context).ValueAsString, (command) =>
976 this._Controller.RectSelection = true;
979 await ContextMenu.ShowAsync(Util.GetScreentPoint(e.Position,this));
984 void gestureRecongnizer_Tapped(GestureRecognizer sender, TappedEventArgs e)
986 bool touched = e.PointerDeviceType == PointerDeviceType.Touch;
987 this.FirstGripper.Enabled = false;
988 this.SecondGripper.Enabled = touched;
989 this.JumpCaret(e.Position);
990 System.Diagnostics.Debug.WriteLine(e.TapCount);
993 this.FirstGripper.Enabled = touched;
994 //タッチスクリーンでダブルタップした場合、アンカーインデックスを単語の先頭にしないとバグる
995 this.Controller.SelectWord(this.Controller.SelectionStart, touched);
999 void JumpCaret(Point p)
1001 TextPoint tp = this.View.GetTextPointFromPostion(p);
1002 if (tp == TextPoint.Null)
1005 int index = this.View.LayoutLines.GetIndexFromTextPoint(tp);
1007 FoldingItem foldingData = this.View.HitFoldingData(p.X, tp.row);
1008 if (foldingData != null)
1010 if (foldingData.Expand)
1011 this.View.LayoutLines.FoldingCollection.Collapse(foldingData);
1013 this.View.LayoutLines.FoldingCollection.Expand(foldingData);
1014 this._Controller.JumpCaret(foldingData.Start, false);
1018 this._Controller.JumpCaret(tp.row, tp.col, false);
1020 if (this.peer != null)
1021 this.peer.OnNotifyCaretChanged();
1022 this.View.IsFocused = true;
1023 this.Focus(FocusState.Programmatic);
1027 void gestureRecongnizer_Dragging(GestureRecognizer sender, DraggingEventArgs e)
1029 Point p = e.Position;
1030 if (this.View.HitTextArea(p.X, p.Y))
1032 TextPoint tp = this.View.GetTextPointFromPostion(p);
1033 this._Controller.MoveCaretAndSelect(tp);
1034 if (this.peer != null)
1035 this.peer.OnNotifyCaretChanged();
1040 bool IsModiferKeyPressed(VirtualKey key)
1042 CoreVirtualKeyStates state = Window.Current.CoreWindow.GetKeyState(key);
1043 return (state & CoreVirtualKeyStates.Down) == CoreVirtualKeyStates.Down;
1045 void Refresh(Rectangle updateRect)
1047 if (this.rectangle.ActualWidth == 0 || this.rectangle.ActualHeight == 0 || this.Visibility == Windows.UI.Xaml.Visibility.Collapsed)
1050 this.Render.BegineDraw();
1052 this.View.Draw(updateRect);
1054 this.Render.FillBackground(updateRect);
1055 this.FirstGripper.Draw();
1056 this.SecondGripper.Draw();
1057 this.Render.EndDraw();
1061 bool Resize(double width, double height)
1063 if (width == 0 || height == 0)
1064 throw new ArgumentOutOfRangeException();
1065 if (this.Render.Resize(this.rectangle, width, height))
1067 this.View.PageBound = new Rectangle(0, 0, width, height);
1069 if (this.horizontalScrollBar != null)
1071 this.horizontalScrollBar.LargeChange = this.View.PageBound.Width;
1072 this.horizontalScrollBar.Maximum = this.View.LongestWidth + this.horizontalScrollBar.LargeChange + 1;
1074 if (this.verticalScrollBar != null)
1076 this.verticalScrollBar.LargeChange = this.View.LineCountOnScreen;
1077 this.verticalScrollBar.Maximum = this.View.LayoutLines.Count + this.verticalScrollBar.LargeChange + 1;
1084 void View_SrcChanged(object sender, EventArgs e)
1086 if (this.horizontalScrollBar == null || this.verticalScrollBar == null)
1088 EditView view = this.View;
1089 if (view.Src.Row > this.verticalScrollBar.Maximum)
1090 this.verticalScrollBar.Maximum = view.Src.Row + view.LineCountOnScreen + 1;
1091 double absoulteX = Math.Abs(view.Src.X);
1092 if (absoulteX > this.horizontalScrollBar.Maximum)
1093 this.horizontalScrollBar.Maximum = absoulteX + view.PageBound.Width + 1;
1094 if (view.Src.Row != this.verticalScrollBar.Value)
1095 this.verticalScrollBar.Value = view.Src.Row;
1096 if (view.Src.X != this.horizontalScrollBar.Value)
1097 this.horizontalScrollBar.Value = Math.Abs(view.Src.X);
1100 void FooTextBox_SizeChanged(object sender, SizeChangedEventArgs e)
1102 if (this.Resize(this.rectangle.ActualWidth, this.rectangle.ActualHeight))
1109 void horizontalScrollBar_Scroll(object sender, ScrollEventArgs e)
1111 if (this.horizontalScrollBar == null)
1114 if (this.FlowDirection == FlowDirection.LeftToRight)
1115 toX = this.horizontalScrollBar.Value;
1117 toX = -this.horizontalScrollBar.Value;
1118 this._Controller.Scroll(toX, this.View.Src.Row, false, false);
1119 this.FirstGripper.Enabled = false;
1120 this.SecondGripper.Enabled = false;
1124 void verticalScrollBar_Scroll(object sender, ScrollEventArgs e)
1126 if (this.verticalScrollBar == null)
1128 int newRow = (int)this.verticalScrollBar.Value;
1129 if (newRow >= this.View.LayoutLines.Count)
1131 this._Controller.Scroll(this.View.Src.X, newRow, false, false);
1132 this.FirstGripper.Enabled = false;
1133 this.SecondGripper.Enabled = false;
1137 void Document_Update(object sender, DocumentUpdateEventArgs e)
1139 if (this.textStore.IsLocked())
1141 if (e.type == UpdateType.Replace)
1142 TextStoreHelper.NotifyTextChanged(this.textStore, e.startIndex, e.removeLength, e.insertLength);
1145 void FooTextBox_Loaded(object sender, RoutedEventArgs e)
1147 this.Focus(FocusState.Programmatic);
1150 void timer_Tick(object sender, object e)
1152 bool updateAll = this.View.LayoutLines.HilightAll() || this.View.LayoutLines.GenerateFolding();
1158 public static void OnPropertyChanged(object sender, DependencyPropertyChangedEventArgs e)
1160 FooTextBox source = (FooTextBox)sender;
1161 if (e.Property.Equals(IndentModeProperty))
1162 source.Controller.IndentMode = source.IndentMode;
1163 if (e.Property.Equals(SelectionProperty) && !source.nowCaretMove)
1164 source._Controller.Select(source.Selection.Index,source.Selection.Length);
1165 if (e.Property.Equals(CaretPostionPropertyKey) && !source.nowCaretMove)
1166 source.JumpCaret(source.CaretPostion.row, source.CaretPostion.col);
1167 if (e.Property.Equals(InsertModeProperty))
1168 source.View.InsertMode = source.InsertMode;
1169 if (e.Property.Equals(TabCharsProperty))
1170 source.View.TabStops = source.TabChars;
1171 if (e.Property.Equals(RectSelectModeProperty))
1172 source._Controller.RectSelection = source.RectSelectMode;
1173 if (e.Property.Equals(DrawCaretProperty))
1174 source.View.HideCaret = !source.DrawCaret;
1175 if (e.Property.Equals(DrawCaretLineProperty))
1176 source.View.HideLineMarker = !source.DrawCaretLine;
1177 if (e.Property.Equals(DrawLineNumberProperty))
1179 source.View.DrawLineNumber = source.DrawLineNumber;
1180 source._Controller.JumpCaret(source.View.CaretPostion.row, source.View.CaretPostion.col);
1182 if(e.Property.Equals(MagnificationPowerPropertyKey))
1183 source.Render.FontSize = source.FontSize * source.MagnificationPower;
1184 if (e.Property.Equals(FontFamilyProperty))
1185 source.Render.FontFamily = source.FontFamily;
1186 if (e.Property.Equals(FontStyleProperty))
1187 source.Render.FontStyle = source.FontStyle;
1188 if (e.Property.Equals(FontWeightProperty))
1189 source.Render.FontWeigth = source.FontWeight;
1190 if (e.Property.Equals(FontSizeProperty))
1191 source.Render.FontSize = source.FontSize;
1192 if (e.Property.Equals(ForegroundProperty))
1193 source.Render.Foreground = D2DRenderBase.ToColor4(source.Foreground);
1194 if (e.Property.Equals(BackgroundProperty))
1195 source.Render.Background = D2DRenderBase.ToColor4(source.Background);
1196 if (e.Property.Equals(ControlCharProperty))
1197 source.Render.ControlChar = D2DRenderBase.ToColor4(source.ControlChar);
1198 if (e.Property.Equals(HilightProperty))
1199 source.Render.Hilight = D2DRenderBase.ToColor4(source.Hilight);
1200 if (e.Property.Equals(Keyword1Property))
1201 source.Render.Keyword1 = D2DRenderBase.ToColor4(source.Keyword1);
1202 if (e.Property.Equals(Keyword2Property))
1203 source.Render.Keyword2 = D2DRenderBase.ToColor4(source.Keyword2);
1204 if (e.Property.Equals(CommentProperty))
1205 source.Render.Comment = D2DRenderBase.ToColor4(source.Comment);
1206 if (e.Property.Equals(LiteralProperty))
1207 source.Render.Literal = D2DRenderBase.ToColor4(source.Literal);
1208 if (e.Property.Equals(URLProperty))
1209 source.Render.Url = D2DRenderBase.ToColor4(source.URL);
1210 if (e.Property.Equals(InsertCaretProperty))
1211 source.Render.InsertCaret = D2DRenderBase.ToColor4(source.InsertCaret);
1212 if (e.Property.Equals(OverwriteCaretProperty))
1213 source.Render.OverwriteCaret = D2DRenderBase.ToColor4(source.OverwriteCaret);
1214 if (e.Property.Equals(PaddingProperty))
1215 source.View.Padding = new Padding((int)source.Padding.Left, (int)source.Padding.Top, (int)source.Padding.Right, (int)source.Padding.Bottom);
1216 if (e.Property.Equals(LineMarkerProperty))
1217 source.Render.LineMarker = D2DRenderBase.ToColor4(source.LineMarker);
1218 if (e.Property.Equals(MarkURLProperty))
1219 source.View.UrlMark = source.MarkURL;
1220 if (e.Property.Equals(ShowFullSpaceProperty))
1221 source.Render.ShowFullSpace = source.ShowFullSpace;
1222 if (e.Property.Equals(ShowHalfSpaceProperty))
1223 source.Render.ShowHalfSpace = source.ShowHalfSpace;
1224 if (e.Property.Equals(ShowTabProperty))
1225 source.Render.ShowTab = source.ShowTab;
1226 if (e.Property.Equals(ShowLineBreakProperty))
1227 source.Render.ShowLineBreak = source.ShowLineBreak;
1228 if (e.Property.Equals(LineBreakProperty))
1229 source.View.LineBreak = source.LineBreakMethod;
1230 if (e.Property.Equals(LineBreakCharCountProperty))
1231 source.View.LineBreakCharCount = source.LineBreakCharCount;
1232 if (e.Property.Equals(UpdateAreaProperty))
1233 source.Render.UpdateArea = D2DRenderBase.ToColor4(source.UpdateArea);
1234 if (e.Property.Equals(LineNumberProperty))
1235 source.Render.LineNumber = D2DRenderBase.ToColor4(source.LineNumber);
1236 if (e.Property.Equals(FlowDirectionProperty))
1238 source.Render.RightToLeft = source.FlowDirection == Windows.UI.Xaml.FlowDirection.RightToLeft;
1239 if(source.horizontalScrollBar != null)
1240 source.horizontalScrollBar.FlowDirection = source.FlowDirection;
1242 if (e.Property.Equals(DrawRulerProperty))
1244 source.View.HideRuler = !source.DrawRuler;
1245 source._Controller.JumpCaret(source.View.CaretPostion.row, source.View.CaretPostion.col);
1253 /// コンテキストメニューが表示されるときに呼び出されます
1255 public event EventHandler<FooContextMenuEventArgs> ContextMenuOpening;
1261 internal Controller Controller
1265 return this._Controller;
1270 /// 文字列の描写に使用されるアンチエイリアシング モードを表します
1272 public TextAntialiasMode TextAntialiasMode
1276 return this.Render.TextAntialiasMode;
1280 this.Render.TextAntialiasMode = value;
1287 public IHilighter Hilighter
1291 return this.View.Hilighter;
1295 this.View.Hilighter = value;
1296 this.View.LayoutLines.ClearLayoutCache();
1301 /// フォールティングを作成するインターフェイスを表す
1303 public IFoldingStrategy FoldingStrategy
1307 return this.View.LayoutLines.FoldingStrategy;
1311 this.View.LayoutLines.FoldingStrategy = value;
1313 this.View.LayoutLines.FoldingCollection.Clear();
1320 public MarkerPatternSet MarkerPatternSet
1324 return this.View.MarkerPatternSet;
1331 public Document Document
1340 public LineToIndexTable LayoutLineCollection
1342 get { return this.View.LayoutLines; }
1348 public string SelectedText
1352 return this._Controller.SelectedText;
1356 int oldLength = this.Document.Length;
1357 this._Controller.SelectedText = value;
1364 public IndentMode IndentMode
1366 get { return (IndentMode)GetValue(IndentModeProperty); }
1367 set { SetValue(IndentModeProperty, value); }
1371 /// IndentModeの依存プロパティを表す
1373 public static readonly DependencyProperty IndentModeProperty =
1374 DependencyProperty.Register("IndentMode", typeof(IndentMode), typeof(FooTextBox), new PropertyMetadata(IndentMode.Tab,OnPropertyChanged));
1380 /// Lengthが0の場合はキャレット位置を表します。
1381 /// 矩形選択モードの場合、選択範囲の文字数ではなく、開始位置から終了位置までの長さとなります
1383 public TextRange Selection
1385 get { return (TextRange)GetValue(SelectionProperty); }
1386 set { SetValue(SelectionProperty, value); }
1390 /// Selectionの依存プロパティを表す
1392 public static readonly DependencyProperty SelectionProperty =
1393 DependencyProperty.Register("Selection", typeof(TextRange), typeof(FooTextBox), new PropertyMetadata(0));
1398 public double MagnificationPower
1400 get { return (double)GetValue(MagnificationPowerPropertyKey); }
1401 set { SetValue(MagnificationPowerPropertyKey, value); }
1407 public static readonly DependencyProperty MagnificationPowerPropertyKey =
1408 DependencyProperty.Register("MagnificationPower", typeof(double), typeof(FooTextBox), new PropertyMetadata(1.0, OnPropertyChanged));
1413 public TextPoint CaretPostion
1415 get { return (TextPoint)GetValue(CaretPostionPropertyKey); }
1416 set { SetValue(CaretPostionPropertyKey, value); }
1419 static readonly DependencyProperty CaretPostionPropertyKey =
1420 DependencyProperty.Register("CaretPostion", typeof(TextPoint), typeof(FooTextBox), new PropertyMetadata(new TextPoint(), OnPropertyChanged));
1425 public new FlowDirection FlowDirection
1427 get { return (FlowDirection)GetValue(FlowDirectionProperty); }
1428 set { SetValue(FlowDirectionProperty, value); }
1432 /// レタリング方向を表す。これは依存プロパティです
1434 public new static readonly DependencyProperty FlowDirectionProperty =
1435 DependencyProperty.Register("FlowDirection", typeof(FlowDirection), typeof(FooTextBox), new PropertyMetadata(FlowDirection.LeftToRight,OnPropertyChanged));
1440 public new FontFamily FontFamily
1442 get { return (FontFamily)GetValue(FontFamilyProperty); }
1443 set { SetValue(FontFamilyProperty, value); }
1447 /// FontFamilyの依存プロパティを表す
1449 public new static readonly DependencyProperty FontFamilyProperty =
1450 DependencyProperty.Register("FontFamily", typeof(FontFamily), typeof(FooTextBox), new PropertyMetadata(new FontFamily("Cambria"), OnPropertyChanged));
1455 public new double FontSize
1457 get { return (double)GetValue(FontSizeProperty); }
1458 set { SetValue(FontSizeProperty, value); }
1462 /// FontSizeの依存プロパティを表す
1464 public new static readonly DependencyProperty FontSizeProperty =
1465 DependencyProperty.Register("FontSize", typeof(double), typeof(FooTextBox), new PropertyMetadata(12.0,OnPropertyChanged));
1470 public new FontStyle FontStyle
1472 get { return (FontStyle)GetValue(FontStyleProperty); }
1473 set { SetValue(FontStyleProperty, value); }
1477 /// FontStyleの依存プロパティを表す
1479 public new static readonly DependencyProperty FontStyleProperty =
1480 DependencyProperty.Register("FontStyle", typeof(FontStyle), typeof(FooTextBox), new PropertyMetadata(FontStyle.Normal,OnPropertyChanged));
1485 public new FontWeight FontWeight
1487 get { return (FontWeight)GetValue(FontWeightProperty); }
1488 set { SetValue(FontWeightProperty, value); }
1492 /// FontWeigthの依存プロパティを表す
1494 public new static readonly DependencyProperty FontWeightProperty =
1495 DependencyProperty.Register("FontWeigth", typeof(FontWeight), typeof(FooTextBox), new PropertyMetadata(FontWeights.Normal,OnPropertyChanged));
1498 /// デフォルトの文字色を表す。これは依存プロパティです
1500 public new Windows.UI.Color Foreground
1502 get { return (Windows.UI.Color)GetValue(ForegroundProperty); }
1503 set { SetValue(ForegroundProperty, value); }
1507 /// Foregroundの依存プロパティを表す
1509 public new static readonly DependencyProperty ForegroundProperty =
1510 DependencyProperty.Register("Foreground", typeof(Windows.UI.Color), typeof(FooTextBox), new PropertyMetadata(Colors.Black, OnPropertyChanged));
1513 /// 背景色を表す。これは依存プロパティです
1515 public new Windows.UI.Color Background
1517 get { return (Windows.UI.Color)GetValue(BackgroundProperty); }
1518 set { SetValue(BackgroundProperty, value); }
1522 /// Backgroundの依存プロパティを表す
1524 public new static readonly DependencyProperty BackgroundProperty =
1525 DependencyProperty.Register("Background", typeof(Windows.UI.Color), typeof(FooTextBox), new PropertyMetadata(Colors.White, OnPropertyChanged));
1528 /// コントロールコードの文字色を表す。これは依存プロパティです
1530 public Windows.UI.Color ControlChar
1532 get { return (Windows.UI.Color)GetValue(ControlCharProperty); }
1533 set { SetValue(ControlCharProperty, value); }
1537 /// ControlCharの依存プロパティを表す
1539 public static readonly DependencyProperty ControlCharProperty =
1540 DependencyProperty.Register("ControlChar", typeof(Windows.UI.Color), typeof(FooTextBox), new PropertyMetadata(Colors.Gray, OnPropertyChanged));
1543 /// 選択時の背景色を表す。これは依存プロパティです
1545 public Windows.UI.Color Hilight
1547 get { return (Windows.UI.Color)GetValue(HilightProperty); }
1548 set { SetValue(HilightProperty, value); }
1552 /// Hilightの依存プロパティを表す
1554 public static readonly DependencyProperty HilightProperty =
1555 DependencyProperty.Register("Hilight", typeof(Windows.UI.Color), typeof(FooTextBox), new PropertyMetadata(Colors.DeepSkyBlue, OnPropertyChanged));
1558 /// キーワード1の文字色を表す。これは依存プロパティです
1560 public Windows.UI.Color Keyword1
1562 get { return (Windows.UI.Color)GetValue(Keyword1Property); }
1563 set { SetValue(Keyword1Property, value); }
1567 /// Keyword1の依存プロパティを表す
1569 public static readonly DependencyProperty Keyword1Property =
1570 DependencyProperty.Register("Keyword1", typeof(Windows.UI.Color), typeof(FooTextBox), new PropertyMetadata(Colors.Blue, OnPropertyChanged));
1573 /// キーワード2の文字色を表す。これは依存プロパティです
1575 public Windows.UI.Color Keyword2
1577 get { return (Windows.UI.Color)GetValue(Keyword2Property); }
1578 set { SetValue(Keyword2Property, value); }
1582 /// Keyword2の依存プロパティを表す
1584 public static readonly DependencyProperty Keyword2Property =
1585 DependencyProperty.Register("Keyword2", typeof(Windows.UI.Color), typeof(FooTextBox), new PropertyMetadata(Colors.DarkCyan, OnPropertyChanged));
1588 /// コメントの文字色を表す。これは依存プロパティです
1590 public Windows.UI.Color Comment
1592 get { return (Windows.UI.Color)GetValue(CommentProperty); }
1593 set { SetValue(CommentProperty, value); }
1597 /// Commentの依存プロパティを表す
1599 public static readonly DependencyProperty CommentProperty =
1600 DependencyProperty.Register("Comment", typeof(Windows.UI.Color), typeof(FooTextBox), new PropertyMetadata(Colors.Green, OnPropertyChanged));
1603 /// 文字リテラルの文字色を表す。これは依存プロパティです
1605 public Windows.UI.Color Literal
1607 get { return (Windows.UI.Color)GetValue(LiteralProperty); }
1608 set { SetValue(LiteralProperty, value); }
1612 /// Literalの依存プロパティを表す
1614 public static readonly DependencyProperty LiteralProperty =
1615 DependencyProperty.Register("Literal", typeof(Windows.UI.Color), typeof(FooTextBox), new PropertyMetadata(Colors.Brown, OnPropertyChanged));
1618 /// URLの文字色を表す。これは依存プロパティです
1620 public Windows.UI.Color URL
1622 get { return (Windows.UI.Color)GetValue(URLProperty); }
1623 set { SetValue(URLProperty, value); }
1629 public static readonly DependencyProperty URLProperty =
1630 DependencyProperty.Register("URL", typeof(Windows.UI.Color), typeof(FooTextBox), new PropertyMetadata(Colors.Blue, OnPropertyChanged));
1635 public Windows.UI.Color UpdateArea
1637 get { return (Windows.UI.Color)GetValue(UpdateAreaProperty); }
1638 set { SetValue(UpdateAreaProperty, value); }
1642 /// UpdateAreaの依存プロパティを表す
1644 public static readonly DependencyProperty UpdateAreaProperty =
1645 DependencyProperty.Register("UpdateArea", typeof(Windows.UI.Color), typeof(FooTextBox), new PropertyMetadata(Colors.MediumSeaGreen));
1650 public Windows.UI.Color LineMarker
1652 get { return (Windows.UI.Color)GetValue(LineMarkerProperty); }
1653 set { SetValue(LineMarkerProperty, value); }
1657 /// LineMarkerの依存プロパティを表す
1659 public static readonly DependencyProperty LineMarkerProperty =
1660 DependencyProperty.Register("LineMarker", typeof(Windows.UI.Color), typeof(FooTextBox), new PropertyMetadata(Colors.Gray, OnPropertyChanged));
1663 /// 挿入モード時のキャレットの色を表す
1665 public Windows.UI.Color InsertCaret
1667 get { return (Windows.UI.Color)GetValue(InsertCaretProperty); }
1668 set { SetValue(InsertCaretProperty, value); }
1672 /// InsertCaretの依存プロパティを表す
1674 public static readonly DependencyProperty InsertCaretProperty =
1675 DependencyProperty.Register("InsertCaret", typeof(Windows.UI.Color), typeof(FooTextBox), new PropertyMetadata(Colors.Black, OnPropertyChanged));
1678 /// 上書きモード時のキャレット職を表す
1680 public Windows.UI.Color OverwriteCaret
1682 get { return (Windows.UI.Color)GetValue(OverwriteCaretProperty); }
1683 set { SetValue(OverwriteCaretProperty, value); }
1687 /// OverwriteCaretの依存プロパティを表す
1689 public static readonly DependencyProperty OverwriteCaretProperty =
1690 DependencyProperty.Register("OverwriteCaret", typeof(Windows.UI.Color), typeof(FooTextBox), new PropertyMetadata(Colors.Black, OnPropertyChanged));
1695 public Windows.UI.Color LineNumber
1697 get { return (Windows.UI.Color)GetValue(LineNumberProperty); }
1698 set { SetValue(LineNumberProperty, value); }
1702 /// Using a DependencyProperty as the backing store for LineNumber. This enables animation, styling, binding, etc...
1704 public static readonly DependencyProperty LineNumberProperty =
1705 DependencyProperty.Register("LineNumber", typeof(Windows.UI.Color), typeof(FooTextBox), new PropertyMetadata(Colors.DimGray,OnPropertyChanged));
1710 public new Thickness Padding
1712 get { return (Thickness)GetValue(PaddingProperty); }
1713 set { SetValue(PaddingProperty, value); }
1717 /// Paddingの依存プロパティを表す
1719 public new static readonly DependencyProperty PaddingProperty =
1720 DependencyProperty.Register("Padding", typeof(Thickness), typeof(FooTextBox), new PropertyMetadata(new Thickness(),OnPropertyChanged));
1723 /// 挿入モードなら真を返し、そうでないなら、偽を返す。これは依存プロパティです
1725 public bool InsertMode
1727 get { return (bool)GetValue(InsertModeProperty); }
1728 set { SetValue(InsertModeProperty, value); }
1732 /// InsertModeの依存プロパティを表す
1734 public static readonly DependencyProperty InsertModeProperty =
1735 DependencyProperty.Register("InsertMode",
1738 new PropertyMetadata(true, OnPropertyChanged));
1741 /// タブの文字数を表す。これは依存プロパティです
1745 get { return (int)GetValue(TabCharsProperty); }
1746 set { SetValue(TabCharsProperty, value); }
1750 /// TabCharsの依存プロパティを表す
1752 public static readonly DependencyProperty TabCharsProperty =
1753 DependencyProperty.Register("TabChars",
1756 new PropertyMetadata(4, OnPropertyChanged));
1759 /// 矩形選択モードなら真を返し、そうでないなら偽を返す。これは依存プロパティです
1761 public bool RectSelectMode
1763 get { return (bool)GetValue(RectSelectModeProperty); }
1764 set { SetValue(RectSelectModeProperty, value); }
1768 /// RectSelectModeの依存プロパティを表す
1770 public static readonly DependencyProperty RectSelectModeProperty =
1771 DependencyProperty.Register("RectSelectMode", typeof(bool), typeof(FooTextBox), new PropertyMetadata(false, OnPropertyChanged));
1777 /// 変更した場合、レイアウトの再構築を行う必要があります
1779 public LineBreakMethod LineBreakMethod
1781 get { return (LineBreakMethod)GetValue(LineBreakProperty); }
1782 set { SetValue(LineBreakProperty, value); }
1786 /// LineBreakMethodの依存プロパティを表す
1788 public static readonly DependencyProperty LineBreakProperty =
1789 DependencyProperty.Register("LineBreakMethod", typeof(LineBreakMethod), typeof(FooTextBox), new PropertyMetadata(LineBreakMethod.None, OnPropertyChanged));
1793 /// 折り返しの幅を指定する。LineBreakMethod.CharUnit以外の時は無視されます
1796 /// 変更した場合、レイアウトの再構築を行う必要があります
1798 public int LineBreakCharCount
1800 get { return (int)GetValue(LineBreakCharCountProperty); }
1801 set { SetValue(LineBreakCharCountProperty, value); }
1805 /// LineBreakCharCountの依存プロパティを表す
1807 public static readonly DependencyProperty LineBreakCharCountProperty =
1808 DependencyProperty.Register("LineBreakCharCount", typeof(int), typeof(FooTextBox), new PropertyMetadata(80));
1811 /// キャレットを描くなら真。そうでないなら偽を返す。これは依存プロパティです
1813 public bool DrawCaret
1815 get { return (bool)GetValue(DrawCaretProperty); }
1816 set { SetValue(DrawCaretProperty, value); }
1820 /// DrawCaretの依存プロパティを表す
1822 public static readonly DependencyProperty DrawCaretProperty =
1823 DependencyProperty.Register("DrawCaret", typeof(bool), typeof(FooTextBox), new PropertyMetadata(true, OnPropertyChanged));
1827 /// キャレットラインを描くなら真。そうでないなら偽を返す。これは依存プロパティです
1829 public bool DrawCaretLine
1831 get { return (bool)GetValue(DrawCaretLineProperty); }
1832 set { SetValue(DrawCaretLineProperty, value); }
1836 /// DrawCaretLineの依存プロパティを表す
1838 public static readonly DependencyProperty DrawCaretLineProperty =
1839 DependencyProperty.Register("DrawCaretLine", typeof(bool), typeof(FooTextBox), new PropertyMetadata(false, OnPropertyChanged));
1842 /// 行番号を描くなら真。そうでなければ偽。これは依存プロパティです
1844 public bool DrawLineNumber
1846 get { return (bool)GetValue(DrawLineNumberProperty); }
1847 set { SetValue(DrawLineNumberProperty, value); }
1851 /// ルーラーを描くなら真。そうでなければ偽。これは依存プロパティです
1853 public bool DrawRuler
1855 get { return (bool)GetValue(DrawRulerProperty); }
1856 set { SetValue(DrawRulerProperty, value); }
1860 /// DrawRulerの依存プロパティを表す
1862 public static readonly DependencyProperty DrawRulerProperty =
1863 DependencyProperty.Register("DrawRuler", typeof(bool), typeof(FooTextBox), new PropertyMetadata(false, OnPropertyChanged));
1867 /// DrawLineNumberの依存プロパティを表す
1869 public static readonly DependencyProperty DrawLineNumberProperty =
1870 DependencyProperty.Register("DrawLineNumber", typeof(bool), typeof(FooTextBox), new PropertyMetadata(false, OnPropertyChanged));
1873 /// URLに下線を引くなら真。そうでないなら偽を表す。これは依存プロパティです
1877 get { return (bool)GetValue(MarkURLProperty); }
1878 set { SetValue(MarkURLProperty, value); }
1882 /// MarkURLの依存プロパティを表す
1884 public static readonly DependencyProperty MarkURLProperty =
1885 DependencyProperty.Register("MarkURL", typeof(bool), typeof(FooTextBox), new PropertyMetadata(false, OnPropertyChanged));
1888 /// 全角スペースを表示するなら真。そうでないなら偽
1890 public bool ShowFullSpace
1892 get { return (bool)GetValue(ShowFullSpaceProperty); }
1893 set { SetValue(ShowFullSpaceProperty, value); }
1897 /// ShowFullSpaceの依存プロパティを表す
1899 public static readonly DependencyProperty ShowFullSpaceProperty =
1900 DependencyProperty.Register("ShowFullSpace", typeof(bool), typeof(FooTextBox), new PropertyMetadata(false, OnPropertyChanged));
1903 /// 半角スペースを表示するなら真。そうでないなら偽
1905 public bool ShowHalfSpace
1907 get { return (bool)GetValue(ShowHalfSpaceProperty); }
1908 set { SetValue(ShowHalfSpaceProperty, value); }
1912 /// ShowHalfSpaceの依存プロパティを表す
1914 public static readonly DependencyProperty ShowHalfSpaceProperty =
1915 DependencyProperty.Register("ShowHalfSpace", typeof(bool), typeof(FooTextBox), new PropertyMetadata(false, OnPropertyChanged));
1918 /// タブを表示するなら真。そうでないなら偽
1922 get { return (bool)GetValue(ShowTabProperty); }
1923 set { SetValue(ShowTabProperty, value); }
1927 /// ShowTabの依存プロパティを表す
1929 public static readonly DependencyProperty ShowTabProperty =
1930 DependencyProperty.Register("ShowTab", typeof(bool), typeof(FooTextBox), new PropertyMetadata(false, OnPropertyChanged));
1933 /// 改行マークを表示するなら真。そうでないなら偽
1935 public bool ShowLineBreak
1937 get { return (bool)GetValue(ShowLineBreakProperty); }
1938 set { SetValue(ShowLineBreakProperty, value); }
1942 /// ShowLineBreakの依存プロパティを表す
1944 public static readonly DependencyProperty ShowLineBreakProperty =
1945 DependencyProperty.Register("ShowLineBreak", typeof(bool), typeof(FooTextBox), new PropertyMetadata(false,OnPropertyChanged));
1952 /// コンテキストメニューのイベントデーターを表す
1954 public class FooContextMenuEventArgs
1957 /// 処理済みなら真。そうでないなら偽
1959 public bool Handled = false;
1961 /// コンテキストメニューを表示すべき座標を表す
1963 public Windows.Foundation.Point Postion;
1967 /// <param name="pos"></param>
1968 public FooContextMenuEventArgs(Windows.Foundation.Point pos)