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.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 this._Controller.MoveCaretVertical(-1, isShiftPressed);
\r
418 isMovedCaret = true;
\r
420 case VirtualKey.Down:
\r
421 this._Controller.MoveCaretVertical(+1, isShiftPressed);
\r
424 isMovedCaret = true;
\r
426 case VirtualKey.Left:
\r
427 this._Controller.MoveCaretHorizontical(-1, isShiftPressed, isControlPressed);
\r
430 isMovedCaret = true;
\r
432 case VirtualKey.Right:
\r
433 this._Controller.MoveCaretHorizontical(1, isShiftPressed, isControlPressed);
\r
436 isMovedCaret = true;
\r
438 case VirtualKey.PageUp:
\r
439 this._Controller.Scroll(ScrollDirection.Up, this.View.LineCountOnScreen, isShiftPressed, true);
\r
441 isMovedCaret = true;
\r
443 case VirtualKey.PageDown:
\r
444 this._Controller.Scroll(ScrollDirection.Down, this.View.LineCountOnScreen, isShiftPressed, true);
\r
446 isMovedCaret = true;
\r
448 case VirtualKey.Home:
\r
449 if (isControlPressed)
\r
450 this._Controller.JumpToHead(isShiftPressed);
\r
452 this._Controller.JumpCaret(this.View.CaretPostion.row, 0);
\r
454 isMovedCaret = true;
\r
456 case VirtualKey.End:
\r
457 if (isControlPressed)
\r
458 this._Controller.JumpToEnd(isShiftPressed);
\r
460 this._Controller.JumpCaret(this.View.CaretPostion.row, this.View.LayoutLines[this.View.CaretPostion.row].Length - 1);
\r
462 isMovedCaret = true;
\r
464 case VirtualKey.Tab:
\r
465 if (!isControlPressed)
\r
467 if (this._Controller.SelectionLength == 0)
\r
468 this._Controller.DoInputChar('\t');
\r
469 else if (isShiftPressed)
\r
470 this._Controller.DownIndent();
\r
472 this._Controller.UpIndent();
\r
477 case VirtualKey.Enter:
\r
478 this._Controller.DoEnterAction();
\r
482 case VirtualKey.Insert:
\r
483 if(this.View.InsertMode)
\r
484 this.View.InsertMode = false;
\r
486 this.View.InsertMode = true;
\r
491 if (isControlPressed)
\r
499 if (isControlPressed)
\r
501 if (this._Controller.RectSelection)
\r
502 this._Controller.RectSelection = false;
\r
504 this._Controller.RectSelection = true;
\r
510 if (isControlPressed)
\r
512 this.CopyCommand();
\r
517 if (isControlPressed)
\r
524 if (isControlPressed)
\r
526 await this.PasteCommand();
\r
531 if (isControlPressed)
\r
533 this.Document.UndoManager.redo();
\r
539 if (isControlPressed)
\r
541 this.Document.UndoManager.undo();
\r
546 case VirtualKey.Back:
\r
547 this._Controller.DoBackSpaceAction();
\r
551 case VirtualKey.Delete:
\r
552 this._Controller.DoDeleteAction();
\r
557 if (isMovedCaret && this.peer != null)
\r
558 this.peer.OnNotifyCaretChanged();
\r
563 protected override void OnPointerPressed(PointerRoutedEventArgs e)
\r
565 this.CapturePointer(e.Pointer);
\r
566 this.gestureRecongnizer.ProcessDownEvent(e.GetCurrentPoint(this));
\r
571 protected override void OnPointerMoved(PointerRoutedEventArgs e)
\r
573 this.gestureRecongnizer.ProcessMoveEvents(e.GetIntermediatePoints(this));
\r
576 if (e.Pointer.PointerDeviceType == PointerDeviceType.Mouse && this.Document.State != AsyncState.Loading)
\r
578 Point p = e.GetCurrentPoint(this).Position;
\r
579 if (this.View.HitTextArea(p.X, p.Y))
\r
581 TextPoint tp = this.View.GetTextPointFromPostion(p);
\r
582 if (this._Controller.IsMarker(tp, HilightType.Url))
\r
583 Window.Current.CoreWindow.PointerCursor = new CoreCursor(CoreCursorType.Hand, 101);
\r
585 Window.Current.CoreWindow.PointerCursor = new CoreCursor(CoreCursorType.IBeam, 101);
\r
589 Window.Current.CoreWindow.PointerCursor = new CoreCursor(CoreCursorType.Arrow, 101);
\r
595 protected override void OnPointerReleased(PointerRoutedEventArgs e)
\r
597 this.gestureRecongnizer.ProcessUpEvent(e.GetCurrentPoint(this));
\r
598 this.ReleasePointerCapture(e.Pointer);
\r
603 protected override void OnPointerCanceled(PointerRoutedEventArgs e)
\r
605 this.gestureRecongnizer.CompleteGesture();
\r
606 this.ReleasePointerCapture(e.Pointer);
\r
611 protected override void OnPointerCaptureLost(PointerRoutedEventArgs e)
\r
613 this.gestureRecongnizer.CompleteGesture();
\r
614 this.ReleasePointerCapture(e.Pointer);
\r
619 protected override void OnPointerWheelChanged(PointerRoutedEventArgs e)
\r
621 bool shift = (e.KeyModifiers & Windows.System.VirtualKeyModifiers.Shift) ==
\r
622 Windows.System.VirtualKeyModifiers.Shift;
\r
623 bool ctrl = (e.KeyModifiers & Windows.System.VirtualKeyModifiers.Control) ==
\r
624 Windows.System.VirtualKeyModifiers.Control;
\r
625 this.gestureRecongnizer.ProcessMouseWheelEvent(e.GetCurrentPoint(this), shift, ctrl);
\r
629 void CoreWindow_CharacterReceived(CoreWindow sender, CharacterReceivedEventArgs args)
\r
631 if (this.FocusState == FocusState.Unfocused || this.Document.State == AsyncState.Loading)
\r
633 if (args.KeyCode >= 00 && args.KeyCode <= 0x1f)
\r
635 this._Controller.DoInputString(Char.ConvertFromUtf32((int)args.KeyCode));
\r
639 bool textStore_IsReadOnly()
\r
644 bool textStore_IsLoading()
\r
646 return this.Document.State == AsyncState.Loading;
\r
649 void textStore_CompositionEnded()
\r
651 TextStoreHelper.EndCompostion(this.Document);
\r
655 void textStore_CompositionUpdated(int start, int end)
\r
657 if (TextStoreHelper.ScrollToCompstionUpdated(this.textStore, this.View, start, end))
\r
660 bool textStore_CompositionStarted()
\r
662 return TextStoreHelper.StartCompstion(this.Document);
\r
665 string _textStore_GetString(int start, int length)
\r
667 return this.Document.ToString(start, length);
\r
670 void _textStore_GetStringExtent(
\r
673 out POINT o_topLeft,
\r
674 out POINT o_bottomRight
\r
677 Point startPos, endPos;
\r
678 TextStoreHelper.GetStringExtent(this.Document, this.View, i_startIndex, i_endIndex, out startPos, out endPos);
\r
680 var gt = this.TransformToVisual(Window.Current.Content);
\r
681 startPos = gt.TransformPoint(startPos);
\r
682 endPos = gt.TransformPoint(endPos);
\r
684 o_topLeft = new POINT((int)startPos.X, (int)startPos.Y);
\r
685 o_bottomRight = new POINT((int)endPos.X, (int)endPos.Y);
\r
688 void _textStore_GetScreenExtent(out POINT o_topLeft, out POINT o_bottomRight)
\r
690 var pointTopLeft = new Point(0, 0);
\r
691 var pointBottomRight = new Point(this.RenderSize.Width, this.RenderSize.Height);
\r
693 var gt = this.TransformToVisual(Window.Current.Content);
\r
694 pointTopLeft = gt.TransformPoint(pointTopLeft);
\r
695 pointBottomRight = gt.TransformPoint(pointBottomRight);
\r
697 o_topLeft = new POINT((int)pointTopLeft.X, (int)pointTopLeft.Y);
\r
698 o_bottomRight = new POINT((int)pointBottomRight.X, (int)pointBottomRight.Y);
\r
701 void _textStore_GetSelectionIndex(out int o_startIndex, out int o_endIndex)
\r
703 TextStoreHelper.GetSelection(this._Controller, this.View.Selections, out o_startIndex, out o_endIndex);
\r
706 void _textStore_SetSelectionIndex(int i_startIndex, int i_endIndex)
\r
708 if (this.Document.State == AsyncState.Loading)
\r
710 TextStoreHelper.SetSelectionIndex(this._Controller, this.View, i_startIndex, i_endIndex);
\r
714 void _textStore_InsertAtSelection(string i_value)
\r
716 TextStoreHelper.InsertTextAtSelection(this._Controller, i_value);
\r
720 void Controller_CaretMoved(object sender, EventArgs e)
\r
722 SetValue(CaretPostionPropertyKey, this.View.CaretPostion);
\r
723 if (this.textStore.IsLocked() == false)
\r
724 this.textStore.NotifySelectionChanged();
\r
728 Rectangle hitedSecondGripperRect = Rectangle.Empty,hitedFirstGripperRect = Rectangle.Empty;
\r
729 void gestureRecongnizer_ManipulationStarted(GestureRecognizer sender, ManipulationStartedEventArgs e)
\r
731 if (this.Document.State == AsyncState.Loading)
\r
733 TextPoint tp = this.View.GetTextPointFromPostion(e.Position);
\r
734 if (tp == this.View.CaretPostion)
\r
736 this.isHitCaret = true;
\r
737 this.hitedSecondGripperRect = Rectangle.Empty;
\r
739 Rectangle gripperRect = this.gripper.HitTest(GripperType.Second,e.Position);
\r
740 if (gripperRect != Rectangle.Empty)
\r
742 this.isHitCaret = true;
\r
743 this.hitedSecondGripperRect = gripperRect;
\r
745 gripperRect = this.gripper.HitTest(GripperType.First,e.Position);
\r
746 if (gripperRect != Rectangle.Empty)
\r
748 this.isHitCaret = true;
\r
749 this.hitedFirstGripperRect = gripperRect;
\r
753 void gestureRecongnizer_ManipulationUpdated(GestureRecognizer sender, ManipulationUpdatedEventArgs e)
\r
755 if (this.Document.State == AsyncState.Loading)
\r
757 if (this.isHitCaret)
\r
759 Point p = e.Position;
\r
760 if (this.hitedFirstGripperRect != Rectangle.Empty)
\r
761 p = this.gripper.GetPointOnGripper(GripperType.First,this.hitedFirstGripperRect, p);
\r
762 else if (this.hitedSecondGripperRect != Rectangle.Empty)
\r
763 p = this.gripper.GetPointOnGripper(GripperType.Second,this.hitedSecondGripperRect, p);
\r
764 if (this.View.HitTextArea(p.X, p.Y))
\r
766 TextPoint tp = this.View.GetTextPointFromPostion(p);
\r
767 if (this._Controller.IsReverseSelect())
\r
769 if (this.hitedFirstGripperRect == this.hitedSecondGripperRect)
\r
770 this._Controller.MoveCaretAndSelect(tp);
\r
771 else if (this.hitedSecondGripperRect != Rectangle.Empty)
\r
772 this._Controller.MoveSelectBefore(tp);
\r
774 this._Controller.MoveCaretAndSelect(tp);
\r
778 if(this.hitedFirstGripperRect == this.hitedSecondGripperRect)
\r
779 this._Controller.MoveCaretAndSelect(tp);
\r
780 else if (this.hitedFirstGripperRect != Rectangle.Empty)
\r
781 this._Controller.MoveSelectBefore(tp);
\r
783 this._Controller.MoveCaretAndSelect(tp);
\r
785 if (this.peer != null)
\r
786 this.peer.OnNotifyCaretChanged();
\r
791 if (e.Delta.Scale < 1)
\r
793 double newSize = this.Render.FontSize - 1;
\r
796 this.Render.FontSize = newSize;
\r
798 SetValue(MagnificationPowerPropertyKey, this.Render.FontSize / this.FontSize);
\r
802 if (e.Delta.Scale > 1)
\r
804 double newSize = this.Render.FontSize + 1;
\r
807 this.Render.FontSize = newSize;
\r
809 SetValue(MagnificationPowerPropertyKey, this.Render.FontSize / this.FontSize);
\r
813 Point translation = e.Delta.Translation;
\r
815 int scrollCount = (int)Math.Abs(translation.Y);
\r
816 if (scrollCount > 0)
\r
818 if (scrollCount > this.View.LineCountOnScreen) //ホイール対策
\r
819 scrollCount = this.View.LineCountOnScreen;
\r
820 if (translation.Y > 0)
\r
821 this._Controller.Scroll(ScrollDirection.Up, scrollCount, false, false);
\r
823 this._Controller.Scroll(ScrollDirection.Down, scrollCount, false, false);
\r
824 this.gripper.Enabled = false;
\r
829 int deltax = (int)Math.Abs(translation.X);
\r
832 if (translation.X < 0)
\r
833 this._Controller.Scroll(ScrollDirection.Left, deltax, false, false);
\r
835 this._Controller.Scroll(ScrollDirection.Right, deltax, false, false);
\r
836 this.gripper.Enabled = false;
\r
841 void gestureRecongnizer_ManipulationCompleted(GestureRecognizer sender, ManipulationCompletedEventArgs e)
\r
843 this.isHitCaret = false;
\r
844 this.hitedFirstGripperRect = Rectangle.Empty;
\r
845 this.hitedSecondGripperRect = Rectangle.Empty;
\r
848 async void gestureRecongnizer_RightTapped(GestureRecognizer sender, RightTappedEventArgs e)
\r
850 ResourceMap map = ResourceManager.Current.MainResourceMap.GetSubtree("FooEditEngine.Metro/Resources");
\r
851 if (this.View.HitTextArea(e.Position.X, e.Position.Y))
\r
853 FooContextMenuEventArgs args = new FooContextMenuEventArgs(e.Position);
\r
854 if (this.ContextMenuOpening != null)
\r
855 this.ContextMenuOpening(this, args);
\r
858 PopupMenu ContextMenu = new PopupMenu();
\r
859 ContextMenu.Commands.Add(new UICommand(map.GetValue("CopyMenuName").ValueAsString, (command) =>
\r
861 this.CopyCommand();
\r
863 ContextMenu.Commands.Add(new UICommand(map.GetValue("CutMenuName").ValueAsString, (command) =>
\r
867 ContextMenu.Commands.Add(new UICommand(map.GetValue("PasteMenuName").ValueAsString, async (command) =>
\r
869 await this.PasteCommand();
\r
871 if (this._Controller.RectSelection)
\r
873 ContextMenu.Commands.Add(new UICommand(map.GetValue("LineSelectMenuName").ValueAsString, (command) =>
\r
875 this._Controller.RectSelection = false;
\r
880 ContextMenu.Commands.Add(new UICommand(map.GetValue("RectSelectMenuName").ValueAsString, (command) =>
\r
882 this._Controller.RectSelection = true;
\r
885 await ContextMenu.ShowAsync(Util.GetScreentPoint(e.Position,this));
\r
890 void gestureRecongnizer_Tapped(GestureRecognizer sender, TappedEventArgs e)
\r
892 this.gripper.Enabled = e.PointerDeviceType == PointerDeviceType.Touch;
\r
893 this.JumpCaret(e.Position);
\r
896 void JumpCaret(Point p)
\r
898 if (this.Document.State == AsyncState.Loading)
\r
901 TextPoint tp = this.View.GetTextPointFromPostion(p);
\r
902 if (tp == TextPoint.Null)
\r
905 int index = this.View.LayoutLines.GetIndexFromTextPoint(tp);
\r
907 FoldingItem foldingData = this.View.HitFoldingData(p.X, tp.row);
\r
908 if (foldingData != null)
\r
910 if (foldingData.Expand)
\r
911 this.View.LayoutLines.FoldingCollection.Collapse(foldingData);
\r
913 this.View.LayoutLines.FoldingCollection.Expand(foldingData);
\r
914 this._Controller.JumpCaret(foldingData.Start, false);
\r
918 this._Controller.JumpCaret(tp.row, tp.col, false);
\r
920 if (this.peer != null)
\r
921 this.peer.OnNotifyCaretChanged();
\r
922 this.Focus(FocusState.Pointer);
\r
926 void gestureRecongnizer_Dragging(GestureRecognizer sender, DraggingEventArgs e)
\r
928 if (this.Document.State == AsyncState.Loading)
\r
930 Point p = e.Position;
\r
931 if (this.View.HitTextArea(p.X, p.Y))
\r
933 TextPoint tp = this.View.GetTextPointFromPostion(p);
\r
934 this._Controller.MoveCaretAndSelect(tp);
\r
935 if (this.peer != null)
\r
936 this.peer.OnNotifyCaretChanged();
\r
941 bool IsModiferKeyPressed(VirtualKey key)
\r
943 CoreVirtualKeyStates state = Window.Current.CoreWindow.GetKeyState(key);
\r
944 return (state & CoreVirtualKeyStates.Down) == CoreVirtualKeyStates.Down;
\r
946 void Refresh(Rectangle updateRect)
\r
948 if (this.rectangle.ActualWidth == 0 || this.rectangle.ActualHeight == 0/* || !this.Render.IsCanDraw()*/)
\r
951 this.Render.BeginDraw();
\r
952 if (this.Document.State != AsyncState.Loading)
\r
953 this.View.Draw(updateRect);
\r
955 this.Render.FillBackground(updateRect);
\r
956 this.gripper.DrawGrippers();
\r
957 this.Render.EndDraw();
\r
961 bool Resize(double width, double height)
\r
963 if (width == 0 || height == 0)
\r
964 throw new ArgumentOutOfRangeException();
\r
965 if (this.Document.State != AsyncState.Loading && this.Render.Resize(this.rectangle, width, height))
\r
967 this.View.PageBound = new Rectangle(0, 0, width, height);
\r
969 if (this.horizontalScrollBar != null)
\r
971 this.horizontalScrollBar.LargeChange = this.View.PageBound.Width;
\r
972 this.horizontalScrollBar.Maximum = this.View.LongestWidth + this.horizontalScrollBar.LargeChange + 1;
\r
974 if (this.verticalScrollBar != null)
\r
976 this.verticalScrollBar.LargeChange = this.View.LineCountOnScreen;
\r
977 this.verticalScrollBar.Maximum = this.View.LayoutLines.Count + this.verticalScrollBar.LargeChange + 1;
\r
984 void View_SrcChanged(object sender, EventArgs e)
\r
986 if (this.horizontalScrollBar == null || this.verticalScrollBar == null)
\r
988 EditView view = this.View;
\r
989 if (view.Src.Row > this.verticalScrollBar.Maximum)
\r
990 this.verticalScrollBar.Maximum = view.Src.Row + view.LineCountOnScreen + 1;
\r
991 double absoulteX = Math.Abs(view.Src.X);
\r
992 if (absoulteX > this.horizontalScrollBar.Maximum)
\r
993 this.horizontalScrollBar.Maximum = absoulteX + view.PageBound.Width + 1;
\r
994 if (view.Src.Row != this.verticalScrollBar.Value)
\r
995 this.verticalScrollBar.Value = view.Src.Row;
\r
996 if (view.Src.X != this.horizontalScrollBar.Value)
\r
997 this.horizontalScrollBar.Value = Math.Abs(view.Src.X);
\r
1000 void FooTextBox_SizeChanged(object sender, SizeChangedEventArgs e)
\r
1002 if (this.Document.State == AsyncState.Loading || this.Resize(this.rectangle.ActualWidth, this.rectangle.ActualHeight))
\r
1009 void horizontalScrollBar_Scroll(object sender, ScrollEventArgs e)
\r
1011 if (this.Document.State == AsyncState.Loading)
\r
1013 if (this.horizontalScrollBar == null)
\r
1016 if (this.FlowDirection == FlowDirection.LeftToRight)
\r
1017 toX = this.horizontalScrollBar.Value;
\r
1019 toX = -this.horizontalScrollBar.Value;
\r
1020 this._Controller.Scroll(toX, this.View.Src.Row, false, false);
\r
1021 this.gripper.Enabled = false;
\r
1025 void verticalScrollBar_Scroll(object sender, ScrollEventArgs e)
\r
1027 if (this.Document.State == AsyncState.Loading)
\r
1029 if (this.verticalScrollBar == null)
\r
1031 int newRow = (int)this.verticalScrollBar.Value;
\r
1032 if (newRow >= this.View.LayoutLines.Count)
\r
1034 this._Controller.Scroll(this.View.Src.X, newRow, false, false);
\r
1035 this.gripper.Enabled = false;
\r
1039 void Document_Update(object sender, DocumentUpdateEventArgs e)
\r
1041 if (this.textStore.IsLocked() || this.Document.State == AsyncState.Loading || e.type == UpdateType.Clear)
\r
1043 if (e.removeLength == 0)
\r
1044 this.textStore.NotifyTextChanged(e.startIndex, e.startIndex, e.startIndex + e.insertLength);
\r
1046 this.textStore.NotifyTextChanged(e.startIndex, e.startIndex + 1, e.startIndex + e.insertLength - e.removeLength);
\r
1049 void Document_Progress(object sender, ProgressEventArgs e)
\r
1051 if (this.Document.State == AsyncState.Loading)
\r
1055 case ProgressState.Start:
\r
1056 this.textStore.NotifyTextChanged(0, this.Document.Length, 0);
\r
1058 case ProgressState.Complete:
\r
1059 this.textStore.NotifyTextChanged(0, 0, this.Document.Length);
\r
1060 if (this.verticalScrollBar != null)
\r
1061 this.verticalScrollBar.Maximum = this.View.LayoutLines.Count;
\r
1062 this.View.CalculateLineCountOnScreen();
\r
1067 void FooTextBox_Loaded(object sender, RoutedEventArgs e)
\r
1069 this.Focus(FocusState.Programmatic);
\r
1073 public static void OnPropertyChanged(object sender, DependencyPropertyChangedEventArgs e)
\r
1075 FooTextBox source = (FooTextBox)sender;
\r
1076 if (e.Property.Equals(InsertModeProperty))
\r
1077 source.View.InsertMode = source.InsertMode;
\r
1078 if (e.Property.Equals(TabCharsProperty))
\r
1079 source.View.TabStops = source.TabChars;
\r
1080 if (e.Property.Equals(RectSelectModeProperty))
\r
1081 source._Controller.RectSelection = source.RectSelectMode;
\r
1082 if (e.Property.Equals(DrawCaretProperty))
\r
1083 source.View.HideCaret = !source.DrawCaret;
\r
1084 if (e.Property.Equals(DrawCaretLineProperty))
\r
1085 source.View.HideLineMarker = !source.DrawCaretLine;
\r
1086 if (e.Property.Equals(DrawLineNumberProperty))
\r
1088 source.View.DrawLineNumber = source.DrawLineNumber;
\r
1089 source._Controller.JumpCaret(source.View.CaretPostion.row, source.View.CaretPostion.col);
\r
1091 if(e.Property.Equals(MagnificationPowerPropertyKey))
\r
1092 source.Render.FontSize = source.FontSize * source.MagnificationPower;
\r
1093 if (e.Property.Equals(FontFamilyProperty))
\r
1094 source.Render.FontFamily = source.FontFamily;
\r
1095 if (e.Property.Equals(FontStyleProperty))
\r
1096 source.Render.FontStyle = source.FontStyle;
\r
1097 if (e.Property.Equals(FontWeightProperty))
\r
1098 source.Render.FontWeigth = source.FontWeight;
\r
1099 if (e.Property.Equals(FontSizeProperty))
\r
1100 source.Render.FontSize = source.FontSize;
\r
1101 if (e.Property.Equals(ForegroundProperty))
\r
1102 source.Render.Foreground = source.Foreground;
\r
1103 if (e.Property.Equals(BackgroundProperty))
\r
1104 source.Render.Background = source.Background;
\r
1105 if (e.Property.Equals(ControlCharProperty))
\r
1106 source.Render.ControlChar = source.ControlChar;
\r
1107 if (e.Property.Equals(HilightProperty))
\r
1108 source.Render.Hilight = source.Hilight;
\r
1109 if (e.Property.Equals(Keyword1Property))
\r
1110 source.Render.Keyword1 = source.Keyword1;
\r
1111 if (e.Property.Equals(Keyword2Property))
\r
1112 source.Render.Keyword2 = source.Keyword2;
\r
1113 if (e.Property.Equals(CommentProperty))
\r
1114 source.Render.Comment = source.Comment;
\r
1115 if (e.Property.Equals(LiteralProperty))
\r
1116 source.Render.Literal = source.Literal;
\r
1117 if (e.Property.Equals(URLProperty))
\r
1118 source.Render.Url = source.URL;
\r
1119 if (e.Property.Equals(InsertCaretProperty))
\r
1120 source.Render.InsertCaret = source.InsertCaret;
\r
1121 if (e.Property.Equals(OverwriteCaretProperty))
\r
1122 source.Render.OverwriteCaret = source.OverwriteCaret;
\r
1123 if (e.Property.Equals(LineMarkerProperty))
\r
1124 source.Render.LineMarker = source.LineMarker;
\r
1125 if (e.Property.Equals(MarkURLProperty))
\r
1126 source.View.UrlMark = source.MarkURL;
\r
1127 if (e.Property.Equals(ShowFullSpaceProperty))
\r
1128 source.Render.ShowFullSpace = source.ShowFullSpace;
\r
1129 if (e.Property.Equals(ShowHalfSpaceProperty))
\r
1130 source.Render.ShowHalfSpace = source.ShowHalfSpace;
\r
1131 if (e.Property.Equals(ShowTabProperty))
\r
1132 source.Render.ShowTab = source.ShowTab;
\r
1133 if (e.Property.Equals(ShowLineBreakProperty))
\r
1134 source.Render.ShowLineBreak = source.ShowLineBreak;
\r
1135 if (e.Property.Equals(LineBreakProperty))
\r
1136 source.View.LineBreak = source.LineBreakMethod;
\r
1137 if (e.Property.Equals(LineBreakCharCountProperty))
\r
1138 source.View.LineBreakCharCount = source.LineBreakCharCount;
\r
1139 if (e.Property.Equals(FlowDirectionProperty))
\r
1141 source.Render.RightToLeft = source.FlowDirection == Windows.UI.Xaml.FlowDirection.RightToLeft;
\r
1142 if(source.horizontalScrollBar != null)
\r
1143 source.horizontalScrollBar.FlowDirection = source.FlowDirection;
\r
1145 if (e.Property.Equals(DrawRulerProperty))
\r
1147 source.View.HideRuler = !source.DrawRuler;
\r
1148 source._Controller.JumpCaret(source.View.CaretPostion.row, source.View.CaretPostion.col);
\r
1156 /// コンテキストメニューが表示されるときに呼び出されます
\r
1158 public event EventHandler<FooContextMenuEventArgs> ContextMenuOpening;
\r
1164 internal Controller Controller
\r
1168 return this._Controller;
\r
1173 /// 文字列の描写に使用されるアンチエイリアシング モードを表します
\r
1175 public TextAntialiasMode TextAntialiasMode
\r
1179 return this.Render.TextAntialiasMode;
\r
1183 this.Render.TextAntialiasMode = value;
\r
1188 /// シンタックスハイライターを表す
\r
1190 public IHilighter Hilighter
\r
1194 return this.View.Hilighter;
\r
1198 this.View.Hilighter = value;
\r
1199 this.View.LayoutLines.ClearLayoutCache();
\r
1204 /// フォールティングを作成するインターフェイスを表す
\r
1206 public IFoldingStrategy FoldingStrategy
\r
1210 return this.View.LayoutLines.FoldingStrategy;
\r
1214 this.View.LayoutLines.FoldingStrategy = value;
\r
1215 if (value == null)
\r
1216 this.View.LayoutLines.FoldingCollection.Clear();
\r
1223 public Document Document
\r
1232 public LineToIndexTable LayoutLineCollection
\r
1234 get { return this.View.LayoutLines; }
\r
1240 public string SelectedText
\r
1244 return this._Controller.SelectedText;
\r
1248 int oldLength = this.Document.Length;
\r
1249 this._Controller.SelectedText = value;
\r
1256 /// <remarks>SelectionLengthが0の場合はキャレット位置を表します</remarks>
\r
1257 public int SelectionStart
\r
1259 get { return this._Controller.SelectionStart; }
\r
1265 /// <remarks>矩形選択モードの場合、選択範囲の文字数ではなく、開始位置から終了位置までの長さとなります</remarks>
\r
1266 public int SelectionLength
\r
1268 get { return this._Controller.SelectionLength; }
\r
1274 public double MagnificationPower
\r
1276 get { return (double)GetValue(MagnificationPowerPropertyKey); }
\r
1277 set { SetValue(MagnificationPowerPropertyKey, value); }
\r
1283 public static readonly DependencyProperty MagnificationPowerPropertyKey =
\r
1284 DependencyProperty.Register("MagnificationPower", typeof(double), typeof(FooTextBox), new PropertyMetadata(1.0, OnPropertyChanged));
\r
1287 /// キャレット位置を表す。このプロパティは変更しても値が反映されません
\r
1289 public TextPoint CaretPostion
\r
1291 get { return (TextPoint)GetValue(CaretPostionPropertyKey); }
\r
1292 set { SetValue(CaretPostionPropertyKey, value); }
\r
1295 static readonly DependencyProperty CaretPostionPropertyKey =
\r
1296 DependencyProperty.Register("CaretPostion", typeof(TextPoint), typeof(FooTextBox), new PropertyMetadata(new TextPoint(), OnPropertyChanged));
\r
1301 public new FlowDirection FlowDirection
\r
1303 get { return (FlowDirection)GetValue(FlowDirectionProperty); }
\r
1304 set { SetValue(FlowDirectionProperty, value); }
\r
1308 /// レタリング方向を表す。これは依存プロパティです
\r
1310 public new static readonly DependencyProperty FlowDirectionProperty =
\r
1311 DependencyProperty.Register("FlowDirection", typeof(FlowDirection), typeof(FooTextBox), new PropertyMetadata(FlowDirection.LeftToRight,OnPropertyChanged));
\r
1316 public new FontFamily FontFamily
\r
1318 get { return (FontFamily)GetValue(FontFamilyProperty); }
\r
1319 set { SetValue(FontFamilyProperty, value); }
\r
1323 /// FontFamilyの依存プロパティを表す
\r
1325 public new static readonly DependencyProperty FontFamilyProperty =
\r
1326 DependencyProperty.Register("FontFamily", typeof(FontFamily), typeof(FooTextBox), new PropertyMetadata(new FontFamily("Cambria"), OnPropertyChanged));
\r
1331 public new double FontSize
\r
1333 get { return (double)GetValue(FontSizeProperty); }
\r
1334 set { SetValue(FontSizeProperty, value); }
\r
1338 /// FontSizeの依存プロパティを表す
\r
1340 public new static readonly DependencyProperty FontSizeProperty =
\r
1341 DependencyProperty.Register("FontSize", typeof(double), typeof(FooTextBox), new PropertyMetadata(12.0,OnPropertyChanged));
\r
1346 public new FontStyle FontStyle
\r
1348 get { return (FontStyle)GetValue(FontStyleProperty); }
\r
1349 set { SetValue(FontStyleProperty, value); }
\r
1353 /// FontStyleの依存プロパティを表す
\r
1355 public new static readonly DependencyProperty FontStyleProperty =
\r
1356 DependencyProperty.Register("FontStyle", typeof(FontStyle), typeof(FooTextBox), new PropertyMetadata(FontStyle.Normal,OnPropertyChanged));
\r
1361 public new FontWeight FontWeight
\r
1363 get { return (FontWeight)GetValue(FontWeightProperty); }
\r
1364 set { SetValue(FontWeightProperty, value); }
\r
1368 /// FontWeigthの依存プロパティを表す
\r
1370 public new static readonly DependencyProperty FontWeightProperty =
\r
1371 DependencyProperty.Register("FontWeigth", typeof(FontWeight), typeof(FooTextBox), new PropertyMetadata(FontWeights.Normal,OnPropertyChanged));
\r
1374 /// デフォルトの文字色を表す。これは依存プロパティです
\r
1376 public new Windows.UI.Color Foreground
\r
1378 get { return (Windows.UI.Color)GetValue(ForegroundProperty); }
\r
1379 set { SetValue(ForegroundProperty, value); }
\r
1383 /// Foregroundの依存プロパティを表す
\r
1385 public new static readonly DependencyProperty ForegroundProperty =
\r
1386 DependencyProperty.Register("Foreground", typeof(Windows.UI.Color), typeof(FooTextBox), new PropertyMetadata(Colors.Black, OnPropertyChanged));
\r
1389 /// 背景色を表す。これは依存プロパティです
\r
1391 public new Windows.UI.Color Background
\r
1393 get { return (Windows.UI.Color)GetValue(BackgroundProperty); }
\r
1394 set { SetValue(BackgroundProperty, value); }
\r
1398 /// Backgroundの依存プロパティを表す
\r
1400 public new static readonly DependencyProperty BackgroundProperty =
\r
1401 DependencyProperty.Register("Background", typeof(Windows.UI.Color), typeof(FooTextBox), new PropertyMetadata(Colors.White, OnPropertyChanged));
\r
1404 /// コントロールコードの文字色を表す。これは依存プロパティです
\r
1406 public Windows.UI.Color ControlChar
\r
1408 get { return (Windows.UI.Color)GetValue(ControlCharProperty); }
\r
1409 set { SetValue(ControlCharProperty, value); }
\r
1413 /// ControlCharの依存プロパティを表す
\r
1415 public static readonly DependencyProperty ControlCharProperty =
\r
1416 DependencyProperty.Register("ControlChar", typeof(Windows.UI.Color), typeof(FooTextBox), new PropertyMetadata(Colors.Gray, OnPropertyChanged));
\r
1419 /// 選択時の背景色を表す。これは依存プロパティです
\r
1421 public Windows.UI.Color Hilight
\r
1423 get { return (Windows.UI.Color)GetValue(HilightProperty); }
\r
1424 set { SetValue(HilightProperty, value); }
\r
1428 /// Hilightの依存プロパティを表す
\r
1430 public static readonly DependencyProperty HilightProperty =
\r
1431 DependencyProperty.Register("Hilight", typeof(Windows.UI.Color), typeof(FooTextBox), new PropertyMetadata(Colors.DeepSkyBlue, OnPropertyChanged));
\r
1434 /// キーワード1の文字色を表す。これは依存プロパティです
\r
1436 public Windows.UI.Color Keyword1
\r
1438 get { return (Windows.UI.Color)GetValue(Keyword1Property); }
\r
1439 set { SetValue(Keyword1Property, value); }
\r
1443 /// Keyword1の依存プロパティを表す
\r
1445 public static readonly DependencyProperty Keyword1Property =
\r
1446 DependencyProperty.Register("Keyword1", typeof(Windows.UI.Color), typeof(FooTextBox), new PropertyMetadata(Colors.Blue, OnPropertyChanged));
\r
1449 /// キーワード2の文字色を表す。これは依存プロパティです
\r
1451 public Windows.UI.Color Keyword2
\r
1453 get { return (Windows.UI.Color)GetValue(Keyword2Property); }
\r
1454 set { SetValue(Keyword2Property, value); }
\r
1458 /// Keyword2の依存プロパティを表す
\r
1460 public static readonly DependencyProperty Keyword2Property =
\r
1461 DependencyProperty.Register("Keyword2", typeof(Windows.UI.Color), typeof(FooTextBox), new PropertyMetadata(Colors.DarkCyan, OnPropertyChanged));
\r
1464 /// コメントの文字色を表す。これは依存プロパティです
\r
1466 public Windows.UI.Color Comment
\r
1468 get { return (Windows.UI.Color)GetValue(CommentProperty); }
\r
1469 set { SetValue(CommentProperty, value); }
\r
1473 /// Commentの依存プロパティを表す
\r
1475 public static readonly DependencyProperty CommentProperty =
\r
1476 DependencyProperty.Register("Comment", typeof(Windows.UI.Color), typeof(FooTextBox), new PropertyMetadata(Colors.Green, OnPropertyChanged));
\r
1479 /// 文字リテラルの文字色を表す。これは依存プロパティです
\r
1481 public Windows.UI.Color Literal
\r
1483 get { return (Windows.UI.Color)GetValue(LiteralProperty); }
\r
1484 set { SetValue(LiteralProperty, value); }
\r
1488 /// Literalの依存プロパティを表す
\r
1490 public static readonly DependencyProperty LiteralProperty =
\r
1491 DependencyProperty.Register("Literal", typeof(Windows.UI.Color), typeof(FooTextBox), new PropertyMetadata(Colors.Brown, OnPropertyChanged));
\r
1494 /// URLの文字色を表す。これは依存プロパティです
\r
1496 public Windows.UI.Color URL
\r
1498 get { return (Windows.UI.Color)GetValue(URLProperty); }
\r
1499 set { SetValue(URLProperty, value); }
\r
1503 /// URLの依存プロパティを表す
\r
1505 public static readonly DependencyProperty URLProperty =
\r
1506 DependencyProperty.Register("URL", typeof(Windows.UI.Color), typeof(FooTextBox), new PropertyMetadata(Colors.Blue, OnPropertyChanged));
\r
1512 public Windows.UI.Color LineMarker
\r
1514 get { return (Windows.UI.Color)GetValue(LineMarkerProperty); }
\r
1515 set { SetValue(LineMarkerProperty, value); }
\r
1519 /// LineMarkerの依存プロパティを表す
\r
1521 public static readonly DependencyProperty LineMarkerProperty =
\r
1522 DependencyProperty.Register("LineMarker", typeof(Windows.UI.Color), typeof(FooTextBox), new PropertyMetadata(Colors.Gray, OnPropertyChanged));
\r
1525 /// 挿入モード時のキャレットの色を表す
\r
1527 public Windows.UI.Color InsertCaret
\r
1529 get { return (Windows.UI.Color)GetValue(InsertCaretProperty); }
\r
1530 set { SetValue(InsertCaretProperty, value); }
\r
1534 /// InsertCaretの依存プロパティを表す
\r
1536 public static readonly DependencyProperty InsertCaretProperty =
\r
1537 DependencyProperty.Register("InsertCaret", typeof(Windows.UI.Color), typeof(FooTextBox), new PropertyMetadata(Colors.Black, OnPropertyChanged));
\r
1540 /// 上書きモード時のキャレット職を表す
\r
1542 public Windows.UI.Color OverwriteCaret
\r
1544 get { return (Windows.UI.Color)GetValue(OverwriteCaretProperty); }
\r
1545 set { SetValue(OverwriteCaretProperty, value); }
\r
1549 /// OverwriteCaretの依存プロパティを表す
\r
1551 public static readonly DependencyProperty OverwriteCaretProperty =
\r
1552 DependencyProperty.Register("OverwriteCaret", typeof(Windows.UI.Color), typeof(FooTextBox), new PropertyMetadata(Colors.Black, OnPropertyChanged));
\r
1555 /// 挿入モードなら真を返し、そうでないなら、偽を返す。これは依存プロパティです
\r
1557 public bool InsertMode
\r
1559 get { return (bool)GetValue(InsertModeProperty); }
\r
1560 set { SetValue(InsertModeProperty, value); }
\r
1564 /// InsertModeの依存プロパティを表す
\r
1566 public static readonly DependencyProperty InsertModeProperty =
\r
1567 DependencyProperty.Register("InsertMode",
\r
1569 typeof(FooTextBox),
\r
1570 new PropertyMetadata(true, OnPropertyChanged));
\r
1573 /// タブの文字数を表す。これは依存プロパティです
\r
1575 public int TabChars
\r
1577 get { return (int)GetValue(TabCharsProperty); }
\r
1578 set { SetValue(TabCharsProperty, value); }
\r
1582 /// TabCharsの依存プロパティを表す
\r
1584 public static readonly DependencyProperty TabCharsProperty =
\r
1585 DependencyProperty.Register("TabChars",
\r
1587 typeof(FooTextBox),
\r
1588 new PropertyMetadata(4, OnPropertyChanged));
\r
1591 /// 矩形選択モードなら真を返し、そうでないなら偽を返す。これは依存プロパティです
\r
1593 public bool RectSelectMode
\r
1595 get { return (bool)GetValue(RectSelectModeProperty); }
\r
1596 set { SetValue(RectSelectModeProperty, value); }
\r
1600 /// RectSelectModeの依存プロパティを表す
\r
1602 public static readonly DependencyProperty RectSelectModeProperty =
\r
1603 DependencyProperty.Register("RectSelectMode", typeof(bool), typeof(FooTextBox), new PropertyMetadata(false, OnPropertyChanged));
\r
1609 /// 変更した場合、レイアウトの再構築を行う必要があります
\r
1611 public LineBreakMethod LineBreakMethod
\r
1613 get { return (LineBreakMethod)GetValue(LineBreakProperty); }
\r
1614 set { SetValue(LineBreakProperty, value); }
\r
1618 /// LineBreakMethodの依存プロパティを表す
\r
1620 public static readonly DependencyProperty LineBreakProperty =
\r
1621 DependencyProperty.Register("LineBreakMethod", typeof(LineBreakMethod), typeof(FooTextBox), new PropertyMetadata(LineBreakMethod.None, OnPropertyChanged));
\r
1625 /// 折り返しの幅を指定する。LineBreakMethod.CharUnit以外の時は無視されます
\r
1628 /// 変更した場合、レイアウトの再構築を行う必要があります
\r
1630 public int LineBreakCharCount
\r
1632 get { return (int)GetValue(LineBreakCharCountProperty); }
\r
1633 set { SetValue(LineBreakCharCountProperty, value); }
\r
1637 /// LineBreakCharCountの依存プロパティを表す
\r
1639 public static readonly DependencyProperty LineBreakCharCountProperty =
\r
1640 DependencyProperty.Register("LineBreakCharCount", typeof(int), typeof(FooTextBox), new PropertyMetadata(80));
\r
1643 /// キャレットを描くなら真。そうでないなら偽を返す。これは依存プロパティです
\r
1645 public bool DrawCaret
\r
1647 get { return (bool)GetValue(DrawCaretProperty); }
\r
1648 set { SetValue(DrawCaretProperty, value); }
\r
1652 /// DrawCaretの依存プロパティを表す
\r
1654 public static readonly DependencyProperty DrawCaretProperty =
\r
1655 DependencyProperty.Register("DrawCaret", typeof(bool), typeof(FooTextBox), new PropertyMetadata(true, OnPropertyChanged));
\r
1659 /// キャレットラインを描くなら真。そうでないなら偽を返す。これは依存プロパティです
\r
1661 public bool DrawCaretLine
\r
1663 get { return (bool)GetValue(DrawCaretLineProperty); }
\r
1664 set { SetValue(DrawCaretLineProperty, value); }
\r
1668 /// DrawCaretLineの依存プロパティを表す
\r
1670 public static readonly DependencyProperty DrawCaretLineProperty =
\r
1671 DependencyProperty.Register("DrawCaretLine", typeof(bool), typeof(FooTextBox), new PropertyMetadata(true, OnPropertyChanged));
\r
1674 /// 行番号を描くなら真。そうでなければ偽。これは依存プロパティです
\r
1676 public bool DrawLineNumber
\r
1678 get { return (bool)GetValue(DrawLineNumberProperty); }
\r
1679 set { SetValue(DrawLineNumberProperty, value); }
\r
1683 /// ルーラーを描くなら真。そうでなければ偽。これは依存プロパティです
\r
1685 public bool DrawRuler
\r
1687 get { return (bool)GetValue(DrawRulerProperty); }
\r
1688 set { SetValue(DrawRulerProperty, value); }
\r
1692 /// DrawRulerの依存プロパティを表す
\r
1694 public static readonly DependencyProperty DrawRulerProperty =
\r
1695 DependencyProperty.Register("DrawRuler", typeof(bool), typeof(FooTextBox), new PropertyMetadata(false, OnPropertyChanged));
\r
1699 /// DrawLineNumberの依存プロパティを表す
\r
1701 public static readonly DependencyProperty DrawLineNumberProperty =
\r
1702 DependencyProperty.Register("DrawLineNumber", typeof(bool), typeof(FooTextBox), new PropertyMetadata(false, OnPropertyChanged));
\r
1705 /// URLに下線を引くなら真。そうでないなら偽を表す。これは依存プロパティです
\r
1707 public bool MarkURL
\r
1709 get { return (bool)GetValue(MarkURLProperty); }
\r
1710 set { SetValue(MarkURLProperty, value); }
\r
1714 /// MarkURLの依存プロパティを表す
\r
1716 public static readonly DependencyProperty MarkURLProperty =
\r
1717 DependencyProperty.Register("MarkURL", typeof(bool), typeof(FooTextBox), new PropertyMetadata(false, OnPropertyChanged));
\r
1720 /// 全角スペースを表示するなら真。そうでないなら偽
\r
1722 public bool ShowFullSpace
\r
1724 get { return (bool)GetValue(ShowFullSpaceProperty); }
\r
1725 set { SetValue(ShowFullSpaceProperty, value); }
\r
1729 /// ShowFullSpaceの依存プロパティを表す
\r
1731 public static readonly DependencyProperty ShowFullSpaceProperty =
\r
1732 DependencyProperty.Register("ShowFullSpace", typeof(bool), typeof(FooTextBox), new PropertyMetadata(false, OnPropertyChanged));
\r
1735 /// 半角スペースを表示するなら真。そうでないなら偽
\r
1737 public bool ShowHalfSpace
\r
1739 get { return (bool)GetValue(ShowHalfSpaceProperty); }
\r
1740 set { SetValue(ShowHalfSpaceProperty, value); }
\r
1744 /// ShowHalfSpaceの依存プロパティを表す
\r
1746 public static readonly DependencyProperty ShowHalfSpaceProperty =
\r
1747 DependencyProperty.Register("ShowHalfSpace", typeof(bool), typeof(FooTextBox), new PropertyMetadata(false, OnPropertyChanged));
\r
1750 /// タブを表示するなら真。そうでないなら偽
\r
1752 public bool ShowTab
\r
1754 get { return (bool)GetValue(ShowTabProperty); }
\r
1755 set { SetValue(ShowTabProperty, value); }
\r
1759 /// ShowTabの依存プロパティを表す
\r
1761 public static readonly DependencyProperty ShowTabProperty =
\r
1762 DependencyProperty.Register("ShowTab", typeof(bool), typeof(FooTextBox), new PropertyMetadata(false, OnPropertyChanged));
\r
1765 /// 改行マークを表示するなら真。そうでないなら偽
\r
1767 public bool ShowLineBreak
\r
1769 get { return (bool)GetValue(ShowLineBreakProperty); }
\r
1770 set { SetValue(ShowLineBreakProperty, value); }
\r
1774 /// ShowLineBreakの依存プロパティを表す
\r
1776 public static readonly DependencyProperty ShowLineBreakProperty =
\r
1777 DependencyProperty.Register("ShowLineBreak", typeof(bool), typeof(FooTextBox), new PropertyMetadata(false,OnPropertyChanged));
\r
1783 /// コンテキストメニューのイベントデーターを表す
\r
1785 public class FooContextMenuEventArgs
\r
1788 /// 処理済みなら真。そうでないなら偽
\r
1790 public bool Handled = false;
\r
1792 /// コンテキストメニューを表示すべき座標を表す
\r
1794 public Windows.Foundation.Point Postion;
\r
1798 /// <param name="pos"></param>
\r
1799 public FooContextMenuEventArgs(Windows.Foundation.Point pos)
\r
1801 this.Postion = pos;
\r