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
12 using System.ComponentModel;
\r
13 using System.Threading.Tasks;
\r
14 using Windows.ApplicationModel.Resources.Core;
\r
15 using Windows.Devices.Input;
\r
16 using Windows.System;
\r
17 using Windows.ApplicationModel.DataTransfer;
\r
18 using Windows.Foundation;
\r
20 using Windows.UI.Input;
\r
21 using Windows.UI.Core;
\r
22 using Windows.UI.Popups;
\r
23 using Windows.UI.Text;
\r
24 using Windows.UI.Xaml.Media;
\r
25 using Windows.UI.Xaml;
\r
26 using Windows.UI.Xaml.Controls;
\r
27 using Windows.UI.Xaml.Controls.Primitives;
\r
28 using Windows.UI.Xaml.Input;
\r
29 using DotNetTextStore;
\r
30 using DotNetTextStore.UnmanagedAPI.TSF;
\r
31 using DotNetTextStore.UnmanagedAPI.WinDef;
\r
33 // テンプレート コントロールのアイテム テンプレートについては、http://go.microsoft.com/fwlink/?LinkId=234235 を参照してください
\r
35 namespace FooEditEngine.Metro
\r
40 public sealed class FooTextBox : Control
\r
43 Controller _Controller;
\r
45 ScrollBar horizontalScrollBar, verticalScrollBar;
\r
46 Windows.UI.Xaml.Shapes.Rectangle rectangle;
\r
47 GestureRecognizer gestureRecongnizer = new GestureRecognizer();
\r
48 TextStore2 textStore;
\r
49 GripperManager gripper;
\r
50 FooTextBoxAutomationPeer peer;
\r
57 this.DefaultStyleKey = typeof(FooTextBox);
\r
59 this.textStore = new TextStore2();
\r
60 this.textStore.IsLoading += textStore_IsLoading;
\r
61 this.textStore.IsReadOnly += textStore_IsReadOnly;
\r
62 this.textStore.GetStringLength += () => this.Document.Length;
\r
63 this.textStore.GetString += _textStore_GetString;
\r
64 this.textStore.GetSelectionIndex += _textStore_GetSelectionIndex;
\r
65 this.textStore.SetSelectionIndex += _textStore_SetSelectionIndex;
\r
66 this.textStore.InsertAtSelection += _textStore_InsertAtSelection;
\r
67 this.textStore.GetScreenExtent += _textStore_GetScreenExtent;
\r
68 this.textStore.GetStringExtent += _textStore_GetStringExtent;
\r
69 this.textStore.CompositionStarted += textStore_CompositionStarted;
\r
70 this.textStore.CompositionUpdated += textStore_CompositionUpdated;
\r
71 this.textStore.CompositionEnded += textStore_CompositionEnded;
\r
73 this.Document = new Document();
\r
74 DocumentExtend.Progress += Document_Progress;
\r
76 this.rectangle = new Windows.UI.Xaml.Shapes.Rectangle();
\r
77 this.rectangle.Margin = this.Padding;
\r
78 this.Render = new D2DRender(this,this.rectangle,this.textStore);
\r
80 this.View = new EditView(this.Document, this.Render, new Margin(D2DRender.CramToFitWidth / 2, D2DRender.CramToFitWidth, D2DRender.CramToFitWidth / 2, D2DRender.CramToFitWidth));
\r
81 this.View.SrcChanged += View_SrcChanged;
\r
82 this.View.InsertMode = this.InsertMode;
\r
83 this.View.DrawLineNumber = this.DrawLineNumber;
\r
84 this.View.HideCaret = !this.DrawCaret;
\r
85 this.View.HideLineMarker = !this.DrawCaretLine;
\r
86 this.View.HideRuler = !this.DrawRuler;
\r
87 this.View.UrlMark = this.MarkURL;
\r
88 this.View.TabStops = this.TabChars;
\r
90 this._Controller = new Controller(this.Document, this.View);
\r
91 this._Controller.CaretMoved += Controller_CaretMoved;
\r
93 this.gestureRecongnizer.GestureSettings = GestureSettings.Drag |
\r
94 GestureSettings.RightTap |
\r
95 GestureSettings.Tap |
\r
96 GestureSettings.ManipulationTranslateX |
\r
97 GestureSettings.ManipulationTranslateY |
\r
98 GestureSettings.ManipulationScale;
\r
99 this.gestureRecongnizer.RightTapped += gestureRecongnizer_RightTapped;
\r
100 this.gestureRecongnizer.Tapped += gestureRecongnizer_Tapped;
\r
101 this.gestureRecongnizer.Dragging += gestureRecongnizer_Dragging;
\r
102 this.gestureRecongnizer.ManipulationStarted += gestureRecongnizer_ManipulationStarted;
\r
103 this.gestureRecongnizer.ManipulationUpdated += gestureRecongnizer_ManipulationUpdated;
\r
104 this.gestureRecongnizer.ManipulationCompleted += gestureRecongnizer_ManipulationCompleted;
\r
106 //Viewの初期化が終わった直後に置かないと例外が発生する
\r
107 this.Document.Update += Document_Update;
\r
109 Window.Current.CoreWindow.CharacterReceived += CoreWindow_CharacterReceived;
\r
111 this.SizeChanged += FooTextBox_SizeChanged;
\r
113 this.gripper = new GripperManager(this._Controller, this.View, this.Render);
\r
115 this.Loaded += FooTextBox_Loaded;
\r
121 /// <param name="start">開始インデックス</param>
\r
122 /// <param name="length">長さ</param>
\r
123 public void Select(int start, int length)
\r
125 if (this.Document.State == AsyncState.Loading)
\r
126 throw new InvalidOperationException();
\r
127 this._Controller.Select(start, length);
\r
131 /// キャレットを指定した行に移動させます
\r
133 /// <param name="index">インデックス</param>
\r
134 /// <remarks>このメソッドを呼び出すと選択状態は解除されます</remarks>
\r
135 public void JumpCaret(int index)
\r
137 if (this.Document.State == AsyncState.Loading)
\r
138 throw new InvalidOperationException();
\r
139 this._Controller.JumpCaret(index);
\r
142 /// キャレットを指定した行と桁に移動させます
\r
144 /// <param name="row">行番号</param>
\r
145 /// <param name="col">桁</param>
\r
146 /// <remarks>このメソッドを呼び出すと選択状態は解除されます</remarks>
\r
147 public void JumpCaret(int row, int col)
\r
149 if (this.Document.State == AsyncState.Loading)
\r
150 throw new InvalidOperationException();
\r
151 this._Controller.JumpCaret(row, col);
\r
155 /// 選択中のテキストをクリップボードにコピーします
\r
159 if (this.Document.State == AsyncState.Loading)
\r
160 throw new InvalidOperationException();
\r
161 string text = this._Controller.SelectedText;
\r
162 if (text != null && text != string.Empty)
\r
164 DataPackage dataPackage = new DataPackage();
\r
165 dataPackage.RequestedOperation = DataPackageOperation.Copy;
\r
166 dataPackage.SetText(text);
\r
168 Clipboard.SetContent(dataPackage);
\r
173 /// 選択中のテキストをクリップボードに切り取ります
\r
177 if (this.Document.State == AsyncState.Loading)
\r
178 throw new InvalidOperationException();
\r
179 string text = this._Controller.SelectedText;
\r
180 if (text != null && text != string.Empty)
\r
182 DataPackage dataPackage = new DataPackage();
\r
183 dataPackage.RequestedOperation = DataPackageOperation.Copy;
\r
184 dataPackage.SetText(text);
\r
186 Clipboard.SetContent(dataPackage);
\r
188 this._Controller.SelectedText = "";
\r
193 /// 選択中のテキストを貼り付けます
\r
195 public async Task PasteAsync()
\r
197 if (this.Document.State == AsyncState.Loading)
\r
198 throw new InvalidOperationException();
\r
200 var dataPackageView = Clipboard.GetContent();
\r
201 if (dataPackageView.Contains(StandardDataFormats.Text))
\r
203 this._Controller.SelectedText = await dataPackageView.GetTextAsync();
\r
210 public void SelectAll()
\r
212 if (this.Document.State == AsyncState.Loading)
\r
213 throw new InvalidOperationException();
\r
214 this._Controller.Select(0, this.Document.Length);
\r
220 public void DeSelectAll()
\r
222 if (this.Document.State == AsyncState.Loading)
\r
223 throw new InvalidOperationException();
\r
224 this._Controller.DeSelectAll();
\r
230 /// <param name="tp">テキストポイント</param>
\r
231 /// <returns>座標</returns>
\r
232 /// <remarks>テキストポイントがクライアント領域の原点より外にある場合、返される値は原点に丸められます</remarks>
\r
233 public Windows.Foundation.Point GetPostionFromTextPoint(TextPoint tp)
\r
235 if (this.Document.State == AsyncState.Loading)
\r
236 throw new InvalidOperationException();
\r
237 if (this.Document.FireUpdateEvent == false)
\r
238 throw new InvalidOperationException("");
\r
239 return this.View.GetPostionFromTextPoint(tp);
\r
243 /// 対応するテキストポイントを返します
\r
245 /// <param name="p">クライアント領域の原点を左上とする座標</param>
\r
246 /// <returns>テキストポイント</returns>
\r
247 public TextPoint GetTextPointFromPostion(Windows.Foundation.Point p)
\r
249 if (this.Document.State == AsyncState.Loading)
\r
250 throw new InvalidOperationException();
\r
251 if (this.Document.FireUpdateEvent == false)
\r
252 throw new InvalidOperationException("");
\r
253 return this.View.GetTextPointFromPostion(p);
\r
259 /// <param name="row">レイアウト行</param>
\r
260 /// <returns>行の高さ</returns>
\r
261 public double GetLineHeight(int row)
\r
263 if (this.Document.State == AsyncState.Loading)
\r
264 throw new InvalidOperationException();
\r
265 if (this.Document.FireUpdateEvent == false)
\r
266 throw new InvalidOperationException("");
\r
267 return this.View.LayoutLines.GetLayout(row).Height; ;
\r
271 /// インデックスに対応する座標を得ます
\r
273 /// <param name="index">インデックス</param>
\r
274 /// <returns>座標を返す</returns>
\r
275 public Windows.Foundation.Point GetPostionFromIndex(int index)
\r
277 if (this.Document.State == AsyncState.Loading)
\r
278 throw new InvalidOperationException();
\r
279 if (this.Document.FireUpdateEvent == false)
\r
280 throw new InvalidOperationException("");
\r
281 TextPoint tp = this.View.GetLayoutLineFromIndex(index);
\r
282 return this.View.GetPostionFromTextPoint(tp);
\r
286 /// 座標からインデックスに変換します
\r
288 /// <param name="p">座標</param>
\r
289 /// <returns>インデックスを返す</returns>
\r
290 public int GetIndexFromPostion(Windows.Foundation.Point p)
\r
292 if (this.Document.State == AsyncState.Loading)
\r
293 throw new InvalidOperationException();
\r
294 if (this.Document.FireUpdateEvent == false)
\r
295 throw new InvalidOperationException("");
\r
296 TextPoint tp = this.View.GetTextPointFromPostion(p);
\r
297 return this.View.GetIndexFromLayoutLine(tp);
\r
303 public void Refresh()
\r
305 this.Refresh(this.View.PageBound);
\r
309 /// レイアウト行をすべて破棄し、再度レイアウトを行う
\r
311 public void PerfomLayouts()
\r
313 this.View.PerfomLayouts();
\r
316 internal void ScrollIntoView(int row, bool alignTop)
\r
318 this.View.Scroll(0, row);
\r
321 double y = this.Render.TextArea.Height;
\r
322 for (int i = row; i >= 0; i--)
\r
324 int lineHeadIndex = this.View.LayoutLines.GetIndexFromLineNumber(i);
\r
325 int lineLength = this.View.LayoutLines.GetLengthFromLineNumber(i);
\r
326 double height = this.View.LayoutLines.GetLayout(i).Height;
\r
327 if (y - height <= 0)
\r
329 this.View.Scroll(0, i);
\r
331 FoldingItem foldingData = this.View.LayoutLines.FoldingCollection.Get(lineHeadIndex, lineLength);
\r
333 if (foldingData != null && foldingData.IsHidden(lineHeadIndex))
\r
351 async Task PasteCommand()
\r
353 await this.PasteAsync();
\r
361 protected override Windows.UI.Xaml.Automation.Peers.AutomationPeer OnCreateAutomationPeer()
\r
363 this.peer = new FooTextBoxAutomationPeer(this);
\r
368 protected override void OnApplyTemplate()
\r
370 base.OnApplyTemplate();
\r
372 Grid grid = this.GetTemplateChild("PART_Grid") as Grid;
\r
375 Grid.SetRow(this.rectangle, 0);
\r
376 Grid.SetColumn(this.rectangle, 0);
\r
377 grid.Children.Add(this.rectangle);
\r
380 this.horizontalScrollBar = this.GetTemplateChild("PART_HorizontalScrollBar") as ScrollBar;
\r
381 if (this.horizontalScrollBar != null)
\r
383 this.horizontalScrollBar.SmallChange = 10;
\r
384 this.horizontalScrollBar.LargeChange = 100;
\r
385 this.horizontalScrollBar.Maximum = this.horizontalScrollBar.LargeChange + 1;
\r
386 this.horizontalScrollBar.Scroll += new ScrollEventHandler(horizontalScrollBar_Scroll);
\r
388 this.verticalScrollBar = this.GetTemplateChild("PART_VerticalScrollBar") as ScrollBar;
\r
389 if (this.verticalScrollBar != null)
\r
391 this.verticalScrollBar.SmallChange = 1;
\r
392 this.verticalScrollBar.LargeChange = 10;
\r
393 this.verticalScrollBar.Maximum = this.View.LayoutLines.Count;
\r
394 this.verticalScrollBar.Scroll += new ScrollEventHandler(verticalScrollBar_Scroll);
\r
399 protected override void OnGotFocus(RoutedEventArgs e)
\r
401 base.OnGotFocus(e);
\r
402 this.textStore.SetFocus();
\r
406 protected override async void OnKeyDown(KeyRoutedEventArgs e)
\r
408 if (this.Document.State == AsyncState.Loading)
\r
410 bool isControlPressed = this.IsModiferKeyPressed(VirtualKey.Control);
\r
411 bool isShiftPressed = this.IsModiferKeyPressed(VirtualKey.Shift);
\r
412 bool isMovedCaret = false;
\r
415 case VirtualKey.Up:
\r
416 this._Controller.MoveCaretVertical(-1, isShiftPressed);
\r
419 isMovedCaret = true;
\r
421 case VirtualKey.Down:
\r
422 this._Controller.MoveCaretVertical(+1, isShiftPressed);
\r
425 isMovedCaret = true;
\r
427 case VirtualKey.Left:
\r
428 this._Controller.MoveCaretHorizontical(-1, isShiftPressed, isControlPressed);
\r
431 isMovedCaret = true;
\r
433 case VirtualKey.Right:
\r
434 this._Controller.MoveCaretHorizontical(1, isShiftPressed, isControlPressed);
\r
437 isMovedCaret = true;
\r
439 case VirtualKey.PageUp:
\r
440 this._Controller.Scroll(ScrollDirection.Up, this.View.LineCountOnScreen, isShiftPressed, true);
\r
442 isMovedCaret = true;
\r
444 case VirtualKey.PageDown:
\r
445 this._Controller.Scroll(ScrollDirection.Down, this.View.LineCountOnScreen, isShiftPressed, true);
\r
447 isMovedCaret = true;
\r
449 case VirtualKey.Home:
\r
450 if (isControlPressed)
\r
451 this._Controller.JumpToHead(isShiftPressed);
\r
453 this._Controller.JumpCaret(this.View.CaretPostion.row, 0);
\r
455 isMovedCaret = true;
\r
457 case VirtualKey.End:
\r
458 if (isControlPressed)
\r
459 this._Controller.JumpToEnd(isShiftPressed);
\r
461 this._Controller.JumpCaret(this.View.CaretPostion.row, this.View.LayoutLines[this.View.CaretPostion.row].Length - 1);
\r
463 isMovedCaret = true;
\r
465 case VirtualKey.Tab:
\r
466 if (!isControlPressed)
\r
468 if (this._Controller.SelectionLength == 0)
\r
469 this._Controller.DoInputChar('\t');
\r
470 else if (isShiftPressed)
\r
471 this._Controller.DownIndent();
\r
473 this._Controller.UpIndent();
\r
478 case VirtualKey.Enter:
\r
479 this._Controller.DoEnterAction();
\r
483 case VirtualKey.Insert:
\r
484 if(this.View.InsertMode)
\r
485 this.View.InsertMode = false;
\r
487 this.View.InsertMode = true;
\r
492 if (isControlPressed)
\r
500 if (isControlPressed)
\r
502 if (this._Controller.RectSelection)
\r
503 this._Controller.RectSelection = false;
\r
505 this._Controller.RectSelection = true;
\r
511 if (isControlPressed)
\r
513 this.CopyCommand();
\r
518 if (isControlPressed)
\r
525 if (isControlPressed)
\r
527 await this.PasteCommand();
\r
532 if (isControlPressed)
\r
534 this.Document.UndoManager.redo();
\r
540 if (isControlPressed)
\r
542 this.Document.UndoManager.undo();
\r
547 case VirtualKey.Back:
\r
548 this._Controller.DoBackSpaceAction();
\r
552 case VirtualKey.Delete:
\r
553 this._Controller.DoDeleteAction();
\r
558 if (isMovedCaret && this.peer != null)
\r
559 this.peer.OnNotifyCaretChanged();
\r
564 protected override void OnPointerPressed(PointerRoutedEventArgs e)
\r
566 this.CapturePointer(e.Pointer);
\r
567 this.gestureRecongnizer.ProcessDownEvent(e.GetCurrentPoint(this));
\r
572 protected override void OnPointerMoved(PointerRoutedEventArgs e)
\r
574 this.gestureRecongnizer.ProcessMoveEvents(e.GetIntermediatePoints(this));
\r
577 if (e.Pointer.PointerDeviceType == PointerDeviceType.Mouse && this.Document.State != AsyncState.Loading)
\r
579 Point p = e.GetCurrentPoint(this).Position;
\r
580 if (this.View.HitTextArea(p.X, p.Y))
\r
582 TextPoint tp = this.View.GetTextPointFromPostion(p);
\r
583 if (this._Controller.IsMarker(tp, HilightType.Url))
\r
584 Window.Current.CoreWindow.PointerCursor = new CoreCursor(CoreCursorType.Hand, 101);
\r
586 Window.Current.CoreWindow.PointerCursor = new CoreCursor(CoreCursorType.IBeam, 101);
\r
590 Window.Current.CoreWindow.PointerCursor = new CoreCursor(CoreCursorType.Arrow, 101);
\r
596 protected override void OnPointerReleased(PointerRoutedEventArgs e)
\r
598 this.gestureRecongnizer.ProcessUpEvent(e.GetCurrentPoint(this));
\r
599 this.ReleasePointerCapture(e.Pointer);
\r
604 protected override void OnPointerCanceled(PointerRoutedEventArgs e)
\r
606 this.gestureRecongnizer.CompleteGesture();
\r
607 this.ReleasePointerCapture(e.Pointer);
\r
612 protected override void OnPointerCaptureLost(PointerRoutedEventArgs e)
\r
614 this.gestureRecongnizer.CompleteGesture();
\r
615 this.ReleasePointerCapture(e.Pointer);
\r
620 protected override void OnPointerWheelChanged(PointerRoutedEventArgs e)
\r
622 bool shift = (e.KeyModifiers & Windows.System.VirtualKeyModifiers.Shift) ==
\r
623 Windows.System.VirtualKeyModifiers.Shift;
\r
624 bool ctrl = (e.KeyModifiers & Windows.System.VirtualKeyModifiers.Control) ==
\r
625 Windows.System.VirtualKeyModifiers.Control;
\r
626 this.gestureRecongnizer.ProcessMouseWheelEvent(e.GetCurrentPoint(this), shift, ctrl);
\r
630 void CoreWindow_CharacterReceived(CoreWindow sender, CharacterReceivedEventArgs args)
\r
632 if (this.FocusState == FocusState.Unfocused || this.Document.State == AsyncState.Loading)
\r
634 if (args.KeyCode >= 00 && args.KeyCode <= 0x1f)
\r
636 this._Controller.DoInputString(Char.ConvertFromUtf32((int)args.KeyCode));
\r
640 bool textStore_IsReadOnly()
\r
645 bool textStore_IsLoading()
\r
647 return this.Document.State == AsyncState.Loading;
\r
650 void textStore_CompositionEnded()
\r
652 TextStoreHelper.EndCompostion(this.Document);
\r
656 void textStore_CompositionUpdated(int start, int end)
\r
658 if (TextStoreHelper.ScrollToCompstionUpdated(this.textStore, this.View, start, end))
\r
661 bool textStore_CompositionStarted()
\r
663 return TextStoreHelper.StartCompstion(this.Document);
\r
666 string _textStore_GetString(int start, int length)
\r
668 return this.Document.ToString(start, length);
\r
671 void _textStore_GetStringExtent(
\r
674 out POINT o_topLeft,
\r
675 out POINT o_bottomRight
\r
678 Point startPos, endPos;
\r
679 TextStoreHelper.GetStringExtent(this.Document, this.View, i_startIndex, i_endIndex, out startPos, out endPos);
\r
681 var gt = this.TransformToVisual(Window.Current.Content);
\r
682 startPos = gt.TransformPoint(startPos);
\r
683 endPos = gt.TransformPoint(endPos);
\r
685 o_topLeft = new POINT((int)startPos.X, (int)startPos.Y);
\r
686 o_bottomRight = new POINT((int)endPos.X, (int)endPos.Y);
\r
689 void _textStore_GetScreenExtent(out POINT o_topLeft, out POINT o_bottomRight)
\r
691 var pointTopLeft = new Point(0, 0);
\r
692 var pointBottomRight = new Point(this.RenderSize.Width, this.RenderSize.Height);
\r
694 var gt = this.TransformToVisual(Window.Current.Content);
\r
695 pointTopLeft = gt.TransformPoint(pointTopLeft);
\r
696 pointBottomRight = gt.TransformPoint(pointBottomRight);
\r
698 o_topLeft = new POINT((int)pointTopLeft.X, (int)pointTopLeft.Y);
\r
699 o_bottomRight = new POINT((int)pointBottomRight.X, (int)pointBottomRight.Y);
\r
702 void _textStore_GetSelectionIndex(out int o_startIndex, out int o_endIndex)
\r
704 TextStoreHelper.GetSelection(this._Controller, this.View.Selections, out o_startIndex, out o_endIndex);
\r
707 void _textStore_SetSelectionIndex(int i_startIndex, int i_endIndex)
\r
709 if (this.Document.State == AsyncState.Loading)
\r
711 TextStoreHelper.SetSelectionIndex(this._Controller, this.View, i_startIndex, i_endIndex);
\r
715 void _textStore_InsertAtSelection(string i_value)
\r
717 TextStoreHelper.InsertTextAtSelection(this._Controller, i_value);
\r
721 void Controller_CaretMoved(object sender, EventArgs e)
\r
723 SetValue(CaretPostionPropertyKey, this.View.CaretPostion);
\r
724 if (this.textStore.IsLocked() == false)
\r
725 this.textStore.NotifySelectionChanged();
\r
729 Rectangle hitedSecondGripperRect = Rectangle.Empty,hitedFirstGripperRect = Rectangle.Empty;
\r
730 void gestureRecongnizer_ManipulationStarted(GestureRecognizer sender, ManipulationStartedEventArgs e)
\r
732 if (this.Document.State == AsyncState.Loading)
\r
734 TextPoint tp = this.View.GetTextPointFromPostion(e.Position);
\r
735 if (tp == this.View.CaretPostion)
\r
737 this.isHitCaret = true;
\r
738 this.hitedSecondGripperRect = Rectangle.Empty;
\r
740 Rectangle gripperRect = this.gripper.HitTest(GripperType.Second,e.Position);
\r
741 if (gripperRect != Rectangle.Empty)
\r
743 this.isHitCaret = true;
\r
744 this.hitedSecondGripperRect = gripperRect;
\r
746 gripperRect = this.gripper.HitTest(GripperType.First,e.Position);
\r
747 if (gripperRect != Rectangle.Empty)
\r
749 this.isHitCaret = true;
\r
750 this.hitedFirstGripperRect = gripperRect;
\r
754 void gestureRecongnizer_ManipulationUpdated(GestureRecognizer sender, ManipulationUpdatedEventArgs e)
\r
756 if (this.Document.State == AsyncState.Loading)
\r
758 if (this.isHitCaret)
\r
760 Point p = e.Position;
\r
761 if (this.hitedFirstGripperRect != Rectangle.Empty)
\r
762 p = this.gripper.GetPointOnGripper(GripperType.First,this.hitedFirstGripperRect, p);
\r
763 else if (this.hitedSecondGripperRect != Rectangle.Empty)
\r
764 p = this.gripper.GetPointOnGripper(GripperType.Second,this.hitedSecondGripperRect, p);
\r
765 if (this.View.HitTextArea(p.X, p.Y))
\r
767 TextPoint tp = this.View.GetTextPointFromPostion(p);
\r
768 if (this._Controller.IsReverseSelect())
\r
770 if (this.hitedFirstGripperRect == this.hitedSecondGripperRect)
\r
771 this._Controller.MoveCaretAndSelect(tp);
\r
772 else if (this.hitedSecondGripperRect != Rectangle.Empty)
\r
773 this._Controller.MoveSelectBefore(tp);
\r
775 this._Controller.MoveCaretAndSelect(tp);
\r
779 if(this.hitedFirstGripperRect == this.hitedSecondGripperRect)
\r
780 this._Controller.MoveCaretAndSelect(tp);
\r
781 else if (this.hitedFirstGripperRect != Rectangle.Empty)
\r
782 this._Controller.MoveSelectBefore(tp);
\r
784 this._Controller.MoveCaretAndSelect(tp);
\r
786 if (this.peer != null)
\r
787 this.peer.OnNotifyCaretChanged();
\r
792 if (e.Delta.Scale < 1)
\r
794 double newSize = this.Render.FontSize - 1;
\r
797 this.Render.FontSize = newSize;
\r
799 SetValue(MagnificationPowerPropertyKey, this.Render.FontSize / this.FontSize);
\r
803 if (e.Delta.Scale > 1)
\r
805 double newSize = this.Render.FontSize + 1;
\r
808 this.Render.FontSize = newSize;
\r
810 SetValue(MagnificationPowerPropertyKey, this.Render.FontSize / this.FontSize);
\r
814 Point translation = e.Delta.Translation;
\r
816 int scrollCount = (int)Math.Abs(translation.Y);
\r
817 if (scrollCount > 0)
\r
819 if (scrollCount > this.View.LineCountOnScreen) //ホイール対策
\r
820 scrollCount = this.View.LineCountOnScreen;
\r
821 if (translation.Y > 0)
\r
822 this._Controller.Scroll(ScrollDirection.Up, scrollCount, false, false);
\r
824 this._Controller.Scroll(ScrollDirection.Down, scrollCount, false, false);
\r
825 this.gripper.Enabled = false;
\r
830 int deltax = (int)Math.Abs(translation.X);
\r
833 if (translation.X < 0)
\r
834 this._Controller.Scroll(ScrollDirection.Left, deltax, false, false);
\r
836 this._Controller.Scroll(ScrollDirection.Right, deltax, false, false);
\r
837 this.gripper.Enabled = false;
\r
842 void gestureRecongnizer_ManipulationCompleted(GestureRecognizer sender, ManipulationCompletedEventArgs e)
\r
844 this.isHitCaret = false;
\r
845 this.hitedFirstGripperRect = Rectangle.Empty;
\r
846 this.hitedSecondGripperRect = Rectangle.Empty;
\r
849 async void gestureRecongnizer_RightTapped(GestureRecognizer sender, RightTappedEventArgs e)
\r
851 ResourceMap map = ResourceManager.Current.MainResourceMap.GetSubtree("FooEditEngine.Metro/Resources");
\r
852 if (this.View.HitTextArea(e.Position.X, e.Position.Y))
\r
854 FooContextMenuEventArgs args = new FooContextMenuEventArgs(e.Position);
\r
855 if (this.ContextMenuOpening != null)
\r
856 this.ContextMenuOpening(this, args);
\r
859 PopupMenu ContextMenu = new PopupMenu();
\r
860 ContextMenu.Commands.Add(new UICommand(map.GetValue("CopyMenuName").ValueAsString, (command) =>
\r
862 this.CopyCommand();
\r
864 ContextMenu.Commands.Add(new UICommand(map.GetValue("CutMenuName").ValueAsString, (command) =>
\r
868 ContextMenu.Commands.Add(new UICommand(map.GetValue("PasteMenuName").ValueAsString, async (command) =>
\r
870 await this.PasteCommand();
\r
872 if (this._Controller.RectSelection)
\r
874 ContextMenu.Commands.Add(new UICommand(map.GetValue("LineSelectMenuName").ValueAsString, (command) =>
\r
876 this._Controller.RectSelection = false;
\r
881 ContextMenu.Commands.Add(new UICommand(map.GetValue("RectSelectMenuName").ValueAsString, (command) =>
\r
883 this._Controller.RectSelection = true;
\r
886 await ContextMenu.ShowAsync(Util.GetScreentPoint(e.Position,this));
\r
891 void gestureRecongnizer_Tapped(GestureRecognizer sender, TappedEventArgs e)
\r
893 this.gripper.Enabled = e.PointerDeviceType == PointerDeviceType.Touch;
\r
894 this.JumpCaret(e.Position);
\r
897 void JumpCaret(Point p)
\r
899 if (this.Document.State == AsyncState.Loading)
\r
902 TextPoint tp = this.View.GetTextPointFromPostion(p);
\r
903 if (tp == TextPoint.Null)
\r
906 int index = this.View.LayoutLines.GetIndexFromTextPoint(tp);
\r
908 FoldingItem foldingData = this.View.HitFoldingData(p.X, tp.row);
\r
909 if (foldingData != null)
\r
911 if (foldingData.Expand)
\r
912 this.View.LayoutLines.FoldingCollection.Collapse(foldingData);
\r
914 this.View.LayoutLines.FoldingCollection.Expand(foldingData);
\r
915 this._Controller.JumpCaret(foldingData.Start, false);
\r
919 this._Controller.JumpCaret(tp.row, tp.col, false);
\r
921 if (this.peer != null)
\r
922 this.peer.OnNotifyCaretChanged();
\r
923 this.Focus(FocusState.Pointer);
\r
927 void gestureRecongnizer_Dragging(GestureRecognizer sender, DraggingEventArgs e)
\r
929 if (this.Document.State == AsyncState.Loading)
\r
931 Point p = e.Position;
\r
932 if (this.View.HitTextArea(p.X, p.Y))
\r
934 TextPoint tp = this.View.GetTextPointFromPostion(p);
\r
935 this._Controller.MoveCaretAndSelect(tp);
\r
936 if (this.peer != null)
\r
937 this.peer.OnNotifyCaretChanged();
\r
942 bool IsModiferKeyPressed(VirtualKey key)
\r
944 CoreVirtualKeyStates state = Window.Current.CoreWindow.GetKeyState(key);
\r
945 return (state & CoreVirtualKeyStates.Down) == CoreVirtualKeyStates.Down;
\r
947 void Refresh(Rectangle updateRect)
\r
949 if (this.rectangle.ActualWidth == 0 || this.rectangle.ActualHeight == 0/* || !this.Render.IsCanDraw()*/)
\r
952 this.Render.BeginDraw();
\r
953 if (this.Document.State != AsyncState.Loading)
\r
954 this.View.Draw(updateRect);
\r
956 this.Render.FillBackground(updateRect);
\r
957 this.gripper.DrawGrippers();
\r
958 this.Render.EndDraw();
\r
962 bool Resize(double width, double height)
\r
964 if (width == 0 || height == 0)
\r
965 throw new ArgumentOutOfRangeException();
\r
966 if (this.Document.State != AsyncState.Loading && this.Render.Resize(this.rectangle, width, height))
\r
968 this.View.PageBound = new Rectangle(0, 0, width, height);
\r
970 if (this.horizontalScrollBar != null)
\r
972 this.horizontalScrollBar.LargeChange = this.View.PageBound.Width;
\r
973 this.horizontalScrollBar.Maximum = this.View.LongestWidth + this.horizontalScrollBar.LargeChange + 1;
\r
975 if (this.verticalScrollBar != null)
\r
977 this.verticalScrollBar.LargeChange = this.View.LineCountOnScreen;
\r
978 this.verticalScrollBar.Maximum = this.View.LayoutLines.Count + this.verticalScrollBar.LargeChange + 1;
\r
985 void View_SrcChanged(object sender, EventArgs e)
\r
987 if (this.horizontalScrollBar == null || this.verticalScrollBar == null)
\r
989 EditView view = this.View;
\r
990 if (view.Src.Row > this.verticalScrollBar.Maximum)
\r
991 this.verticalScrollBar.Maximum = view.Src.Row + view.LineCountOnScreen + 1;
\r
992 double absoulteX = Math.Abs(view.Src.X);
\r
993 if (absoulteX > this.horizontalScrollBar.Maximum)
\r
994 this.horizontalScrollBar.Maximum = absoulteX + view.PageBound.Width + 1;
\r
995 if (view.Src.Row != this.verticalScrollBar.Value)
\r
996 this.verticalScrollBar.Value = view.Src.Row;
\r
997 if (view.Src.X != this.horizontalScrollBar.Value)
\r
998 this.horizontalScrollBar.Value = Math.Abs(view.Src.X);
\r
1001 void FooTextBox_SizeChanged(object sender, SizeChangedEventArgs e)
\r
1003 if (this.Document.State == AsyncState.Loading || this.Resize(this.rectangle.ActualWidth, this.rectangle.ActualHeight))
\r
1010 void horizontalScrollBar_Scroll(object sender, ScrollEventArgs e)
\r
1012 if (this.Document.State == AsyncState.Loading)
\r
1014 if (this.horizontalScrollBar == null)
\r
1017 if (this.FlowDirection == FlowDirection.LeftToRight)
\r
1018 toX = this.horizontalScrollBar.Value;
\r
1020 toX = -this.horizontalScrollBar.Value;
\r
1021 this._Controller.Scroll(toX, this.View.Src.Row, false, false);
\r
1022 this.gripper.Enabled = false;
\r
1026 void verticalScrollBar_Scroll(object sender, ScrollEventArgs e)
\r
1028 if (this.Document.State == AsyncState.Loading)
\r
1030 if (this.verticalScrollBar == null)
\r
1032 int newRow = (int)this.verticalScrollBar.Value;
\r
1033 if (newRow >= this.View.LayoutLines.Count)
\r
1035 this._Controller.Scroll(this.View.Src.X, newRow, false, false);
\r
1036 this.gripper.Enabled = false;
\r
1040 void Document_Update(object sender, DocumentUpdateEventArgs e)
\r
1042 if (this.textStore.IsLocked() || this.Document.State == AsyncState.Loading || e.type == UpdateType.Clear)
\r
1044 if (e.removeLength == 0)
\r
1045 this.textStore.NotifyTextChanged(e.startIndex, e.startIndex, e.startIndex + e.insertLength);
\r
1047 this.textStore.NotifyTextChanged(e.startIndex, e.startIndex + 1, e.startIndex + e.insertLength - e.removeLength);
\r
1050 void Document_Progress(object sender, ProgressEventArgs e)
\r
1052 if (this.Document.State == AsyncState.Loading)
\r
1056 case ProgressState.Start:
\r
1057 this.textStore.NotifyTextChanged(0, this.Document.Length, 0);
\r
1059 case ProgressState.Complete:
\r
1060 this.textStore.NotifyTextChanged(0, 0, this.Document.Length);
\r
1061 if (this.verticalScrollBar != null)
\r
1062 this.verticalScrollBar.Maximum = this.View.LayoutLines.Count;
\r
1063 this.View.CalculateLineCountOnScreen();
\r
1068 void FooTextBox_Loaded(object sender, RoutedEventArgs e)
\r
1070 this.Focus(FocusState.Programmatic);
\r
1074 public static void OnPropertyChanged(object sender, DependencyPropertyChangedEventArgs e)
\r
1076 FooTextBox source = (FooTextBox)sender;
\r
1077 if (e.Property.Equals(InsertModeProperty))
\r
1078 source.View.InsertMode = source.InsertMode;
\r
1079 if (e.Property.Equals(TabCharsProperty))
\r
1080 source.View.TabStops = source.TabChars;
\r
1081 if (e.Property.Equals(RectSelectModeProperty))
\r
1082 source._Controller.RectSelection = source.RectSelectMode;
\r
1083 if (e.Property.Equals(DrawCaretProperty))
\r
1084 source.View.HideCaret = !source.DrawCaret;
\r
1085 if (e.Property.Equals(DrawCaretLineProperty))
\r
1086 source.View.HideLineMarker = !source.DrawCaretLine;
\r
1087 if (e.Property.Equals(DrawLineNumberProperty))
\r
1089 source.View.DrawLineNumber = source.DrawLineNumber;
\r
1090 source._Controller.JumpCaret(source.View.CaretPostion.row, source.View.CaretPostion.col);
\r
1092 if(e.Property.Equals(MagnificationPowerPropertyKey))
\r
1093 source.Render.FontSize = source.FontSize * source.MagnificationPower;
\r
1094 if (e.Property.Equals(FontFamilyProperty))
\r
1095 source.Render.FontFamily = source.FontFamily;
\r
1096 if (e.Property.Equals(FontStyleProperty))
\r
1097 source.Render.FontStyle = source.FontStyle;
\r
1098 if (e.Property.Equals(FontWeightProperty))
\r
1099 source.Render.FontWeigth = source.FontWeight;
\r
1100 if (e.Property.Equals(FontSizeProperty))
\r
1101 source.Render.FontSize = source.FontSize;
\r
1102 if (e.Property.Equals(ForegroundProperty))
\r
1103 source.Render.Foreground = source.Foreground;
\r
1104 if (e.Property.Equals(BackgroundProperty))
\r
1105 source.Render.Background = source.Background;
\r
1106 if (e.Property.Equals(ControlCharProperty))
\r
1107 source.Render.ControlChar = source.ControlChar;
\r
1108 if (e.Property.Equals(HilightProperty))
\r
1109 source.Render.Hilight = source.Hilight;
\r
1110 if (e.Property.Equals(Keyword1Property))
\r
1111 source.Render.Keyword1 = source.Keyword1;
\r
1112 if (e.Property.Equals(Keyword2Property))
\r
1113 source.Render.Keyword2 = source.Keyword2;
\r
1114 if (e.Property.Equals(CommentProperty))
\r
1115 source.Render.Comment = source.Comment;
\r
1116 if (e.Property.Equals(LiteralProperty))
\r
1117 source.Render.Literal = source.Literal;
\r
1118 if (e.Property.Equals(URLProperty))
\r
1119 source.Render.Url = source.URL;
\r
1120 if (e.Property.Equals(InsertCaretProperty))
\r
1121 source.Render.InsertCaret = source.InsertCaret;
\r
1122 if (e.Property.Equals(OverwriteCaretProperty))
\r
1123 source.Render.OverwriteCaret = source.OverwriteCaret;
\r
1124 if (e.Property.Equals(LineMarkerProperty))
\r
1125 source.Render.LineMarker = source.LineMarker;
\r
1126 if (e.Property.Equals(MarkURLProperty))
\r
1127 source.View.UrlMark = source.MarkURL;
\r
1128 if (e.Property.Equals(ShowFullSpaceProperty))
\r
1129 source.Render.ShowFullSpace = source.ShowFullSpace;
\r
1130 if (e.Property.Equals(ShowHalfSpaceProperty))
\r
1131 source.Render.ShowHalfSpace = source.ShowHalfSpace;
\r
1132 if (e.Property.Equals(ShowTabProperty))
\r
1133 source.Render.ShowTab = source.ShowTab;
\r
1134 if (e.Property.Equals(ShowLineBreakProperty))
\r
1135 source.Render.ShowLineBreak = source.ShowLineBreak;
\r
1136 if (e.Property.Equals(LineBreakProperty))
\r
1137 source.View.LineBreak = source.LineBreakMethod;
\r
1138 if (e.Property.Equals(LineBreakCharCountProperty))
\r
1139 source.View.LineBreakCharCount = source.LineBreakCharCount;
\r
1140 if (e.Property.Equals(FlowDirectionProperty))
\r
1142 source.Render.RightToLeft = source.FlowDirection == Windows.UI.Xaml.FlowDirection.RightToLeft;
\r
1143 if(source.horizontalScrollBar != null)
\r
1144 source.horizontalScrollBar.FlowDirection = source.FlowDirection;
\r
1146 if (e.Property.Equals(DrawRulerProperty))
\r
1148 source.View.HideRuler = !source.DrawRuler;
\r
1149 source._Controller.JumpCaret(source.View.CaretPostion.row, source.View.CaretPostion.col);
\r
1157 /// コンテキストメニューが表示されるときに呼び出されます
\r
1159 public event EventHandler<FooContextMenuEventArgs> ContextMenuOpening;
\r
1165 internal Controller Controller
\r
1169 return this._Controller;
\r
1174 /// 文字列の描写に使用されるアンチエイリアシング モードを表します
\r
1176 public TextAntialiasMode TextAntialiasMode
\r
1180 return this.Render.TextAntialiasMode;
\r
1184 this.Render.TextAntialiasMode = value;
\r
1189 /// シンタックスハイライターを表す
\r
1191 public IHilighter Hilighter
\r
1195 return this.View.Hilighter;
\r
1199 this.View.Hilighter = value;
\r
1200 this.View.LayoutLines.ClearLayoutCache();
\r
1205 /// フォールティングを作成するインターフェイスを表す
\r
1207 public IFoldingStrategy FoldingStrategy
\r
1211 return this.View.LayoutLines.FoldingStrategy;
\r
1215 this.View.LayoutLines.FoldingStrategy = value;
\r
1216 if (value == null)
\r
1217 this.View.LayoutLines.FoldingCollection.Clear();
\r
1224 public Document Document
\r
1233 public LineToIndexTable LayoutLineCollection
\r
1235 get { return this.View.LayoutLines; }
\r
1241 public string SelectedText
\r
1245 return this._Controller.SelectedText;
\r
1249 int oldLength = this.Document.Length;
\r
1250 this._Controller.SelectedText = value;
\r
1257 /// <remarks>SelectionLengthが0の場合はキャレット位置を表します</remarks>
\r
1258 public int SelectionStart
\r
1260 get { return this._Controller.SelectionStart; }
\r
1266 /// <remarks>矩形選択モードの場合、選択範囲の文字数ではなく、開始位置から終了位置までの長さとなります</remarks>
\r
1267 public int SelectionLength
\r
1269 get { return this._Controller.SelectionLength; }
\r
1275 public double MagnificationPower
\r
1277 get { return (double)GetValue(MagnificationPowerPropertyKey); }
\r
1278 set { SetValue(MagnificationPowerPropertyKey, value); }
\r
1284 public static readonly DependencyProperty MagnificationPowerPropertyKey =
\r
1285 DependencyProperty.Register("MagnificationPower", typeof(double), typeof(FooTextBox), new PropertyMetadata(1.0, OnPropertyChanged));
\r
1288 /// キャレット位置を表す。このプロパティは変更しても値が反映されません
\r
1290 public TextPoint CaretPostion
\r
1292 get { return (TextPoint)GetValue(CaretPostionPropertyKey); }
\r
1293 set { SetValue(CaretPostionPropertyKey, value); }
\r
1296 static readonly DependencyProperty CaretPostionPropertyKey =
\r
1297 DependencyProperty.Register("CaretPostion", typeof(TextPoint), typeof(FooTextBox), new PropertyMetadata(new TextPoint(), OnPropertyChanged));
\r
1302 public new FlowDirection FlowDirection
\r
1304 get { return (FlowDirection)GetValue(FlowDirectionProperty); }
\r
1305 set { SetValue(FlowDirectionProperty, value); }
\r
1309 /// レタリング方向を表す。これは依存プロパティです
\r
1311 public new static readonly DependencyProperty FlowDirectionProperty =
\r
1312 DependencyProperty.Register("FlowDirection", typeof(FlowDirection), typeof(FooTextBox), new PropertyMetadata(FlowDirection.LeftToRight,OnPropertyChanged));
\r
1317 public new FontFamily FontFamily
\r
1319 get { return (FontFamily)GetValue(FontFamilyProperty); }
\r
1320 set { SetValue(FontFamilyProperty, value); }
\r
1324 /// FontFamilyの依存プロパティを表す
\r
1326 public new static readonly DependencyProperty FontFamilyProperty =
\r
1327 DependencyProperty.Register("FontFamily", typeof(FontFamily), typeof(FooTextBox), new PropertyMetadata(new FontFamily("Cambria"), OnPropertyChanged));
\r
1332 public new double FontSize
\r
1334 get { return (double)GetValue(FontSizeProperty); }
\r
1335 set { SetValue(FontSizeProperty, value); }
\r
1339 /// FontSizeの依存プロパティを表す
\r
1341 public new static readonly DependencyProperty FontSizeProperty =
\r
1342 DependencyProperty.Register("FontSize", typeof(double), typeof(FooTextBox), new PropertyMetadata(12.0,OnPropertyChanged));
\r
1347 public new FontStyle FontStyle
\r
1349 get { return (FontStyle)GetValue(FontStyleProperty); }
\r
1350 set { SetValue(FontStyleProperty, value); }
\r
1354 /// FontStyleの依存プロパティを表す
\r
1356 public new static readonly DependencyProperty FontStyleProperty =
\r
1357 DependencyProperty.Register("FontStyle", typeof(FontStyle), typeof(FooTextBox), new PropertyMetadata(FontStyle.Normal,OnPropertyChanged));
\r
1362 public new FontWeight FontWeight
\r
1364 get { return (FontWeight)GetValue(FontWeightProperty); }
\r
1365 set { SetValue(FontWeightProperty, value); }
\r
1369 /// FontWeigthの依存プロパティを表す
\r
1371 public new static readonly DependencyProperty FontWeightProperty =
\r
1372 DependencyProperty.Register("FontWeigth", typeof(FontWeight), typeof(FooTextBox), new PropertyMetadata(FontWeights.Normal,OnPropertyChanged));
\r
1375 /// デフォルトの文字色を表す。これは依存プロパティです
\r
1377 public new Windows.UI.Color Foreground
\r
1379 get { return (Windows.UI.Color)GetValue(ForegroundProperty); }
\r
1380 set { SetValue(ForegroundProperty, value); }
\r
1384 /// Foregroundの依存プロパティを表す
\r
1386 public new static readonly DependencyProperty ForegroundProperty =
\r
1387 DependencyProperty.Register("Foreground", typeof(Windows.UI.Color), typeof(FooTextBox), new PropertyMetadata(Colors.Black, OnPropertyChanged));
\r
1390 /// 背景色を表す。これは依存プロパティです
\r
1392 public new Windows.UI.Color Background
\r
1394 get { return (Windows.UI.Color)GetValue(BackgroundProperty); }
\r
1395 set { SetValue(BackgroundProperty, value); }
\r
1399 /// Backgroundの依存プロパティを表す
\r
1401 public new static readonly DependencyProperty BackgroundProperty =
\r
1402 DependencyProperty.Register("Background", typeof(Windows.UI.Color), typeof(FooTextBox), new PropertyMetadata(Colors.White, OnPropertyChanged));
\r
1405 /// コントロールコードの文字色を表す。これは依存プロパティです
\r
1407 public Windows.UI.Color ControlChar
\r
1409 get { return (Windows.UI.Color)GetValue(ControlCharProperty); }
\r
1410 set { SetValue(ControlCharProperty, value); }
\r
1414 /// ControlCharの依存プロパティを表す
\r
1416 public static readonly DependencyProperty ControlCharProperty =
\r
1417 DependencyProperty.Register("ControlChar", typeof(Windows.UI.Color), typeof(FooTextBox), new PropertyMetadata(Colors.Gray, OnPropertyChanged));
\r
1420 /// 選択時の背景色を表す。これは依存プロパティです
\r
1422 public Windows.UI.Color Hilight
\r
1424 get { return (Windows.UI.Color)GetValue(HilightProperty); }
\r
1425 set { SetValue(HilightProperty, value); }
\r
1429 /// Hilightの依存プロパティを表す
\r
1431 public static readonly DependencyProperty HilightProperty =
\r
1432 DependencyProperty.Register("Hilight", typeof(Windows.UI.Color), typeof(FooTextBox), new PropertyMetadata(Colors.DeepSkyBlue, OnPropertyChanged));
\r
1435 /// キーワード1の文字色を表す。これは依存プロパティです
\r
1437 public Windows.UI.Color Keyword1
\r
1439 get { return (Windows.UI.Color)GetValue(Keyword1Property); }
\r
1440 set { SetValue(Keyword1Property, value); }
\r
1444 /// Keyword1の依存プロパティを表す
\r
1446 public static readonly DependencyProperty Keyword1Property =
\r
1447 DependencyProperty.Register("Keyword1", typeof(Windows.UI.Color), typeof(FooTextBox), new PropertyMetadata(Colors.Blue, OnPropertyChanged));
\r
1450 /// キーワード2の文字色を表す。これは依存プロパティです
\r
1452 public Windows.UI.Color Keyword2
\r
1454 get { return (Windows.UI.Color)GetValue(Keyword2Property); }
\r
1455 set { SetValue(Keyword2Property, value); }
\r
1459 /// Keyword2の依存プロパティを表す
\r
1461 public static readonly DependencyProperty Keyword2Property =
\r
1462 DependencyProperty.Register("Keyword2", typeof(Windows.UI.Color), typeof(FooTextBox), new PropertyMetadata(Colors.DarkCyan, OnPropertyChanged));
\r
1465 /// コメントの文字色を表す。これは依存プロパティです
\r
1467 public Windows.UI.Color Comment
\r
1469 get { return (Windows.UI.Color)GetValue(CommentProperty); }
\r
1470 set { SetValue(CommentProperty, value); }
\r
1474 /// Commentの依存プロパティを表す
\r
1476 public static readonly DependencyProperty CommentProperty =
\r
1477 DependencyProperty.Register("Comment", typeof(Windows.UI.Color), typeof(FooTextBox), new PropertyMetadata(Colors.Green, OnPropertyChanged));
\r
1480 /// 文字リテラルの文字色を表す。これは依存プロパティです
\r
1482 public Windows.UI.Color Literal
\r
1484 get { return (Windows.UI.Color)GetValue(LiteralProperty); }
\r
1485 set { SetValue(LiteralProperty, value); }
\r
1489 /// Literalの依存プロパティを表す
\r
1491 public static readonly DependencyProperty LiteralProperty =
\r
1492 DependencyProperty.Register("Literal", typeof(Windows.UI.Color), typeof(FooTextBox), new PropertyMetadata(Colors.Brown, OnPropertyChanged));
\r
1495 /// URLの文字色を表す。これは依存プロパティです
\r
1497 public Windows.UI.Color URL
\r
1499 get { return (Windows.UI.Color)GetValue(URLProperty); }
\r
1500 set { SetValue(URLProperty, value); }
\r
1504 /// URLの依存プロパティを表す
\r
1506 public static readonly DependencyProperty URLProperty =
\r
1507 DependencyProperty.Register("URL", typeof(Windows.UI.Color), typeof(FooTextBox), new PropertyMetadata(Colors.Blue, OnPropertyChanged));
\r
1513 public Windows.UI.Color LineMarker
\r
1515 get { return (Windows.UI.Color)GetValue(LineMarkerProperty); }
\r
1516 set { SetValue(LineMarkerProperty, value); }
\r
1520 /// LineMarkerの依存プロパティを表す
\r
1522 public static readonly DependencyProperty LineMarkerProperty =
\r
1523 DependencyProperty.Register("LineMarker", typeof(Windows.UI.Color), typeof(FooTextBox), new PropertyMetadata(Colors.Gray, OnPropertyChanged));
\r
1526 /// 挿入モード時のキャレットの色を表す
\r
1528 public Windows.UI.Color InsertCaret
\r
1530 get { return (Windows.UI.Color)GetValue(InsertCaretProperty); }
\r
1531 set { SetValue(InsertCaretProperty, value); }
\r
1535 /// InsertCaretの依存プロパティを表す
\r
1537 public static readonly DependencyProperty InsertCaretProperty =
\r
1538 DependencyProperty.Register("InsertCaret", typeof(Windows.UI.Color), typeof(FooTextBox), new PropertyMetadata(Colors.Black, OnPropertyChanged));
\r
1541 /// 上書きモード時のキャレット職を表す
\r
1543 public Windows.UI.Color OverwriteCaret
\r
1545 get { return (Windows.UI.Color)GetValue(OverwriteCaretProperty); }
\r
1546 set { SetValue(OverwriteCaretProperty, value); }
\r
1550 /// OverwriteCaretの依存プロパティを表す
\r
1552 public static readonly DependencyProperty OverwriteCaretProperty =
\r
1553 DependencyProperty.Register("OverwriteCaret", typeof(Windows.UI.Color), typeof(FooTextBox), new PropertyMetadata(Colors.Black, OnPropertyChanged));
\r
1556 /// 挿入モードなら真を返し、そうでないなら、偽を返す。これは依存プロパティです
\r
1558 public bool InsertMode
\r
1560 get { return (bool)GetValue(InsertModeProperty); }
\r
1561 set { SetValue(InsertModeProperty, value); }
\r
1565 /// InsertModeの依存プロパティを表す
\r
1567 public static readonly DependencyProperty InsertModeProperty =
\r
1568 DependencyProperty.Register("InsertMode",
\r
1570 typeof(FooTextBox),
\r
1571 new PropertyMetadata(true, OnPropertyChanged));
\r
1574 /// タブの文字数を表す。これは依存プロパティです
\r
1576 public int TabChars
\r
1578 get { return (int)GetValue(TabCharsProperty); }
\r
1579 set { SetValue(TabCharsProperty, value); }
\r
1583 /// TabCharsの依存プロパティを表す
\r
1585 public static readonly DependencyProperty TabCharsProperty =
\r
1586 DependencyProperty.Register("TabChars",
\r
1588 typeof(FooTextBox),
\r
1589 new PropertyMetadata(4, OnPropertyChanged));
\r
1592 /// 矩形選択モードなら真を返し、そうでないなら偽を返す。これは依存プロパティです
\r
1594 public bool RectSelectMode
\r
1596 get { return (bool)GetValue(RectSelectModeProperty); }
\r
1597 set { SetValue(RectSelectModeProperty, value); }
\r
1601 /// RectSelectModeの依存プロパティを表す
\r
1603 public static readonly DependencyProperty RectSelectModeProperty =
\r
1604 DependencyProperty.Register("RectSelectMode", typeof(bool), typeof(FooTextBox), new PropertyMetadata(false, OnPropertyChanged));
\r
1610 /// 変更した場合、レイアウトの再構築を行う必要があります
\r
1612 public LineBreakMethod LineBreakMethod
\r
1614 get { return (LineBreakMethod)GetValue(LineBreakProperty); }
\r
1615 set { SetValue(LineBreakProperty, value); }
\r
1619 /// LineBreakMethodの依存プロパティを表す
\r
1621 public static readonly DependencyProperty LineBreakProperty =
\r
1622 DependencyProperty.Register("LineBreakMethod", typeof(LineBreakMethod), typeof(FooTextBox), new PropertyMetadata(LineBreakMethod.None, OnPropertyChanged));
\r
1626 /// 折り返しの幅を指定する。LineBreakMethod.CharUnit以外の時は無視されます
\r
1629 /// 変更した場合、レイアウトの再構築を行う必要があります
\r
1631 public int LineBreakCharCount
\r
1633 get { return (int)GetValue(LineBreakCharCountProperty); }
\r
1634 set { SetValue(LineBreakCharCountProperty, value); }
\r
1638 /// LineBreakCharCountの依存プロパティを表す
\r
1640 public static readonly DependencyProperty LineBreakCharCountProperty =
\r
1641 DependencyProperty.Register("LineBreakCharCount", typeof(int), typeof(FooTextBox), new PropertyMetadata(80));
\r
1644 /// キャレットを描くなら真。そうでないなら偽を返す。これは依存プロパティです
\r
1646 public bool DrawCaret
\r
1648 get { return (bool)GetValue(DrawCaretProperty); }
\r
1649 set { SetValue(DrawCaretProperty, value); }
\r
1653 /// DrawCaretの依存プロパティを表す
\r
1655 public static readonly DependencyProperty DrawCaretProperty =
\r
1656 DependencyProperty.Register("DrawCaret", typeof(bool), typeof(FooTextBox), new PropertyMetadata(true, OnPropertyChanged));
\r
1660 /// キャレットラインを描くなら真。そうでないなら偽を返す。これは依存プロパティです
\r
1662 public bool DrawCaretLine
\r
1664 get { return (bool)GetValue(DrawCaretLineProperty); }
\r
1665 set { SetValue(DrawCaretLineProperty, value); }
\r
1669 /// DrawCaretLineの依存プロパティを表す
\r
1671 public static readonly DependencyProperty DrawCaretLineProperty =
\r
1672 DependencyProperty.Register("DrawCaretLine", typeof(bool), typeof(FooTextBox), new PropertyMetadata(true, OnPropertyChanged));
\r
1675 /// 行番号を描くなら真。そうでなければ偽。これは依存プロパティです
\r
1677 public bool DrawLineNumber
\r
1679 get { return (bool)GetValue(DrawLineNumberProperty); }
\r
1680 set { SetValue(DrawLineNumberProperty, value); }
\r
1684 /// ルーラーを描くなら真。そうでなければ偽。これは依存プロパティです
\r
1686 public bool DrawRuler
\r
1688 get { return (bool)GetValue(DrawRulerProperty); }
\r
1689 set { SetValue(DrawRulerProperty, value); }
\r
1693 /// DrawRulerの依存プロパティを表す
\r
1695 public static readonly DependencyProperty DrawRulerProperty =
\r
1696 DependencyProperty.Register("DrawRuler", typeof(bool), typeof(FooTextBox), new PropertyMetadata(false, OnPropertyChanged));
\r
1700 /// DrawLineNumberの依存プロパティを表す
\r
1702 public static readonly DependencyProperty DrawLineNumberProperty =
\r
1703 DependencyProperty.Register("DrawLineNumber", typeof(bool), typeof(FooTextBox), new PropertyMetadata(false, OnPropertyChanged));
\r
1706 /// URLに下線を引くなら真。そうでないなら偽を表す。これは依存プロパティです
\r
1708 public bool MarkURL
\r
1710 get { return (bool)GetValue(MarkURLProperty); }
\r
1711 set { SetValue(MarkURLProperty, value); }
\r
1715 /// MarkURLの依存プロパティを表す
\r
1717 public static readonly DependencyProperty MarkURLProperty =
\r
1718 DependencyProperty.Register("MarkURL", typeof(bool), typeof(FooTextBox), new PropertyMetadata(false, OnPropertyChanged));
\r
1721 /// 全角スペースを表示するなら真。そうでないなら偽
\r
1723 public bool ShowFullSpace
\r
1725 get { return (bool)GetValue(ShowFullSpaceProperty); }
\r
1726 set { SetValue(ShowFullSpaceProperty, value); }
\r
1730 /// ShowFullSpaceの依存プロパティを表す
\r
1732 public static readonly DependencyProperty ShowFullSpaceProperty =
\r
1733 DependencyProperty.Register("ShowFullSpace", typeof(bool), typeof(FooTextBox), new PropertyMetadata(false, OnPropertyChanged));
\r
1736 /// 半角スペースを表示するなら真。そうでないなら偽
\r
1738 public bool ShowHalfSpace
\r
1740 get { return (bool)GetValue(ShowHalfSpaceProperty); }
\r
1741 set { SetValue(ShowHalfSpaceProperty, value); }
\r
1745 /// ShowHalfSpaceの依存プロパティを表す
\r
1747 public static readonly DependencyProperty ShowHalfSpaceProperty =
\r
1748 DependencyProperty.Register("ShowHalfSpace", typeof(bool), typeof(FooTextBox), new PropertyMetadata(false, OnPropertyChanged));
\r
1751 /// タブを表示するなら真。そうでないなら偽
\r
1753 public bool ShowTab
\r
1755 get { return (bool)GetValue(ShowTabProperty); }
\r
1756 set { SetValue(ShowTabProperty, value); }
\r
1760 /// ShowTabの依存プロパティを表す
\r
1762 public static readonly DependencyProperty ShowTabProperty =
\r
1763 DependencyProperty.Register("ShowTab", typeof(bool), typeof(FooTextBox), new PropertyMetadata(false, OnPropertyChanged));
\r
1766 /// 改行マークを表示するなら真。そうでないなら偽
\r
1768 public bool ShowLineBreak
\r
1770 get { return (bool)GetValue(ShowLineBreakProperty); }
\r
1771 set { SetValue(ShowLineBreakProperty, value); }
\r
1775 /// ShowLineBreakの依存プロパティを表す
\r
1777 public static readonly DependencyProperty ShowLineBreakProperty =
\r
1778 DependencyProperty.Register("ShowLineBreak", typeof(bool), typeof(FooTextBox), new PropertyMetadata(false,OnPropertyChanged));
\r
1784 /// コンテキストメニューのイベントデーターを表す
\r
1786 public class FooContextMenuEventArgs
\r
1789 /// 処理済みなら真。そうでないなら偽
\r
1791 public bool Handled = false;
\r
1793 /// コンテキストメニューを表示すべき座標を表す
\r
1795 public Windows.Foundation.Point Postion;
\r
1799 /// <param name="pos"></param>
\r
1800 public FooContextMenuEventArgs(Windows.Foundation.Point pos)
\r
1802 this.Postion = pos;
\r