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 this.Document.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.GetData(row).Layout.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 LineToIndexTableData lineData = this.View.LayoutLines.GetData(i);
\r
325 double height = lineData.Layout.Height;
\r
326 if (y - height <= 0)
\r
328 this.View.Scroll(0, i);
\r
330 FoldingItem foldingData = this.View.LayoutLines.FoldingCollection.Get(lineData.Index, lineData.Length);
\r
332 if (foldingData != null && foldingData.IsHidden(lineData.Index))
\r
350 async Task PasteCommand()
\r
352 await this.PasteAsync();
\r
360 protected override Windows.UI.Xaml.Automation.Peers.AutomationPeer OnCreateAutomationPeer()
\r
362 this.peer = new FooTextBoxAutomationPeer(this);
\r
367 protected override void OnApplyTemplate()
\r
369 base.OnApplyTemplate();
\r
371 Grid grid = this.GetTemplateChild("PART_Grid") as Grid;
\r
374 Grid.SetRow(this.rectangle, 0);
\r
375 Grid.SetColumn(this.rectangle, 0);
\r
376 grid.Children.Add(this.rectangle);
\r
379 this.horizontalScrollBar = this.GetTemplateChild("PART_HorizontalScrollBar") as ScrollBar;
\r
380 if (this.horizontalScrollBar != null)
\r
382 this.horizontalScrollBar.SmallChange = 10;
\r
383 this.horizontalScrollBar.LargeChange = 100;
\r
384 this.horizontalScrollBar.Maximum = this.horizontalScrollBar.LargeChange + 1;
\r
385 this.horizontalScrollBar.Scroll += new ScrollEventHandler(horizontalScrollBar_Scroll);
\r
387 this.verticalScrollBar = this.GetTemplateChild("PART_VerticalScrollBar") as ScrollBar;
\r
388 if (this.verticalScrollBar != null)
\r
390 this.verticalScrollBar.SmallChange = 1;
\r
391 this.verticalScrollBar.LargeChange = 10;
\r
392 this.verticalScrollBar.Maximum = this.View.LayoutLines.Count;
\r
393 this.verticalScrollBar.Scroll += new ScrollEventHandler(verticalScrollBar_Scroll);
\r
398 protected override void OnGotFocus(RoutedEventArgs e)
\r
400 base.OnGotFocus(e);
\r
401 this.textStore.SetFocus();
\r
405 protected override async void OnKeyDown(KeyRoutedEventArgs e)
\r
407 if (this.Document.State == AsyncState.Loading)
\r
409 bool isControlPressed = this.IsModiferKeyPressed(VirtualKey.Control);
\r
410 bool isShiftPressed = this.IsModiferKeyPressed(VirtualKey.Shift);
\r
411 bool isMovedCaret = false;
\r
414 case VirtualKey.Up:
\r
415 if (this._Controller.IsCanMoveCaret(-1, MoveFlow.Vertical))
\r
416 this._Controller.MoveCaretVertical(-1, isShiftPressed);
\r
419 isMovedCaret = true;
\r
421 case VirtualKey.Down:
\r
422 if (this._Controller.IsCanMoveCaret(+1, MoveFlow.Vertical))
\r
423 this._Controller.MoveCaretVertical(+1, isShiftPressed);
\r
426 isMovedCaret = true;
\r
428 case VirtualKey.Left:
\r
429 if (this._Controller.IsCanMoveCaret(-1, MoveFlow.Horizontical))
\r
430 this._Controller.MoveCaretHorizontical(-1, isShiftPressed, isControlPressed);
\r
433 isMovedCaret = true;
\r
435 case VirtualKey.Right:
\r
436 if (this._Controller.IsCanMoveCaret(1, MoveFlow.Horizontical))
\r
437 this._Controller.MoveCaretHorizontical(1, isShiftPressed, isControlPressed);
\r
440 isMovedCaret = true;
\r
442 case VirtualKey.PageUp:
\r
443 this._Controller.Scroll(ScrollDirection.Up, this.View.LineCountOnScreen, isShiftPressed, true);
\r
445 isMovedCaret = true;
\r
447 case VirtualKey.PageDown:
\r
448 this._Controller.Scroll(ScrollDirection.Down, this.View.LineCountOnScreen, isShiftPressed, true);
\r
450 isMovedCaret = true;
\r
452 case VirtualKey.Home:
\r
453 if (isControlPressed)
\r
454 this._Controller.JumpToHead(isShiftPressed);
\r
456 this._Controller.JumpCaret(this.View.CaretPostion.row, 0);
\r
458 isMovedCaret = true;
\r
460 case VirtualKey.End:
\r
461 if (isControlPressed)
\r
462 this._Controller.JumpToEnd(isShiftPressed);
\r
464 this._Controller.JumpCaret(this.View.CaretPostion.row, this.View.LayoutLines[this.View.CaretPostion.row].Length - 1);
\r
466 isMovedCaret = true;
\r
468 case VirtualKey.Tab:
\r
469 if (!isControlPressed && !isShiftPressed)
\r
471 this._Controller.DoInputChar('\t');
\r
476 case VirtualKey.Enter:
\r
477 this._Controller.DoEnterAction();
\r
481 case VirtualKey.Insert:
\r
482 if(this.View.InsertMode)
\r
483 this.View.InsertMode = false;
\r
485 this.View.InsertMode = true;
\r
490 if (isControlPressed)
\r
498 if (isControlPressed)
\r
500 if (this._Controller.RectSelection)
\r
501 this._Controller.RectSelection = false;
\r
503 this._Controller.RectSelection = true;
\r
509 if (isControlPressed)
\r
511 this.CopyCommand();
\r
516 if (isControlPressed)
\r
523 if (isControlPressed)
\r
525 await this.PasteCommand();
\r
530 if (isControlPressed)
\r
532 this.Document.UndoManager.redo();
\r
538 if (isControlPressed)
\r
540 this.Document.UndoManager.undo();
\r
545 case VirtualKey.Back:
\r
546 this._Controller.DoBackSpaceAction();
\r
550 case VirtualKey.Delete:
\r
551 this._Controller.DoDeleteAction();
\r
556 if (isMovedCaret && this.peer != null)
\r
557 this.peer.OnNotifyCaretChanged();
\r
562 protected override void OnPointerPressed(PointerRoutedEventArgs e)
\r
564 this.CapturePointer(e.Pointer);
\r
565 this.gestureRecongnizer.ProcessDownEvent(e.GetCurrentPoint(this));
\r
570 protected override void OnPointerMoved(PointerRoutedEventArgs e)
\r
572 this.gestureRecongnizer.ProcessMoveEvents(e.GetIntermediatePoints(this));
\r
575 if (e.Pointer.PointerDeviceType == PointerDeviceType.Mouse && this.Document.State != AsyncState.Loading)
\r
577 Point p = e.GetCurrentPoint(this).Position;
\r
578 if (this.View.HitTextArea(p.X, p.Y))
\r
580 TextPoint tp = this.View.GetTextPointFromPostion(p);
\r
581 if (this._Controller.IsMarker(tp, HilightType.Url))
\r
582 Window.Current.CoreWindow.PointerCursor = new CoreCursor(CoreCursorType.Hand, 101);
\r
584 Window.Current.CoreWindow.PointerCursor = new CoreCursor(CoreCursorType.IBeam, 101);
\r
588 Window.Current.CoreWindow.PointerCursor = new CoreCursor(CoreCursorType.Arrow, 101);
\r
594 protected override void OnPointerReleased(PointerRoutedEventArgs e)
\r
596 this.gestureRecongnizer.ProcessUpEvent(e.GetCurrentPoint(this));
\r
597 this.ReleasePointerCapture(e.Pointer);
\r
602 protected override void OnPointerCanceled(PointerRoutedEventArgs e)
\r
604 this.gestureRecongnizer.CompleteGesture();
\r
605 this.ReleasePointerCapture(e.Pointer);
\r
610 protected override void OnPointerCaptureLost(PointerRoutedEventArgs e)
\r
612 this.gestureRecongnizer.CompleteGesture();
\r
613 this.ReleasePointerCapture(e.Pointer);
\r
618 protected override void OnPointerWheelChanged(PointerRoutedEventArgs e)
\r
620 bool shift = (e.KeyModifiers & Windows.System.VirtualKeyModifiers.Shift) ==
\r
621 Windows.System.VirtualKeyModifiers.Shift;
\r
622 bool ctrl = (e.KeyModifiers & Windows.System.VirtualKeyModifiers.Control) ==
\r
623 Windows.System.VirtualKeyModifiers.Control;
\r
624 this.gestureRecongnizer.ProcessMouseWheelEvent(e.GetCurrentPoint(this), shift, ctrl);
\r
628 void CoreWindow_CharacterReceived(CoreWindow sender, CharacterReceivedEventArgs args)
\r
630 if (this.FocusState == FocusState.Unfocused || this.Document.State == AsyncState.Loading)
\r
632 if (args.KeyCode >= 00 && args.KeyCode <= 0x1f)
\r
634 this._Controller.DoInputString(Char.ConvertFromUtf32((int)args.KeyCode));
\r
638 bool textStore_IsReadOnly()
\r
643 bool textStore_IsLoading()
\r
645 return this.Document.State == AsyncState.Loading;
\r
648 void textStore_CompositionEnded()
\r
650 TextStoreHelper.EndCompostion(this.Document);
\r
654 void textStore_CompositionUpdated(int start, int end)
\r
656 if (TextStoreHelper.ScrollToCompstionUpdated(this.textStore, this.View, start, end))
\r
659 bool textStore_CompositionStarted()
\r
661 return TextStoreHelper.StartCompstion(this.Document);
\r
664 string _textStore_GetString(int start, int length)
\r
666 return this.Document.ToString(start, length);
\r
669 void _textStore_GetStringExtent(
\r
672 out POINT o_topLeft,
\r
673 out POINT o_bottomRight
\r
676 Point startPos, endPos;
\r
677 TextStoreHelper.GetStringExtent(this.Document, this.View, i_startIndex, i_endIndex, out startPos, out endPos);
\r
679 var gt = this.TransformToVisual(Window.Current.Content);
\r
680 startPos = gt.TransformPoint(startPos);
\r
681 endPos = gt.TransformPoint(endPos);
\r
683 o_topLeft = new POINT((int)startPos.X, (int)startPos.Y);
\r
684 o_bottomRight = new POINT((int)endPos.X, (int)endPos.Y);
\r
687 void _textStore_GetScreenExtent(out POINT o_topLeft, out POINT o_bottomRight)
\r
689 var pointTopLeft = new Point(0, 0);
\r
690 var pointBottomRight = new Point(this.RenderSize.Width, this.RenderSize.Height);
\r
692 var gt = this.TransformToVisual(Window.Current.Content);
\r
693 pointTopLeft = gt.TransformPoint(pointTopLeft);
\r
694 pointBottomRight = gt.TransformPoint(pointBottomRight);
\r
696 o_topLeft = new POINT((int)pointTopLeft.X, (int)pointTopLeft.Y);
\r
697 o_bottomRight = new POINT((int)pointBottomRight.X, (int)pointBottomRight.Y);
\r
700 void _textStore_GetSelectionIndex(out int o_startIndex, out int o_endIndex)
\r
702 TextStoreHelper.GetSelection(this._Controller, this.Document, out o_startIndex, out o_endIndex);
\r
705 void _textStore_SetSelectionIndex(int i_startIndex, int i_endIndex)
\r
707 if (this.Document.State == AsyncState.Loading)
\r
709 TextStoreHelper.SetSelectionIndex(this._Controller, this.View, i_startIndex, i_endIndex);
\r
713 void _textStore_InsertAtSelection(string i_value)
\r
715 TextStoreHelper.InsertTextAtSelection(this._Controller, i_value);
\r
719 void Controller_CaretMoved(object sender, EventArgs e)
\r
721 SetValue(CaretPostionPropertyKey, this.View.CaretPostion);
\r
722 if (this.textStore.IsLocked() == false)
\r
723 this.textStore.NotifySelectionChanged();
\r
727 Rectangle hitedSecondGripperRect = Rectangle.Empty,hitedFirstGripperRect = Rectangle.Empty;
\r
728 void gestureRecongnizer_ManipulationStarted(GestureRecognizer sender, ManipulationStartedEventArgs e)
\r
730 if (this.Document.State == AsyncState.Loading)
\r
732 TextPoint tp = this.View.GetTextPointFromPostion(e.Position);
\r
733 if (tp == this.View.CaretPostion)
\r
735 this.isHitCaret = true;
\r
736 this.hitedSecondGripperRect = Rectangle.Empty;
\r
738 Rectangle gripperRect = this.gripper.HitTest(GripperType.Second,e.Position);
\r
739 if (gripperRect != Rectangle.Empty)
\r
741 this.isHitCaret = true;
\r
742 this.hitedSecondGripperRect = gripperRect;
\r
744 gripperRect = this.gripper.HitTest(GripperType.First,e.Position);
\r
745 if (gripperRect != Rectangle.Empty)
\r
747 this.isHitCaret = true;
\r
748 this.hitedFirstGripperRect = gripperRect;
\r
752 void gestureRecongnizer_ManipulationUpdated(GestureRecognizer sender, ManipulationUpdatedEventArgs e)
\r
754 if (this.Document.State == AsyncState.Loading)
\r
756 if (this.isHitCaret)
\r
758 Point p = e.Position;
\r
759 if (this.hitedFirstGripperRect != Rectangle.Empty)
\r
760 p = this.gripper.GetPointOnGripper(GripperType.First,this.hitedFirstGripperRect, p);
\r
761 else if (this.hitedSecondGripperRect != Rectangle.Empty)
\r
762 p = this.gripper.GetPointOnGripper(GripperType.Second,this.hitedSecondGripperRect, p);
\r
763 if (this.View.HitTextArea(p.X, p.Y))
\r
765 TextPoint tp = this.View.GetTextPointFromPostion(p);
\r
766 if (this._Controller.IsReverseSelect())
\r
768 if (this.hitedFirstGripperRect == this.hitedSecondGripperRect)
\r
769 this._Controller.MoveCaretAndSelect(tp);
\r
770 else if (this.hitedSecondGripperRect != Rectangle.Empty)
\r
771 this._Controller.MoveSelectBefore(tp);
\r
773 this._Controller.MoveCaretAndSelect(tp);
\r
777 if(this.hitedFirstGripperRect == this.hitedSecondGripperRect)
\r
778 this._Controller.MoveCaretAndSelect(tp);
\r
779 else if (this.hitedFirstGripperRect != Rectangle.Empty)
\r
780 this._Controller.MoveSelectBefore(tp);
\r
782 this._Controller.MoveCaretAndSelect(tp);
\r
784 if (this.peer != null)
\r
785 this.peer.OnNotifyCaretChanged();
\r
790 if (e.Delta.Scale < 1)
\r
792 double newSize = this.Render.FontSize - 1;
\r
795 this.Render.FontSize = newSize;
\r
797 SetValue(MagnificationPowerPropertyKey, this.Render.FontSize / this.FontSize);
\r
801 if (e.Delta.Scale > 1)
\r
803 double newSize = this.Render.FontSize + 1;
\r
806 this.Render.FontSize = newSize;
\r
808 SetValue(MagnificationPowerPropertyKey, this.Render.FontSize / this.FontSize);
\r
812 Point translation = e.Delta.Translation;
\r
814 int scrollCount = (int)Math.Abs(translation.Y);
\r
815 if (scrollCount > 0)
\r
817 if (scrollCount > this.View.LineCountOnScreen) //ホイール対策
\r
818 scrollCount = this.View.LineCountOnScreen;
\r
819 if (translation.Y > 0)
\r
820 this._Controller.Scroll(ScrollDirection.Up, scrollCount, false, false);
\r
822 this._Controller.Scroll(ScrollDirection.Down, scrollCount, false, false);
\r
823 this.gripper.Enabled = false;
\r
828 int deltax = (int)Math.Abs(translation.X);
\r
831 if (translation.X < 0)
\r
832 this._Controller.Scroll(ScrollDirection.Left, deltax, false, false);
\r
834 this._Controller.Scroll(ScrollDirection.Right, deltax, false, false);
\r
835 this.gripper.Enabled = false;
\r
840 void gestureRecongnizer_ManipulationCompleted(GestureRecognizer sender, ManipulationCompletedEventArgs e)
\r
842 this.isHitCaret = false;
\r
843 this.hitedFirstGripperRect = Rectangle.Empty;
\r
844 this.hitedSecondGripperRect = Rectangle.Empty;
\r
847 async void gestureRecongnizer_RightTapped(GestureRecognizer sender, RightTappedEventArgs e)
\r
849 ResourceMap map = ResourceManager.Current.MainResourceMap.GetSubtree("FooEditEngine.Metro/Resources");
\r
850 if (this.View.HitTextArea(e.Position.X, e.Position.Y))
\r
852 FooContextMenuEventArgs args = new FooContextMenuEventArgs(e.Position);
\r
853 if (this.ContextMenuOpening != null)
\r
854 this.ContextMenuOpening(this, args);
\r
857 PopupMenu ContextMenu = new PopupMenu();
\r
858 ContextMenu.Commands.Add(new UICommand(map.GetValue("CopyMenuName").ValueAsString, (command) =>
\r
860 this.CopyCommand();
\r
862 ContextMenu.Commands.Add(new UICommand(map.GetValue("CutMenuName").ValueAsString, (command) =>
\r
866 ContextMenu.Commands.Add(new UICommand(map.GetValue("PasteMenuName").ValueAsString, async (command) =>
\r
868 await this.PasteCommand();
\r
870 if (this._Controller.RectSelection)
\r
872 ContextMenu.Commands.Add(new UICommand(map.GetValue("LineSelectMenuName").ValueAsString, (command) =>
\r
874 this._Controller.RectSelection = false;
\r
879 ContextMenu.Commands.Add(new UICommand(map.GetValue("RectSelectMenuName").ValueAsString, (command) =>
\r
881 this._Controller.RectSelection = true;
\r
884 await ContextMenu.ShowAsync(Util.GetScreentPoint(e.Position,this));
\r
889 void gestureRecongnizer_Tapped(GestureRecognizer sender, TappedEventArgs e)
\r
891 this.gripper.Enabled = e.PointerDeviceType == PointerDeviceType.Touch;
\r
892 this.JumpCaret(e.Position);
\r
895 void JumpCaret(Point p)
\r
897 if (this.Document.State == AsyncState.Loading)
\r
900 TextPoint tp = this.View.GetTextPointFromPostion(p);
\r
901 if (tp == TextPoint.Null)
\r
904 int index = this.View.LayoutLines.GetIndexFromTextPoint(tp);
\r
906 FoldingItem foldingData = this.View.HitFoldingData(p.X, tp.row);
\r
907 if (foldingData != null)
\r
909 if (foldingData.Expand)
\r
910 this.View.LayoutLines.FoldingCollection.Collapse(foldingData);
\r
912 this.View.LayoutLines.FoldingCollection.Expand(foldingData);
\r
913 this._Controller.JumpCaret(foldingData.Start, false);
\r
917 this._Controller.JumpCaret(tp.row, tp.col, false);
\r
919 if (this.peer != null)
\r
920 this.peer.OnNotifyCaretChanged();
\r
921 this.Focus(FocusState.Pointer);
\r
925 void gestureRecongnizer_Dragging(GestureRecognizer sender, DraggingEventArgs e)
\r
927 if (this.Document.State == AsyncState.Loading)
\r
929 Point p = e.Position;
\r
930 if (this.View.HitTextArea(p.X, p.Y))
\r
932 TextPoint tp = this.View.GetTextPointFromPostion(p);
\r
933 this._Controller.MoveCaretAndSelect(tp);
\r
934 if (this.peer != null)
\r
935 this.peer.OnNotifyCaretChanged();
\r
940 bool IsModiferKeyPressed(VirtualKey key)
\r
942 CoreVirtualKeyStates state = Window.Current.CoreWindow.GetKeyState(key);
\r
943 return (state & CoreVirtualKeyStates.Down) == CoreVirtualKeyStates.Down;
\r
945 void Refresh(Rectangle updateRect)
\r
947 if (this.rectangle.ActualWidth == 0 || this.rectangle.ActualHeight == 0/* || !this.Render.IsCanDraw()*/)
\r
950 this.Render.BeginDraw();
\r
951 if (this.Document.State != AsyncState.Loading)
\r
952 this.View.Draw(updateRect);
\r
954 this.Render.FillBackground(updateRect);
\r
955 this.gripper.DrawGrippers();
\r
956 this.Render.EndDraw();
\r
960 bool Resize(double width, double height)
\r
962 if (width == 0 || height == 0)
\r
963 throw new ArgumentOutOfRangeException();
\r
964 if (this.Document.State != AsyncState.Loading && this.Render.Resize(this.rectangle, width, height))
\r
966 this.View.PageBound = new Rectangle(0, 0, width, height);
\r
968 if (this.horizontalScrollBar != null)
\r
970 this.horizontalScrollBar.LargeChange = this.View.PageBound.Width;
\r
971 this.horizontalScrollBar.Maximum = this.View.LongestWidth + this.horizontalScrollBar.LargeChange + 1;
\r
973 if (this.verticalScrollBar != null)
\r
975 this.verticalScrollBar.LargeChange = this.View.LineCountOnScreen;
\r
976 this.verticalScrollBar.Maximum = this.View.LayoutLines.Count + this.verticalScrollBar.LargeChange + 1;
\r
983 void View_SrcChanged(object sender, EventArgs e)
\r
985 if (this.horizontalScrollBar == null || this.verticalScrollBar == null)
\r
987 EditView view = this.View;
\r
988 if (view.Src.Row > this.verticalScrollBar.Maximum)
\r
989 this.verticalScrollBar.Maximum = view.Src.Row + view.LineCountOnScreen + 1;
\r
990 double absoulteX = Math.Abs(view.Src.X);
\r
991 if (absoulteX > this.horizontalScrollBar.Maximum)
\r
992 this.horizontalScrollBar.Maximum = absoulteX + view.PageBound.Width + 1;
\r
993 if (view.Src.Row != this.verticalScrollBar.Value)
\r
994 this.verticalScrollBar.Value = view.Src.Row;
\r
995 if (view.Src.X != this.horizontalScrollBar.Value)
\r
996 this.horizontalScrollBar.Value = Math.Abs(view.Src.X);
\r
999 void FooTextBox_SizeChanged(object sender, SizeChangedEventArgs e)
\r
1001 if (this.Document.State == AsyncState.Loading || this.Resize(this.rectangle.ActualWidth, this.rectangle.ActualHeight))
\r
1008 void horizontalScrollBar_Scroll(object sender, ScrollEventArgs e)
\r
1010 if (this.Document.State == AsyncState.Loading)
\r
1012 if (this.horizontalScrollBar == null)
\r
1015 if (this.FlowDirection == FlowDirection.LeftToRight)
\r
1016 toX = this.horizontalScrollBar.Value;
\r
1018 toX = -this.horizontalScrollBar.Value;
\r
1019 this._Controller.Scroll(toX, this.View.Src.Row, false, false);
\r
1020 this.gripper.Enabled = false;
\r
1024 void verticalScrollBar_Scroll(object sender, ScrollEventArgs e)
\r
1026 if (this.Document.State == AsyncState.Loading)
\r
1028 if (this.verticalScrollBar == null)
\r
1030 int newRow = (int)this.verticalScrollBar.Value;
\r
1031 if (newRow >= this.View.LayoutLines.Count)
\r
1033 this._Controller.Scroll(this.View.Src.X, newRow, false, false);
\r
1034 this.gripper.Enabled = false;
\r
1038 void Document_Update(object sender, DocumentUpdateEventArgs e)
\r
1040 if (this.textStore.IsLocked() || this.Document.State == AsyncState.Loading || e.type == UpdateType.Clear)
\r
1042 if (e.removeLength == 0)
\r
1043 this.textStore.NotifyTextChanged(e.startIndex, e.startIndex, e.startIndex + e.insertLength);
\r
1045 this.textStore.NotifyTextChanged(e.startIndex, e.startIndex + 1, e.startIndex + e.insertLength - e.removeLength);
\r
1048 void Document_Progress(object sender, ProgressEventArgs e)
\r
1050 if (this.Document.State == AsyncState.Loading)
\r
1054 case ProgressState.Start:
\r
1055 this.textStore.NotifyTextChanged(0, this.Document.Length, 0);
\r
1057 case ProgressState.Complete:
\r
1058 this.textStore.NotifyTextChanged(0, 0, this.Document.Length);
\r
1059 if (this.verticalScrollBar != null)
\r
1060 this.verticalScrollBar.Maximum = this.View.LayoutLines.Count;
\r
1065 void FooTextBox_Loaded(object sender, RoutedEventArgs e)
\r
1067 this.Focus(FocusState.Programmatic);
\r
1071 public static void OnPropertyChanged(object sender, DependencyPropertyChangedEventArgs e)
\r
1073 FooTextBox source = (FooTextBox)sender;
\r
1074 if (e.Property.Equals(InsertModeProperty))
\r
1075 source.View.InsertMode = source.InsertMode;
\r
1076 if (e.Property.Equals(TabCharsProperty))
\r
1077 source.View.TabStops = source.TabChars;
\r
1078 if (e.Property.Equals(RectSelectModeProperty))
\r
1079 source._Controller.RectSelection = source.RectSelectMode;
\r
1080 if (e.Property.Equals(DrawCaretProperty))
\r
1081 source.View.HideCaret = !source.DrawCaret;
\r
1082 if (e.Property.Equals(DrawCaretLineProperty))
\r
1083 source.View.HideLineMarker = !source.DrawCaretLine;
\r
1084 if (e.Property.Equals(DrawLineNumberProperty))
\r
1086 source.View.DrawLineNumber = source.DrawLineNumber;
\r
1087 source._Controller.JumpCaret(source.View.CaretPostion.row, source.View.CaretPostion.col);
\r
1089 if(e.Property.Equals(MagnificationPowerPropertyKey))
\r
1090 source.Render.FontSize = source.FontSize * source.MagnificationPower;
\r
1091 if (e.Property.Equals(FontFamilyProperty))
\r
1092 source.Render.FontFamily = source.FontFamily;
\r
1093 if (e.Property.Equals(FontStyleProperty))
\r
1094 source.Render.FontStyle = source.FontStyle;
\r
1095 if (e.Property.Equals(FontWeightProperty))
\r
1096 source.Render.FontWeigth = source.FontWeight;
\r
1097 if (e.Property.Equals(FontSizeProperty))
\r
1098 source.Render.FontSize = source.FontSize;
\r
1099 if (e.Property.Equals(ForegroundProperty))
\r
1100 source.Render.Foreground = source.Foreground;
\r
1101 if (e.Property.Equals(BackgroundProperty))
\r
1102 source.Render.Background = source.Background;
\r
1103 if (e.Property.Equals(ControlCharProperty))
\r
1104 source.Render.ControlChar = source.ControlChar;
\r
1105 if (e.Property.Equals(HilightProperty))
\r
1106 source.Render.Hilight = source.Hilight;
\r
1107 if (e.Property.Equals(Keyword1Property))
\r
1108 source.Render.Keyword1 = source.Keyword1;
\r
1109 if (e.Property.Equals(Keyword2Property))
\r
1110 source.Render.Keyword2 = source.Keyword2;
\r
1111 if (e.Property.Equals(CommentProperty))
\r
1112 source.Render.Comment = source.Comment;
\r
1113 if (e.Property.Equals(LiteralProperty))
\r
1114 source.Render.Literal = source.Literal;
\r
1115 if (e.Property.Equals(URLProperty))
\r
1116 source.Render.Url = source.URL;
\r
1117 if (e.Property.Equals(InsertCaretProperty))
\r
1118 source.Render.InsertCaret = source.InsertCaret;
\r
1119 if (e.Property.Equals(OverwriteCaretProperty))
\r
1120 source.Render.OverwriteCaret = source.OverwriteCaret;
\r
1121 if (e.Property.Equals(LineMarkerProperty))
\r
1122 source.Render.LineMarker = source.LineMarker;
\r
1123 if (e.Property.Equals(MarkURLProperty))
\r
1124 source.View.UrlMark = source.MarkURL;
\r
1125 if (e.Property.Equals(ShowFullSpaceProperty))
\r
1126 source.Render.ShowFullSpace = source.ShowFullSpace;
\r
1127 if (e.Property.Equals(ShowHalfSpaceProperty))
\r
1128 source.Render.ShowHalfSpace = source.ShowHalfSpace;
\r
1129 if (e.Property.Equals(ShowTabProperty))
\r
1130 source.Render.ShowTab = source.ShowTab;
\r
1131 if (e.Property.Equals(LineBreakProperty))
\r
1132 source.View.LineBreak = source.LineBreakMethod;
\r
1133 if (e.Property.Equals(LineBreakCharCountProperty))
\r
1134 source.View.LineBreakCharCount = source.LineBreakCharCount;
\r
1135 if (e.Property.Equals(FlowDirectionProperty))
\r
1137 source.Render.RightToLeft = source.FlowDirection == Windows.UI.Xaml.FlowDirection.RightToLeft;
\r
1138 if(source.horizontalScrollBar != null)
\r
1139 source.horizontalScrollBar.FlowDirection = source.FlowDirection;
\r
1141 if (e.Property.Equals(DrawRulerProperty))
\r
1143 source.View.HideRuler = !source.DrawRuler;
\r
1144 source._Controller.JumpCaret(source.View.CaretPostion.row, source.View.CaretPostion.col);
\r
1152 /// コンテキストメニューが表示されるときに呼び出されます
\r
1154 public event EventHandler<FooContextMenuEventArgs> ContextMenuOpening;
\r
1160 internal Controller Controller
\r
1164 return this._Controller;
\r
1169 /// 文字列の描写に使用されるアンチエイリアシング モードを表します
\r
1171 public TextAntialiasMode TextAntialiasMode
\r
1175 return this.Render.TextAntialiasMode;
\r
1179 this.Render.TextAntialiasMode = value;
\r
1184 /// シンタックスハイライターを表す
\r
1186 public IHilighter Hilighter
\r
1190 return this.View.Hilighter;
\r
1194 this.View.Hilighter = value;
\r
1195 this.View.LayoutLines.ClearLayoutCache();
\r
1200 /// フォールティングを作成するインターフェイスを表す
\r
1202 public IFoldingStrategy FoldingStrategy
\r
1206 return this.View.LayoutLines.FoldingStrategy;
\r
1210 this.View.LayoutLines.FoldingStrategy = value;
\r
1211 if (value == null)
\r
1212 this.View.LayoutLines.FoldingCollection.Clear();
\r
1219 public Document Document
\r
1228 public LineToIndexTable LayoutLineCollection
\r
1230 get { return this.View.LayoutLines; }
\r
1236 public string SelectedText
\r
1240 return this._Controller.SelectedText;
\r
1244 int oldLength = this.Document.Length;
\r
1245 this._Controller.SelectedText = value;
\r
1252 /// <remarks>SelectionLengthが0の場合はキャレット位置を表します</remarks>
\r
1253 public int SelectionStart
\r
1255 get { return this._Controller.SelectionStart; }
\r
1261 /// <remarks>矩形選択モードの場合、選択範囲の文字数ではなく、開始位置から終了位置までの長さとなります</remarks>
\r
1262 public int SelectionLength
\r
1264 get { return this._Controller.SelectionLength; }
\r
1270 public double MagnificationPower
\r
1272 get { return (double)GetValue(MagnificationPowerPropertyKey); }
\r
1273 set { SetValue(MagnificationPowerPropertyKey, value); }
\r
1279 public static readonly DependencyProperty MagnificationPowerPropertyKey =
\r
1280 DependencyProperty.Register("MagnificationPower", typeof(double), typeof(FooTextBox), new PropertyMetadata(1.0, OnPropertyChanged));
\r
1283 /// キャレット位置を表す。このプロパティは変更しても値が反映されません
\r
1285 public TextPoint CaretPostion
\r
1287 get { return (TextPoint)GetValue(CaretPostionPropertyKey); }
\r
1288 set { SetValue(CaretPostionPropertyKey, value); }
\r
1291 static readonly DependencyProperty CaretPostionPropertyKey =
\r
1292 DependencyProperty.Register("CaretPostion", typeof(TextPoint), typeof(FooTextBox), new PropertyMetadata(new TextPoint(), OnPropertyChanged));
\r
1297 public new FlowDirection FlowDirection
\r
1299 get { return (FlowDirection)GetValue(FlowDirectionProperty); }
\r
1300 set { SetValue(FlowDirectionProperty, value); }
\r
1304 /// レタリング方向を表す。これは依存プロパティです
\r
1306 public new static readonly DependencyProperty FlowDirectionProperty =
\r
1307 DependencyProperty.Register("FlowDirection", typeof(FlowDirection), typeof(FooTextBox), new PropertyMetadata(FlowDirection.LeftToRight,OnPropertyChanged));
\r
1312 public new FontFamily FontFamily
\r
1314 get { return (FontFamily)GetValue(FontFamilyProperty); }
\r
1315 set { SetValue(FontFamilyProperty, value); }
\r
1319 /// FontFamilyの依存プロパティを表す
\r
1321 public new static readonly DependencyProperty FontFamilyProperty =
\r
1322 DependencyProperty.Register("FontFamily", typeof(FontFamily), typeof(FooTextBox), new PropertyMetadata(new FontFamily("Cambria"), OnPropertyChanged));
\r
1327 public new double FontSize
\r
1329 get { return (double)GetValue(FontSizeProperty); }
\r
1330 set { SetValue(FontSizeProperty, value); }
\r
1334 /// FontSizeの依存プロパティを表す
\r
1336 public new static readonly DependencyProperty FontSizeProperty =
\r
1337 DependencyProperty.Register("FontSize", typeof(double), typeof(FooTextBox), new PropertyMetadata(12.0,OnPropertyChanged));
\r
1342 public new FontStyle FontStyle
\r
1344 get { return (FontStyle)GetValue(FontStyleProperty); }
\r
1345 set { SetValue(FontStyleProperty, value); }
\r
1349 /// FontStyleの依存プロパティを表す
\r
1351 public new static readonly DependencyProperty FontStyleProperty =
\r
1352 DependencyProperty.Register("FontStyle", typeof(FontStyle), typeof(FooTextBox), new PropertyMetadata(FontStyle.Normal,OnPropertyChanged));
\r
1357 public new FontWeight FontWeight
\r
1359 get { return (FontWeight)GetValue(FontWeightProperty); }
\r
1360 set { SetValue(FontWeightProperty, value); }
\r
1364 /// FontWeigthの依存プロパティを表す
\r
1366 public new static readonly DependencyProperty FontWeightProperty =
\r
1367 DependencyProperty.Register("FontWeigth", typeof(FontWeight), typeof(FooTextBox), new PropertyMetadata(FontWeights.Normal,OnPropertyChanged));
\r
1370 /// デフォルトの文字色を表す。これは依存プロパティです
\r
1372 public new Windows.UI.Color Foreground
\r
1374 get { return (Windows.UI.Color)GetValue(ForegroundProperty); }
\r
1375 set { SetValue(ForegroundProperty, value); }
\r
1379 /// Foregroundの依存プロパティを表す
\r
1381 public new static readonly DependencyProperty ForegroundProperty =
\r
1382 DependencyProperty.Register("Foreground", typeof(Windows.UI.Color), typeof(FooTextBox), new PropertyMetadata(Colors.Black, OnPropertyChanged));
\r
1385 /// 背景色を表す。これは依存プロパティです
\r
1387 public new Windows.UI.Color Background
\r
1389 get { return (Windows.UI.Color)GetValue(BackgroundProperty); }
\r
1390 set { SetValue(BackgroundProperty, value); }
\r
1394 /// Backgroundの依存プロパティを表す
\r
1396 public new static readonly DependencyProperty BackgroundProperty =
\r
1397 DependencyProperty.Register("Background", typeof(Windows.UI.Color), typeof(FooTextBox), new PropertyMetadata(Colors.White, OnPropertyChanged));
\r
1400 /// コントロールコードの文字色を表す。これは依存プロパティです
\r
1402 public Windows.UI.Color ControlChar
\r
1404 get { return (Windows.UI.Color)GetValue(ControlCharProperty); }
\r
1405 set { SetValue(ControlCharProperty, value); }
\r
1409 /// ControlCharの依存プロパティを表す
\r
1411 public static readonly DependencyProperty ControlCharProperty =
\r
1412 DependencyProperty.Register("ControlChar", typeof(Windows.UI.Color), typeof(FooTextBox), new PropertyMetadata(Colors.Gray, OnPropertyChanged));
\r
1415 /// 選択時の背景色を表す。これは依存プロパティです
\r
1417 public Windows.UI.Color Hilight
\r
1419 get { return (Windows.UI.Color)GetValue(HilightProperty); }
\r
1420 set { SetValue(HilightProperty, value); }
\r
1424 /// Hilightの依存プロパティを表す
\r
1426 public static readonly DependencyProperty HilightProperty =
\r
1427 DependencyProperty.Register("Hilight", typeof(Windows.UI.Color), typeof(FooTextBox), new PropertyMetadata(Colors.Blue, OnPropertyChanged));
\r
1430 /// キーワード1の文字色を表す。これは依存プロパティです
\r
1432 public Windows.UI.Color Keyword1
\r
1434 get { return (Windows.UI.Color)GetValue(Keyword1Property); }
\r
1435 set { SetValue(Keyword1Property, value); }
\r
1439 /// Keyword1の依存プロパティを表す
\r
1441 public static readonly DependencyProperty Keyword1Property =
\r
1442 DependencyProperty.Register("Keyword1", typeof(Windows.UI.Color), typeof(FooTextBox), new PropertyMetadata(Colors.Blue, OnPropertyChanged));
\r
1445 /// キーワード2の文字色を表す。これは依存プロパティです
\r
1447 public Windows.UI.Color Keyword2
\r
1449 get { return (Windows.UI.Color)GetValue(Keyword2Property); }
\r
1450 set { SetValue(Keyword2Property, value); }
\r
1454 /// Keyword2の依存プロパティを表す
\r
1456 public static readonly DependencyProperty Keyword2Property =
\r
1457 DependencyProperty.Register("Keyword2", typeof(Windows.UI.Color), typeof(FooTextBox), new PropertyMetadata(Colors.DarkCyan, OnPropertyChanged));
\r
1460 /// コメントの文字色を表す。これは依存プロパティです
\r
1462 public Windows.UI.Color Comment
\r
1464 get { return (Windows.UI.Color)GetValue(CommentProperty); }
\r
1465 set { SetValue(CommentProperty, value); }
\r
1469 /// Commentの依存プロパティを表す
\r
1471 public static readonly DependencyProperty CommentProperty =
\r
1472 DependencyProperty.Register("Comment", typeof(Windows.UI.Color), typeof(FooTextBox), new PropertyMetadata(Colors.Green, OnPropertyChanged));
\r
1475 /// 文字リテラルの文字色を表す。これは依存プロパティです
\r
1477 public Windows.UI.Color Literal
\r
1479 get { return (Windows.UI.Color)GetValue(LiteralProperty); }
\r
1480 set { SetValue(LiteralProperty, value); }
\r
1484 /// Literalの依存プロパティを表す
\r
1486 public static readonly DependencyProperty LiteralProperty =
\r
1487 DependencyProperty.Register("Literal", typeof(Windows.UI.Color), typeof(FooTextBox), new PropertyMetadata(Colors.Brown, OnPropertyChanged));
\r
1490 /// URLの文字色を表す。これは依存プロパティです
\r
1492 public Windows.UI.Color URL
\r
1494 get { return (Windows.UI.Color)GetValue(URLProperty); }
\r
1495 set { SetValue(URLProperty, value); }
\r
1499 /// URLの依存プロパティを表す
\r
1501 public static readonly DependencyProperty URLProperty =
\r
1502 DependencyProperty.Register("URL", typeof(Windows.UI.Color), typeof(FooTextBox), new PropertyMetadata(Colors.Blue, OnPropertyChanged));
\r
1508 public Windows.UI.Color LineMarker
\r
1510 get { return (Windows.UI.Color)GetValue(LineMarkerProperty); }
\r
1511 set { SetValue(LineMarkerProperty, value); }
\r
1515 /// LineMarkerの依存プロパティを表す
\r
1517 public static readonly DependencyProperty LineMarkerProperty =
\r
1518 DependencyProperty.Register("LineMarker", typeof(Windows.UI.Color), typeof(FooTextBox), new PropertyMetadata(Colors.Gray, OnPropertyChanged));
\r
1521 /// 挿入モード時のキャレットの色を表す
\r
1523 public Windows.UI.Color InsertCaret
\r
1525 get { return (Windows.UI.Color)GetValue(InsertCaretProperty); }
\r
1526 set { SetValue(InsertCaretProperty, value); }
\r
1530 /// InsertCaretの依存プロパティを表す
\r
1532 public static readonly DependencyProperty InsertCaretProperty =
\r
1533 DependencyProperty.Register("InsertCaret", typeof(Windows.UI.Color), typeof(FooTextBox), new PropertyMetadata(Colors.Black, OnPropertyChanged));
\r
1536 /// 上書きモード時のキャレット職を表す
\r
1538 public Windows.UI.Color OverwriteCaret
\r
1540 get { return (Windows.UI.Color)GetValue(OverwriteCaretProperty); }
\r
1541 set { SetValue(OverwriteCaretProperty, value); }
\r
1545 /// OverwriteCaretの依存プロパティを表す
\r
1547 public static readonly DependencyProperty OverwriteCaretProperty =
\r
1548 DependencyProperty.Register("OverwriteCaret", typeof(Windows.UI.Color), typeof(FooTextBox), new PropertyMetadata(Colors.Black, OnPropertyChanged));
\r
1551 /// 挿入モードなら真を返し、そうでないなら、偽を返す。これは依存プロパティです
\r
1553 public bool InsertMode
\r
1555 get { return (bool)GetValue(InsertModeProperty); }
\r
1556 set { SetValue(InsertModeProperty, value); }
\r
1560 /// InsertModeの依存プロパティを表す
\r
1562 public static readonly DependencyProperty InsertModeProperty =
\r
1563 DependencyProperty.Register("InsertMode",
\r
1565 typeof(FooTextBox),
\r
1566 new PropertyMetadata(true, OnPropertyChanged));
\r
1569 /// タブの文字数を表す。これは依存プロパティです
\r
1571 public int TabChars
\r
1573 get { return (int)GetValue(TabCharsProperty); }
\r
1574 set { SetValue(TabCharsProperty, value); }
\r
1578 /// TabCharsの依存プロパティを表す
\r
1580 public static readonly DependencyProperty TabCharsProperty =
\r
1581 DependencyProperty.Register("TabChars",
\r
1583 typeof(FooTextBox),
\r
1584 new PropertyMetadata(4, OnPropertyChanged));
\r
1587 /// 矩形選択モードなら真を返し、そうでないなら偽を返す。これは依存プロパティです
\r
1589 public bool RectSelectMode
\r
1591 get { return (bool)GetValue(RectSelectModeProperty); }
\r
1592 set { SetValue(RectSelectModeProperty, value); }
\r
1596 /// RectSelectModeの依存プロパティを表す
\r
1598 public static readonly DependencyProperty RectSelectModeProperty =
\r
1599 DependencyProperty.Register("RectSelectMode", typeof(bool), typeof(FooTextBox), new PropertyMetadata(false, OnPropertyChanged));
\r
1605 /// 変更した場合、レイアウトの再構築を行う必要があります
\r
1607 public LineBreakMethod LineBreakMethod
\r
1609 get { return (LineBreakMethod)GetValue(LineBreakProperty); }
\r
1610 set { SetValue(LineBreakProperty, value); }
\r
1614 /// LineBreakMethodの依存プロパティを表す
\r
1616 public static readonly DependencyProperty LineBreakProperty =
\r
1617 DependencyProperty.Register("LineBreakMethod", typeof(LineBreakMethod), typeof(FooTextBox), new PropertyMetadata(LineBreakMethod.None, OnPropertyChanged));
\r
1621 /// 折り返しの幅を指定する。LineBreakMethod.CharUnit以外の時は無視されます
\r
1624 /// 変更した場合、レイアウトの再構築を行う必要があります
\r
1626 public int LineBreakCharCount
\r
1628 get { return (int)GetValue(LineBreakCharCountProperty); }
\r
1629 set { SetValue(LineBreakCharCountProperty, value); }
\r
1633 /// LineBreakCharCountの依存プロパティを表す
\r
1635 public static readonly DependencyProperty LineBreakCharCountProperty =
\r
1636 DependencyProperty.Register("LineBreakCharCount", typeof(int), typeof(FooTextBox), new PropertyMetadata(80));
\r
1639 /// キャレットを描くなら真。そうでないなら偽を返す。これは依存プロパティです
\r
1641 public bool DrawCaret
\r
1643 get { return (bool)GetValue(DrawCaretProperty); }
\r
1644 set { SetValue(DrawCaretProperty, value); }
\r
1648 /// DrawCaretの依存プロパティを表す
\r
1650 public static readonly DependencyProperty DrawCaretProperty =
\r
1651 DependencyProperty.Register("DrawCaret", typeof(bool), typeof(FooTextBox), new PropertyMetadata(true, OnPropertyChanged));
\r
1655 /// キャレットラインを描くなら真。そうでないなら偽を返す。これは依存プロパティです
\r
1657 public bool DrawCaretLine
\r
1659 get { return (bool)GetValue(DrawCaretLineProperty); }
\r
1660 set { SetValue(DrawCaretLineProperty, value); }
\r
1664 /// DrawCaretLineの依存プロパティを表す
\r
1666 public static readonly DependencyProperty DrawCaretLineProperty =
\r
1667 DependencyProperty.Register("DrawCaretLine", typeof(bool), typeof(FooTextBox), new PropertyMetadata(true, OnPropertyChanged));
\r
1670 /// 行番号を描くなら真。そうでなければ偽。これは依存プロパティです
\r
1672 public bool DrawLineNumber
\r
1674 get { return (bool)GetValue(DrawLineNumberProperty); }
\r
1675 set { SetValue(DrawLineNumberProperty, value); }
\r
1679 /// ルーラーを描くなら真。そうでなければ偽。これは依存プロパティです
\r
1681 public bool DrawRuler
\r
1683 get { return (bool)GetValue(DrawRulerProperty); }
\r
1684 set { SetValue(DrawRulerProperty, value); }
\r
1688 /// DrawRulerの依存プロパティを表す
\r
1690 public static readonly DependencyProperty DrawRulerProperty =
\r
1691 DependencyProperty.Register("DrawRuler", typeof(bool), typeof(FooTextBox), new PropertyMetadata(false, OnPropertyChanged));
\r
1695 /// DrawLineNumberの依存プロパティを表す
\r
1697 public static readonly DependencyProperty DrawLineNumberProperty =
\r
1698 DependencyProperty.Register("DrawLineNumber", typeof(bool), typeof(FooTextBox), new PropertyMetadata(false, OnPropertyChanged));
\r
1701 /// URLに下線を引くなら真。そうでないなら偽を表す。これは依存プロパティです
\r
1703 public bool MarkURL
\r
1705 get { return (bool)GetValue(MarkURLProperty); }
\r
1706 set { SetValue(MarkURLProperty, value); }
\r
1710 /// MarkURLの依存プロパティを表す
\r
1712 public static readonly DependencyProperty MarkURLProperty =
\r
1713 DependencyProperty.Register("MarkURL", typeof(bool), typeof(FooTextBox), new PropertyMetadata(true, OnPropertyChanged));
\r
1716 /// 全角スペースを表示するなら真。そうでないなら偽
\r
1718 public bool ShowFullSpace
\r
1720 get { return (bool)GetValue(ShowFullSpaceProperty); }
\r
1721 set { SetValue(ShowFullSpaceProperty, value); }
\r
1725 /// ShowFullSpaceの依存プロパティを表す
\r
1727 public static readonly DependencyProperty ShowFullSpaceProperty =
\r
1728 DependencyProperty.Register("ShowFullSpace", typeof(bool), typeof(FooTextBox), new PropertyMetadata(false, OnPropertyChanged));
\r
1731 /// 半角スペースを表示するなら真。そうでないなら偽
\r
1733 public bool ShowHalfSpace
\r
1735 get { return (bool)GetValue(ShowHalfSpaceProperty); }
\r
1736 set { SetValue(ShowHalfSpaceProperty, value); }
\r
1740 /// ShowHalfSpaceの依存プロパティを表す
\r
1742 public static readonly DependencyProperty ShowHalfSpaceProperty =
\r
1743 DependencyProperty.Register("ShowHalfSpace", typeof(bool), typeof(FooTextBox), new PropertyMetadata(false, OnPropertyChanged));
\r
1746 /// タブを表示するなら真。そうでないなら偽
\r
1748 public bool ShowTab
\r
1750 get { return (bool)GetValue(ShowTabProperty); }
\r
1751 set { SetValue(ShowTabProperty, value); }
\r
1755 /// ShowTabの依存プロパティを表す
\r
1757 public static readonly DependencyProperty ShowTabProperty =
\r
1758 DependencyProperty.Register("ShowTab", typeof(bool), typeof(FooTextBox), new PropertyMetadata(false, OnPropertyChanged));
\r
1763 /// コンテキストメニューのイベントデーターを表す
\r
1765 public class FooContextMenuEventArgs
\r
1767 public bool Handled = false;
\r
1768 public Windows.Foundation.Point Postion;
\r
1769 public FooContextMenuEventArgs(Windows.Foundation.Point pos)
\r
1771 this.Postion = pos;
\r