2 * Copyright (C) 2013 FooProject
\r
3 * * This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by
\r
4 * the Free Software Foundation; either version 3 of the License, or (at your option) any later version.
\r
6 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
7 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
\r
9 You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
\r
13 using System.ComponentModel;
\r
14 using System.Threading.Tasks;
\r
15 using Windows.ApplicationModel.Resources.Core;
\r
16 using Windows.Devices.Input;
\r
17 using Windows.System;
\r
18 using Windows.ApplicationModel.DataTransfer;
\r
19 using Windows.Foundation;
\r
21 using Windows.UI.Input;
\r
22 using Windows.UI.Core;
\r
23 using Windows.UI.Popups;
\r
24 using Windows.UI.Text;
\r
25 using Windows.UI.Xaml.Media;
\r
26 using Windows.UI.Xaml;
\r
27 using Windows.UI.Xaml.Controls;
\r
28 using Windows.UI.Xaml.Controls.Primitives;
\r
29 using Windows.UI.Xaml.Input;
\r
30 using DotNetTextStore;
\r
31 using DotNetTextStore.UnmanagedAPI.TSF;
\r
32 using DotNetTextStore.UnmanagedAPI.WinDef;
\r
34 // テンプレート コントロールのアイテム テンプレートについては、http://go.microsoft.com/fwlink/?LinkId=234235 を参照してください
\r
36 namespace FooEditEngine.Metro
\r
41 public sealed class FooTextBox : Control,IDisposable
\r
44 Controller _Controller;
\r
46 ScrollBar horizontalScrollBar, verticalScrollBar;
\r
47 Windows.UI.Xaml.Shapes.Rectangle rectangle;
\r
48 GestureRecognizer gestureRecongnizer = new GestureRecognizer();
\r
49 TextStore2 textStore;
\r
50 FooTextBoxAutomationPeer peer;
\r
51 bool nowCaretMove = false;
\r
58 this.DefaultStyleKey = typeof(FooTextBox);
\r
60 this.textStore = new TextStore2();
\r
61 this.textStore.IsLoading += textStore_IsLoading;
\r
62 this.textStore.IsReadOnly += textStore_IsReadOnly;
\r
63 this.textStore.GetDpi += textStore_GetDpi;
\r
64 this.textStore.GetStringLength += () => this.Document.Length;
\r
65 this.textStore.GetString += _textStore_GetString;
\r
66 this.textStore.GetSelectionIndex += _textStore_GetSelectionIndex;
\r
67 this.textStore.SetSelectionIndex += _textStore_SetSelectionIndex;
\r
68 this.textStore.InsertAtSelection += _textStore_InsertAtSelection;
\r
69 this.textStore.GetScreenExtent += _textStore_GetScreenExtent;
\r
70 this.textStore.GetStringExtent += _textStore_GetStringExtent;
\r
71 this.textStore.CompositionStarted += textStore_CompositionStarted;
\r
72 this.textStore.CompositionUpdated += textStore_CompositionUpdated;
\r
73 this.textStore.CompositionEnded += textStore_CompositionEnded;
\r
75 this.rectangle = new Windows.UI.Xaml.Shapes.Rectangle();
\r
76 this.rectangle.Margin = this.Padding;
\r
77 this.Render = new D2DRender(this,this.rectangle,this.textStore);
\r
79 this.Document = new Document();
\r
80 this.Document.LayoutLines.Render = this.Render;
\r
82 this.View = new EditView(this.Document, this.Render, new Padding(5, Gripper.HitAreaWidth, Gripper.HitAreaWidth / 2, Gripper.HitAreaWidth));
\r
83 this.View.SrcChanged += View_SrcChanged;
\r
84 this.View.InsertMode = this.InsertMode;
\r
85 this.View.DrawLineNumber = this.DrawLineNumber;
\r
86 this.View.HideCaret = !this.DrawCaret;
\r
87 this.View.HideLineMarker = !this.DrawCaretLine;
\r
88 this.View.HideRuler = !this.DrawRuler;
\r
89 this.View.UrlMark = this.MarkURL;
\r
90 this.View.TabStops = this.TabChars;
\r
92 this._Controller = new Controller(this.Document, this.View);
\r
93 this._Controller.SelectionChanged += Controller_SelectionChanged;
\r
95 this.FirstGripper = new Gripper(this._Controller, this.View, this.Render, GripperPostion.Upper);
\r
96 this.SecondGripper = new Gripper(this._Controller, this.View, this.Render, GripperPostion.Bottom);
\r
98 this.gestureRecongnizer.GestureSettings = GestureSettings.Drag |
\r
99 GestureSettings.RightTap |
\r
100 GestureSettings.Tap |
\r
101 GestureSettings.ManipulationTranslateX |
\r
102 GestureSettings.ManipulationTranslateY |
\r
103 GestureSettings.ManipulationScale;
\r
104 this.gestureRecongnizer.RightTapped += gestureRecongnizer_RightTapped;
\r
105 this.gestureRecongnizer.Tapped += gestureRecongnizer_Tapped;
\r
106 this.gestureRecongnizer.Dragging += gestureRecongnizer_Dragging;
\r
107 this.gestureRecongnizer.ManipulationStarted += gestureRecongnizer_ManipulationStarted;
\r
108 this.gestureRecongnizer.ManipulationUpdated += gestureRecongnizer_ManipulationUpdated;
\r
109 this.gestureRecongnizer.ManipulationCompleted += gestureRecongnizer_ManipulationCompleted;
\r
111 //Viewの初期化が終わった直後に置かないと例外が発生する
\r
112 this.Document.Update += Document_Update;
\r
114 Window.Current.CoreWindow.CharacterReceived += CoreWindow_CharacterReceived;
\r
116 this.SizeChanged += FooTextBox_SizeChanged;
\r
118 this.Loaded += FooTextBox_Loaded;
\r
126 this.Dispose(false);
\r
130 /// アンマネージドリソースを解放する
\r
132 public void Dispose()
\r
134 this.Dispose(true);
\r
135 GC.SuppressFinalize(this);
\r
138 bool Disposed = false;
\r
139 private void Dispose(bool disposing)
\r
145 this.textStore.Dispose();
\r
146 this.View.Dispose();
\r
147 this.Render.Dispose();
\r
154 /// <param name="start">開始インデックス</param>
\r
155 /// <param name="length">長さ</param>
\r
156 public void Select(int start, int length)
\r
158 this._Controller.Select(start, length);
\r
162 /// キャレットを指定した行に移動させます
\r
164 /// <param name="index">インデックス</param>
\r
165 /// <remarks>このメソッドを呼び出すと選択状態は解除されます</remarks>
\r
166 public void JumpCaret(int index)
\r
168 this._Controller.JumpCaret(index);
\r
171 /// キャレットを指定した行と桁に移動させます
\r
173 /// <param name="row">行番号</param>
\r
174 /// <param name="col">桁</param>
\r
175 /// <remarks>このメソッドを呼び出すと選択状態は解除されます</remarks>
\r
176 public void JumpCaret(int row, int col)
\r
178 this._Controller.JumpCaret(row, col);
\r
182 /// 選択中のテキストをクリップボードにコピーします
\r
186 string text = this._Controller.SelectedText;
\r
187 if (text != null && text != string.Empty)
\r
189 DataPackage dataPackage = new DataPackage();
\r
190 dataPackage.RequestedOperation = DataPackageOperation.Copy;
\r
191 dataPackage.SetText(text);
\r
193 Clipboard.SetContent(dataPackage);
\r
198 /// 選択中のテキストをクリップボードに切り取ります
\r
202 string text = this._Controller.SelectedText;
\r
203 if (text != null && text != string.Empty)
\r
205 DataPackage dataPackage = new DataPackage();
\r
206 dataPackage.RequestedOperation = DataPackageOperation.Copy;
\r
207 dataPackage.SetText(text);
\r
209 Clipboard.SetContent(dataPackage);
\r
211 this._Controller.SelectedText = "";
\r
216 /// 選択中のテキストを貼り付けます
\r
218 public async Task PasteAsync()
\r
220 var dataPackageView = Clipboard.GetContent();
\r
221 if (dataPackageView.Contains(StandardDataFormats.Text))
\r
223 this._Controller.SelectedText = await dataPackageView.GetTextAsync();
\r
230 public void SelectAll()
\r
232 this._Controller.Select(0, this.Document.Length);
\r
238 public void DeSelectAll()
\r
240 this._Controller.DeSelectAll();
\r
246 /// <param name="tp">テキストポイント</param>
\r
247 /// <returns>座標</returns>
\r
248 /// <remarks>テキストポイントがクライアント領域の原点より外にある場合、返される値は原点に丸められます</remarks>
\r
249 public Windows.Foundation.Point GetPostionFromTextPoint(TextPoint tp)
\r
251 if (this.Document.FireUpdateEvent == false)
\r
252 throw new InvalidOperationException("");
\r
253 return this.View.GetPostionFromTextPoint(tp);
\r
257 /// 対応するテキストポイントを返します
\r
259 /// <param name="p">クライアント領域の原点を左上とする座標</param>
\r
260 /// <returns>テキストポイント</returns>
\r
261 public TextPoint GetTextPointFromPostion(Windows.Foundation.Point p)
\r
263 if (this.Document.FireUpdateEvent == false)
\r
264 throw new InvalidOperationException("");
\r
265 return this.View.GetTextPointFromPostion(p);
\r
271 /// <param name="row">レイアウト行</param>
\r
272 /// <returns>行の高さ</returns>
\r
273 public double GetLineHeight(int row)
\r
275 if (this.Document.FireUpdateEvent == false)
\r
276 throw new InvalidOperationException("");
\r
277 return this.View.LayoutLines.GetLayout(row).Height; ;
\r
281 /// インデックスに対応する座標を得ます
\r
283 /// <param name="index">インデックス</param>
\r
284 /// <returns>座標を返す</returns>
\r
285 public Windows.Foundation.Point GetPostionFromIndex(int index)
\r
287 if (this.Document.FireUpdateEvent == false)
\r
288 throw new InvalidOperationException("");
\r
289 TextPoint tp = this.View.GetLayoutLineFromIndex(index);
\r
290 return this.View.GetPostionFromTextPoint(tp);
\r
294 /// 座標からインデックスに変換します
\r
296 /// <param name="p">座標</param>
\r
297 /// <returns>インデックスを返す</returns>
\r
298 public int GetIndexFromPostion(Windows.Foundation.Point p)
\r
300 if (this.Document.FireUpdateEvent == false)
\r
301 throw new InvalidOperationException("");
\r
302 TextPoint tp = this.View.GetTextPointFromPostion(p);
\r
303 return this.View.GetIndexFromLayoutLine(tp);
\r
309 public void Refresh()
\r
311 this.Refresh(this.View.PageBound);
\r
315 /// レイアウト行をすべて破棄し、再度レイアウトを行う
\r
317 public void PerfomLayouts()
\r
319 this.View.PerfomLayouts();
\r
325 /// <param name="row">行</param>
\r
326 /// <param name="alignTop">指定行を画面上に置くなら真。そうでないなら偽</param>
\r
327 public void ScrollIntoView(int row, bool alignTop)
\r
329 this.View.ScrollIntoView(row, alignTop);
\r
333 /// ファイルからドキュメントを構築する
\r
335 /// <param name="sr">StremReader</param>
\r
336 /// <returns>Taskオブジェクト</returns>
\r
337 public async Task LoadFileAsync(System.IO.StreamReader sr, System.Threading.CancellationTokenSource token)
\r
339 this.IsEnabled = false;
\r
340 this.View.LayoutLines.IsFrozneDirtyFlag = true;
\r
341 WinFileReader fs = new WinFileReader(sr);
\r
342 await this.Document.LoadAsync(fs, token);
\r
343 this.View.LayoutLines.IsFrozneDirtyFlag = false;
\r
344 TextStoreHelper.NotifyTextChanged(this.textStore, 0, 0, this.Document.Length);
\r
345 if (this.verticalScrollBar != null)
\r
346 this.verticalScrollBar.Maximum = this.View.LayoutLines.Count;
\r
347 this.View.CalculateLineCountOnScreen();
\r
348 this.IsEnabled = true;
\r
352 /// ドキュメントの内容をファイルに保存する
\r
354 /// <param name="sw">StreamWriter</param>
\r
355 /// <param name="enc">エンコード</param>
\r
356 /// <returns>Taskオブジェクト</returns>
\r
357 public async Task SaveFile(System.IO.StreamWriter sw, System.Threading.CancellationTokenSource token)
\r
359 WinFileWriter fs = new WinFileWriter(sw);
\r
360 await this.Document.SaveAsync(fs, token);
\r
375 async Task PasteCommand()
\r
377 await this.PasteAsync();
\r
385 protected override Windows.UI.Xaml.Automation.Peers.AutomationPeer OnCreateAutomationPeer()
\r
387 this.peer = new FooTextBoxAutomationPeer(this);
\r
392 protected override void OnApplyTemplate()
\r
394 base.OnApplyTemplate();
\r
396 Grid grid = this.GetTemplateChild("PART_Grid") as Grid;
\r
399 Grid.SetRow(this.rectangle, 0);
\r
400 Grid.SetColumn(this.rectangle, 0);
\r
401 grid.Children.Add(this.rectangle);
\r
404 this.horizontalScrollBar = this.GetTemplateChild("PART_HorizontalScrollBar") as ScrollBar;
\r
405 if (this.horizontalScrollBar != null)
\r
407 this.horizontalScrollBar.SmallChange = 10;
\r
408 this.horizontalScrollBar.LargeChange = 100;
\r
409 this.horizontalScrollBar.Maximum = this.horizontalScrollBar.LargeChange + 1;
\r
410 this.horizontalScrollBar.Scroll += new ScrollEventHandler(horizontalScrollBar_Scroll);
\r
412 this.verticalScrollBar = this.GetTemplateChild("PART_VerticalScrollBar") as ScrollBar;
\r
413 if (this.verticalScrollBar != null)
\r
415 this.verticalScrollBar.SmallChange = 1;
\r
416 this.verticalScrollBar.LargeChange = 10;
\r
417 this.verticalScrollBar.Maximum = this.View.LayoutLines.Count;
\r
418 this.verticalScrollBar.Scroll += new ScrollEventHandler(verticalScrollBar_Scroll);
\r
423 protected override void OnGotFocus(RoutedEventArgs e)
\r
425 base.OnGotFocus(e);
\r
426 this.textStore.SetFocus();
\r
427 this.View.IsFocused = true;
\r
432 protected override void OnLostFocus(RoutedEventArgs e)
\r
434 base.OnLostFocus(e);
\r
435 this.View.IsFocused = false;
\r
440 protected override async void OnKeyDown(KeyRoutedEventArgs e)
\r
442 bool isControlPressed = this.IsModiferKeyPressed(VirtualKey.Control);
\r
443 bool isShiftPressed = this.IsModiferKeyPressed(VirtualKey.Shift);
\r
444 bool isMovedCaret = false;
\r
447 case VirtualKey.Up:
\r
448 this._Controller.MoveCaretVertical(-1, isShiftPressed);
\r
451 isMovedCaret = true;
\r
453 case VirtualKey.Down:
\r
454 this._Controller.MoveCaretVertical(+1, isShiftPressed);
\r
457 isMovedCaret = true;
\r
459 case VirtualKey.Left:
\r
460 this._Controller.MoveCaretHorizontical(-1, isShiftPressed, isControlPressed);
\r
463 isMovedCaret = true;
\r
465 case VirtualKey.Right:
\r
466 this._Controller.MoveCaretHorizontical(1, isShiftPressed, isControlPressed);
\r
469 isMovedCaret = true;
\r
471 case VirtualKey.PageUp:
\r
472 this._Controller.Scroll(ScrollDirection.Up, this.View.LineCountOnScreen, isShiftPressed, true);
\r
474 isMovedCaret = true;
\r
476 case VirtualKey.PageDown:
\r
477 this._Controller.Scroll(ScrollDirection.Down, this.View.LineCountOnScreen, isShiftPressed, true);
\r
479 isMovedCaret = true;
\r
481 case VirtualKey.Home:
\r
482 if (isControlPressed)
\r
483 this._Controller.JumpToHead(isShiftPressed);
\r
485 this.Controller.JumpToLineHead(this.View.CaretPostion.row,isShiftPressed);
\r
487 isMovedCaret = true;
\r
489 case VirtualKey.End:
\r
490 if (isControlPressed)
\r
491 this._Controller.JumpToEnd(isShiftPressed);
\r
493 this.Controller.JumpToLineEnd(this.View.CaretPostion.row,isShiftPressed);
\r
495 isMovedCaret = true;
\r
497 case VirtualKey.Tab:
\r
498 if (!isControlPressed)
\r
500 if (this._Controller.SelectionLength == 0)
\r
501 this._Controller.DoInputChar('\t');
\r
502 else if (isShiftPressed)
\r
503 this._Controller.DownIndent();
\r
505 this._Controller.UpIndent();
\r
510 case VirtualKey.Enter:
\r
511 this._Controller.DoEnterAction();
\r
515 case VirtualKey.Insert:
\r
516 if(this.View.InsertMode)
\r
517 this.View.InsertMode = false;
\r
519 this.View.InsertMode = true;
\r
524 if (isControlPressed)
\r
532 if (isControlPressed)
\r
534 if (this._Controller.RectSelection)
\r
535 this._Controller.RectSelection = false;
\r
537 this._Controller.RectSelection = true;
\r
543 if (isControlPressed)
\r
545 this.CopyCommand();
\r
550 if (isControlPressed)
\r
557 if (isControlPressed)
\r
559 await this.PasteCommand();
\r
564 if (isControlPressed)
\r
566 this.Document.UndoManager.redo();
\r
572 if (isControlPressed)
\r
574 this.Document.UndoManager.undo();
\r
579 case VirtualKey.Back:
\r
580 this._Controller.DoBackSpaceAction();
\r
584 case VirtualKey.Delete:
\r
585 this._Controller.DoDeleteAction();
\r
590 if (isMovedCaret && this.peer != null)
\r
591 this.peer.OnNotifyCaretChanged();
\r
596 protected override void OnPointerPressed(PointerRoutedEventArgs e)
\r
598 this.CapturePointer(e.Pointer);
\r
599 this.gestureRecongnizer.ProcessDownEvent(e.GetCurrentPoint(this));
\r
604 protected override void OnPointerMoved(PointerRoutedEventArgs e)
\r
606 this.gestureRecongnizer.ProcessMoveEvents(e.GetIntermediatePoints(this));
\r
609 if (e.Pointer.PointerDeviceType == PointerDeviceType.Mouse)
\r
611 Point p = e.GetCurrentPoint(this).Position;
\r
612 if (this.View.HitTextArea(p.X, p.Y))
\r
614 TextPoint tp = this.View.GetTextPointFromPostion(p);
\r
615 if (this._Controller.IsMarker(tp, HilightType.Url))
\r
616 Window.Current.CoreWindow.PointerCursor = new CoreCursor(CoreCursorType.Hand, 101);
\r
618 Window.Current.CoreWindow.PointerCursor = new CoreCursor(CoreCursorType.IBeam, 101);
\r
622 Window.Current.CoreWindow.PointerCursor = new CoreCursor(CoreCursorType.Arrow, 101);
\r
628 protected override void OnPointerReleased(PointerRoutedEventArgs e)
\r
630 this.gestureRecongnizer.ProcessUpEvent(e.GetCurrentPoint(this));
\r
631 this.ReleasePointerCapture(e.Pointer);
\r
636 protected override void OnPointerCanceled(PointerRoutedEventArgs e)
\r
638 this.gestureRecongnizer.CompleteGesture();
\r
639 this.ReleasePointerCapture(e.Pointer);
\r
644 protected override void OnPointerCaptureLost(PointerRoutedEventArgs e)
\r
646 this.gestureRecongnizer.CompleteGesture();
\r
647 this.ReleasePointerCapture(e.Pointer);
\r
652 protected override void OnPointerWheelChanged(PointerRoutedEventArgs e)
\r
654 bool shift = (e.KeyModifiers & Windows.System.VirtualKeyModifiers.Shift) ==
\r
655 Windows.System.VirtualKeyModifiers.Shift;
\r
656 bool ctrl = (e.KeyModifiers & Windows.System.VirtualKeyModifiers.Control) ==
\r
657 Windows.System.VirtualKeyModifiers.Control;
\r
658 this.gestureRecongnizer.ProcessMouseWheelEvent(e.GetCurrentPoint(this), shift, ctrl);
\r
662 void CoreWindow_CharacterReceived(CoreWindow sender, CharacterReceivedEventArgs args)
\r
664 if (this.FocusState == FocusState.Unfocused || !this.IsEnabled)
\r
666 if (args.KeyCode >= 00 && args.KeyCode <= 0x1f)
\r
668 this._Controller.DoInputString(Char.ConvertFromUtf32((int)args.KeyCode));
\r
672 double textStore_GetDpi()
\r
675 this.Render.GetDpi(out dpi, out dpi);
\r
679 bool textStore_IsReadOnly()
\r
684 bool textStore_IsLoading()
\r
689 void textStore_CompositionEnded()
\r
691 TextStoreHelper.EndCompostion(this.Document);
\r
695 void textStore_CompositionUpdated(int start, int end)
\r
697 if (TextStoreHelper.ScrollToCompstionUpdated(this.textStore, this.View, start, end))
\r
700 bool textStore_CompositionStarted()
\r
702 return TextStoreHelper.StartCompstion(this.Document);
\r
705 string _textStore_GetString(int start, int length)
\r
707 return this.Document.ToString(start, length);
\r
710 void _textStore_GetStringExtent(
\r
713 out POINT o_topLeft,
\r
714 out POINT o_bottomRight
\r
717 Point startPos, endPos;
\r
718 TextStoreHelper.GetStringExtent(this.Document, this.View, i_startIndex, i_endIndex, out startPos, out endPos);
\r
720 var gt = this.TransformToVisual(Window.Current.Content);
\r
721 startPos = gt.TransformPoint(startPos);
\r
722 endPos = gt.TransformPoint(endPos);
\r
724 o_topLeft = new POINT((int)startPos.X, (int)startPos.Y);
\r
725 o_bottomRight = new POINT((int)endPos.X, (int)endPos.Y);
\r
728 void _textStore_GetScreenExtent(out POINT o_topLeft, out POINT o_bottomRight)
\r
730 var pointTopLeft = new Point(0, 0);
\r
731 var pointBottomRight = new Point(this.RenderSize.Width, this.RenderSize.Height);
\r
733 var gt = this.TransformToVisual(Window.Current.Content);
\r
734 pointTopLeft = gt.TransformPoint(pointTopLeft);
\r
735 pointBottomRight = gt.TransformPoint(pointBottomRight);
\r
737 o_topLeft = new POINT((int)pointTopLeft.X, (int)pointTopLeft.Y);
\r
738 o_bottomRight = new POINT((int)pointBottomRight.X, (int)pointBottomRight.Y);
\r
741 void _textStore_GetSelectionIndex(out int o_startIndex, out int o_endIndex)
\r
743 TextStoreHelper.GetSelection(this._Controller, this.View.Selections, out o_startIndex, out o_endIndex);
\r
746 void _textStore_SetSelectionIndex(int i_startIndex, int i_endIndex)
\r
748 TextStoreHelper.SetSelectionIndex(this._Controller, this.View, i_startIndex, i_endIndex);
\r
752 void _textStore_InsertAtSelection(string i_value,ref int o_stratIndex,ref int o_endIndex)
\r
754 TextStoreHelper.InsertTextAtSelection(this._Controller, i_value);
\r
758 void Controller_SelectionChanged(object sender, EventArgs e)
\r
760 //こうしないと選択できなくなってしまう
\r
761 this.nowCaretMove = true;
\r
762 SetValue(SelectionProperty, new TextRange(this._Controller.SelectionStart, this._Controller.SelectionLength));
\r
763 SetValue(CaretPostionPropertyKey, this.View.CaretPostion);
\r
764 this.nowCaretMove = false;
\r
765 if (this.textStore.IsLocked() == false)
\r
766 this.textStore.NotifySelectionChanged();
\r
769 Gripper FirstGripper, SecondGripper;
\r
771 Gripper hittedGripper;
\r
772 void gestureRecongnizer_ManipulationStarted(GestureRecognizer sender, ManipulationStartedEventArgs e)
\r
774 this.HittedCaret = false;
\r
775 this.hittedGripper = null;
\r
777 Point p = e.Position;
\r
778 TextPoint tp = this.View.GetTextPointFromPostion(p);
\r
779 if (tp == this.View.CaretPostion)
\r
781 HittedCaret = true;
\r
784 if (this.FirstGripper.IsHit(p))
\r
786 hittedGripper = this.FirstGripper;
\r
787 HittedCaret = true;
\r
790 else if (this.SecondGripper.IsHit(p))
\r
792 hittedGripper = this.SecondGripper;
\r
793 HittedCaret = true;
\r
797 void gestureRecongnizer_ManipulationUpdated(GestureRecognizer sender, ManipulationUpdatedEventArgs e)
\r
802 if (this.hittedGripper == null)
\r
805 p = this.hittedGripper.AdjustPoint(e.Position);
\r
807 if (hittedGripper != null)
\r
809 TextPoint tp = this.View.GetTextPointFromPostion(p);
\r
810 if (this._Controller.IsReverseSelect())
\r
812 if (Object.ReferenceEquals(hittedGripper,this.SecondGripper))
\r
813 this._Controller.MoveSelectBefore(tp);
\r
815 this._Controller.MoveCaretAndSelect(tp);
\r
819 if (Object.ReferenceEquals(hittedGripper,this.FirstGripper))
\r
820 this._Controller.MoveSelectBefore(tp);
\r
822 this._Controller.MoveCaretAndSelect(tp);
\r
827 TextPoint tp = this.View.GetTextPointFromPostion(p);
\r
828 this._Controller.MoveCaretAndSelect(tp);
\r
830 if (this.peer != null)
\r
831 this.peer.OnNotifyCaretChanged();
\r
835 if (e.Delta.Scale < 1)
\r
837 double newSize = this.Render.FontSize - 1;
\r
840 this.Render.FontSize = newSize;
\r
842 SetValue(MagnificationPowerPropertyKey, this.Render.FontSize / this.FontSize);
\r
846 if (e.Delta.Scale > 1)
\r
848 double newSize = this.Render.FontSize + 1;
\r
851 this.Render.FontSize = newSize;
\r
853 SetValue(MagnificationPowerPropertyKey, this.Render.FontSize / this.FontSize);
\r
857 Point translation = e.Delta.Translation;
\r
859 int scrollCount = (int)Math.Abs(translation.Y);
\r
860 if (scrollCount > 0)
\r
862 if (scrollCount > this.View.LineCountOnScreen) //ホイール対策
\r
863 scrollCount = this.View.LineCountOnScreen;
\r
864 if (translation.Y > 0)
\r
865 this._Controller.Scroll(ScrollDirection.Up, scrollCount, false, false);
\r
867 this._Controller.Scroll(ScrollDirection.Down, scrollCount, false, false);
\r
868 this.FirstGripper.Enabled = false;
\r
869 this.SecondGripper.Enabled = false;
\r
874 int deltax = (int)Math.Abs(translation.X);
\r
877 if (translation.X < 0)
\r
878 this._Controller.Scroll(ScrollDirection.Left, deltax, false, false);
\r
880 this._Controller.Scroll(ScrollDirection.Right, deltax, false, false);
\r
881 this.FirstGripper.Enabled = false;
\r
882 this.SecondGripper.Enabled = false;
\r
887 void gestureRecongnizer_ManipulationCompleted(GestureRecognizer sender, ManipulationCompletedEventArgs e)
\r
891 async void gestureRecongnizer_RightTapped(GestureRecognizer sender, RightTappedEventArgs e)
\r
893 ResourceMap map = ResourceManager.Current.MainResourceMap.GetSubtree("FooEditEngine.Metro/Resources");
\r
894 ResourceContext context = ResourceContext.GetForCurrentView();
\r
895 if (this.View.HitTextArea(e.Position.X, e.Position.Y))
\r
897 FooContextMenuEventArgs args = new FooContextMenuEventArgs(e.Position);
\r
898 if (this.ContextMenuOpening != null)
\r
899 this.ContextMenuOpening(this, args);
\r
902 PopupMenu ContextMenu = new PopupMenu();
\r
903 ContextMenu.Commands.Add(new UICommand(map.GetValue("CopyMenuName", context).ValueAsString, (command) =>
\r
905 this.CopyCommand();
\r
907 ContextMenu.Commands.Add(new UICommand(map.GetValue("CutMenuName", context).ValueAsString, (command) =>
\r
911 ContextMenu.Commands.Add(new UICommand(map.GetValue("PasteMenuName", context).ValueAsString, async (command) =>
\r
913 await this.PasteCommand();
\r
915 if (this._Controller.RectSelection)
\r
917 ContextMenu.Commands.Add(new UICommand(map.GetValue("LineSelectMenuName", context).ValueAsString, (command) =>
\r
919 this._Controller.RectSelection = false;
\r
924 ContextMenu.Commands.Add(new UICommand(map.GetValue("RectSelectMenuName", context).ValueAsString, (command) =>
\r
926 this._Controller.RectSelection = true;
\r
929 await ContextMenu.ShowAsync(Util.GetScreentPoint(e.Position,this));
\r
934 void gestureRecongnizer_Tapped(GestureRecognizer sender, TappedEventArgs e)
\r
936 bool touched = e.PointerDeviceType == PointerDeviceType.Touch;
\r
937 this.FirstGripper.Enabled = touched;
\r
938 this.SecondGripper.Enabled = touched;
\r
939 this.JumpCaret(e.Position);
\r
942 void JumpCaret(Point p)
\r
944 TextPoint tp = this.View.GetTextPointFromPostion(p);
\r
945 if (tp == TextPoint.Null)
\r
948 int index = this.View.LayoutLines.GetIndexFromTextPoint(tp);
\r
950 FoldingItem foldingData = this.View.HitFoldingData(p.X, tp.row);
\r
951 if (foldingData != null)
\r
953 if (foldingData.Expand)
\r
954 this.View.LayoutLines.FoldingCollection.Collapse(foldingData);
\r
956 this.View.LayoutLines.FoldingCollection.Expand(foldingData);
\r
957 this._Controller.JumpCaret(foldingData.Start, false);
\r
961 this._Controller.JumpCaret(tp.row, tp.col, false);
\r
963 if (this.peer != null)
\r
964 this.peer.OnNotifyCaretChanged();
\r
965 this.View.IsFocused = true;
\r
966 this.Focus(FocusState.Programmatic);
\r
970 void gestureRecongnizer_Dragging(GestureRecognizer sender, DraggingEventArgs e)
\r
972 Point p = e.Position;
\r
973 if (this.View.HitTextArea(p.X, p.Y))
\r
975 TextPoint tp = this.View.GetTextPointFromPostion(p);
\r
976 this._Controller.MoveCaretAndSelect(tp);
\r
977 if (this.peer != null)
\r
978 this.peer.OnNotifyCaretChanged();
\r
983 bool IsModiferKeyPressed(VirtualKey key)
\r
985 CoreVirtualKeyStates state = Window.Current.CoreWindow.GetKeyState(key);
\r
986 return (state & CoreVirtualKeyStates.Down) == CoreVirtualKeyStates.Down;
\r
988 void Refresh(Rectangle updateRect)
\r
990 if (this.rectangle.ActualWidth == 0 || this.rectangle.ActualHeight == 0 || this.Visibility == Windows.UI.Xaml.Visibility.Collapsed)
\r
993 this.Render.BegineDraw();
\r
994 if (this.IsEnabled)
\r
995 this.View.Draw(updateRect);
\r
997 this.Render.FillBackground(updateRect);
\r
998 this.FirstGripper.Draw();
\r
999 this.SecondGripper.Draw();
\r
1000 this.Render.EndDraw();
\r
1004 bool Resize(double width, double height)
\r
1006 if (width == 0 || height == 0)
\r
1007 throw new ArgumentOutOfRangeException();
\r
1008 if (this.Render.Resize(this.rectangle, width, height))
\r
1010 this.View.PageBound = new Rectangle(0, 0, width, height);
\r
1012 if (this.horizontalScrollBar != null)
\r
1014 this.horizontalScrollBar.LargeChange = this.View.PageBound.Width;
\r
1015 this.horizontalScrollBar.Maximum = this.View.LongestWidth + this.horizontalScrollBar.LargeChange + 1;
\r
1017 if (this.verticalScrollBar != null)
\r
1019 this.verticalScrollBar.LargeChange = this.View.LineCountOnScreen;
\r
1020 this.verticalScrollBar.Maximum = this.View.LayoutLines.Count + this.verticalScrollBar.LargeChange + 1;
\r
1027 void View_SrcChanged(object sender, EventArgs e)
\r
1029 if (this.horizontalScrollBar == null || this.verticalScrollBar == null)
\r
1031 EditView view = this.View;
\r
1032 if (view.Src.Row > this.verticalScrollBar.Maximum)
\r
1033 this.verticalScrollBar.Maximum = view.Src.Row + view.LineCountOnScreen + 1;
\r
1034 double absoulteX = Math.Abs(view.Src.X);
\r
1035 if (absoulteX > this.horizontalScrollBar.Maximum)
\r
1036 this.horizontalScrollBar.Maximum = absoulteX + view.PageBound.Width + 1;
\r
1037 if (view.Src.Row != this.verticalScrollBar.Value)
\r
1038 this.verticalScrollBar.Value = view.Src.Row;
\r
1039 if (view.Src.X != this.horizontalScrollBar.Value)
\r
1040 this.horizontalScrollBar.Value = Math.Abs(view.Src.X);
\r
1043 void FooTextBox_SizeChanged(object sender, SizeChangedEventArgs e)
\r
1045 if (this.Resize(this.rectangle.ActualWidth, this.rectangle.ActualHeight))
\r
1052 void horizontalScrollBar_Scroll(object sender, ScrollEventArgs e)
\r
1054 if (this.horizontalScrollBar == null)
\r
1057 if (this.FlowDirection == FlowDirection.LeftToRight)
\r
1058 toX = this.horizontalScrollBar.Value;
\r
1060 toX = -this.horizontalScrollBar.Value;
\r
1061 this._Controller.Scroll(toX, this.View.Src.Row, false, false);
\r
1062 this.FirstGripper.Enabled = false;
\r
1063 this.SecondGripper.Enabled = false;
\r
1067 void verticalScrollBar_Scroll(object sender, ScrollEventArgs e)
\r
1069 if (this.verticalScrollBar == null)
\r
1071 int newRow = (int)this.verticalScrollBar.Value;
\r
1072 if (newRow >= this.View.LayoutLines.Count)
\r
1074 this._Controller.Scroll(this.View.Src.X, newRow, false, false);
\r
1075 this.FirstGripper.Enabled = false;
\r
1076 this.SecondGripper.Enabled = false;
\r
1080 void Document_Update(object sender, DocumentUpdateEventArgs e)
\r
1082 if (this.textStore.IsLocked())
\r
1084 TextStoreHelper.NotifyTextChanged(this.textStore, e.startIndex, e.removeLength, e.insertLength);
\r
1087 void FooTextBox_Loaded(object sender, RoutedEventArgs e)
\r
1089 this.Focus(FocusState.Programmatic);
\r
1093 public static void OnPropertyChanged(object sender, DependencyPropertyChangedEventArgs e)
\r
1095 FooTextBox source = (FooTextBox)sender;
\r
1096 if (e.Property.Equals(IndentModeProperty))
\r
1097 source.Controller.IndentMode = source.IndentMode;
\r
1098 if (e.Property.Equals(SelectionProperty) && !source.nowCaretMove)
\r
1099 source._Controller.Select(source.Selection.Index,source.Selection.Length);
\r
1100 if (e.Property.Equals(CaretPostionPropertyKey) && !source.nowCaretMove)
\r
1101 source.JumpCaret(source.CaretPostion.row, source.CaretPostion.col);
\r
1102 if (e.Property.Equals(InsertModeProperty))
\r
1103 source.View.InsertMode = source.InsertMode;
\r
1104 if (e.Property.Equals(TabCharsProperty))
\r
1105 source.View.TabStops = source.TabChars;
\r
1106 if (e.Property.Equals(RectSelectModeProperty))
\r
1107 source._Controller.RectSelection = source.RectSelectMode;
\r
1108 if (e.Property.Equals(DrawCaretProperty))
\r
1109 source.View.HideCaret = !source.DrawCaret;
\r
1110 if (e.Property.Equals(DrawCaretLineProperty))
\r
1111 source.View.HideLineMarker = !source.DrawCaretLine;
\r
1112 if (e.Property.Equals(DrawLineNumberProperty))
\r
1114 source.View.DrawLineNumber = source.DrawLineNumber;
\r
1115 source._Controller.JumpCaret(source.View.CaretPostion.row, source.View.CaretPostion.col);
\r
1117 if(e.Property.Equals(MagnificationPowerPropertyKey))
\r
1118 source.Render.FontSize = source.FontSize * source.MagnificationPower;
\r
1119 if (e.Property.Equals(FontFamilyProperty))
\r
1120 source.Render.FontFamily = source.FontFamily;
\r
1121 if (e.Property.Equals(FontStyleProperty))
\r
1122 source.Render.FontStyle = source.FontStyle;
\r
1123 if (e.Property.Equals(FontWeightProperty))
\r
1124 source.Render.FontWeigth = source.FontWeight;
\r
1125 if (e.Property.Equals(FontSizeProperty))
\r
1126 source.Render.FontSize = source.FontSize;
\r
1127 if (e.Property.Equals(ForegroundProperty))
\r
1128 source.Render.Foreground = D2DRenderBase.ToColor4(source.Foreground);
\r
1129 if (e.Property.Equals(BackgroundProperty))
\r
1130 source.Render.Background = D2DRenderBase.ToColor4(source.Background);
\r
1131 if (e.Property.Equals(ControlCharProperty))
\r
1132 source.Render.ControlChar = D2DRenderBase.ToColor4(source.ControlChar);
\r
1133 if (e.Property.Equals(HilightProperty))
\r
1134 source.Render.Hilight = D2DRenderBase.ToColor4(source.Hilight);
\r
1135 if (e.Property.Equals(Keyword1Property))
\r
1136 source.Render.Keyword1 = D2DRenderBase.ToColor4(source.Keyword1);
\r
1137 if (e.Property.Equals(Keyword2Property))
\r
1138 source.Render.Keyword2 = D2DRenderBase.ToColor4(source.Keyword2);
\r
1139 if (e.Property.Equals(CommentProperty))
\r
1140 source.Render.Comment = D2DRenderBase.ToColor4(source.Comment);
\r
1141 if (e.Property.Equals(LiteralProperty))
\r
1142 source.Render.Literal = D2DRenderBase.ToColor4(source.Literal);
\r
1143 if (e.Property.Equals(URLProperty))
\r
1144 source.Render.Url = D2DRenderBase.ToColor4(source.URL);
\r
1145 if (e.Property.Equals(InsertCaretProperty))
\r
1146 source.Render.InsertCaret = D2DRenderBase.ToColor4(source.InsertCaret);
\r
1147 if (e.Property.Equals(OverwriteCaretProperty))
\r
1148 source.Render.OverwriteCaret = D2DRenderBase.ToColor4(source.OverwriteCaret);
\r
1149 if (e.Property.Equals(PaddingProperty))
\r
1150 source.View.Padding = new Padding((int)source.Padding.Left, (int)source.Padding.Top, (int)source.Padding.Right, (int)source.Padding.Bottom);
\r
1151 if (e.Property.Equals(LineMarkerProperty))
\r
1152 source.Render.LineMarker = D2DRenderBase.ToColor4(source.LineMarker);
\r
1153 if (e.Property.Equals(MarkURLProperty))
\r
1154 source.View.UrlMark = source.MarkURL;
\r
1155 if (e.Property.Equals(ShowFullSpaceProperty))
\r
1156 source.Render.ShowFullSpace = source.ShowFullSpace;
\r
1157 if (e.Property.Equals(ShowHalfSpaceProperty))
\r
1158 source.Render.ShowHalfSpace = source.ShowHalfSpace;
\r
1159 if (e.Property.Equals(ShowTabProperty))
\r
1160 source.Render.ShowTab = source.ShowTab;
\r
1161 if (e.Property.Equals(ShowLineBreakProperty))
\r
1162 source.Render.ShowLineBreak = source.ShowLineBreak;
\r
1163 if (e.Property.Equals(LineBreakProperty))
\r
1164 source.View.LineBreak = source.LineBreakMethod;
\r
1165 if (e.Property.Equals(LineBreakCharCountProperty))
\r
1166 source.View.LineBreakCharCount = source.LineBreakCharCount;
\r
1167 if (e.Property.Equals(UpdateAreaProperty))
\r
1168 source.Render.UpdateArea = D2DRenderBase.ToColor4(source.UpdateArea);
\r
1169 if (e.Property.Equals(LineNumberProperty))
\r
1170 source.Render.LineNumber = D2DRenderBase.ToColor4(source.LineNumber);
\r
1171 if (e.Property.Equals(FlowDirectionProperty))
\r
1173 source.Render.RightToLeft = source.FlowDirection == Windows.UI.Xaml.FlowDirection.RightToLeft;
\r
1174 if(source.horizontalScrollBar != null)
\r
1175 source.horizontalScrollBar.FlowDirection = source.FlowDirection;
\r
1177 if (e.Property.Equals(DrawRulerProperty))
\r
1179 source.View.HideRuler = !source.DrawRuler;
\r
1180 source._Controller.JumpCaret(source.View.CaretPostion.row, source.View.CaretPostion.col);
\r
1188 /// コンテキストメニューが表示されるときに呼び出されます
\r
1190 public event EventHandler<FooContextMenuEventArgs> ContextMenuOpening;
\r
1196 internal Controller Controller
\r
1200 return this._Controller;
\r
1205 /// 文字列の描写に使用されるアンチエイリアシング モードを表します
\r
1207 public TextAntialiasMode TextAntialiasMode
\r
1211 return this.Render.TextAntialiasMode;
\r
1215 this.Render.TextAntialiasMode = value;
\r
1220 /// シンタックスハイライターを表す
\r
1222 public IHilighter Hilighter
\r
1226 return this.View.Hilighter;
\r
1230 this.View.Hilighter = value;
\r
1231 this.View.LayoutLines.ClearLayoutCache();
\r
1236 /// フォールティングを作成するインターフェイスを表す
\r
1238 public IFoldingStrategy FoldingStrategy
\r
1242 return this.View.LayoutLines.FoldingStrategy;
\r
1246 this.View.LayoutLines.FoldingStrategy = value;
\r
1247 if (value == null)
\r
1248 this.View.LayoutLines.FoldingCollection.Clear();
\r
1253 /// マーカーパターンセットを表す
\r
1255 public MarkerPatternSet MarkerPatternSet
\r
1259 return this.View.MarkerPatternSet;
\r
1266 public Document Document
\r
1275 public LineToIndexTable LayoutLineCollection
\r
1277 get { return this.View.LayoutLines; }
\r
1283 public string SelectedText
\r
1287 return this._Controller.SelectedText;
\r
1291 int oldLength = this.Document.Length;
\r
1292 this._Controller.SelectedText = value;
\r
1299 public IndentMode IndentMode
\r
1301 get { return (IndentMode)GetValue(IndentModeProperty); }
\r
1302 set { SetValue(IndentModeProperty, value); }
\r
1306 /// IndentModeの依存プロパティを表す
\r
1308 public static readonly DependencyProperty IndentModeProperty =
\r
1309 DependencyProperty.Register("IndentMode", typeof(IndentMode), typeof(FooTextBox), new PropertyMetadata(IndentMode.Tab,OnPropertyChanged));
\r
1315 /// Lengthが0の場合はキャレット位置を表します。
\r
1316 /// 矩形選択モードの場合、選択範囲の文字数ではなく、開始位置から終了位置までの長さとなります
\r
1318 public TextRange Selection
\r
1320 get { return (TextRange)GetValue(SelectionProperty); }
\r
1321 set { SetValue(SelectionProperty, value); }
\r
1325 /// Selectionの依存プロパティを表す
\r
1327 public static readonly DependencyProperty SelectionProperty =
\r
1328 DependencyProperty.Register("Selection", typeof(TextRange), typeof(FooTextBox), new PropertyMetadata(0));
\r
1333 public double MagnificationPower
\r
1335 get { return (double)GetValue(MagnificationPowerPropertyKey); }
\r
1336 set { SetValue(MagnificationPowerPropertyKey, value); }
\r
1342 public static readonly DependencyProperty MagnificationPowerPropertyKey =
\r
1343 DependencyProperty.Register("MagnificationPower", typeof(double), typeof(FooTextBox), new PropertyMetadata(1.0, OnPropertyChanged));
\r
1348 public TextPoint CaretPostion
\r
1350 get { return (TextPoint)GetValue(CaretPostionPropertyKey); }
\r
1351 set { SetValue(CaretPostionPropertyKey, value); }
\r
1354 static readonly DependencyProperty CaretPostionPropertyKey =
\r
1355 DependencyProperty.Register("CaretPostion", typeof(TextPoint), typeof(FooTextBox), new PropertyMetadata(new TextPoint(), OnPropertyChanged));
\r
1360 public new FlowDirection FlowDirection
\r
1362 get { return (FlowDirection)GetValue(FlowDirectionProperty); }
\r
1363 set { SetValue(FlowDirectionProperty, value); }
\r
1367 /// レタリング方向を表す。これは依存プロパティです
\r
1369 public new static readonly DependencyProperty FlowDirectionProperty =
\r
1370 DependencyProperty.Register("FlowDirection", typeof(FlowDirection), typeof(FooTextBox), new PropertyMetadata(FlowDirection.LeftToRight,OnPropertyChanged));
\r
1375 public new FontFamily FontFamily
\r
1377 get { return (FontFamily)GetValue(FontFamilyProperty); }
\r
1378 set { SetValue(FontFamilyProperty, value); }
\r
1382 /// FontFamilyの依存プロパティを表す
\r
1384 public new static readonly DependencyProperty FontFamilyProperty =
\r
1385 DependencyProperty.Register("FontFamily", typeof(FontFamily), typeof(FooTextBox), new PropertyMetadata(new FontFamily("Cambria"), OnPropertyChanged));
\r
1390 public new double FontSize
\r
1392 get { return (double)GetValue(FontSizeProperty); }
\r
1393 set { SetValue(FontSizeProperty, value); }
\r
1397 /// FontSizeの依存プロパティを表す
\r
1399 public new static readonly DependencyProperty FontSizeProperty =
\r
1400 DependencyProperty.Register("FontSize", typeof(double), typeof(FooTextBox), new PropertyMetadata(12.0,OnPropertyChanged));
\r
1405 public new FontStyle FontStyle
\r
1407 get { return (FontStyle)GetValue(FontStyleProperty); }
\r
1408 set { SetValue(FontStyleProperty, value); }
\r
1412 /// FontStyleの依存プロパティを表す
\r
1414 public new static readonly DependencyProperty FontStyleProperty =
\r
1415 DependencyProperty.Register("FontStyle", typeof(FontStyle), typeof(FooTextBox), new PropertyMetadata(FontStyle.Normal,OnPropertyChanged));
\r
1420 public new FontWeight FontWeight
\r
1422 get { return (FontWeight)GetValue(FontWeightProperty); }
\r
1423 set { SetValue(FontWeightProperty, value); }
\r
1427 /// FontWeigthの依存プロパティを表す
\r
1429 public new static readonly DependencyProperty FontWeightProperty =
\r
1430 DependencyProperty.Register("FontWeigth", typeof(FontWeight), typeof(FooTextBox), new PropertyMetadata(FontWeights.Normal,OnPropertyChanged));
\r
1433 /// デフォルトの文字色を表す。これは依存プロパティです
\r
1435 public new Windows.UI.Color Foreground
\r
1437 get { return (Windows.UI.Color)GetValue(ForegroundProperty); }
\r
1438 set { SetValue(ForegroundProperty, value); }
\r
1442 /// Foregroundの依存プロパティを表す
\r
1444 public new static readonly DependencyProperty ForegroundProperty =
\r
1445 DependencyProperty.Register("Foreground", typeof(Windows.UI.Color), typeof(FooTextBox), new PropertyMetadata(Colors.Black, OnPropertyChanged));
\r
1448 /// 背景色を表す。これは依存プロパティです
\r
1450 public new Windows.UI.Color Background
\r
1452 get { return (Windows.UI.Color)GetValue(BackgroundProperty); }
\r
1453 set { SetValue(BackgroundProperty, value); }
\r
1457 /// Backgroundの依存プロパティを表す
\r
1459 public new static readonly DependencyProperty BackgroundProperty =
\r
1460 DependencyProperty.Register("Background", typeof(Windows.UI.Color), typeof(FooTextBox), new PropertyMetadata(Colors.White, OnPropertyChanged));
\r
1463 /// コントロールコードの文字色を表す。これは依存プロパティです
\r
1465 public Windows.UI.Color ControlChar
\r
1467 get { return (Windows.UI.Color)GetValue(ControlCharProperty); }
\r
1468 set { SetValue(ControlCharProperty, value); }
\r
1472 /// ControlCharの依存プロパティを表す
\r
1474 public static readonly DependencyProperty ControlCharProperty =
\r
1475 DependencyProperty.Register("ControlChar", typeof(Windows.UI.Color), typeof(FooTextBox), new PropertyMetadata(Colors.Gray, OnPropertyChanged));
\r
1478 /// 選択時の背景色を表す。これは依存プロパティです
\r
1480 public Windows.UI.Color Hilight
\r
1482 get { return (Windows.UI.Color)GetValue(HilightProperty); }
\r
1483 set { SetValue(HilightProperty, value); }
\r
1487 /// Hilightの依存プロパティを表す
\r
1489 public static readonly DependencyProperty HilightProperty =
\r
1490 DependencyProperty.Register("Hilight", typeof(Windows.UI.Color), typeof(FooTextBox), new PropertyMetadata(Colors.DeepSkyBlue, OnPropertyChanged));
\r
1493 /// キーワード1の文字色を表す。これは依存プロパティです
\r
1495 public Windows.UI.Color Keyword1
\r
1497 get { return (Windows.UI.Color)GetValue(Keyword1Property); }
\r
1498 set { SetValue(Keyword1Property, value); }
\r
1502 /// Keyword1の依存プロパティを表す
\r
1504 public static readonly DependencyProperty Keyword1Property =
\r
1505 DependencyProperty.Register("Keyword1", typeof(Windows.UI.Color), typeof(FooTextBox), new PropertyMetadata(Colors.Blue, OnPropertyChanged));
\r
1508 /// キーワード2の文字色を表す。これは依存プロパティです
\r
1510 public Windows.UI.Color Keyword2
\r
1512 get { return (Windows.UI.Color)GetValue(Keyword2Property); }
\r
1513 set { SetValue(Keyword2Property, value); }
\r
1517 /// Keyword2の依存プロパティを表す
\r
1519 public static readonly DependencyProperty Keyword2Property =
\r
1520 DependencyProperty.Register("Keyword2", typeof(Windows.UI.Color), typeof(FooTextBox), new PropertyMetadata(Colors.DarkCyan, OnPropertyChanged));
\r
1523 /// コメントの文字色を表す。これは依存プロパティです
\r
1525 public Windows.UI.Color Comment
\r
1527 get { return (Windows.UI.Color)GetValue(CommentProperty); }
\r
1528 set { SetValue(CommentProperty, value); }
\r
1532 /// Commentの依存プロパティを表す
\r
1534 public static readonly DependencyProperty CommentProperty =
\r
1535 DependencyProperty.Register("Comment", typeof(Windows.UI.Color), typeof(FooTextBox), new PropertyMetadata(Colors.Green, OnPropertyChanged));
\r
1538 /// 文字リテラルの文字色を表す。これは依存プロパティです
\r
1540 public Windows.UI.Color Literal
\r
1542 get { return (Windows.UI.Color)GetValue(LiteralProperty); }
\r
1543 set { SetValue(LiteralProperty, value); }
\r
1547 /// Literalの依存プロパティを表す
\r
1549 public static readonly DependencyProperty LiteralProperty =
\r
1550 DependencyProperty.Register("Literal", typeof(Windows.UI.Color), typeof(FooTextBox), new PropertyMetadata(Colors.Brown, OnPropertyChanged));
\r
1553 /// URLの文字色を表す。これは依存プロパティです
\r
1555 public Windows.UI.Color URL
\r
1557 get { return (Windows.UI.Color)GetValue(URLProperty); }
\r
1558 set { SetValue(URLProperty, value); }
\r
1562 /// URLの依存プロパティを表す
\r
1564 public static readonly DependencyProperty URLProperty =
\r
1565 DependencyProperty.Register("URL", typeof(Windows.UI.Color), typeof(FooTextBox), new PropertyMetadata(Colors.Blue, OnPropertyChanged));
\r
1570 public Windows.UI.Color UpdateArea
\r
1572 get { return (Windows.UI.Color)GetValue(UpdateAreaProperty); }
\r
1573 set { SetValue(UpdateAreaProperty, value); }
\r
1577 /// UpdateAreaの依存プロパティを表す
\r
1579 public static readonly DependencyProperty UpdateAreaProperty =
\r
1580 DependencyProperty.Register("UpdateArea", typeof(Windows.UI.Color), typeof(FooTextBox), new PropertyMetadata(Colors.MediumSeaGreen));
\r
1585 public Windows.UI.Color LineMarker
\r
1587 get { return (Windows.UI.Color)GetValue(LineMarkerProperty); }
\r
1588 set { SetValue(LineMarkerProperty, value); }
\r
1592 /// LineMarkerの依存プロパティを表す
\r
1594 public static readonly DependencyProperty LineMarkerProperty =
\r
1595 DependencyProperty.Register("LineMarker", typeof(Windows.UI.Color), typeof(FooTextBox), new PropertyMetadata(Colors.Gray, OnPropertyChanged));
\r
1598 /// 挿入モード時のキャレットの色を表す
\r
1600 public Windows.UI.Color InsertCaret
\r
1602 get { return (Windows.UI.Color)GetValue(InsertCaretProperty); }
\r
1603 set { SetValue(InsertCaretProperty, value); }
\r
1607 /// InsertCaretの依存プロパティを表す
\r
1609 public static readonly DependencyProperty InsertCaretProperty =
\r
1610 DependencyProperty.Register("InsertCaret", typeof(Windows.UI.Color), typeof(FooTextBox), new PropertyMetadata(Colors.Black, OnPropertyChanged));
\r
1613 /// 上書きモード時のキャレット職を表す
\r
1615 public Windows.UI.Color OverwriteCaret
\r
1617 get { return (Windows.UI.Color)GetValue(OverwriteCaretProperty); }
\r
1618 set { SetValue(OverwriteCaretProperty, value); }
\r
1622 /// OverwriteCaretの依存プロパティを表す
\r
1624 public static readonly DependencyProperty OverwriteCaretProperty =
\r
1625 DependencyProperty.Register("OverwriteCaret", typeof(Windows.UI.Color), typeof(FooTextBox), new PropertyMetadata(Colors.Black, OnPropertyChanged));
\r
1630 public Windows.UI.Color LineNumber
\r
1632 get { return (Windows.UI.Color)GetValue(LineNumberProperty); }
\r
1633 set { SetValue(LineNumberProperty, value); }
\r
1637 /// Using a DependencyProperty as the backing store for LineNumber. This enables animation, styling, binding, etc...
\r
1639 public static readonly DependencyProperty LineNumberProperty =
\r
1640 DependencyProperty.Register("LineNumber", typeof(Windows.UI.Color), typeof(FooTextBox), new PropertyMetadata(Colors.DimGray,OnPropertyChanged));
\r
1645 public new Thickness Padding
\r
1647 get { return (Thickness)GetValue(PaddingProperty); }
\r
1648 set { SetValue(PaddingProperty, value); }
\r
1652 /// Paddingの依存プロパティを表す
\r
1654 public new static readonly DependencyProperty PaddingProperty =
\r
1655 DependencyProperty.Register("Padding", typeof(Thickness), typeof(FooTextBox), new PropertyMetadata(new Thickness(),OnPropertyChanged));
\r
1658 /// 挿入モードなら真を返し、そうでないなら、偽を返す。これは依存プロパティです
\r
1660 public bool InsertMode
\r
1662 get { return (bool)GetValue(InsertModeProperty); }
\r
1663 set { SetValue(InsertModeProperty, value); }
\r
1667 /// InsertModeの依存プロパティを表す
\r
1669 public static readonly DependencyProperty InsertModeProperty =
\r
1670 DependencyProperty.Register("InsertMode",
\r
1672 typeof(FooTextBox),
\r
1673 new PropertyMetadata(true, OnPropertyChanged));
\r
1676 /// タブの文字数を表す。これは依存プロパティです
\r
1678 public int TabChars
\r
1680 get { return (int)GetValue(TabCharsProperty); }
\r
1681 set { SetValue(TabCharsProperty, value); }
\r
1685 /// TabCharsの依存プロパティを表す
\r
1687 public static readonly DependencyProperty TabCharsProperty =
\r
1688 DependencyProperty.Register("TabChars",
\r
1690 typeof(FooTextBox),
\r
1691 new PropertyMetadata(4, OnPropertyChanged));
\r
1694 /// 矩形選択モードなら真を返し、そうでないなら偽を返す。これは依存プロパティです
\r
1696 public bool RectSelectMode
\r
1698 get { return (bool)GetValue(RectSelectModeProperty); }
\r
1699 set { SetValue(RectSelectModeProperty, value); }
\r
1703 /// RectSelectModeの依存プロパティを表す
\r
1705 public static readonly DependencyProperty RectSelectModeProperty =
\r
1706 DependencyProperty.Register("RectSelectMode", typeof(bool), typeof(FooTextBox), new PropertyMetadata(false, OnPropertyChanged));
\r
1712 /// 変更した場合、レイアウトの再構築を行う必要があります
\r
1714 public LineBreakMethod LineBreakMethod
\r
1716 get { return (LineBreakMethod)GetValue(LineBreakProperty); }
\r
1717 set { SetValue(LineBreakProperty, value); }
\r
1721 /// LineBreakMethodの依存プロパティを表す
\r
1723 public static readonly DependencyProperty LineBreakProperty =
\r
1724 DependencyProperty.Register("LineBreakMethod", typeof(LineBreakMethod), typeof(FooTextBox), new PropertyMetadata(LineBreakMethod.None, OnPropertyChanged));
\r
1728 /// 折り返しの幅を指定する。LineBreakMethod.CharUnit以外の時は無視されます
\r
1731 /// 変更した場合、レイアウトの再構築を行う必要があります
\r
1733 public int LineBreakCharCount
\r
1735 get { return (int)GetValue(LineBreakCharCountProperty); }
\r
1736 set { SetValue(LineBreakCharCountProperty, value); }
\r
1740 /// LineBreakCharCountの依存プロパティを表す
\r
1742 public static readonly DependencyProperty LineBreakCharCountProperty =
\r
1743 DependencyProperty.Register("LineBreakCharCount", typeof(int), typeof(FooTextBox), new PropertyMetadata(80));
\r
1746 /// キャレットを描くなら真。そうでないなら偽を返す。これは依存プロパティです
\r
1748 public bool DrawCaret
\r
1750 get { return (bool)GetValue(DrawCaretProperty); }
\r
1751 set { SetValue(DrawCaretProperty, value); }
\r
1755 /// DrawCaretの依存プロパティを表す
\r
1757 public static readonly DependencyProperty DrawCaretProperty =
\r
1758 DependencyProperty.Register("DrawCaret", typeof(bool), typeof(FooTextBox), new PropertyMetadata(true, OnPropertyChanged));
\r
1762 /// キャレットラインを描くなら真。そうでないなら偽を返す。これは依存プロパティです
\r
1764 public bool DrawCaretLine
\r
1766 get { return (bool)GetValue(DrawCaretLineProperty); }
\r
1767 set { SetValue(DrawCaretLineProperty, value); }
\r
1771 /// DrawCaretLineの依存プロパティを表す
\r
1773 public static readonly DependencyProperty DrawCaretLineProperty =
\r
1774 DependencyProperty.Register("DrawCaretLine", typeof(bool), typeof(FooTextBox), new PropertyMetadata(false, OnPropertyChanged));
\r
1777 /// 行番号を描くなら真。そうでなければ偽。これは依存プロパティです
\r
1779 public bool DrawLineNumber
\r
1781 get { return (bool)GetValue(DrawLineNumberProperty); }
\r
1782 set { SetValue(DrawLineNumberProperty, value); }
\r
1786 /// ルーラーを描くなら真。そうでなければ偽。これは依存プロパティです
\r
1788 public bool DrawRuler
\r
1790 get { return (bool)GetValue(DrawRulerProperty); }
\r
1791 set { SetValue(DrawRulerProperty, value); }
\r
1795 /// DrawRulerの依存プロパティを表す
\r
1797 public static readonly DependencyProperty DrawRulerProperty =
\r
1798 DependencyProperty.Register("DrawRuler", typeof(bool), typeof(FooTextBox), new PropertyMetadata(false, OnPropertyChanged));
\r
1802 /// DrawLineNumberの依存プロパティを表す
\r
1804 public static readonly DependencyProperty DrawLineNumberProperty =
\r
1805 DependencyProperty.Register("DrawLineNumber", typeof(bool), typeof(FooTextBox), new PropertyMetadata(false, OnPropertyChanged));
\r
1808 /// URLに下線を引くなら真。そうでないなら偽を表す。これは依存プロパティです
\r
1810 public bool MarkURL
\r
1812 get { return (bool)GetValue(MarkURLProperty); }
\r
1813 set { SetValue(MarkURLProperty, value); }
\r
1817 /// MarkURLの依存プロパティを表す
\r
1819 public static readonly DependencyProperty MarkURLProperty =
\r
1820 DependencyProperty.Register("MarkURL", typeof(bool), typeof(FooTextBox), new PropertyMetadata(false, OnPropertyChanged));
\r
1823 /// 全角スペースを表示するなら真。そうでないなら偽
\r
1825 public bool ShowFullSpace
\r
1827 get { return (bool)GetValue(ShowFullSpaceProperty); }
\r
1828 set { SetValue(ShowFullSpaceProperty, value); }
\r
1832 /// ShowFullSpaceの依存プロパティを表す
\r
1834 public static readonly DependencyProperty ShowFullSpaceProperty =
\r
1835 DependencyProperty.Register("ShowFullSpace", typeof(bool), typeof(FooTextBox), new PropertyMetadata(false, OnPropertyChanged));
\r
1838 /// 半角スペースを表示するなら真。そうでないなら偽
\r
1840 public bool ShowHalfSpace
\r
1842 get { return (bool)GetValue(ShowHalfSpaceProperty); }
\r
1843 set { SetValue(ShowHalfSpaceProperty, value); }
\r
1847 /// ShowHalfSpaceの依存プロパティを表す
\r
1849 public static readonly DependencyProperty ShowHalfSpaceProperty =
\r
1850 DependencyProperty.Register("ShowHalfSpace", typeof(bool), typeof(FooTextBox), new PropertyMetadata(false, OnPropertyChanged));
\r
1853 /// タブを表示するなら真。そうでないなら偽
\r
1855 public bool ShowTab
\r
1857 get { return (bool)GetValue(ShowTabProperty); }
\r
1858 set { SetValue(ShowTabProperty, value); }
\r
1862 /// ShowTabの依存プロパティを表す
\r
1864 public static readonly DependencyProperty ShowTabProperty =
\r
1865 DependencyProperty.Register("ShowTab", typeof(bool), typeof(FooTextBox), new PropertyMetadata(false, OnPropertyChanged));
\r
1868 /// 改行マークを表示するなら真。そうでないなら偽
\r
1870 public bool ShowLineBreak
\r
1872 get { return (bool)GetValue(ShowLineBreakProperty); }
\r
1873 set { SetValue(ShowLineBreakProperty, value); }
\r
1877 /// ShowLineBreakの依存プロパティを表す
\r
1879 public static readonly DependencyProperty ShowLineBreakProperty =
\r
1880 DependencyProperty.Register("ShowLineBreak", typeof(bool), typeof(FooTextBox), new PropertyMetadata(false,OnPropertyChanged));
\r
1887 /// コンテキストメニューのイベントデーターを表す
\r
1889 public class FooContextMenuEventArgs
\r
1892 /// 処理済みなら真。そうでないなら偽
\r
1894 public bool Handled = false;
\r
1896 /// コンテキストメニューを表示すべき座標を表す
\r
1898 public Windows.Foundation.Point Postion;
\r
1902 /// <param name="pos"></param>
\r
1903 public FooContextMenuEventArgs(Windows.Foundation.Point pos)
\r
1905 this.Postion = pos;
\r