2 * Copyright (C) 2013 FooProject
\r
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
\r
4 * the Free Software Foundation; either version 3 of the License, or (at your option) any later version.
\r
6 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
7 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
\r
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/>.
\r
13 using System.ComponentModel;
\r
14 using System.Threading.Tasks;
\r
15 using Windows.ApplicationModel.Resources.Core;
\r
16 using Windows.Devices.Input;
\r
17 using Windows.System;
\r
18 using Windows.ApplicationModel.DataTransfer;
\r
19 using Windows.Foundation;
\r
21 using Windows.UI.Input;
\r
22 using Windows.UI.Core;
\r
23 using Windows.UI.Popups;
\r
24 using Windows.UI.Text;
\r
25 using Windows.UI.Xaml.Media;
\r
26 using Windows.UI.Xaml;
\r
27 using Windows.UI.Xaml.Controls;
\r
28 using Windows.UI.Xaml.Controls.Primitives;
\r
29 using Windows.UI.Xaml.Input;
\r
30 using DotNetTextStore;
\r
31 using DotNetTextStore.UnmanagedAPI.TSF;
\r
32 using DotNetTextStore.UnmanagedAPI.WinDef;
\r
34 // テンプレート コントロールのアイテム テンプレートについては、http://go.microsoft.com/fwlink/?LinkId=234235 を参照してください
\r
36 namespace FooEditEngine.Metro
\r
41 public sealed class FooTextBox : Control,IDisposable
\r
44 Controller _Controller;
\r
46 ScrollBar horizontalScrollBar, verticalScrollBar;
\r
47 Windows.UI.Xaml.Shapes.Rectangle rectangle;
\r
48 GestureRecognizer gestureRecongnizer = new GestureRecognizer();
\r
49 TextStore2 textStore;
\r
50 FooTextBoxAutomationPeer peer;
\r
51 bool nowCaretMove = false;
\r
58 this.DefaultStyleKey = typeof(FooTextBox);
\r
60 this.textStore = new TextStore2();
\r
61 this.textStore.IsLoading += textStore_IsLoading;
\r
62 this.textStore.IsReadOnly += textStore_IsReadOnly;
\r
63 this.textStore.GetDpi += textStore_GetDpi;
\r
64 this.textStore.GetStringLength += () => this.Document.Length;
\r
65 this.textStore.GetString += _textStore_GetString;
\r
66 this.textStore.GetSelectionIndex += _textStore_GetSelectionIndex;
\r
67 this.textStore.SetSelectionIndex += _textStore_SetSelectionIndex;
\r
68 this.textStore.InsertAtSelection += _textStore_InsertAtSelection;
\r
69 this.textStore.GetScreenExtent += _textStore_GetScreenExtent;
\r
70 this.textStore.GetStringExtent += _textStore_GetStringExtent;
\r
71 this.textStore.CompositionStarted += textStore_CompositionStarted;
\r
72 this.textStore.CompositionUpdated += textStore_CompositionUpdated;
\r
73 this.textStore.CompositionEnded += textStore_CompositionEnded;
\r
75 this.Document = new Document();
\r
77 this.rectangle = new Windows.UI.Xaml.Shapes.Rectangle();
\r
78 this.rectangle.Margin = this.Padding;
\r
79 this.Render = new D2DRender(this,this.rectangle,this.textStore);
\r
81 this.View = new EditView(this.Document, this.Render, new Padding(5, Gripper.HitAreaWidth, Gripper.HitAreaWidth / 2, Gripper.HitAreaWidth));
\r
82 this.View.SrcChanged += View_SrcChanged;
\r
83 this.View.InsertMode = this.InsertMode;
\r
84 this.View.DrawLineNumber = this.DrawLineNumber;
\r
85 this.View.HideCaret = !this.DrawCaret;
\r
86 this.View.HideLineMarker = !this.DrawCaretLine;
\r
87 this.View.HideRuler = !this.DrawRuler;
\r
88 this.View.UrlMark = this.MarkURL;
\r
89 this.View.TabStops = this.TabChars;
\r
91 this._Controller = new Controller(this.Document, this.View);
\r
92 this._Controller.SelectionChanged += Controller_SelectionChanged;
\r
94 this.FirstGripper = new Gripper(this._Controller, this.View, this.Render, GripperPostion.Upper);
\r
95 this.SecondGripper = new Gripper(this._Controller, this.View, this.Render, GripperPostion.Bottom);
\r
97 this.gestureRecongnizer.GestureSettings = GestureSettings.Drag |
\r
98 GestureSettings.RightTap |
\r
99 GestureSettings.Tap |
\r
100 GestureSettings.ManipulationTranslateX |
\r
101 GestureSettings.ManipulationTranslateY |
\r
102 GestureSettings.ManipulationScale;
\r
103 this.gestureRecongnizer.RightTapped += gestureRecongnizer_RightTapped;
\r
104 this.gestureRecongnizer.Tapped += gestureRecongnizer_Tapped;
\r
105 this.gestureRecongnizer.Dragging += gestureRecongnizer_Dragging;
\r
106 this.gestureRecongnizer.ManipulationStarted += gestureRecongnizer_ManipulationStarted;
\r
107 this.gestureRecongnizer.ManipulationUpdated += gestureRecongnizer_ManipulationUpdated;
\r
108 this.gestureRecongnizer.ManipulationCompleted += gestureRecongnizer_ManipulationCompleted;
\r
110 //Viewの初期化が終わった直後に置かないと例外が発生する
\r
111 this.Document.Update += Document_Update;
\r
113 Window.Current.CoreWindow.CharacterReceived += CoreWindow_CharacterReceived;
\r
115 this.SizeChanged += FooTextBox_SizeChanged;
\r
117 this.Loaded += FooTextBox_Loaded;
\r
125 this.Dispose(false);
\r
129 /// アンマネージドリソースを解放する
\r
131 public void Dispose()
\r
133 this.Dispose(true);
\r
134 GC.SuppressFinalize(this);
\r
137 bool Disposed = false;
\r
138 private void Dispose(bool disposing)
\r
144 this.textStore.Dispose();
\r
145 this.View.Dispose();
\r
146 this.Render.Dispose();
\r
153 /// <param name="start">開始インデックス</param>
\r
154 /// <param name="length">長さ</param>
\r
155 public void Select(int start, int length)
\r
157 this._Controller.Select(start, length);
\r
161 /// キャレットを指定した行に移動させます
\r
163 /// <param name="index">インデックス</param>
\r
164 /// <remarks>このメソッドを呼び出すと選択状態は解除されます</remarks>
\r
165 public void JumpCaret(int index)
\r
167 this._Controller.JumpCaret(index);
\r
170 /// キャレットを指定した行と桁に移動させます
\r
172 /// <param name="row">行番号</param>
\r
173 /// <param name="col">桁</param>
\r
174 /// <remarks>このメソッドを呼び出すと選択状態は解除されます</remarks>
\r
175 public void JumpCaret(int row, int col)
\r
177 this._Controller.JumpCaret(row, col);
\r
181 /// 選択中のテキストをクリップボードにコピーします
\r
185 string text = this._Controller.SelectedText;
\r
186 if (text != null && text != string.Empty)
\r
188 DataPackage dataPackage = new DataPackage();
\r
189 dataPackage.RequestedOperation = DataPackageOperation.Copy;
\r
190 dataPackage.SetText(text);
\r
192 Clipboard.SetContent(dataPackage);
\r
197 /// 選択中のテキストをクリップボードに切り取ります
\r
201 string text = this._Controller.SelectedText;
\r
202 if (text != null && text != string.Empty)
\r
204 DataPackage dataPackage = new DataPackage();
\r
205 dataPackage.RequestedOperation = DataPackageOperation.Copy;
\r
206 dataPackage.SetText(text);
\r
208 Clipboard.SetContent(dataPackage);
\r
210 this._Controller.SelectedText = "";
\r
215 /// 選択中のテキストを貼り付けます
\r
217 public async Task PasteAsync()
\r
219 var dataPackageView = Clipboard.GetContent();
\r
220 if (dataPackageView.Contains(StandardDataFormats.Text))
\r
222 this._Controller.SelectedText = await dataPackageView.GetTextAsync();
\r
229 public void SelectAll()
\r
231 this._Controller.Select(0, this.Document.Length);
\r
237 public void DeSelectAll()
\r
239 this._Controller.DeSelectAll();
\r
245 /// <param name="tp">テキストポイント</param>
\r
246 /// <returns>座標</returns>
\r
247 /// <remarks>テキストポイントがクライアント領域の原点より外にある場合、返される値は原点に丸められます</remarks>
\r
248 public Windows.Foundation.Point GetPostionFromTextPoint(TextPoint tp)
\r
250 if (this.Document.FireUpdateEvent == false)
\r
251 throw new InvalidOperationException("");
\r
252 return this.View.GetPostionFromTextPoint(tp);
\r
256 /// 対応するテキストポイントを返します
\r
258 /// <param name="p">クライアント領域の原点を左上とする座標</param>
\r
259 /// <returns>テキストポイント</returns>
\r
260 public TextPoint GetTextPointFromPostion(Windows.Foundation.Point p)
\r
262 if (this.Document.FireUpdateEvent == false)
\r
263 throw new InvalidOperationException("");
\r
264 return this.View.GetTextPointFromPostion(p);
\r
270 /// <param name="row">レイアウト行</param>
\r
271 /// <returns>行の高さ</returns>
\r
272 public double GetLineHeight(int row)
\r
274 if (this.Document.FireUpdateEvent == false)
\r
275 throw new InvalidOperationException("");
\r
276 return this.View.LayoutLines.GetLayout(row).Height; ;
\r
280 /// インデックスに対応する座標を得ます
\r
282 /// <param name="index">インデックス</param>
\r
283 /// <returns>座標を返す</returns>
\r
284 public Windows.Foundation.Point GetPostionFromIndex(int index)
\r
286 if (this.Document.FireUpdateEvent == false)
\r
287 throw new InvalidOperationException("");
\r
288 TextPoint tp = this.View.GetLayoutLineFromIndex(index);
\r
289 return this.View.GetPostionFromTextPoint(tp);
\r
293 /// 座標からインデックスに変換します
\r
295 /// <param name="p">座標</param>
\r
296 /// <returns>インデックスを返す</returns>
\r
297 public int GetIndexFromPostion(Windows.Foundation.Point p)
\r
299 if (this.Document.FireUpdateEvent == false)
\r
300 throw new InvalidOperationException("");
\r
301 TextPoint tp = this.View.GetTextPointFromPostion(p);
\r
302 return this.View.GetIndexFromLayoutLine(tp);
\r
308 public void Refresh()
\r
310 this.Refresh(this.View.PageBound);
\r
314 /// レイアウト行をすべて破棄し、再度レイアウトを行う
\r
316 public void PerfomLayouts()
\r
318 this.View.PerfomLayouts();
\r
322 /// ファイルからドキュメントを構築する
\r
324 /// <param name="sr">StremReader</param>
\r
325 /// <returns>Taskオブジェクト</returns>
\r
326 public async Task LoadFileAsync(System.IO.StreamReader sr, System.Threading.CancellationTokenSource token)
\r
328 this.IsEnabled = false;
\r
329 this.View.LayoutLines.IsFrozneDirtyFlag = true;
\r
330 WinFileReader fs = new WinFileReader(sr);
\r
331 await this.Document.LoadAsync(fs, token);
\r
332 this.View.LayoutLines.IsFrozneDirtyFlag = false;
\r
333 TextStoreHelper.NotifyTextChanged(this.textStore, 0, 0, this.Document.Length);
\r
334 if (this.verticalScrollBar != null)
\r
335 this.verticalScrollBar.Maximum = this.View.LayoutLines.Count;
\r
336 this.View.CalculateLineCountOnScreen();
\r
337 this.IsEnabled = true;
\r
341 /// ドキュメントの内容をファイルに保存する
\r
343 /// <param name="sw">StreamWriter</param>
\r
344 /// <param name="enc">エンコード</param>
\r
345 /// <returns>Taskオブジェクト</returns>
\r
346 public async Task SaveFile(System.IO.StreamWriter sw, System.Threading.CancellationTokenSource token)
\r
348 WinFileWriter fs = new WinFileWriter(sw);
\r
349 await this.Document.SaveAsync(fs, token);
\r
364 async Task PasteCommand()
\r
366 await this.PasteAsync();
\r
374 protected override Windows.UI.Xaml.Automation.Peers.AutomationPeer OnCreateAutomationPeer()
\r
376 this.peer = new FooTextBoxAutomationPeer(this);
\r
381 protected override void OnApplyTemplate()
\r
383 base.OnApplyTemplate();
\r
385 Grid grid = this.GetTemplateChild("PART_Grid") as Grid;
\r
388 Grid.SetRow(this.rectangle, 0);
\r
389 Grid.SetColumn(this.rectangle, 0);
\r
390 grid.Children.Add(this.rectangle);
\r
393 this.horizontalScrollBar = this.GetTemplateChild("PART_HorizontalScrollBar") as ScrollBar;
\r
394 if (this.horizontalScrollBar != null)
\r
396 this.horizontalScrollBar.SmallChange = 10;
\r
397 this.horizontalScrollBar.LargeChange = 100;
\r
398 this.horizontalScrollBar.Maximum = this.horizontalScrollBar.LargeChange + 1;
\r
399 this.horizontalScrollBar.Scroll += new ScrollEventHandler(horizontalScrollBar_Scroll);
\r
401 this.verticalScrollBar = this.GetTemplateChild("PART_VerticalScrollBar") as ScrollBar;
\r
402 if (this.verticalScrollBar != null)
\r
404 this.verticalScrollBar.SmallChange = 1;
\r
405 this.verticalScrollBar.LargeChange = 10;
\r
406 this.verticalScrollBar.Maximum = this.View.LayoutLines.Count;
\r
407 this.verticalScrollBar.Scroll += new ScrollEventHandler(verticalScrollBar_Scroll);
\r
412 protected override void OnGotFocus(RoutedEventArgs e)
\r
414 base.OnGotFocus(e);
\r
415 this.textStore.SetFocus();
\r
416 this.View.IsFocused = true;
\r
421 protected override void OnLostFocus(RoutedEventArgs e)
\r
423 base.OnLostFocus(e);
\r
424 this.View.IsFocused = false;
\r
429 protected override async void OnKeyDown(KeyRoutedEventArgs e)
\r
431 bool isControlPressed = this.IsModiferKeyPressed(VirtualKey.Control);
\r
432 bool isShiftPressed = this.IsModiferKeyPressed(VirtualKey.Shift);
\r
433 bool isMovedCaret = false;
\r
436 case VirtualKey.Up:
\r
437 this._Controller.MoveCaretVertical(-1, isShiftPressed);
\r
440 isMovedCaret = true;
\r
442 case VirtualKey.Down:
\r
443 this._Controller.MoveCaretVertical(+1, isShiftPressed);
\r
446 isMovedCaret = true;
\r
448 case VirtualKey.Left:
\r
449 this._Controller.MoveCaretHorizontical(-1, isShiftPressed, isControlPressed);
\r
452 isMovedCaret = true;
\r
454 case VirtualKey.Right:
\r
455 this._Controller.MoveCaretHorizontical(1, isShiftPressed, isControlPressed);
\r
458 isMovedCaret = true;
\r
460 case VirtualKey.PageUp:
\r
461 this._Controller.Scroll(ScrollDirection.Up, this.View.LineCountOnScreen, isShiftPressed, true);
\r
463 isMovedCaret = true;
\r
465 case VirtualKey.PageDown:
\r
466 this._Controller.Scroll(ScrollDirection.Down, this.View.LineCountOnScreen, isShiftPressed, true);
\r
468 isMovedCaret = true;
\r
470 case VirtualKey.Home:
\r
471 if (isControlPressed)
\r
472 this._Controller.JumpToHead(isShiftPressed);
\r
474 this.Controller.JumpToLineHead(this.View.CaretPostion.row,isShiftPressed);
\r
476 isMovedCaret = true;
\r
478 case VirtualKey.End:
\r
479 if (isControlPressed)
\r
480 this._Controller.JumpToEnd(isShiftPressed);
\r
482 this.Controller.JumpToLineEnd(this.View.CaretPostion.row,isShiftPressed);
\r
484 isMovedCaret = true;
\r
486 case VirtualKey.Tab:
\r
487 if (!isControlPressed)
\r
489 if (this._Controller.SelectionLength == 0)
\r
490 this._Controller.DoInputChar('\t');
\r
491 else if (isShiftPressed)
\r
492 this._Controller.DownIndent();
\r
494 this._Controller.UpIndent();
\r
499 case VirtualKey.Enter:
\r
500 this._Controller.DoEnterAction();
\r
504 case VirtualKey.Insert:
\r
505 if(this.View.InsertMode)
\r
506 this.View.InsertMode = false;
\r
508 this.View.InsertMode = true;
\r
513 if (isControlPressed)
\r
521 if (isControlPressed)
\r
523 if (this._Controller.RectSelection)
\r
524 this._Controller.RectSelection = false;
\r
526 this._Controller.RectSelection = true;
\r
532 if (isControlPressed)
\r
534 this.CopyCommand();
\r
539 if (isControlPressed)
\r
546 if (isControlPressed)
\r
548 await this.PasteCommand();
\r
553 if (isControlPressed)
\r
555 this.Document.UndoManager.redo();
\r
561 if (isControlPressed)
\r
563 this.Document.UndoManager.undo();
\r
568 case VirtualKey.Back:
\r
569 this._Controller.DoBackSpaceAction();
\r
573 case VirtualKey.Delete:
\r
574 this._Controller.DoDeleteAction();
\r
579 if (isMovedCaret && this.peer != null)
\r
580 this.peer.OnNotifyCaretChanged();
\r
585 protected override void OnPointerPressed(PointerRoutedEventArgs e)
\r
587 this.CapturePointer(e.Pointer);
\r
588 this.gestureRecongnizer.ProcessDownEvent(e.GetCurrentPoint(this));
\r
593 protected override void OnPointerMoved(PointerRoutedEventArgs e)
\r
595 this.gestureRecongnizer.ProcessMoveEvents(e.GetIntermediatePoints(this));
\r
598 if (e.Pointer.PointerDeviceType == PointerDeviceType.Mouse)
\r
600 Point p = e.GetCurrentPoint(this).Position;
\r
601 if (this.View.HitTextArea(p.X, p.Y))
\r
603 TextPoint tp = this.View.GetTextPointFromPostion(p);
\r
604 if (this._Controller.IsMarker(tp, HilightType.Url))
\r
605 Window.Current.CoreWindow.PointerCursor = new CoreCursor(CoreCursorType.Hand, 101);
\r
607 Window.Current.CoreWindow.PointerCursor = new CoreCursor(CoreCursorType.IBeam, 101);
\r
611 Window.Current.CoreWindow.PointerCursor = new CoreCursor(CoreCursorType.Arrow, 101);
\r
617 protected override void OnPointerReleased(PointerRoutedEventArgs e)
\r
619 this.gestureRecongnizer.ProcessUpEvent(e.GetCurrentPoint(this));
\r
620 this.ReleasePointerCapture(e.Pointer);
\r
625 protected override void OnPointerCanceled(PointerRoutedEventArgs e)
\r
627 this.gestureRecongnizer.CompleteGesture();
\r
628 this.ReleasePointerCapture(e.Pointer);
\r
633 protected override void OnPointerCaptureLost(PointerRoutedEventArgs e)
\r
635 this.gestureRecongnizer.CompleteGesture();
\r
636 this.ReleasePointerCapture(e.Pointer);
\r
641 protected override void OnPointerWheelChanged(PointerRoutedEventArgs e)
\r
643 bool shift = (e.KeyModifiers & Windows.System.VirtualKeyModifiers.Shift) ==
\r
644 Windows.System.VirtualKeyModifiers.Shift;
\r
645 bool ctrl = (e.KeyModifiers & Windows.System.VirtualKeyModifiers.Control) ==
\r
646 Windows.System.VirtualKeyModifiers.Control;
\r
647 this.gestureRecongnizer.ProcessMouseWheelEvent(e.GetCurrentPoint(this), shift, ctrl);
\r
651 void CoreWindow_CharacterReceived(CoreWindow sender, CharacterReceivedEventArgs args)
\r
653 if (this.FocusState == FocusState.Unfocused || !this.IsEnabled)
\r
655 if (args.KeyCode >= 00 && args.KeyCode <= 0x1f)
\r
657 this._Controller.DoInputString(Char.ConvertFromUtf32((int)args.KeyCode));
\r
661 double textStore_GetDpi()
\r
664 this.Render.GetDpi(out dpi, out dpi);
\r
668 bool textStore_IsReadOnly()
\r
673 bool textStore_IsLoading()
\r
678 void textStore_CompositionEnded()
\r
680 TextStoreHelper.EndCompostion(this.Document);
\r
684 void textStore_CompositionUpdated(int start, int end)
\r
686 if (TextStoreHelper.ScrollToCompstionUpdated(this.textStore, this.View, start, end))
\r
689 bool textStore_CompositionStarted()
\r
691 return TextStoreHelper.StartCompstion(this.Document);
\r
694 string _textStore_GetString(int start, int length)
\r
696 return this.Document.ToString(start, length);
\r
699 void _textStore_GetStringExtent(
\r
702 out POINT o_topLeft,
\r
703 out POINT o_bottomRight
\r
706 Point startPos, endPos;
\r
707 TextStoreHelper.GetStringExtent(this.Document, this.View, i_startIndex, i_endIndex, out startPos, out endPos);
\r
709 var gt = this.TransformToVisual(Window.Current.Content);
\r
710 startPos = gt.TransformPoint(startPos);
\r
711 endPos = gt.TransformPoint(endPos);
\r
713 o_topLeft = new POINT((int)startPos.X, (int)startPos.Y);
\r
714 o_bottomRight = new POINT((int)endPos.X, (int)endPos.Y);
\r
717 void _textStore_GetScreenExtent(out POINT o_topLeft, out POINT o_bottomRight)
\r
719 var pointTopLeft = new Point(0, 0);
\r
720 var pointBottomRight = new Point(this.RenderSize.Width, this.RenderSize.Height);
\r
722 var gt = this.TransformToVisual(Window.Current.Content);
\r
723 pointTopLeft = gt.TransformPoint(pointTopLeft);
\r
724 pointBottomRight = gt.TransformPoint(pointBottomRight);
\r
726 o_topLeft = new POINT((int)pointTopLeft.X, (int)pointTopLeft.Y);
\r
727 o_bottomRight = new POINT((int)pointBottomRight.X, (int)pointBottomRight.Y);
\r
730 void _textStore_GetSelectionIndex(out int o_startIndex, out int o_endIndex)
\r
732 TextStoreHelper.GetSelection(this._Controller, this.View.Selections, out o_startIndex, out o_endIndex);
\r
735 void _textStore_SetSelectionIndex(int i_startIndex, int i_endIndex)
\r
737 TextStoreHelper.SetSelectionIndex(this._Controller, this.View, i_startIndex, i_endIndex);
\r
741 void _textStore_InsertAtSelection(string i_value)
\r
743 TextStoreHelper.InsertTextAtSelection(this._Controller, i_value);
\r
747 void Controller_SelectionChanged(object sender, EventArgs e)
\r
749 //こうしないと選択できなくなってしまう
\r
750 this.nowCaretMove = true;
\r
751 SetValue(SelectionProperty, new TextRange(this._Controller.SelectionStart, this._Controller.SelectionLength));
\r
752 SetValue(CaretPostionPropertyKey, this.View.CaretPostion);
\r
753 this.nowCaretMove = false;
\r
754 if (this.textStore.IsLocked() == false)
\r
755 this.textStore.NotifySelectionChanged();
\r
758 Gripper FirstGripper, SecondGripper;
\r
760 Gripper hittedGripper;
\r
761 void gestureRecongnizer_ManipulationStarted(GestureRecognizer sender, ManipulationStartedEventArgs e)
\r
763 this.HittedCaret = false;
\r
764 this.hittedGripper = null;
\r
766 Point p = e.Position;
\r
767 TextPoint tp = this.View.GetTextPointFromPostion(p);
\r
768 if (tp == this.View.CaretPostion)
\r
770 HittedCaret = true;
\r
773 if (this.FirstGripper.IsHit(p))
\r
775 hittedGripper = this.FirstGripper;
\r
776 HittedCaret = true;
\r
779 else if (this.SecondGripper.IsHit(p))
\r
781 hittedGripper = this.SecondGripper;
\r
782 HittedCaret = true;
\r
786 void gestureRecongnizer_ManipulationUpdated(GestureRecognizer sender, ManipulationUpdatedEventArgs e)
\r
791 if (this.hittedGripper == null)
\r
794 p = this.hittedGripper.AdjustPoint(e.Position);
\r
796 if (hittedGripper != null)
\r
798 TextPoint tp = this.View.GetTextPointFromPostion(p);
\r
799 if (this._Controller.IsReverseSelect())
\r
801 if (Object.ReferenceEquals(hittedGripper,this.SecondGripper))
\r
802 this._Controller.MoveSelectBefore(tp);
\r
804 this._Controller.MoveCaretAndSelect(tp);
\r
808 if (Object.ReferenceEquals(hittedGripper,this.FirstGripper))
\r
809 this._Controller.MoveSelectBefore(tp);
\r
811 this._Controller.MoveCaretAndSelect(tp);
\r
813 if (this.peer != null)
\r
814 this.peer.OnNotifyCaretChanged();
\r
819 if (e.Delta.Scale < 1)
\r
821 double newSize = this.Render.FontSize - 1;
\r
824 this.Render.FontSize = newSize;
\r
826 SetValue(MagnificationPowerPropertyKey, this.Render.FontSize / this.FontSize);
\r
830 if (e.Delta.Scale > 1)
\r
832 double newSize = this.Render.FontSize + 1;
\r
835 this.Render.FontSize = newSize;
\r
837 SetValue(MagnificationPowerPropertyKey, this.Render.FontSize / this.FontSize);
\r
841 Point translation = e.Delta.Translation;
\r
843 int scrollCount = (int)Math.Abs(translation.Y);
\r
844 if (scrollCount > 0)
\r
846 if (scrollCount > this.View.LineCountOnScreen) //ホイール対策
\r
847 scrollCount = this.View.LineCountOnScreen;
\r
848 if (translation.Y > 0)
\r
849 this._Controller.Scroll(ScrollDirection.Up, scrollCount, false, false);
\r
851 this._Controller.Scroll(ScrollDirection.Down, scrollCount, false, false);
\r
852 this.FirstGripper.Enabled = false;
\r
853 this.SecondGripper.Enabled = false;
\r
858 int deltax = (int)Math.Abs(translation.X);
\r
861 if (translation.X < 0)
\r
862 this._Controller.Scroll(ScrollDirection.Left, deltax, false, false);
\r
864 this._Controller.Scroll(ScrollDirection.Right, deltax, false, false);
\r
865 this.FirstGripper.Enabled = false;
\r
866 this.SecondGripper.Enabled = false;
\r
871 void gestureRecongnizer_ManipulationCompleted(GestureRecognizer sender, ManipulationCompletedEventArgs e)
\r
875 async void gestureRecongnizer_RightTapped(GestureRecognizer sender, RightTappedEventArgs e)
\r
877 ResourceMap map = ResourceManager.Current.MainResourceMap.GetSubtree("FooEditEngine.Metro/Resources");
\r
878 ResourceContext context = ResourceContext.GetForCurrentView();
\r
879 if (this.View.HitTextArea(e.Position.X, e.Position.Y))
\r
881 FooContextMenuEventArgs args = new FooContextMenuEventArgs(e.Position);
\r
882 if (this.ContextMenuOpening != null)
\r
883 this.ContextMenuOpening(this, args);
\r
886 PopupMenu ContextMenu = new PopupMenu();
\r
887 ContextMenu.Commands.Add(new UICommand(map.GetValue("CopyMenuName", context).ValueAsString, (command) =>
\r
889 this.CopyCommand();
\r
891 ContextMenu.Commands.Add(new UICommand(map.GetValue("CutMenuName", context).ValueAsString, (command) =>
\r
895 ContextMenu.Commands.Add(new UICommand(map.GetValue("PasteMenuName", context).ValueAsString, async (command) =>
\r
897 await this.PasteCommand();
\r
899 if (this._Controller.RectSelection)
\r
901 ContextMenu.Commands.Add(new UICommand(map.GetValue("LineSelectMenuName", context).ValueAsString, (command) =>
\r
903 this._Controller.RectSelection = false;
\r
908 ContextMenu.Commands.Add(new UICommand(map.GetValue("RectSelectMenuName", context).ValueAsString, (command) =>
\r
910 this._Controller.RectSelection = true;
\r
913 await ContextMenu.ShowAsync(Util.GetScreentPoint(e.Position,this));
\r
918 void gestureRecongnizer_Tapped(GestureRecognizer sender, TappedEventArgs e)
\r
920 bool touched = e.PointerDeviceType == PointerDeviceType.Touch;
\r
921 this.FirstGripper.Enabled = touched;
\r
922 this.SecondGripper.Enabled = touched;
\r
923 this.JumpCaret(e.Position);
\r
926 void JumpCaret(Point p)
\r
928 TextPoint tp = this.View.GetTextPointFromPostion(p);
\r
929 if (tp == TextPoint.Null)
\r
932 int index = this.View.LayoutLines.GetIndexFromTextPoint(tp);
\r
934 FoldingItem foldingData = this.View.HitFoldingData(p.X, tp.row);
\r
935 if (foldingData != null)
\r
937 if (foldingData.Expand)
\r
938 this.View.LayoutLines.FoldingCollection.Collapse(foldingData);
\r
940 this.View.LayoutLines.FoldingCollection.Expand(foldingData);
\r
941 this._Controller.JumpCaret(foldingData.Start, false);
\r
945 this._Controller.JumpCaret(tp.row, tp.col, false);
\r
947 if (this.peer != null)
\r
948 this.peer.OnNotifyCaretChanged();
\r
949 this.View.IsFocused = true;
\r
953 void gestureRecongnizer_Dragging(GestureRecognizer sender, DraggingEventArgs e)
\r
955 Point p = e.Position;
\r
956 if (this.View.HitTextArea(p.X, p.Y))
\r
958 TextPoint tp = this.View.GetTextPointFromPostion(p);
\r
959 this._Controller.MoveCaretAndSelect(tp);
\r
960 if (this.peer != null)
\r
961 this.peer.OnNotifyCaretChanged();
\r
966 bool IsModiferKeyPressed(VirtualKey key)
\r
968 CoreVirtualKeyStates state = Window.Current.CoreWindow.GetKeyState(key);
\r
969 return (state & CoreVirtualKeyStates.Down) == CoreVirtualKeyStates.Down;
\r
971 void Refresh(Rectangle updateRect)
\r
973 if (this.rectangle.ActualWidth == 0 || this.rectangle.ActualHeight == 0/* || !this.Render.IsCanDraw()*/)
\r
976 this.Render.BegineDraw();
\r
977 if (this.IsEnabled)
\r
978 this.View.Draw(updateRect);
\r
980 this.Render.FillBackground(updateRect);
\r
981 this.FirstGripper.Draw();
\r
982 this.SecondGripper.Draw();
\r
983 this.Render.EndDraw();
\r
987 bool Resize(double width, double height)
\r
989 if (width == 0 || height == 0)
\r
990 throw new ArgumentOutOfRangeException();
\r
991 if (this.Render.Resize(this.rectangle, width, height))
\r
993 this.View.PageBound = new Rectangle(0, 0, width, height);
\r
995 if (this.horizontalScrollBar != null)
\r
997 this.horizontalScrollBar.LargeChange = this.View.PageBound.Width;
\r
998 this.horizontalScrollBar.Maximum = this.View.LongestWidth + this.horizontalScrollBar.LargeChange + 1;
\r
1000 if (this.verticalScrollBar != null)
\r
1002 this.verticalScrollBar.LargeChange = this.View.LineCountOnScreen;
\r
1003 this.verticalScrollBar.Maximum = this.View.LayoutLines.Count + this.verticalScrollBar.LargeChange + 1;
\r
1010 void View_SrcChanged(object sender, EventArgs e)
\r
1012 if (this.horizontalScrollBar == null || this.verticalScrollBar == null)
\r
1014 EditView view = this.View;
\r
1015 if (view.Src.Row > this.verticalScrollBar.Maximum)
\r
1016 this.verticalScrollBar.Maximum = view.Src.Row + view.LineCountOnScreen + 1;
\r
1017 double absoulteX = Math.Abs(view.Src.X);
\r
1018 if (absoulteX > this.horizontalScrollBar.Maximum)
\r
1019 this.horizontalScrollBar.Maximum = absoulteX + view.PageBound.Width + 1;
\r
1020 if (view.Src.Row != this.verticalScrollBar.Value)
\r
1021 this.verticalScrollBar.Value = view.Src.Row;
\r
1022 if (view.Src.X != this.horizontalScrollBar.Value)
\r
1023 this.horizontalScrollBar.Value = Math.Abs(view.Src.X);
\r
1026 void FooTextBox_SizeChanged(object sender, SizeChangedEventArgs e)
\r
1028 if (this.Resize(this.rectangle.ActualWidth, this.rectangle.ActualHeight))
\r
1035 void horizontalScrollBar_Scroll(object sender, ScrollEventArgs e)
\r
1037 if (this.horizontalScrollBar == null)
\r
1040 if (this.FlowDirection == FlowDirection.LeftToRight)
\r
1041 toX = this.horizontalScrollBar.Value;
\r
1043 toX = -this.horizontalScrollBar.Value;
\r
1044 this._Controller.Scroll(toX, this.View.Src.Row, false, false);
\r
1045 this.FirstGripper.Enabled = false;
\r
1046 this.SecondGripper.Enabled = false;
\r
1050 void verticalScrollBar_Scroll(object sender, ScrollEventArgs e)
\r
1052 if (this.verticalScrollBar == null)
\r
1054 int newRow = (int)this.verticalScrollBar.Value;
\r
1055 if (newRow >= this.View.LayoutLines.Count)
\r
1057 this._Controller.Scroll(this.View.Src.X, newRow, false, false);
\r
1058 this.FirstGripper.Enabled = false;
\r
1059 this.SecondGripper.Enabled = false;
\r
1063 void Document_Update(object sender, DocumentUpdateEventArgs e)
\r
1065 if (this.textStore.IsLocked())
\r
1067 TextStoreHelper.NotifyTextChanged(this.textStore, e.startIndex, e.removeLength, e.insertLength);
\r
1070 void FooTextBox_Loaded(object sender, RoutedEventArgs e)
\r
1072 this.Focus(FocusState.Programmatic);
\r
1076 public static void OnPropertyChanged(object sender, DependencyPropertyChangedEventArgs e)
\r
1078 FooTextBox source = (FooTextBox)sender;
\r
1079 if (e.Property.Equals(SelectionProperty) && !source.nowCaretMove)
\r
1080 source._Controller.Select(source.Selection.Index,source.Selection.Length);
\r
1081 if (e.Property.Equals(CaretPostionPropertyKey) && !source.nowCaretMove)
\r
1082 source.JumpCaret(source.CaretPostion.row, source.CaretPostion.col);
\r
1083 if (e.Property.Equals(InsertModeProperty))
\r
1084 source.View.InsertMode = source.InsertMode;
\r
1085 if (e.Property.Equals(TabCharsProperty))
\r
1086 source.View.TabStops = source.TabChars;
\r
1087 if (e.Property.Equals(RectSelectModeProperty))
\r
1088 source._Controller.RectSelection = source.RectSelectMode;
\r
1089 if (e.Property.Equals(DrawCaretProperty))
\r
1090 source.View.HideCaret = !source.DrawCaret;
\r
1091 if (e.Property.Equals(DrawCaretLineProperty))
\r
1092 source.View.HideLineMarker = !source.DrawCaretLine;
\r
1093 if (e.Property.Equals(DrawLineNumberProperty))
\r
1095 source.View.DrawLineNumber = source.DrawLineNumber;
\r
1096 source._Controller.JumpCaret(source.View.CaretPostion.row, source.View.CaretPostion.col);
\r
1098 if(e.Property.Equals(MagnificationPowerPropertyKey))
\r
1099 source.Render.FontSize = source.FontSize * source.MagnificationPower;
\r
1100 if (e.Property.Equals(FontFamilyProperty))
\r
1101 source.Render.FontFamily = source.FontFamily;
\r
1102 if (e.Property.Equals(FontStyleProperty))
\r
1103 source.Render.FontStyle = source.FontStyle;
\r
1104 if (e.Property.Equals(FontWeightProperty))
\r
1105 source.Render.FontWeigth = source.FontWeight;
\r
1106 if (e.Property.Equals(FontSizeProperty))
\r
1107 source.Render.FontSize = source.FontSize;
\r
1108 if (e.Property.Equals(ForegroundProperty))
\r
1109 source.Render.Foreground = D2DRenderBase.ToColor4(source.Foreground);
\r
1110 if (e.Property.Equals(BackgroundProperty))
\r
1111 source.Render.Background = D2DRenderBase.ToColor4(source.Background);
\r
1112 if (e.Property.Equals(ControlCharProperty))
\r
1113 source.Render.ControlChar = D2DRenderBase.ToColor4(source.ControlChar);
\r
1114 if (e.Property.Equals(HilightProperty))
\r
1115 source.Render.Hilight = D2DRenderBase.ToColor4(source.Hilight);
\r
1116 if (e.Property.Equals(Keyword1Property))
\r
1117 source.Render.Keyword1 = D2DRenderBase.ToColor4(source.Keyword1);
\r
1118 if (e.Property.Equals(Keyword2Property))
\r
1119 source.Render.Keyword2 = D2DRenderBase.ToColor4(source.Keyword2);
\r
1120 if (e.Property.Equals(CommentProperty))
\r
1121 source.Render.Comment = D2DRenderBase.ToColor4(source.Comment);
\r
1122 if (e.Property.Equals(LiteralProperty))
\r
1123 source.Render.Literal = D2DRenderBase.ToColor4(source.Literal);
\r
1124 if (e.Property.Equals(URLProperty))
\r
1125 source.Render.Url = D2DRenderBase.ToColor4(source.URL);
\r
1126 if (e.Property.Equals(InsertCaretProperty))
\r
1127 source.Render.InsertCaret = D2DRenderBase.ToColor4(source.InsertCaret);
\r
1128 if (e.Property.Equals(OverwriteCaretProperty))
\r
1129 source.Render.OverwriteCaret = D2DRenderBase.ToColor4(source.OverwriteCaret);
\r
1130 if (e.Property.Equals(PaddingProperty))
\r
1131 source.View.Padding = new Padding((int)source.Padding.Left, (int)source.Padding.Top, (int)source.Padding.Right, (int)source.Padding.Bottom);
\r
1132 if (e.Property.Equals(LineMarkerProperty))
\r
1133 source.Render.LineMarker = D2DRenderBase.ToColor4(source.LineMarker);
\r
1134 if (e.Property.Equals(MarkURLProperty))
\r
1135 source.View.UrlMark = source.MarkURL;
\r
1136 if (e.Property.Equals(ShowFullSpaceProperty))
\r
1137 source.Render.ShowFullSpace = source.ShowFullSpace;
\r
1138 if (e.Property.Equals(ShowHalfSpaceProperty))
\r
1139 source.Render.ShowHalfSpace = source.ShowHalfSpace;
\r
1140 if (e.Property.Equals(ShowTabProperty))
\r
1141 source.Render.ShowTab = source.ShowTab;
\r
1142 if (e.Property.Equals(ShowLineBreakProperty))
\r
1143 source.Render.ShowLineBreak = source.ShowLineBreak;
\r
1144 if (e.Property.Equals(LineBreakProperty))
\r
1145 source.View.LineBreak = source.LineBreakMethod;
\r
1146 if (e.Property.Equals(LineBreakCharCountProperty))
\r
1147 source.View.LineBreakCharCount = source.LineBreakCharCount;
\r
1148 if (e.Property.Equals(UpdateAreaProperty))
\r
1149 source.Render.UpdateArea = D2DRenderBase.ToColor4(source.UpdateArea);
\r
1150 if (e.Property.Equals(FlowDirectionProperty))
\r
1152 source.Render.RightToLeft = source.FlowDirection == Windows.UI.Xaml.FlowDirection.RightToLeft;
\r
1153 if(source.horizontalScrollBar != null)
\r
1154 source.horizontalScrollBar.FlowDirection = source.FlowDirection;
\r
1156 if (e.Property.Equals(DrawRulerProperty))
\r
1158 source.View.HideRuler = !source.DrawRuler;
\r
1159 source._Controller.JumpCaret(source.View.CaretPostion.row, source.View.CaretPostion.col);
\r
1167 /// コンテキストメニューが表示されるときに呼び出されます
\r
1169 public event EventHandler<FooContextMenuEventArgs> ContextMenuOpening;
\r
1175 internal Controller Controller
\r
1179 return this._Controller;
\r
1184 /// 文字列の描写に使用されるアンチエイリアシング モードを表します
\r
1186 public TextAntialiasMode TextAntialiasMode
\r
1190 return this.Render.TextAntialiasMode;
\r
1194 this.Render.TextAntialiasMode = value;
\r
1199 /// シンタックスハイライターを表す
\r
1201 public IHilighter Hilighter
\r
1205 return this.View.Hilighter;
\r
1209 this.View.Hilighter = value;
\r
1210 this.View.LayoutLines.ClearLayoutCache();
\r
1215 /// フォールティングを作成するインターフェイスを表す
\r
1217 public IFoldingStrategy FoldingStrategy
\r
1221 return this.View.LayoutLines.FoldingStrategy;
\r
1225 this.View.LayoutLines.FoldingStrategy = value;
\r
1226 if (value == null)
\r
1227 this.View.LayoutLines.FoldingCollection.Clear();
\r
1232 /// マーカーパターンセットを表す
\r
1234 public MarkerPatternSet MarkerPatternSet
\r
1238 return this.View.MarkerPatternSet;
\r
1245 public Document Document
\r
1254 public LineToIndexTable LayoutLineCollection
\r
1256 get { return this.View.LayoutLines; }
\r
1262 public string SelectedText
\r
1266 return this._Controller.SelectedText;
\r
1270 int oldLength = this.Document.Length;
\r
1271 this._Controller.SelectedText = value;
\r
1279 /// Lengthが0の場合はキャレット位置を表します。
\r
1280 /// 矩形選択モードの場合、選択範囲の文字数ではなく、開始位置から終了位置までの長さとなります
\r
1282 public TextRange Selection
\r
1284 get { return (TextRange)GetValue(SelectionProperty); }
\r
1285 set { SetValue(SelectionProperty, value); }
\r
1289 /// Selectionの依存プロパティを表す
\r
1291 public static readonly DependencyProperty SelectionProperty =
\r
1292 DependencyProperty.Register("Selection", typeof(TextRange), typeof(FooTextBox), new PropertyMetadata(0));
\r
1297 public double MagnificationPower
\r
1299 get { return (double)GetValue(MagnificationPowerPropertyKey); }
\r
1300 set { SetValue(MagnificationPowerPropertyKey, value); }
\r
1306 public static readonly DependencyProperty MagnificationPowerPropertyKey =
\r
1307 DependencyProperty.Register("MagnificationPower", typeof(double), typeof(FooTextBox), new PropertyMetadata(1.0, OnPropertyChanged));
\r
1312 public TextPoint CaretPostion
\r
1314 get { return (TextPoint)GetValue(CaretPostionPropertyKey); }
\r
1315 set { SetValue(CaretPostionPropertyKey, value); }
\r
1318 static readonly DependencyProperty CaretPostionPropertyKey =
\r
1319 DependencyProperty.Register("CaretPostion", typeof(TextPoint), typeof(FooTextBox), new PropertyMetadata(new TextPoint(), OnPropertyChanged));
\r
1324 public new FlowDirection FlowDirection
\r
1326 get { return (FlowDirection)GetValue(FlowDirectionProperty); }
\r
1327 set { SetValue(FlowDirectionProperty, value); }
\r
1331 /// レタリング方向を表す。これは依存プロパティです
\r
1333 public new static readonly DependencyProperty FlowDirectionProperty =
\r
1334 DependencyProperty.Register("FlowDirection", typeof(FlowDirection), typeof(FooTextBox), new PropertyMetadata(FlowDirection.LeftToRight,OnPropertyChanged));
\r
1339 public new FontFamily FontFamily
\r
1341 get { return (FontFamily)GetValue(FontFamilyProperty); }
\r
1342 set { SetValue(FontFamilyProperty, value); }
\r
1346 /// FontFamilyの依存プロパティを表す
\r
1348 public new static readonly DependencyProperty FontFamilyProperty =
\r
1349 DependencyProperty.Register("FontFamily", typeof(FontFamily), typeof(FooTextBox), new PropertyMetadata(new FontFamily("Cambria"), OnPropertyChanged));
\r
1354 public new double FontSize
\r
1356 get { return (double)GetValue(FontSizeProperty); }
\r
1357 set { SetValue(FontSizeProperty, value); }
\r
1361 /// FontSizeの依存プロパティを表す
\r
1363 public new static readonly DependencyProperty FontSizeProperty =
\r
1364 DependencyProperty.Register("FontSize", typeof(double), typeof(FooTextBox), new PropertyMetadata(12.0,OnPropertyChanged));
\r
1369 public new FontStyle FontStyle
\r
1371 get { return (FontStyle)GetValue(FontStyleProperty); }
\r
1372 set { SetValue(FontStyleProperty, value); }
\r
1376 /// FontStyleの依存プロパティを表す
\r
1378 public new static readonly DependencyProperty FontStyleProperty =
\r
1379 DependencyProperty.Register("FontStyle", typeof(FontStyle), typeof(FooTextBox), new PropertyMetadata(FontStyle.Normal,OnPropertyChanged));
\r
1384 public new FontWeight FontWeight
\r
1386 get { return (FontWeight)GetValue(FontWeightProperty); }
\r
1387 set { SetValue(FontWeightProperty, value); }
\r
1391 /// FontWeigthの依存プロパティを表す
\r
1393 public new static readonly DependencyProperty FontWeightProperty =
\r
1394 DependencyProperty.Register("FontWeigth", typeof(FontWeight), typeof(FooTextBox), new PropertyMetadata(FontWeights.Normal,OnPropertyChanged));
\r
1397 /// デフォルトの文字色を表す。これは依存プロパティです
\r
1399 public new Windows.UI.Color Foreground
\r
1401 get { return (Windows.UI.Color)GetValue(ForegroundProperty); }
\r
1402 set { SetValue(ForegroundProperty, value); }
\r
1406 /// Foregroundの依存プロパティを表す
\r
1408 public new static readonly DependencyProperty ForegroundProperty =
\r
1409 DependencyProperty.Register("Foreground", typeof(Windows.UI.Color), typeof(FooTextBox), new PropertyMetadata(Colors.Black, OnPropertyChanged));
\r
1412 /// 背景色を表す。これは依存プロパティです
\r
1414 public new Windows.UI.Color Background
\r
1416 get { return (Windows.UI.Color)GetValue(BackgroundProperty); }
\r
1417 set { SetValue(BackgroundProperty, value); }
\r
1421 /// Backgroundの依存プロパティを表す
\r
1423 public new static readonly DependencyProperty BackgroundProperty =
\r
1424 DependencyProperty.Register("Background", typeof(Windows.UI.Color), typeof(FooTextBox), new PropertyMetadata(Colors.White, OnPropertyChanged));
\r
1427 /// コントロールコードの文字色を表す。これは依存プロパティです
\r
1429 public Windows.UI.Color ControlChar
\r
1431 get { return (Windows.UI.Color)GetValue(ControlCharProperty); }
\r
1432 set { SetValue(ControlCharProperty, value); }
\r
1436 /// ControlCharの依存プロパティを表す
\r
1438 public static readonly DependencyProperty ControlCharProperty =
\r
1439 DependencyProperty.Register("ControlChar", typeof(Windows.UI.Color), typeof(FooTextBox), new PropertyMetadata(Colors.Gray, OnPropertyChanged));
\r
1442 /// 選択時の背景色を表す。これは依存プロパティです
\r
1444 public Windows.UI.Color Hilight
\r
1446 get { return (Windows.UI.Color)GetValue(HilightProperty); }
\r
1447 set { SetValue(HilightProperty, value); }
\r
1451 /// Hilightの依存プロパティを表す
\r
1453 public static readonly DependencyProperty HilightProperty =
\r
1454 DependencyProperty.Register("Hilight", typeof(Windows.UI.Color), typeof(FooTextBox), new PropertyMetadata(Colors.DeepSkyBlue, OnPropertyChanged));
\r
1457 /// キーワード1の文字色を表す。これは依存プロパティです
\r
1459 public Windows.UI.Color Keyword1
\r
1461 get { return (Windows.UI.Color)GetValue(Keyword1Property); }
\r
1462 set { SetValue(Keyword1Property, value); }
\r
1466 /// Keyword1の依存プロパティを表す
\r
1468 public static readonly DependencyProperty Keyword1Property =
\r
1469 DependencyProperty.Register("Keyword1", typeof(Windows.UI.Color), typeof(FooTextBox), new PropertyMetadata(Colors.Blue, OnPropertyChanged));
\r
1472 /// キーワード2の文字色を表す。これは依存プロパティです
\r
1474 public Windows.UI.Color Keyword2
\r
1476 get { return (Windows.UI.Color)GetValue(Keyword2Property); }
\r
1477 set { SetValue(Keyword2Property, value); }
\r
1481 /// Keyword2の依存プロパティを表す
\r
1483 public static readonly DependencyProperty Keyword2Property =
\r
1484 DependencyProperty.Register("Keyword2", typeof(Windows.UI.Color), typeof(FooTextBox), new PropertyMetadata(Colors.DarkCyan, OnPropertyChanged));
\r
1487 /// コメントの文字色を表す。これは依存プロパティです
\r
1489 public Windows.UI.Color Comment
\r
1491 get { return (Windows.UI.Color)GetValue(CommentProperty); }
\r
1492 set { SetValue(CommentProperty, value); }
\r
1496 /// Commentの依存プロパティを表す
\r
1498 public static readonly DependencyProperty CommentProperty =
\r
1499 DependencyProperty.Register("Comment", typeof(Windows.UI.Color), typeof(FooTextBox), new PropertyMetadata(Colors.Green, OnPropertyChanged));
\r
1502 /// 文字リテラルの文字色を表す。これは依存プロパティです
\r
1504 public Windows.UI.Color Literal
\r
1506 get { return (Windows.UI.Color)GetValue(LiteralProperty); }
\r
1507 set { SetValue(LiteralProperty, value); }
\r
1511 /// Literalの依存プロパティを表す
\r
1513 public static readonly DependencyProperty LiteralProperty =
\r
1514 DependencyProperty.Register("Literal", typeof(Windows.UI.Color), typeof(FooTextBox), new PropertyMetadata(Colors.Brown, OnPropertyChanged));
\r
1517 /// URLの文字色を表す。これは依存プロパティです
\r
1519 public Windows.UI.Color URL
\r
1521 get { return (Windows.UI.Color)GetValue(URLProperty); }
\r
1522 set { SetValue(URLProperty, value); }
\r
1526 /// URLの依存プロパティを表す
\r
1528 public static readonly DependencyProperty URLProperty =
\r
1529 DependencyProperty.Register("URL", typeof(Windows.UI.Color), typeof(FooTextBox), new PropertyMetadata(Colors.Blue, OnPropertyChanged));
\r
1534 public Windows.UI.Color UpdateArea
\r
1536 get { return (Windows.UI.Color)GetValue(UpdateAreaProperty); }
\r
1537 set { SetValue(UpdateAreaProperty, value); }
\r
1541 /// UpdateAreaの依存プロパティを表す
\r
1543 public static readonly DependencyProperty UpdateAreaProperty =
\r
1544 DependencyProperty.Register("UpdateArea", typeof(Windows.UI.Color), typeof(FooTextBox), new PropertyMetadata(Colors.MediumSeaGreen));
\r
1549 public Windows.UI.Color LineMarker
\r
1551 get { return (Windows.UI.Color)GetValue(LineMarkerProperty); }
\r
1552 set { SetValue(LineMarkerProperty, value); }
\r
1556 /// LineMarkerの依存プロパティを表す
\r
1558 public static readonly DependencyProperty LineMarkerProperty =
\r
1559 DependencyProperty.Register("LineMarker", typeof(Windows.UI.Color), typeof(FooTextBox), new PropertyMetadata(Colors.Gray, OnPropertyChanged));
\r
1562 /// 挿入モード時のキャレットの色を表す
\r
1564 public Windows.UI.Color InsertCaret
\r
1566 get { return (Windows.UI.Color)GetValue(InsertCaretProperty); }
\r
1567 set { SetValue(InsertCaretProperty, value); }
\r
1571 /// InsertCaretの依存プロパティを表す
\r
1573 public static readonly DependencyProperty InsertCaretProperty =
\r
1574 DependencyProperty.Register("InsertCaret", typeof(Windows.UI.Color), typeof(FooTextBox), new PropertyMetadata(Colors.Black, OnPropertyChanged));
\r
1577 /// 上書きモード時のキャレット職を表す
\r
1579 public Windows.UI.Color OverwriteCaret
\r
1581 get { return (Windows.UI.Color)GetValue(OverwriteCaretProperty); }
\r
1582 set { SetValue(OverwriteCaretProperty, value); }
\r
1586 /// OverwriteCaretの依存プロパティを表す
\r
1588 public static readonly DependencyProperty OverwriteCaretProperty =
\r
1589 DependencyProperty.Register("OverwriteCaret", typeof(Windows.UI.Color), typeof(FooTextBox), new PropertyMetadata(Colors.Black, OnPropertyChanged));
\r
1594 public new Thickness Padding
\r
1596 get { return (Thickness)GetValue(PaddingProperty); }
\r
1597 set { SetValue(PaddingProperty, value); }
\r
1601 /// Paddingの依存プロパティを表す
\r
1603 public new static readonly DependencyProperty PaddingProperty =
\r
1604 DependencyProperty.Register("Padding", typeof(Thickness), typeof(FooTextBox), new PropertyMetadata(new Thickness(),OnPropertyChanged));
\r
1607 /// 挿入モードなら真を返し、そうでないなら、偽を返す。これは依存プロパティです
\r
1609 public bool InsertMode
\r
1611 get { return (bool)GetValue(InsertModeProperty); }
\r
1612 set { SetValue(InsertModeProperty, value); }
\r
1616 /// InsertModeの依存プロパティを表す
\r
1618 public static readonly DependencyProperty InsertModeProperty =
\r
1619 DependencyProperty.Register("InsertMode",
\r
1621 typeof(FooTextBox),
\r
1622 new PropertyMetadata(true, OnPropertyChanged));
\r
1625 /// タブの文字数を表す。これは依存プロパティです
\r
1627 public int TabChars
\r
1629 get { return (int)GetValue(TabCharsProperty); }
\r
1630 set { SetValue(TabCharsProperty, value); }
\r
1634 /// TabCharsの依存プロパティを表す
\r
1636 public static readonly DependencyProperty TabCharsProperty =
\r
1637 DependencyProperty.Register("TabChars",
\r
1639 typeof(FooTextBox),
\r
1640 new PropertyMetadata(4, OnPropertyChanged));
\r
1643 /// 矩形選択モードなら真を返し、そうでないなら偽を返す。これは依存プロパティです
\r
1645 public bool RectSelectMode
\r
1647 get { return (bool)GetValue(RectSelectModeProperty); }
\r
1648 set { SetValue(RectSelectModeProperty, value); }
\r
1652 /// RectSelectModeの依存プロパティを表す
\r
1654 public static readonly DependencyProperty RectSelectModeProperty =
\r
1655 DependencyProperty.Register("RectSelectMode", typeof(bool), typeof(FooTextBox), new PropertyMetadata(false, OnPropertyChanged));
\r
1661 /// 変更した場合、レイアウトの再構築を行う必要があります
\r
1663 public LineBreakMethod LineBreakMethod
\r
1665 get { return (LineBreakMethod)GetValue(LineBreakProperty); }
\r
1666 set { SetValue(LineBreakProperty, value); }
\r
1670 /// LineBreakMethodの依存プロパティを表す
\r
1672 public static readonly DependencyProperty LineBreakProperty =
\r
1673 DependencyProperty.Register("LineBreakMethod", typeof(LineBreakMethod), typeof(FooTextBox), new PropertyMetadata(LineBreakMethod.None, OnPropertyChanged));
\r
1677 /// 折り返しの幅を指定する。LineBreakMethod.CharUnit以外の時は無視されます
\r
1680 /// 変更した場合、レイアウトの再構築を行う必要があります
\r
1682 public int LineBreakCharCount
\r
1684 get { return (int)GetValue(LineBreakCharCountProperty); }
\r
1685 set { SetValue(LineBreakCharCountProperty, value); }
\r
1689 /// LineBreakCharCountの依存プロパティを表す
\r
1691 public static readonly DependencyProperty LineBreakCharCountProperty =
\r
1692 DependencyProperty.Register("LineBreakCharCount", typeof(int), typeof(FooTextBox), new PropertyMetadata(80));
\r
1695 /// キャレットを描くなら真。そうでないなら偽を返す。これは依存プロパティです
\r
1697 public bool DrawCaret
\r
1699 get { return (bool)GetValue(DrawCaretProperty); }
\r
1700 set { SetValue(DrawCaretProperty, value); }
\r
1704 /// DrawCaretの依存プロパティを表す
\r
1706 public static readonly DependencyProperty DrawCaretProperty =
\r
1707 DependencyProperty.Register("DrawCaret", typeof(bool), typeof(FooTextBox), new PropertyMetadata(true, OnPropertyChanged));
\r
1711 /// キャレットラインを描くなら真。そうでないなら偽を返す。これは依存プロパティです
\r
1713 public bool DrawCaretLine
\r
1715 get { return (bool)GetValue(DrawCaretLineProperty); }
\r
1716 set { SetValue(DrawCaretLineProperty, value); }
\r
1720 /// DrawCaretLineの依存プロパティを表す
\r
1722 public static readonly DependencyProperty DrawCaretLineProperty =
\r
1723 DependencyProperty.Register("DrawCaretLine", typeof(bool), typeof(FooTextBox), new PropertyMetadata(false, OnPropertyChanged));
\r
1726 /// 行番号を描くなら真。そうでなければ偽。これは依存プロパティです
\r
1728 public bool DrawLineNumber
\r
1730 get { return (bool)GetValue(DrawLineNumberProperty); }
\r
1731 set { SetValue(DrawLineNumberProperty, value); }
\r
1735 /// ルーラーを描くなら真。そうでなければ偽。これは依存プロパティです
\r
1737 public bool DrawRuler
\r
1739 get { return (bool)GetValue(DrawRulerProperty); }
\r
1740 set { SetValue(DrawRulerProperty, value); }
\r
1744 /// DrawRulerの依存プロパティを表す
\r
1746 public static readonly DependencyProperty DrawRulerProperty =
\r
1747 DependencyProperty.Register("DrawRuler", typeof(bool), typeof(FooTextBox), new PropertyMetadata(false, OnPropertyChanged));
\r
1751 /// DrawLineNumberの依存プロパティを表す
\r
1753 public static readonly DependencyProperty DrawLineNumberProperty =
\r
1754 DependencyProperty.Register("DrawLineNumber", typeof(bool), typeof(FooTextBox), new PropertyMetadata(false, OnPropertyChanged));
\r
1757 /// URLに下線を引くなら真。そうでないなら偽を表す。これは依存プロパティです
\r
1759 public bool MarkURL
\r
1761 get { return (bool)GetValue(MarkURLProperty); }
\r
1762 set { SetValue(MarkURLProperty, value); }
\r
1766 /// MarkURLの依存プロパティを表す
\r
1768 public static readonly DependencyProperty MarkURLProperty =
\r
1769 DependencyProperty.Register("MarkURL", typeof(bool), typeof(FooTextBox), new PropertyMetadata(false, OnPropertyChanged));
\r
1772 /// 全角スペースを表示するなら真。そうでないなら偽
\r
1774 public bool ShowFullSpace
\r
1776 get { return (bool)GetValue(ShowFullSpaceProperty); }
\r
1777 set { SetValue(ShowFullSpaceProperty, value); }
\r
1781 /// ShowFullSpaceの依存プロパティを表す
\r
1783 public static readonly DependencyProperty ShowFullSpaceProperty =
\r
1784 DependencyProperty.Register("ShowFullSpace", typeof(bool), typeof(FooTextBox), new PropertyMetadata(false, OnPropertyChanged));
\r
1787 /// 半角スペースを表示するなら真。そうでないなら偽
\r
1789 public bool ShowHalfSpace
\r
1791 get { return (bool)GetValue(ShowHalfSpaceProperty); }
\r
1792 set { SetValue(ShowHalfSpaceProperty, value); }
\r
1796 /// ShowHalfSpaceの依存プロパティを表す
\r
1798 public static readonly DependencyProperty ShowHalfSpaceProperty =
\r
1799 DependencyProperty.Register("ShowHalfSpace", typeof(bool), typeof(FooTextBox), new PropertyMetadata(false, OnPropertyChanged));
\r
1802 /// タブを表示するなら真。そうでないなら偽
\r
1804 public bool ShowTab
\r
1806 get { return (bool)GetValue(ShowTabProperty); }
\r
1807 set { SetValue(ShowTabProperty, value); }
\r
1811 /// ShowTabの依存プロパティを表す
\r
1813 public static readonly DependencyProperty ShowTabProperty =
\r
1814 DependencyProperty.Register("ShowTab", typeof(bool), typeof(FooTextBox), new PropertyMetadata(false, OnPropertyChanged));
\r
1817 /// 改行マークを表示するなら真。そうでないなら偽
\r
1819 public bool ShowLineBreak
\r
1821 get { return (bool)GetValue(ShowLineBreakProperty); }
\r
1822 set { SetValue(ShowLineBreakProperty, value); }
\r
1826 /// ShowLineBreakの依存プロパティを表す
\r
1828 public static readonly DependencyProperty ShowLineBreakProperty =
\r
1829 DependencyProperty.Register("ShowLineBreak", typeof(bool), typeof(FooTextBox), new PropertyMetadata(false,OnPropertyChanged));
\r
1836 /// コンテキストメニューのイベントデーターを表す
\r
1838 public class FooContextMenuEventArgs
\r
1841 /// 処理済みなら真。そうでないなら偽
\r
1843 public bool Handled = false;
\r
1845 /// コンテキストメニューを表示すべき座標を表す
\r
1847 public Windows.Foundation.Point Postion;
\r
1851 /// <param name="pos"></param>
\r
1852 public FooContextMenuEventArgs(Windows.Foundation.Point pos)
\r
1854 this.Postion = pos;
\r