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,IDisposable
\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 FooTextBoxAutomationPeer peer;
\r
50 bool nowCaretMove = false;
\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(Gripper.GripperWidth / 2, Gripper.GripperWidth, Gripper.GripperWidth / 2, Gripper.GripperWidth));
\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.SelectionChanged += Controller_SelectionChanged;
\r
93 this.FirstGripper = new Gripper(this._Controller, this.View, this.Render, GripperPostion.Upper);
\r
94 this.SecondGripper = new Gripper(this._Controller, this.View, this.Render, GripperPostion.Bottom);
\r
96 this.gestureRecongnizer.GestureSettings = GestureSettings.Drag |
\r
97 GestureSettings.RightTap |
\r
98 GestureSettings.Tap |
\r
99 GestureSettings.ManipulationTranslateX |
\r
100 GestureSettings.ManipulationTranslateY |
\r
101 GestureSettings.ManipulationScale;
\r
102 this.gestureRecongnizer.RightTapped += gestureRecongnizer_RightTapped;
\r
103 this.gestureRecongnizer.Tapped += gestureRecongnizer_Tapped;
\r
104 this.gestureRecongnizer.Dragging += gestureRecongnizer_Dragging;
\r
105 this.gestureRecongnizer.ManipulationStarted += gestureRecongnizer_ManipulationStarted;
\r
106 this.gestureRecongnizer.ManipulationUpdated += gestureRecongnizer_ManipulationUpdated;
\r
107 this.gestureRecongnizer.ManipulationCompleted += gestureRecongnizer_ManipulationCompleted;
\r
109 //Viewの初期化が終わった直後に置かないと例外が発生する
\r
110 this.Document.Update += Document_Update;
\r
112 Window.Current.CoreWindow.CharacterReceived += CoreWindow_CharacterReceived;
\r
114 this.SizeChanged += FooTextBox_SizeChanged;
\r
116 this.Loaded += FooTextBox_Loaded;
\r
124 this.Dispose(false);
\r
128 /// アンマネージドリソースを解放する
\r
130 public void Dispose()
\r
132 this.Dispose(true);
\r
133 GC.SuppressFinalize(this);
\r
136 bool Disposed = false;
\r
137 private void Dispose(bool disposing)
\r
143 this.textStore.Dispose();
\r
144 this.View.Dispose();
\r
145 this.Render.Dispose();
\r
147 DocumentExtend.Progress -= this.Document_Progress;
\r
153 /// <param name="start">開始インデックス</param>
\r
154 /// <param name="length">長さ</param>
\r
155 public void Select(int start, int length)
\r
157 if (this.Document.State == AsyncState.Loading)
\r
158 throw new InvalidOperationException();
\r
159 this._Controller.Select(start, length);
\r
163 /// キャレットを指定した行に移動させます
\r
165 /// <param name="index">インデックス</param>
\r
166 /// <remarks>このメソッドを呼び出すと選択状態は解除されます</remarks>
\r
167 public void JumpCaret(int index)
\r
169 if (this.Document.State == AsyncState.Loading)
\r
170 throw new InvalidOperationException();
\r
171 this._Controller.JumpCaret(index);
\r
174 /// キャレットを指定した行と桁に移動させます
\r
176 /// <param name="row">行番号</param>
\r
177 /// <param name="col">桁</param>
\r
178 /// <remarks>このメソッドを呼び出すと選択状態は解除されます</remarks>
\r
179 public void JumpCaret(int row, int col)
\r
181 if (this.Document.State == AsyncState.Loading)
\r
182 throw new InvalidOperationException();
\r
183 this._Controller.JumpCaret(row, col);
\r
187 /// 選択中のテキストをクリップボードにコピーします
\r
191 if (this.Document.State == AsyncState.Loading)
\r
192 throw new InvalidOperationException();
\r
193 string text = this._Controller.SelectedText;
\r
194 if (text != null && text != string.Empty)
\r
196 DataPackage dataPackage = new DataPackage();
\r
197 dataPackage.RequestedOperation = DataPackageOperation.Copy;
\r
198 dataPackage.SetText(text);
\r
200 Clipboard.SetContent(dataPackage);
\r
205 /// 選択中のテキストをクリップボードに切り取ります
\r
209 if (this.Document.State == AsyncState.Loading)
\r
210 throw new InvalidOperationException();
\r
211 string text = this._Controller.SelectedText;
\r
212 if (text != null && text != string.Empty)
\r
214 DataPackage dataPackage = new DataPackage();
\r
215 dataPackage.RequestedOperation = DataPackageOperation.Copy;
\r
216 dataPackage.SetText(text);
\r
218 Clipboard.SetContent(dataPackage);
\r
220 this._Controller.SelectedText = "";
\r
225 /// 選択中のテキストを貼り付けます
\r
227 public async Task PasteAsync()
\r
229 if (this.Document.State == AsyncState.Loading)
\r
230 throw new InvalidOperationException();
\r
232 var dataPackageView = Clipboard.GetContent();
\r
233 if (dataPackageView.Contains(StandardDataFormats.Text))
\r
235 this._Controller.SelectedText = await dataPackageView.GetTextAsync();
\r
242 public void SelectAll()
\r
244 if (this.Document.State == AsyncState.Loading)
\r
245 throw new InvalidOperationException();
\r
246 this._Controller.Select(0, this.Document.Length);
\r
252 public void DeSelectAll()
\r
254 if (this.Document.State == AsyncState.Loading)
\r
255 throw new InvalidOperationException();
\r
256 this._Controller.DeSelectAll();
\r
262 /// <param name="tp">テキストポイント</param>
\r
263 /// <returns>座標</returns>
\r
264 /// <remarks>テキストポイントがクライアント領域の原点より外にある場合、返される値は原点に丸められます</remarks>
\r
265 public Windows.Foundation.Point GetPostionFromTextPoint(TextPoint tp)
\r
267 if (this.Document.State == AsyncState.Loading)
\r
268 throw new InvalidOperationException();
\r
269 if (this.Document.FireUpdateEvent == false)
\r
270 throw new InvalidOperationException("");
\r
271 return this.View.GetPostionFromTextPoint(tp);
\r
275 /// 対応するテキストポイントを返します
\r
277 /// <param name="p">クライアント領域の原点を左上とする座標</param>
\r
278 /// <returns>テキストポイント</returns>
\r
279 public TextPoint GetTextPointFromPostion(Windows.Foundation.Point p)
\r
281 if (this.Document.State == AsyncState.Loading)
\r
282 throw new InvalidOperationException();
\r
283 if (this.Document.FireUpdateEvent == false)
\r
284 throw new InvalidOperationException("");
\r
285 return this.View.GetTextPointFromPostion(p);
\r
291 /// <param name="row">レイアウト行</param>
\r
292 /// <returns>行の高さ</returns>
\r
293 public double GetLineHeight(int row)
\r
295 if (this.Document.State == AsyncState.Loading)
\r
296 throw new InvalidOperationException();
\r
297 if (this.Document.FireUpdateEvent == false)
\r
298 throw new InvalidOperationException("");
\r
299 return this.View.LayoutLines.GetLayout(row).Height; ;
\r
303 /// インデックスに対応する座標を得ます
\r
305 /// <param name="index">インデックス</param>
\r
306 /// <returns>座標を返す</returns>
\r
307 public Windows.Foundation.Point GetPostionFromIndex(int index)
\r
309 if (this.Document.State == AsyncState.Loading)
\r
310 throw new InvalidOperationException();
\r
311 if (this.Document.FireUpdateEvent == false)
\r
312 throw new InvalidOperationException("");
\r
313 TextPoint tp = this.View.GetLayoutLineFromIndex(index);
\r
314 return this.View.GetPostionFromTextPoint(tp);
\r
318 /// 座標からインデックスに変換します
\r
320 /// <param name="p">座標</param>
\r
321 /// <returns>インデックスを返す</returns>
\r
322 public int GetIndexFromPostion(Windows.Foundation.Point p)
\r
324 if (this.Document.State == AsyncState.Loading)
\r
325 throw new InvalidOperationException();
\r
326 if (this.Document.FireUpdateEvent == false)
\r
327 throw new InvalidOperationException("");
\r
328 TextPoint tp = this.View.GetTextPointFromPostion(p);
\r
329 return this.View.GetIndexFromLayoutLine(tp);
\r
335 public void Refresh()
\r
337 this.Refresh(this.View.PageBound);
\r
341 /// レイアウト行をすべて破棄し、再度レイアウトを行う
\r
343 public void PerfomLayouts()
\r
345 this.View.PerfomLayouts();
\r
360 async Task PasteCommand()
\r
362 await this.PasteAsync();
\r
370 protected override Windows.UI.Xaml.Automation.Peers.AutomationPeer OnCreateAutomationPeer()
\r
372 this.peer = new FooTextBoxAutomationPeer(this);
\r
377 protected override void OnApplyTemplate()
\r
379 base.OnApplyTemplate();
\r
381 Grid grid = this.GetTemplateChild("PART_Grid") as Grid;
\r
384 Grid.SetRow(this.rectangle, 0);
\r
385 Grid.SetColumn(this.rectangle, 0);
\r
386 grid.Children.Add(this.rectangle);
\r
389 this.horizontalScrollBar = this.GetTemplateChild("PART_HorizontalScrollBar") as ScrollBar;
\r
390 if (this.horizontalScrollBar != null)
\r
392 this.horizontalScrollBar.SmallChange = 10;
\r
393 this.horizontalScrollBar.LargeChange = 100;
\r
394 this.horizontalScrollBar.Maximum = this.horizontalScrollBar.LargeChange + 1;
\r
395 this.horizontalScrollBar.Scroll += new ScrollEventHandler(horizontalScrollBar_Scroll);
\r
397 this.verticalScrollBar = this.GetTemplateChild("PART_VerticalScrollBar") as ScrollBar;
\r
398 if (this.verticalScrollBar != null)
\r
400 this.verticalScrollBar.SmallChange = 1;
\r
401 this.verticalScrollBar.LargeChange = 10;
\r
402 this.verticalScrollBar.Maximum = this.View.LayoutLines.Count;
\r
403 this.verticalScrollBar.Scroll += new ScrollEventHandler(verticalScrollBar_Scroll);
\r
408 protected override void OnGotFocus(RoutedEventArgs e)
\r
410 base.OnGotFocus(e);
\r
411 this.textStore.SetFocus();
\r
412 this.View.IsFocused = true;
\r
417 protected override void OnLostFocus(RoutedEventArgs e)
\r
419 base.OnLostFocus(e);
\r
420 this.View.IsFocused = false;
\r
425 protected override async void OnKeyDown(KeyRoutedEventArgs e)
\r
427 if (this.Document.State == AsyncState.Loading)
\r
429 bool isControlPressed = this.IsModiferKeyPressed(VirtualKey.Control);
\r
430 bool isShiftPressed = this.IsModiferKeyPressed(VirtualKey.Shift);
\r
431 bool isMovedCaret = false;
\r
434 case VirtualKey.Up:
\r
435 this._Controller.MoveCaretVertical(-1, isShiftPressed);
\r
438 isMovedCaret = true;
\r
440 case VirtualKey.Down:
\r
441 this._Controller.MoveCaretVertical(+1, isShiftPressed);
\r
444 isMovedCaret = true;
\r
446 case VirtualKey.Left:
\r
447 this._Controller.MoveCaretHorizontical(-1, isShiftPressed, isControlPressed);
\r
450 isMovedCaret = true;
\r
452 case VirtualKey.Right:
\r
453 this._Controller.MoveCaretHorizontical(1, isShiftPressed, isControlPressed);
\r
456 isMovedCaret = true;
\r
458 case VirtualKey.PageUp:
\r
459 this._Controller.Scroll(ScrollDirection.Up, this.View.LineCountOnScreen, isShiftPressed, true);
\r
461 isMovedCaret = true;
\r
463 case VirtualKey.PageDown:
\r
464 this._Controller.Scroll(ScrollDirection.Down, this.View.LineCountOnScreen, isShiftPressed, true);
\r
466 isMovedCaret = true;
\r
468 case VirtualKey.Home:
\r
469 if (isControlPressed)
\r
470 this._Controller.JumpToHead(isShiftPressed);
\r
472 this.Controller.JumpToLineHead(this.View.CaretPostion.row,isShiftPressed);
\r
474 isMovedCaret = true;
\r
476 case VirtualKey.End:
\r
477 if (isControlPressed)
\r
478 this._Controller.JumpToEnd(isShiftPressed);
\r
480 this.Controller.JumpToLineEnd(this.View.CaretPostion.row,isShiftPressed);
\r
482 isMovedCaret = true;
\r
484 case VirtualKey.Tab:
\r
485 if (!isControlPressed)
\r
487 if (this._Controller.SelectionLength == 0)
\r
488 this._Controller.DoInputChar('\t');
\r
489 else if (isShiftPressed)
\r
490 this._Controller.DownIndent();
\r
492 this._Controller.UpIndent();
\r
497 case VirtualKey.Enter:
\r
498 this._Controller.DoEnterAction();
\r
502 case VirtualKey.Insert:
\r
503 if(this.View.InsertMode)
\r
504 this.View.InsertMode = false;
\r
506 this.View.InsertMode = true;
\r
511 if (isControlPressed)
\r
519 if (isControlPressed)
\r
521 if (this._Controller.RectSelection)
\r
522 this._Controller.RectSelection = false;
\r
524 this._Controller.RectSelection = true;
\r
530 if (isControlPressed)
\r
532 this.CopyCommand();
\r
537 if (isControlPressed)
\r
544 if (isControlPressed)
\r
546 await this.PasteCommand();
\r
551 if (isControlPressed)
\r
553 this.Document.UndoManager.redo();
\r
559 if (isControlPressed)
\r
561 this.Document.UndoManager.undo();
\r
566 case VirtualKey.Back:
\r
567 this._Controller.DoBackSpaceAction();
\r
571 case VirtualKey.Delete:
\r
572 this._Controller.DoDeleteAction();
\r
577 if (isMovedCaret && this.peer != null)
\r
578 this.peer.OnNotifyCaretChanged();
\r
583 protected override void OnPointerPressed(PointerRoutedEventArgs e)
\r
585 this.CapturePointer(e.Pointer);
\r
586 this.gestureRecongnizer.ProcessDownEvent(e.GetCurrentPoint(this));
\r
591 protected override void OnPointerMoved(PointerRoutedEventArgs e)
\r
593 this.gestureRecongnizer.ProcessMoveEvents(e.GetIntermediatePoints(this));
\r
596 if (e.Pointer.PointerDeviceType == PointerDeviceType.Mouse && this.Document.State != AsyncState.Loading)
\r
598 Point p = e.GetCurrentPoint(this).Position;
\r
599 if (this.View.HitTextArea(p.X, p.Y))
\r
601 TextPoint tp = this.View.GetTextPointFromPostion(p);
\r
602 if (this._Controller.IsMarker(tp, HilightType.Url))
\r
603 Window.Current.CoreWindow.PointerCursor = new CoreCursor(CoreCursorType.Hand, 101);
\r
605 Window.Current.CoreWindow.PointerCursor = new CoreCursor(CoreCursorType.IBeam, 101);
\r
609 Window.Current.CoreWindow.PointerCursor = new CoreCursor(CoreCursorType.Arrow, 101);
\r
615 protected override void OnPointerReleased(PointerRoutedEventArgs e)
\r
617 this.gestureRecongnizer.ProcessUpEvent(e.GetCurrentPoint(this));
\r
618 this.ReleasePointerCapture(e.Pointer);
\r
623 protected override void OnPointerCanceled(PointerRoutedEventArgs e)
\r
625 this.gestureRecongnizer.CompleteGesture();
\r
626 this.ReleasePointerCapture(e.Pointer);
\r
631 protected override void OnPointerCaptureLost(PointerRoutedEventArgs e)
\r
633 this.gestureRecongnizer.CompleteGesture();
\r
634 this.ReleasePointerCapture(e.Pointer);
\r
639 protected override void OnPointerWheelChanged(PointerRoutedEventArgs e)
\r
641 bool shift = (e.KeyModifiers & Windows.System.VirtualKeyModifiers.Shift) ==
\r
642 Windows.System.VirtualKeyModifiers.Shift;
\r
643 bool ctrl = (e.KeyModifiers & Windows.System.VirtualKeyModifiers.Control) ==
\r
644 Windows.System.VirtualKeyModifiers.Control;
\r
645 this.gestureRecongnizer.ProcessMouseWheelEvent(e.GetCurrentPoint(this), shift, ctrl);
\r
649 void CoreWindow_CharacterReceived(CoreWindow sender, CharacterReceivedEventArgs args)
\r
651 if (this.FocusState == FocusState.Unfocused || this.Document.State == AsyncState.Loading)
\r
653 if (args.KeyCode >= 00 && args.KeyCode <= 0x1f)
\r
655 this._Controller.DoInputString(Char.ConvertFromUtf32((int)args.KeyCode));
\r
659 bool textStore_IsReadOnly()
\r
664 bool textStore_IsLoading()
\r
666 return this.Document.State == AsyncState.Loading;
\r
669 void textStore_CompositionEnded()
\r
671 TextStoreHelper.EndCompostion(this.Document);
\r
675 void textStore_CompositionUpdated(int start, int end)
\r
677 if (TextStoreHelper.ScrollToCompstionUpdated(this.textStore, this.View, start, end))
\r
680 bool textStore_CompositionStarted()
\r
682 return TextStoreHelper.StartCompstion(this.Document);
\r
685 string _textStore_GetString(int start, int length)
\r
687 return this.Document.ToString(start, length);
\r
690 void _textStore_GetStringExtent(
\r
693 out POINT o_topLeft,
\r
694 out POINT o_bottomRight
\r
697 Point startPos, endPos;
\r
698 TextStoreHelper.GetStringExtent(this.Document, this.View, i_startIndex, i_endIndex, out startPos, out endPos);
\r
700 var gt = this.TransformToVisual(Window.Current.Content);
\r
701 startPos = gt.TransformPoint(startPos);
\r
702 endPos = gt.TransformPoint(endPos);
\r
704 o_topLeft = new POINT((int)startPos.X, (int)startPos.Y);
\r
705 o_bottomRight = new POINT((int)endPos.X, (int)endPos.Y);
\r
708 void _textStore_GetScreenExtent(out POINT o_topLeft, out POINT o_bottomRight)
\r
710 var pointTopLeft = new Point(0, 0);
\r
711 var pointBottomRight = new Point(this.RenderSize.Width, this.RenderSize.Height);
\r
713 var gt = this.TransformToVisual(Window.Current.Content);
\r
714 pointTopLeft = gt.TransformPoint(pointTopLeft);
\r
715 pointBottomRight = gt.TransformPoint(pointBottomRight);
\r
717 o_topLeft = new POINT((int)pointTopLeft.X, (int)pointTopLeft.Y);
\r
718 o_bottomRight = new POINT((int)pointBottomRight.X, (int)pointBottomRight.Y);
\r
721 void _textStore_GetSelectionIndex(out int o_startIndex, out int o_endIndex)
\r
723 TextStoreHelper.GetSelection(this._Controller, this.View.Selections, out o_startIndex, out o_endIndex);
\r
726 void _textStore_SetSelectionIndex(int i_startIndex, int i_endIndex)
\r
728 if (this.Document.State == AsyncState.Loading)
\r
730 TextStoreHelper.SetSelectionIndex(this._Controller, this.View, i_startIndex, i_endIndex);
\r
734 void _textStore_InsertAtSelection(string i_value)
\r
736 TextStoreHelper.InsertTextAtSelection(this._Controller, i_value);
\r
740 void Controller_SelectionChanged(object sender, EventArgs e)
\r
742 //こうしないと選択できなくなってしまう
\r
743 this.nowCaretMove = true;
\r
744 SetValue(SelectionProperty, new TextRange(this._Controller.SelectionStart, this._Controller.SelectionLength));
\r
745 SetValue(CaretPostionPropertyKey, this.View.CaretPostion);
\r
746 this.nowCaretMove = false;
\r
747 if (this.textStore.IsLocked() == false)
\r
748 this.textStore.NotifySelectionChanged();
\r
751 Gripper FirstGripper, SecondGripper;
\r
753 Gripper hittedGripper;
\r
754 void gestureRecongnizer_ManipulationStarted(GestureRecognizer sender, ManipulationStartedEventArgs e)
\r
756 this.HittedCaret = false;
\r
757 this.hittedGripper = null;
\r
759 Point p = e.Position;
\r
760 TextPoint tp = this.View.GetTextPointFromPostion(p);
\r
761 if (tp == this.View.CaretPostion)
\r
763 HittedCaret = true;
\r
766 if (this.FirstGripper.IsHit(p))
\r
768 hittedGripper = this.FirstGripper;
\r
769 HittedCaret = true;
\r
772 else if (this.SecondGripper.IsHit(p))
\r
774 hittedGripper = this.SecondGripper;
\r
775 HittedCaret = true;
\r
779 void gestureRecongnizer_ManipulationUpdated(GestureRecognizer sender, ManipulationUpdatedEventArgs e)
\r
781 if (this.Document.State == AsyncState.Loading)
\r
787 if (this.hittedGripper == null)
\r
790 p = this.hittedGripper.AdjustPoint(e.Position);
\r
792 if (hittedGripper != null)
\r
794 TextPoint tp = this.View.GetTextPointFromPostion(p);
\r
795 if (this._Controller.IsReverseSelect())
\r
797 if (Object.ReferenceEquals(hittedGripper,this.SecondGripper))
\r
798 this._Controller.MoveSelectBefore(tp);
\r
800 this._Controller.MoveCaretAndSelect(tp);
\r
804 if (Object.ReferenceEquals(hittedGripper,this.FirstGripper))
\r
805 this._Controller.MoveSelectBefore(tp);
\r
807 this._Controller.MoveCaretAndSelect(tp);
\r
809 if (this.peer != null)
\r
810 this.peer.OnNotifyCaretChanged();
\r
815 if (e.Delta.Scale < 1)
\r
817 double newSize = this.Render.FontSize - 1;
\r
820 this.Render.FontSize = newSize;
\r
822 SetValue(MagnificationPowerPropertyKey, this.Render.FontSize / this.FontSize);
\r
826 if (e.Delta.Scale > 1)
\r
828 double newSize = this.Render.FontSize + 1;
\r
831 this.Render.FontSize = newSize;
\r
833 SetValue(MagnificationPowerPropertyKey, this.Render.FontSize / this.FontSize);
\r
837 Point translation = e.Delta.Translation;
\r
839 int scrollCount = (int)Math.Abs(translation.Y);
\r
840 if (scrollCount > 0)
\r
842 if (scrollCount > this.View.LineCountOnScreen) //ホイール対策
\r
843 scrollCount = this.View.LineCountOnScreen;
\r
844 if (translation.Y > 0)
\r
845 this._Controller.Scroll(ScrollDirection.Up, scrollCount, false, false);
\r
847 this._Controller.Scroll(ScrollDirection.Down, scrollCount, false, false);
\r
848 this.FirstGripper.Enabled = false;
\r
849 this.SecondGripper.Enabled = false;
\r
854 int deltax = (int)Math.Abs(translation.X);
\r
857 if (translation.X < 0)
\r
858 this._Controller.Scroll(ScrollDirection.Left, deltax, false, false);
\r
860 this._Controller.Scroll(ScrollDirection.Right, deltax, false, false);
\r
861 this.FirstGripper.Enabled = false;
\r
862 this.SecondGripper.Enabled = false;
\r
867 void gestureRecongnizer_ManipulationCompleted(GestureRecognizer sender, ManipulationCompletedEventArgs e)
\r
871 async void gestureRecongnizer_RightTapped(GestureRecognizer sender, RightTappedEventArgs e)
\r
873 ResourceMap map = ResourceManager.Current.MainResourceMap.GetSubtree("FooEditEngine.Metro/Resources");
\r
874 ResourceContext context = ResourceContext.GetForCurrentView();
\r
875 if (this.View.HitTextArea(e.Position.X, e.Position.Y))
\r
877 FooContextMenuEventArgs args = new FooContextMenuEventArgs(e.Position);
\r
878 if (this.ContextMenuOpening != null)
\r
879 this.ContextMenuOpening(this, args);
\r
882 PopupMenu ContextMenu = new PopupMenu();
\r
883 ContextMenu.Commands.Add(new UICommand(map.GetValue("CopyMenuName", context).ValueAsString, (command) =>
\r
885 this.CopyCommand();
\r
887 ContextMenu.Commands.Add(new UICommand(map.GetValue("CutMenuName", context).ValueAsString, (command) =>
\r
891 ContextMenu.Commands.Add(new UICommand(map.GetValue("PasteMenuName", context).ValueAsString, async (command) =>
\r
893 await this.PasteCommand();
\r
895 if (this._Controller.RectSelection)
\r
897 ContextMenu.Commands.Add(new UICommand(map.GetValue("LineSelectMenuName", context).ValueAsString, (command) =>
\r
899 this._Controller.RectSelection = false;
\r
904 ContextMenu.Commands.Add(new UICommand(map.GetValue("RectSelectMenuName", context).ValueAsString, (command) =>
\r
906 this._Controller.RectSelection = true;
\r
909 await ContextMenu.ShowAsync(Util.GetScreentPoint(e.Position,this));
\r
914 void gestureRecongnizer_Tapped(GestureRecognizer sender, TappedEventArgs e)
\r
916 bool touched = e.PointerDeviceType == PointerDeviceType.Touch;
\r
917 this.FirstGripper.Enabled = touched;
\r
918 this.SecondGripper.Enabled = touched;
\r
919 this.JumpCaret(e.Position);
\r
922 void JumpCaret(Point p)
\r
924 if (this.Document.State == AsyncState.Loading)
\r
927 TextPoint tp = this.View.GetTextPointFromPostion(p);
\r
928 if (tp == TextPoint.Null)
\r
931 int index = this.View.LayoutLines.GetIndexFromTextPoint(tp);
\r
933 FoldingItem foldingData = this.View.HitFoldingData(p.X, tp.row);
\r
934 if (foldingData != null)
\r
936 if (foldingData.Expand)
\r
937 this.View.LayoutLines.FoldingCollection.Collapse(foldingData);
\r
939 this.View.LayoutLines.FoldingCollection.Expand(foldingData);
\r
940 this._Controller.JumpCaret(foldingData.Start, false);
\r
944 this._Controller.JumpCaret(tp.row, tp.col, false);
\r
946 if (this.peer != null)
\r
947 this.peer.OnNotifyCaretChanged();
\r
948 this.Focus(FocusState.Pointer);
\r
952 void gestureRecongnizer_Dragging(GestureRecognizer sender, DraggingEventArgs e)
\r
954 if (this.Document.State == AsyncState.Loading)
\r
956 Point p = e.Position;
\r
957 if (this.View.HitTextArea(p.X, p.Y))
\r
959 TextPoint tp = this.View.GetTextPointFromPostion(p);
\r
960 this._Controller.MoveCaretAndSelect(tp);
\r
961 if (this.peer != null)
\r
962 this.peer.OnNotifyCaretChanged();
\r
967 bool IsModiferKeyPressed(VirtualKey key)
\r
969 CoreVirtualKeyStates state = Window.Current.CoreWindow.GetKeyState(key);
\r
970 return (state & CoreVirtualKeyStates.Down) == CoreVirtualKeyStates.Down;
\r
972 void Refresh(Rectangle updateRect)
\r
974 if (this.rectangle.ActualWidth == 0 || this.rectangle.ActualHeight == 0/* || !this.Render.IsCanDraw()*/)
\r
977 this.Render.BeginDraw();
\r
978 if (this.Document.State != AsyncState.Loading)
\r
979 this.View.Draw(updateRect);
\r
981 this.Render.FillBackground(updateRect);
\r
982 this.FirstGripper.Draw();
\r
983 this.SecondGripper.Draw();
\r
984 this.Render.EndDraw();
\r
988 bool Resize(double width, double height)
\r
990 if (width == 0 || height == 0)
\r
991 throw new ArgumentOutOfRangeException();
\r
992 if (this.Document.State != AsyncState.Loading && this.Render.Resize(this.rectangle, width, height))
\r
994 this.View.PageBound = new Rectangle(0, 0, width, height);
\r
996 if (this.horizontalScrollBar != null)
\r
998 this.horizontalScrollBar.LargeChange = this.View.PageBound.Width;
\r
999 this.horizontalScrollBar.Maximum = this.View.LongestWidth + this.horizontalScrollBar.LargeChange + 1;
\r
1001 if (this.verticalScrollBar != null)
\r
1003 this.verticalScrollBar.LargeChange = this.View.LineCountOnScreen;
\r
1004 this.verticalScrollBar.Maximum = this.View.LayoutLines.Count + this.verticalScrollBar.LargeChange + 1;
\r
1011 void View_SrcChanged(object sender, EventArgs e)
\r
1013 if (this.horizontalScrollBar == null || this.verticalScrollBar == null)
\r
1015 EditView view = this.View;
\r
1016 if (view.Src.Row > this.verticalScrollBar.Maximum)
\r
1017 this.verticalScrollBar.Maximum = view.Src.Row + view.LineCountOnScreen + 1;
\r
1018 double absoulteX = Math.Abs(view.Src.X);
\r
1019 if (absoulteX > this.horizontalScrollBar.Maximum)
\r
1020 this.horizontalScrollBar.Maximum = absoulteX + view.PageBound.Width + 1;
\r
1021 if (view.Src.Row != this.verticalScrollBar.Value)
\r
1022 this.verticalScrollBar.Value = view.Src.Row;
\r
1023 if (view.Src.X != this.horizontalScrollBar.Value)
\r
1024 this.horizontalScrollBar.Value = Math.Abs(view.Src.X);
\r
1027 void FooTextBox_SizeChanged(object sender, SizeChangedEventArgs e)
\r
1029 if (this.Document.State == AsyncState.Loading || this.Resize(this.rectangle.ActualWidth, this.rectangle.ActualHeight))
\r
1036 void horizontalScrollBar_Scroll(object sender, ScrollEventArgs e)
\r
1038 if (this.Document.State == AsyncState.Loading)
\r
1040 if (this.horizontalScrollBar == null)
\r
1043 if (this.FlowDirection == FlowDirection.LeftToRight)
\r
1044 toX = this.horizontalScrollBar.Value;
\r
1046 toX = -this.horizontalScrollBar.Value;
\r
1047 this._Controller.Scroll(toX, this.View.Src.Row, false, false);
\r
1048 this.FirstGripper.Enabled = false;
\r
1049 this.SecondGripper.Enabled = false;
\r
1053 void verticalScrollBar_Scroll(object sender, ScrollEventArgs e)
\r
1055 if (this.Document.State == AsyncState.Loading)
\r
1057 if (this.verticalScrollBar == null)
\r
1059 int newRow = (int)this.verticalScrollBar.Value;
\r
1060 if (newRow >= this.View.LayoutLines.Count)
\r
1062 this._Controller.Scroll(this.View.Src.X, newRow, false, false);
\r
1063 this.FirstGripper.Enabled = false;
\r
1064 this.SecondGripper.Enabled = false;
\r
1068 void Document_Update(object sender, DocumentUpdateEventArgs e)
\r
1070 if (this.textStore.IsLocked() || this.Document.State == AsyncState.Loading || e.type == UpdateType.Clear)
\r
1072 if (e.removeLength == 0)
\r
1073 this.textStore.NotifyTextChanged(e.startIndex, e.startIndex, e.startIndex + e.insertLength);
\r
1075 this.textStore.NotifyTextChanged(e.startIndex, e.startIndex + 1, e.startIndex + e.insertLength - e.removeLength);
\r
1078 void Document_Progress(object sender, ProgressEventArgs e)
\r
1080 if (this.Document.State == AsyncState.Loading)
\r
1084 case ProgressState.Start:
\r
1085 this.textStore.NotifyTextChanged(0, this.Document.Length, 0);
\r
1087 case ProgressState.Complete:
\r
1088 this.textStore.NotifyTextChanged(0, 0, this.Document.Length);
\r
1089 if (this.verticalScrollBar != null)
\r
1090 this.verticalScrollBar.Maximum = this.View.LayoutLines.Count;
\r
1091 this.View.CalculateLineCountOnScreen();
\r
1096 void FooTextBox_Loaded(object sender, RoutedEventArgs e)
\r
1098 this.Focus(FocusState.Programmatic);
\r
1102 public static void OnPropertyChanged(object sender, DependencyPropertyChangedEventArgs e)
\r
1104 FooTextBox source = (FooTextBox)sender;
\r
1105 if (e.Property.Equals(SelectionProperty) && !source.nowCaretMove)
\r
1106 source._Controller.Select(source.Selection.Index,source.Selection.Length);
\r
1107 if (e.Property.Equals(CaretPostionPropertyKey) && !source.nowCaretMove)
\r
1108 source.JumpCaret(source.CaretPostion.row, source.CaretPostion.col);
\r
1109 if (e.Property.Equals(InsertModeProperty))
\r
1110 source.View.InsertMode = source.InsertMode;
\r
1111 if (e.Property.Equals(TabCharsProperty))
\r
1112 source.View.TabStops = source.TabChars;
\r
1113 if (e.Property.Equals(RectSelectModeProperty))
\r
1114 source._Controller.RectSelection = source.RectSelectMode;
\r
1115 if (e.Property.Equals(DrawCaretProperty))
\r
1116 source.View.HideCaret = !source.DrawCaret;
\r
1117 if (e.Property.Equals(DrawCaretLineProperty))
\r
1118 source.View.HideLineMarker = !source.DrawCaretLine;
\r
1119 if (e.Property.Equals(DrawLineNumberProperty))
\r
1121 source.View.DrawLineNumber = source.DrawLineNumber;
\r
1122 source._Controller.JumpCaret(source.View.CaretPostion.row, source.View.CaretPostion.col);
\r
1124 if(e.Property.Equals(MagnificationPowerPropertyKey))
\r
1125 source.Render.FontSize = source.FontSize * source.MagnificationPower;
\r
1126 if (e.Property.Equals(FontFamilyProperty))
\r
1127 source.Render.FontFamily = source.FontFamily;
\r
1128 if (e.Property.Equals(FontStyleProperty))
\r
1129 source.Render.FontStyle = source.FontStyle;
\r
1130 if (e.Property.Equals(FontWeightProperty))
\r
1131 source.Render.FontWeigth = source.FontWeight;
\r
1132 if (e.Property.Equals(FontSizeProperty))
\r
1133 source.Render.FontSize = source.FontSize;
\r
1134 if (e.Property.Equals(ForegroundProperty))
\r
1135 source.Render.Foreground = source.Foreground;
\r
1136 if (e.Property.Equals(BackgroundProperty))
\r
1137 source.Render.Background = source.Background;
\r
1138 if (e.Property.Equals(ControlCharProperty))
\r
1139 source.Render.ControlChar = source.ControlChar;
\r
1140 if (e.Property.Equals(HilightProperty))
\r
1141 source.Render.Hilight = source.Hilight;
\r
1142 if (e.Property.Equals(Keyword1Property))
\r
1143 source.Render.Keyword1 = source.Keyword1;
\r
1144 if (e.Property.Equals(Keyword2Property))
\r
1145 source.Render.Keyword2 = source.Keyword2;
\r
1146 if (e.Property.Equals(CommentProperty))
\r
1147 source.Render.Comment = source.Comment;
\r
1148 if (e.Property.Equals(LiteralProperty))
\r
1149 source.Render.Literal = source.Literal;
\r
1150 if (e.Property.Equals(URLProperty))
\r
1151 source.Render.Url = source.URL;
\r
1152 if (e.Property.Equals(InsertCaretProperty))
\r
1153 source.Render.InsertCaret = source.InsertCaret;
\r
1154 if (e.Property.Equals(OverwriteCaretProperty))
\r
1155 source.Render.OverwriteCaret = source.OverwriteCaret;
\r
1156 if (e.Property.Equals(LineMarkerProperty))
\r
1157 source.Render.LineMarker = source.LineMarker;
\r
1158 if (e.Property.Equals(MarkURLProperty))
\r
1159 source.View.UrlMark = source.MarkURL;
\r
1160 if (e.Property.Equals(ShowFullSpaceProperty))
\r
1161 source.Render.ShowFullSpace = source.ShowFullSpace;
\r
1162 if (e.Property.Equals(ShowHalfSpaceProperty))
\r
1163 source.Render.ShowHalfSpace = source.ShowHalfSpace;
\r
1164 if (e.Property.Equals(ShowTabProperty))
\r
1165 source.Render.ShowTab = source.ShowTab;
\r
1166 if (e.Property.Equals(ShowLineBreakProperty))
\r
1167 source.Render.ShowLineBreak = source.ShowLineBreak;
\r
1168 if (e.Property.Equals(LineBreakProperty))
\r
1169 source.View.LineBreak = source.LineBreakMethod;
\r
1170 if (e.Property.Equals(LineBreakCharCountProperty))
\r
1171 source.View.LineBreakCharCount = source.LineBreakCharCount;
\r
1172 if (e.Property.Equals(FlowDirectionProperty))
\r
1174 source.Render.RightToLeft = source.FlowDirection == Windows.UI.Xaml.FlowDirection.RightToLeft;
\r
1175 if(source.horizontalScrollBar != null)
\r
1176 source.horizontalScrollBar.FlowDirection = source.FlowDirection;
\r
1178 if (e.Property.Equals(DrawRulerProperty))
\r
1180 source.View.HideRuler = !source.DrawRuler;
\r
1181 source._Controller.JumpCaret(source.View.CaretPostion.row, source.View.CaretPostion.col);
\r
1189 /// コンテキストメニューが表示されるときに呼び出されます
\r
1191 public event EventHandler<FooContextMenuEventArgs> ContextMenuOpening;
\r
1197 internal Controller Controller
\r
1201 return this._Controller;
\r
1206 /// 文字列の描写に使用されるアンチエイリアシング モードを表します
\r
1208 public TextAntialiasMode TextAntialiasMode
\r
1212 return this.Render.TextAntialiasMode;
\r
1216 this.Render.TextAntialiasMode = value;
\r
1221 /// シンタックスハイライターを表す
\r
1223 public IHilighter Hilighter
\r
1227 return this.View.Hilighter;
\r
1231 this.View.Hilighter = value;
\r
1232 this.View.LayoutLines.ClearLayoutCache();
\r
1237 /// フォールティングを作成するインターフェイスを表す
\r
1239 public IFoldingStrategy FoldingStrategy
\r
1243 return this.View.LayoutLines.FoldingStrategy;
\r
1247 this.View.LayoutLines.FoldingStrategy = value;
\r
1248 if (value == null)
\r
1249 this.View.LayoutLines.FoldingCollection.Clear();
\r
1254 /// マーカーパターンセットを表す
\r
1256 public MarkerPatternSet MarkerPatternSet
\r
1260 return this.View.MarkerPatternSet;
\r
1267 public Document Document
\r
1276 public LineToIndexTable LayoutLineCollection
\r
1278 get { return this.View.LayoutLines; }
\r
1284 public string SelectedText
\r
1288 return this._Controller.SelectedText;
\r
1292 int oldLength = this.Document.Length;
\r
1293 this._Controller.SelectedText = value;
\r
1301 /// Lengthが0の場合はキャレット位置を表します。
\r
1302 /// 矩形選択モードの場合、選択範囲の文字数ではなく、開始位置から終了位置までの長さとなります
\r
1304 public TextRange Selection
\r
1306 get { return (TextRange)GetValue(SelectionProperty); }
\r
1307 set { SetValue(SelectionProperty, value); }
\r
1311 /// Selectionの依存プロパティを表す
\r
1313 public static readonly DependencyProperty SelectionProperty =
\r
1314 DependencyProperty.Register("Selection", typeof(TextRange), typeof(FooTextBox), new PropertyMetadata(0));
\r
1319 public double MagnificationPower
\r
1321 get { return (double)GetValue(MagnificationPowerPropertyKey); }
\r
1322 set { SetValue(MagnificationPowerPropertyKey, value); }
\r
1328 public static readonly DependencyProperty MagnificationPowerPropertyKey =
\r
1329 DependencyProperty.Register("MagnificationPower", typeof(double), typeof(FooTextBox), new PropertyMetadata(1.0, OnPropertyChanged));
\r
1334 public TextPoint CaretPostion
\r
1336 get { return (TextPoint)GetValue(CaretPostionPropertyKey); }
\r
1337 set { SetValue(CaretPostionPropertyKey, value); }
\r
1340 static readonly DependencyProperty CaretPostionPropertyKey =
\r
1341 DependencyProperty.Register("CaretPostion", typeof(TextPoint), typeof(FooTextBox), new PropertyMetadata(new TextPoint(), OnPropertyChanged));
\r
1346 public new FlowDirection FlowDirection
\r
1348 get { return (FlowDirection)GetValue(FlowDirectionProperty); }
\r
1349 set { SetValue(FlowDirectionProperty, value); }
\r
1353 /// レタリング方向を表す。これは依存プロパティです
\r
1355 public new static readonly DependencyProperty FlowDirectionProperty =
\r
1356 DependencyProperty.Register("FlowDirection", typeof(FlowDirection), typeof(FooTextBox), new PropertyMetadata(FlowDirection.LeftToRight,OnPropertyChanged));
\r
1361 public new FontFamily FontFamily
\r
1363 get { return (FontFamily)GetValue(FontFamilyProperty); }
\r
1364 set { SetValue(FontFamilyProperty, value); }
\r
1368 /// FontFamilyの依存プロパティを表す
\r
1370 public new static readonly DependencyProperty FontFamilyProperty =
\r
1371 DependencyProperty.Register("FontFamily", typeof(FontFamily), typeof(FooTextBox), new PropertyMetadata(new FontFamily("Cambria"), OnPropertyChanged));
\r
1376 public new double FontSize
\r
1378 get { return (double)GetValue(FontSizeProperty); }
\r
1379 set { SetValue(FontSizeProperty, value); }
\r
1383 /// FontSizeの依存プロパティを表す
\r
1385 public new static readonly DependencyProperty FontSizeProperty =
\r
1386 DependencyProperty.Register("FontSize", typeof(double), typeof(FooTextBox), new PropertyMetadata(12.0,OnPropertyChanged));
\r
1391 public new FontStyle FontStyle
\r
1393 get { return (FontStyle)GetValue(FontStyleProperty); }
\r
1394 set { SetValue(FontStyleProperty, value); }
\r
1398 /// FontStyleの依存プロパティを表す
\r
1400 public new static readonly DependencyProperty FontStyleProperty =
\r
1401 DependencyProperty.Register("FontStyle", typeof(FontStyle), typeof(FooTextBox), new PropertyMetadata(FontStyle.Normal,OnPropertyChanged));
\r
1406 public new FontWeight FontWeight
\r
1408 get { return (FontWeight)GetValue(FontWeightProperty); }
\r
1409 set { SetValue(FontWeightProperty, value); }
\r
1413 /// FontWeigthの依存プロパティを表す
\r
1415 public new static readonly DependencyProperty FontWeightProperty =
\r
1416 DependencyProperty.Register("FontWeigth", typeof(FontWeight), typeof(FooTextBox), new PropertyMetadata(FontWeights.Normal,OnPropertyChanged));
\r
1419 /// デフォルトの文字色を表す。これは依存プロパティです
\r
1421 public new Windows.UI.Color Foreground
\r
1423 get { return (Windows.UI.Color)GetValue(ForegroundProperty); }
\r
1424 set { SetValue(ForegroundProperty, value); }
\r
1428 /// Foregroundの依存プロパティを表す
\r
1430 public new static readonly DependencyProperty ForegroundProperty =
\r
1431 DependencyProperty.Register("Foreground", typeof(Windows.UI.Color), typeof(FooTextBox), new PropertyMetadata(Colors.Black, OnPropertyChanged));
\r
1434 /// 背景色を表す。これは依存プロパティです
\r
1436 public new Windows.UI.Color Background
\r
1438 get { return (Windows.UI.Color)GetValue(BackgroundProperty); }
\r
1439 set { SetValue(BackgroundProperty, value); }
\r
1443 /// Backgroundの依存プロパティを表す
\r
1445 public new static readonly DependencyProperty BackgroundProperty =
\r
1446 DependencyProperty.Register("Background", typeof(Windows.UI.Color), typeof(FooTextBox), new PropertyMetadata(Colors.White, OnPropertyChanged));
\r
1449 /// コントロールコードの文字色を表す。これは依存プロパティです
\r
1451 public Windows.UI.Color ControlChar
\r
1453 get { return (Windows.UI.Color)GetValue(ControlCharProperty); }
\r
1454 set { SetValue(ControlCharProperty, value); }
\r
1458 /// ControlCharの依存プロパティを表す
\r
1460 public static readonly DependencyProperty ControlCharProperty =
\r
1461 DependencyProperty.Register("ControlChar", typeof(Windows.UI.Color), typeof(FooTextBox), new PropertyMetadata(Colors.Gray, OnPropertyChanged));
\r
1464 /// 選択時の背景色を表す。これは依存プロパティです
\r
1466 public Windows.UI.Color Hilight
\r
1468 get { return (Windows.UI.Color)GetValue(HilightProperty); }
\r
1469 set { SetValue(HilightProperty, value); }
\r
1473 /// Hilightの依存プロパティを表す
\r
1475 public static readonly DependencyProperty HilightProperty =
\r
1476 DependencyProperty.Register("Hilight", typeof(Windows.UI.Color), typeof(FooTextBox), new PropertyMetadata(Colors.DeepSkyBlue, OnPropertyChanged));
\r
1479 /// キーワード1の文字色を表す。これは依存プロパティです
\r
1481 public Windows.UI.Color Keyword1
\r
1483 get { return (Windows.UI.Color)GetValue(Keyword1Property); }
\r
1484 set { SetValue(Keyword1Property, value); }
\r
1488 /// Keyword1の依存プロパティを表す
\r
1490 public static readonly DependencyProperty Keyword1Property =
\r
1491 DependencyProperty.Register("Keyword1", typeof(Windows.UI.Color), typeof(FooTextBox), new PropertyMetadata(Colors.Blue, OnPropertyChanged));
\r
1494 /// キーワード2の文字色を表す。これは依存プロパティです
\r
1496 public Windows.UI.Color Keyword2
\r
1498 get { return (Windows.UI.Color)GetValue(Keyword2Property); }
\r
1499 set { SetValue(Keyword2Property, value); }
\r
1503 /// Keyword2の依存プロパティを表す
\r
1505 public static readonly DependencyProperty Keyword2Property =
\r
1506 DependencyProperty.Register("Keyword2", typeof(Windows.UI.Color), typeof(FooTextBox), new PropertyMetadata(Colors.DarkCyan, OnPropertyChanged));
\r
1509 /// コメントの文字色を表す。これは依存プロパティです
\r
1511 public Windows.UI.Color Comment
\r
1513 get { return (Windows.UI.Color)GetValue(CommentProperty); }
\r
1514 set { SetValue(CommentProperty, value); }
\r
1518 /// Commentの依存プロパティを表す
\r
1520 public static readonly DependencyProperty CommentProperty =
\r
1521 DependencyProperty.Register("Comment", typeof(Windows.UI.Color), typeof(FooTextBox), new PropertyMetadata(Colors.Green, OnPropertyChanged));
\r
1524 /// 文字リテラルの文字色を表す。これは依存プロパティです
\r
1526 public Windows.UI.Color Literal
\r
1528 get { return (Windows.UI.Color)GetValue(LiteralProperty); }
\r
1529 set { SetValue(LiteralProperty, value); }
\r
1533 /// Literalの依存プロパティを表す
\r
1535 public static readonly DependencyProperty LiteralProperty =
\r
1536 DependencyProperty.Register("Literal", typeof(Windows.UI.Color), typeof(FooTextBox), new PropertyMetadata(Colors.Brown, OnPropertyChanged));
\r
1539 /// URLの文字色を表す。これは依存プロパティです
\r
1541 public Windows.UI.Color URL
\r
1543 get { return (Windows.UI.Color)GetValue(URLProperty); }
\r
1544 set { SetValue(URLProperty, value); }
\r
1548 /// URLの依存プロパティを表す
\r
1550 public static readonly DependencyProperty URLProperty =
\r
1551 DependencyProperty.Register("URL", typeof(Windows.UI.Color), typeof(FooTextBox), new PropertyMetadata(Colors.Blue, OnPropertyChanged));
\r
1557 public Windows.UI.Color LineMarker
\r
1559 get { return (Windows.UI.Color)GetValue(LineMarkerProperty); }
\r
1560 set { SetValue(LineMarkerProperty, value); }
\r
1564 /// LineMarkerの依存プロパティを表す
\r
1566 public static readonly DependencyProperty LineMarkerProperty =
\r
1567 DependencyProperty.Register("LineMarker", typeof(Windows.UI.Color), typeof(FooTextBox), new PropertyMetadata(Colors.Gray, OnPropertyChanged));
\r
1570 /// 挿入モード時のキャレットの色を表す
\r
1572 public Windows.UI.Color InsertCaret
\r
1574 get { return (Windows.UI.Color)GetValue(InsertCaretProperty); }
\r
1575 set { SetValue(InsertCaretProperty, value); }
\r
1579 /// InsertCaretの依存プロパティを表す
\r
1581 public static readonly DependencyProperty InsertCaretProperty =
\r
1582 DependencyProperty.Register("InsertCaret", typeof(Windows.UI.Color), typeof(FooTextBox), new PropertyMetadata(Colors.Black, OnPropertyChanged));
\r
1585 /// 上書きモード時のキャレット職を表す
\r
1587 public Windows.UI.Color OverwriteCaret
\r
1589 get { return (Windows.UI.Color)GetValue(OverwriteCaretProperty); }
\r
1590 set { SetValue(OverwriteCaretProperty, value); }
\r
1594 /// OverwriteCaretの依存プロパティを表す
\r
1596 public static readonly DependencyProperty OverwriteCaretProperty =
\r
1597 DependencyProperty.Register("OverwriteCaret", typeof(Windows.UI.Color), typeof(FooTextBox), new PropertyMetadata(Colors.Black, OnPropertyChanged));
\r
1600 /// 挿入モードなら真を返し、そうでないなら、偽を返す。これは依存プロパティです
\r
1602 public bool InsertMode
\r
1604 get { return (bool)GetValue(InsertModeProperty); }
\r
1605 set { SetValue(InsertModeProperty, value); }
\r
1609 /// InsertModeの依存プロパティを表す
\r
1611 public static readonly DependencyProperty InsertModeProperty =
\r
1612 DependencyProperty.Register("InsertMode",
\r
1614 typeof(FooTextBox),
\r
1615 new PropertyMetadata(true, OnPropertyChanged));
\r
1618 /// タブの文字数を表す。これは依存プロパティです
\r
1620 public int TabChars
\r
1622 get { return (int)GetValue(TabCharsProperty); }
\r
1623 set { SetValue(TabCharsProperty, value); }
\r
1627 /// TabCharsの依存プロパティを表す
\r
1629 public static readonly DependencyProperty TabCharsProperty =
\r
1630 DependencyProperty.Register("TabChars",
\r
1632 typeof(FooTextBox),
\r
1633 new PropertyMetadata(4, OnPropertyChanged));
\r
1636 /// 矩形選択モードなら真を返し、そうでないなら偽を返す。これは依存プロパティです
\r
1638 public bool RectSelectMode
\r
1640 get { return (bool)GetValue(RectSelectModeProperty); }
\r
1641 set { SetValue(RectSelectModeProperty, value); }
\r
1645 /// RectSelectModeの依存プロパティを表す
\r
1647 public static readonly DependencyProperty RectSelectModeProperty =
\r
1648 DependencyProperty.Register("RectSelectMode", typeof(bool), typeof(FooTextBox), new PropertyMetadata(false, OnPropertyChanged));
\r
1654 /// 変更した場合、レイアウトの再構築を行う必要があります
\r
1656 public LineBreakMethod LineBreakMethod
\r
1658 get { return (LineBreakMethod)GetValue(LineBreakProperty); }
\r
1659 set { SetValue(LineBreakProperty, value); }
\r
1663 /// LineBreakMethodの依存プロパティを表す
\r
1665 public static readonly DependencyProperty LineBreakProperty =
\r
1666 DependencyProperty.Register("LineBreakMethod", typeof(LineBreakMethod), typeof(FooTextBox), new PropertyMetadata(LineBreakMethod.None, OnPropertyChanged));
\r
1670 /// 折り返しの幅を指定する。LineBreakMethod.CharUnit以外の時は無視されます
\r
1673 /// 変更した場合、レイアウトの再構築を行う必要があります
\r
1675 public int LineBreakCharCount
\r
1677 get { return (int)GetValue(LineBreakCharCountProperty); }
\r
1678 set { SetValue(LineBreakCharCountProperty, value); }
\r
1682 /// LineBreakCharCountの依存プロパティを表す
\r
1684 public static readonly DependencyProperty LineBreakCharCountProperty =
\r
1685 DependencyProperty.Register("LineBreakCharCount", typeof(int), typeof(FooTextBox), new PropertyMetadata(80));
\r
1688 /// キャレットを描くなら真。そうでないなら偽を返す。これは依存プロパティです
\r
1690 public bool DrawCaret
\r
1692 get { return (bool)GetValue(DrawCaretProperty); }
\r
1693 set { SetValue(DrawCaretProperty, value); }
\r
1697 /// DrawCaretの依存プロパティを表す
\r
1699 public static readonly DependencyProperty DrawCaretProperty =
\r
1700 DependencyProperty.Register("DrawCaret", typeof(bool), typeof(FooTextBox), new PropertyMetadata(true, OnPropertyChanged));
\r
1704 /// キャレットラインを描くなら真。そうでないなら偽を返す。これは依存プロパティです
\r
1706 public bool DrawCaretLine
\r
1708 get { return (bool)GetValue(DrawCaretLineProperty); }
\r
1709 set { SetValue(DrawCaretLineProperty, value); }
\r
1713 /// DrawCaretLineの依存プロパティを表す
\r
1715 public static readonly DependencyProperty DrawCaretLineProperty =
\r
1716 DependencyProperty.Register("DrawCaretLine", typeof(bool), typeof(FooTextBox), new PropertyMetadata(false, OnPropertyChanged));
\r
1719 /// 行番号を描くなら真。そうでなければ偽。これは依存プロパティです
\r
1721 public bool DrawLineNumber
\r
1723 get { return (bool)GetValue(DrawLineNumberProperty); }
\r
1724 set { SetValue(DrawLineNumberProperty, value); }
\r
1728 /// ルーラーを描くなら真。そうでなければ偽。これは依存プロパティです
\r
1730 public bool DrawRuler
\r
1732 get { return (bool)GetValue(DrawRulerProperty); }
\r
1733 set { SetValue(DrawRulerProperty, value); }
\r
1737 /// DrawRulerの依存プロパティを表す
\r
1739 public static readonly DependencyProperty DrawRulerProperty =
\r
1740 DependencyProperty.Register("DrawRuler", typeof(bool), typeof(FooTextBox), new PropertyMetadata(false, OnPropertyChanged));
\r
1744 /// DrawLineNumberの依存プロパティを表す
\r
1746 public static readonly DependencyProperty DrawLineNumberProperty =
\r
1747 DependencyProperty.Register("DrawLineNumber", typeof(bool), typeof(FooTextBox), new PropertyMetadata(false, OnPropertyChanged));
\r
1750 /// URLに下線を引くなら真。そうでないなら偽を表す。これは依存プロパティです
\r
1752 public bool MarkURL
\r
1754 get { return (bool)GetValue(MarkURLProperty); }
\r
1755 set { SetValue(MarkURLProperty, value); }
\r
1759 /// MarkURLの依存プロパティを表す
\r
1761 public static readonly DependencyProperty MarkURLProperty =
\r
1762 DependencyProperty.Register("MarkURL", typeof(bool), typeof(FooTextBox), new PropertyMetadata(false, OnPropertyChanged));
\r
1765 /// 全角スペースを表示するなら真。そうでないなら偽
\r
1767 public bool ShowFullSpace
\r
1769 get { return (bool)GetValue(ShowFullSpaceProperty); }
\r
1770 set { SetValue(ShowFullSpaceProperty, value); }
\r
1774 /// ShowFullSpaceの依存プロパティを表す
\r
1776 public static readonly DependencyProperty ShowFullSpaceProperty =
\r
1777 DependencyProperty.Register("ShowFullSpace", typeof(bool), typeof(FooTextBox), new PropertyMetadata(false, OnPropertyChanged));
\r
1780 /// 半角スペースを表示するなら真。そうでないなら偽
\r
1782 public bool ShowHalfSpace
\r
1784 get { return (bool)GetValue(ShowHalfSpaceProperty); }
\r
1785 set { SetValue(ShowHalfSpaceProperty, value); }
\r
1789 /// ShowHalfSpaceの依存プロパティを表す
\r
1791 public static readonly DependencyProperty ShowHalfSpaceProperty =
\r
1792 DependencyProperty.Register("ShowHalfSpace", typeof(bool), typeof(FooTextBox), new PropertyMetadata(false, OnPropertyChanged));
\r
1795 /// タブを表示するなら真。そうでないなら偽
\r
1797 public bool ShowTab
\r
1799 get { return (bool)GetValue(ShowTabProperty); }
\r
1800 set { SetValue(ShowTabProperty, value); }
\r
1804 /// ShowTabの依存プロパティを表す
\r
1806 public static readonly DependencyProperty ShowTabProperty =
\r
1807 DependencyProperty.Register("ShowTab", typeof(bool), typeof(FooTextBox), new PropertyMetadata(false, OnPropertyChanged));
\r
1810 /// 改行マークを表示するなら真。そうでないなら偽
\r
1812 public bool ShowLineBreak
\r
1814 get { return (bool)GetValue(ShowLineBreakProperty); }
\r
1815 set { SetValue(ShowLineBreakProperty, value); }
\r
1819 /// ShowLineBreakの依存プロパティを表す
\r
1821 public static readonly DependencyProperty ShowLineBreakProperty =
\r
1822 DependencyProperty.Register("ShowLineBreak", typeof(bool), typeof(FooTextBox), new PropertyMetadata(false,OnPropertyChanged));
\r
1829 /// コンテキストメニューのイベントデーターを表す
\r
1831 public class FooContextMenuEventArgs
\r
1834 /// 処理済みなら真。そうでないなら偽
\r
1836 public bool Handled = false;
\r
1838 /// コンテキストメニューを表示すべき座標を表す
\r
1840 public Windows.Foundation.Point Postion;
\r
1844 /// <param name="pos"></param>
\r
1845 public FooContextMenuEventArgs(Windows.Foundation.Point pos)
\r
1847 this.Postion = pos;
\r