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(D2DRender.GripperWidth / 2, D2DRender.GripperWidth, D2DRender.GripperWidth / 2, D2DRender.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, GripperType.First);
\r
94 this.SecondGripper = new Gripper(this._Controller, this.View, this.Render, GripperType.Second);
\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.JumpCaret(this.View.CaretPostion.row, 0);
\r
474 isMovedCaret = true;
\r
476 case VirtualKey.End:
\r
477 if (isControlPressed)
\r
478 this._Controller.JumpToEnd(isShiftPressed);
\r
480 this._Controller.JumpCaret(this.View.CaretPostion.row, this.View.LayoutLines[this.View.CaretPostion.row].Length - 1);
\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
752 void gestureRecongnizer_ManipulationStarted(GestureRecognizer sender, ManipulationStartedEventArgs e)
\r
756 void gestureRecongnizer_ManipulationUpdated(GestureRecognizer sender, ManipulationUpdatedEventArgs e)
\r
758 if (this.Document.State == AsyncState.Loading)
\r
760 bool HittedCaret = false;
\r
762 TextPoint tp = this.View.GetTextPointFromPostion(e.Position);
\r
763 Point p = e.Position;
\r
765 if (tp == this.View.CaretPostion)
\r
767 HittedCaret = true;
\r
770 Gripper hittedGripper = null;
\r
771 if (this.FirstGripper.IsHit(p))
\r
773 p = this.FirstGripper.AdjustPoint(p);
\r
774 hittedGripper = this.FirstGripper;
\r
775 HittedCaret = true;
\r
777 else if (this.SecondGripper.IsHit(p))
\r
779 p = this.SecondGripper.AdjustPoint(p);
\r
780 hittedGripper = this.SecondGripper;
\r
781 HittedCaret = true;
\r
786 if (hittedGripper != null && this.View.HitTextArea(p.X, p.Y))
\r
788 tp = this.View.GetTextPointFromPostion(p);
\r
789 if (this._Controller.IsReverseSelect())
\r
791 if (Object.ReferenceEquals(hittedGripper,this.SecondGripper))
\r
792 this._Controller.MoveSelectBefore(tp);
\r
794 this._Controller.MoveCaretAndSelect(tp);
\r
798 if (Object.ReferenceEquals(hittedGripper,this.FirstGripper))
\r
799 this._Controller.MoveSelectBefore(tp);
\r
801 this._Controller.MoveCaretAndSelect(tp);
\r
803 if (this.peer != null)
\r
804 this.peer.OnNotifyCaretChanged();
\r
809 if (e.Delta.Scale < 1)
\r
811 double newSize = this.Render.FontSize - 1;
\r
814 this.Render.FontSize = newSize;
\r
816 SetValue(MagnificationPowerPropertyKey, this.Render.FontSize / this.FontSize);
\r
820 if (e.Delta.Scale > 1)
\r
822 double newSize = this.Render.FontSize + 1;
\r
825 this.Render.FontSize = newSize;
\r
827 SetValue(MagnificationPowerPropertyKey, this.Render.FontSize / this.FontSize);
\r
831 Point translation = e.Delta.Translation;
\r
833 int scrollCount = (int)Math.Abs(translation.Y);
\r
834 if (scrollCount > 0)
\r
836 if (scrollCount > this.View.LineCountOnScreen) //ホイール対策
\r
837 scrollCount = this.View.LineCountOnScreen;
\r
838 if (translation.Y > 0)
\r
839 this._Controller.Scroll(ScrollDirection.Up, scrollCount, false, false);
\r
841 this._Controller.Scroll(ScrollDirection.Down, scrollCount, false, false);
\r
842 this.FirstGripper.Enabled = false;
\r
843 this.SecondGripper.Enabled = false;
\r
848 int deltax = (int)Math.Abs(translation.X);
\r
851 if (translation.X < 0)
\r
852 this._Controller.Scroll(ScrollDirection.Left, deltax, false, false);
\r
854 this._Controller.Scroll(ScrollDirection.Right, deltax, false, false);
\r
855 this.FirstGripper.Enabled = false;
\r
856 this.SecondGripper.Enabled = false;
\r
861 void gestureRecongnizer_ManipulationCompleted(GestureRecognizer sender, ManipulationCompletedEventArgs e)
\r
865 async void gestureRecongnizer_RightTapped(GestureRecognizer sender, RightTappedEventArgs e)
\r
867 ResourceMap map = ResourceManager.Current.MainResourceMap.GetSubtree("FooEditEngine.Metro/Resources");
\r
868 if (this.View.HitTextArea(e.Position.X, e.Position.Y))
\r
870 FooContextMenuEventArgs args = new FooContextMenuEventArgs(e.Position);
\r
871 if (this.ContextMenuOpening != null)
\r
872 this.ContextMenuOpening(this, args);
\r
875 PopupMenu ContextMenu = new PopupMenu();
\r
876 ContextMenu.Commands.Add(new UICommand(map.GetValue("CopyMenuName").ValueAsString, (command) =>
\r
878 this.CopyCommand();
\r
880 ContextMenu.Commands.Add(new UICommand(map.GetValue("CutMenuName").ValueAsString, (command) =>
\r
884 ContextMenu.Commands.Add(new UICommand(map.GetValue("PasteMenuName").ValueAsString, async (command) =>
\r
886 await this.PasteCommand();
\r
888 if (this._Controller.RectSelection)
\r
890 ContextMenu.Commands.Add(new UICommand(map.GetValue("LineSelectMenuName").ValueAsString, (command) =>
\r
892 this._Controller.RectSelection = false;
\r
897 ContextMenu.Commands.Add(new UICommand(map.GetValue("RectSelectMenuName").ValueAsString, (command) =>
\r
899 this._Controller.RectSelection = true;
\r
902 await ContextMenu.ShowAsync(Util.GetScreentPoint(e.Position,this));
\r
907 void gestureRecongnizer_Tapped(GestureRecognizer sender, TappedEventArgs e)
\r
909 bool touched = e.PointerDeviceType == PointerDeviceType.Touch;
\r
910 this.FirstGripper.Enabled = touched;
\r
911 this.SecondGripper.Enabled = touched;
\r
912 this.JumpCaret(e.Position);
\r
915 void JumpCaret(Point p)
\r
917 if (this.Document.State == AsyncState.Loading)
\r
920 TextPoint tp = this.View.GetTextPointFromPostion(p);
\r
921 if (tp == TextPoint.Null)
\r
924 int index = this.View.LayoutLines.GetIndexFromTextPoint(tp);
\r
926 FoldingItem foldingData = this.View.HitFoldingData(p.X, tp.row);
\r
927 if (foldingData != null)
\r
929 if (foldingData.Expand)
\r
930 this.View.LayoutLines.FoldingCollection.Collapse(foldingData);
\r
932 this.View.LayoutLines.FoldingCollection.Expand(foldingData);
\r
933 this._Controller.JumpCaret(foldingData.Start, false);
\r
937 this._Controller.JumpCaret(tp.row, tp.col, false);
\r
939 if (this.peer != null)
\r
940 this.peer.OnNotifyCaretChanged();
\r
941 this.Focus(FocusState.Pointer);
\r
945 void gestureRecongnizer_Dragging(GestureRecognizer sender, DraggingEventArgs e)
\r
947 if (this.Document.State == AsyncState.Loading)
\r
949 Point p = e.Position;
\r
950 if (this.View.HitTextArea(p.X, p.Y))
\r
952 TextPoint tp = this.View.GetTextPointFromPostion(p);
\r
953 this._Controller.MoveCaretAndSelect(tp);
\r
954 if (this.peer != null)
\r
955 this.peer.OnNotifyCaretChanged();
\r
960 bool IsModiferKeyPressed(VirtualKey key)
\r
962 CoreVirtualKeyStates state = Window.Current.CoreWindow.GetKeyState(key);
\r
963 return (state & CoreVirtualKeyStates.Down) == CoreVirtualKeyStates.Down;
\r
965 void Refresh(Rectangle updateRect)
\r
967 if (this.rectangle.ActualWidth == 0 || this.rectangle.ActualHeight == 0/* || !this.Render.IsCanDraw()*/)
\r
970 this.Render.BeginDraw();
\r
971 if (this.Document.State != AsyncState.Loading)
\r
972 this.View.Draw(updateRect);
\r
974 this.Render.FillBackground(updateRect);
\r
975 this.FirstGripper.Draw();
\r
976 this.SecondGripper.Draw();
\r
977 this.Render.EndDraw();
\r
981 bool Resize(double width, double height)
\r
983 if (width == 0 || height == 0)
\r
984 throw new ArgumentOutOfRangeException();
\r
985 if (this.Document.State != AsyncState.Loading && this.Render.Resize(this.rectangle, width, height))
\r
987 this.View.PageBound = new Rectangle(0, 0, width, height);
\r
989 if (this.horizontalScrollBar != null)
\r
991 this.horizontalScrollBar.LargeChange = this.View.PageBound.Width;
\r
992 this.horizontalScrollBar.Maximum = this.View.LongestWidth + this.horizontalScrollBar.LargeChange + 1;
\r
994 if (this.verticalScrollBar != null)
\r
996 this.verticalScrollBar.LargeChange = this.View.LineCountOnScreen;
\r
997 this.verticalScrollBar.Maximum = this.View.LayoutLines.Count + this.verticalScrollBar.LargeChange + 1;
\r
1004 void View_SrcChanged(object sender, EventArgs e)
\r
1006 if (this.horizontalScrollBar == null || this.verticalScrollBar == null)
\r
1008 EditView view = this.View;
\r
1009 if (view.Src.Row > this.verticalScrollBar.Maximum)
\r
1010 this.verticalScrollBar.Maximum = view.Src.Row + view.LineCountOnScreen + 1;
\r
1011 double absoulteX = Math.Abs(view.Src.X);
\r
1012 if (absoulteX > this.horizontalScrollBar.Maximum)
\r
1013 this.horizontalScrollBar.Maximum = absoulteX + view.PageBound.Width + 1;
\r
1014 if (view.Src.Row != this.verticalScrollBar.Value)
\r
1015 this.verticalScrollBar.Value = view.Src.Row;
\r
1016 if (view.Src.X != this.horizontalScrollBar.Value)
\r
1017 this.horizontalScrollBar.Value = Math.Abs(view.Src.X);
\r
1020 void FooTextBox_SizeChanged(object sender, SizeChangedEventArgs e)
\r
1022 if (this.Document.State == AsyncState.Loading || this.Resize(this.rectangle.ActualWidth, this.rectangle.ActualHeight))
\r
1029 void horizontalScrollBar_Scroll(object sender, ScrollEventArgs e)
\r
1031 if (this.Document.State == AsyncState.Loading)
\r
1033 if (this.horizontalScrollBar == null)
\r
1036 if (this.FlowDirection == FlowDirection.LeftToRight)
\r
1037 toX = this.horizontalScrollBar.Value;
\r
1039 toX = -this.horizontalScrollBar.Value;
\r
1040 this._Controller.Scroll(toX, this.View.Src.Row, false, false);
\r
1041 this.FirstGripper.Enabled = false;
\r
1042 this.SecondGripper.Enabled = false;
\r
1046 void verticalScrollBar_Scroll(object sender, ScrollEventArgs e)
\r
1048 if (this.Document.State == AsyncState.Loading)
\r
1050 if (this.verticalScrollBar == null)
\r
1052 int newRow = (int)this.verticalScrollBar.Value;
\r
1053 if (newRow >= this.View.LayoutLines.Count)
\r
1055 this._Controller.Scroll(this.View.Src.X, newRow, false, false);
\r
1056 this.FirstGripper.Enabled = false;
\r
1057 this.SecondGripper.Enabled = false;
\r
1061 void Document_Update(object sender, DocumentUpdateEventArgs e)
\r
1063 if (this.textStore.IsLocked() || this.Document.State == AsyncState.Loading || e.type == UpdateType.Clear)
\r
1065 if (e.removeLength == 0)
\r
1066 this.textStore.NotifyTextChanged(e.startIndex, e.startIndex, e.startIndex + e.insertLength);
\r
1068 this.textStore.NotifyTextChanged(e.startIndex, e.startIndex + 1, e.startIndex + e.insertLength - e.removeLength);
\r
1071 void Document_Progress(object sender, ProgressEventArgs e)
\r
1073 if (this.Document.State == AsyncState.Loading)
\r
1077 case ProgressState.Start:
\r
1078 this.textStore.NotifyTextChanged(0, this.Document.Length, 0);
\r
1080 case ProgressState.Complete:
\r
1081 this.textStore.NotifyTextChanged(0, 0, this.Document.Length);
\r
1082 if (this.verticalScrollBar != null)
\r
1083 this.verticalScrollBar.Maximum = this.View.LayoutLines.Count;
\r
1084 this.View.CalculateLineCountOnScreen();
\r
1089 void FooTextBox_Loaded(object sender, RoutedEventArgs e)
\r
1091 this.Focus(FocusState.Programmatic);
\r
1095 public static void OnPropertyChanged(object sender, DependencyPropertyChangedEventArgs e)
\r
1097 FooTextBox source = (FooTextBox)sender;
\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 = source.Foreground;
\r
1129 if (e.Property.Equals(BackgroundProperty))
\r
1130 source.Render.Background = source.Background;
\r
1131 if (e.Property.Equals(ControlCharProperty))
\r
1132 source.Render.ControlChar = source.ControlChar;
\r
1133 if (e.Property.Equals(HilightProperty))
\r
1134 source.Render.Hilight = source.Hilight;
\r
1135 if (e.Property.Equals(Keyword1Property))
\r
1136 source.Render.Keyword1 = source.Keyword1;
\r
1137 if (e.Property.Equals(Keyword2Property))
\r
1138 source.Render.Keyword2 = source.Keyword2;
\r
1139 if (e.Property.Equals(CommentProperty))
\r
1140 source.Render.Comment = source.Comment;
\r
1141 if (e.Property.Equals(LiteralProperty))
\r
1142 source.Render.Literal = source.Literal;
\r
1143 if (e.Property.Equals(URLProperty))
\r
1144 source.Render.Url = source.URL;
\r
1145 if (e.Property.Equals(InsertCaretProperty))
\r
1146 source.Render.InsertCaret = source.InsertCaret;
\r
1147 if (e.Property.Equals(OverwriteCaretProperty))
\r
1148 source.Render.OverwriteCaret = source.OverwriteCaret;
\r
1149 if (e.Property.Equals(LineMarkerProperty))
\r
1150 source.Render.LineMarker = source.LineMarker;
\r
1151 if (e.Property.Equals(MarkURLProperty))
\r
1152 source.View.UrlMark = source.MarkURL;
\r
1153 if (e.Property.Equals(ShowFullSpaceProperty))
\r
1154 source.Render.ShowFullSpace = source.ShowFullSpace;
\r
1155 if (e.Property.Equals(ShowHalfSpaceProperty))
\r
1156 source.Render.ShowHalfSpace = source.ShowHalfSpace;
\r
1157 if (e.Property.Equals(ShowTabProperty))
\r
1158 source.Render.ShowTab = source.ShowTab;
\r
1159 if (e.Property.Equals(ShowLineBreakProperty))
\r
1160 source.Render.ShowLineBreak = source.ShowLineBreak;
\r
1161 if (e.Property.Equals(LineBreakProperty))
\r
1162 source.View.LineBreak = source.LineBreakMethod;
\r
1163 if (e.Property.Equals(LineBreakCharCountProperty))
\r
1164 source.View.LineBreakCharCount = source.LineBreakCharCount;
\r
1165 if (e.Property.Equals(FlowDirectionProperty))
\r
1167 source.Render.RightToLeft = source.FlowDirection == Windows.UI.Xaml.FlowDirection.RightToLeft;
\r
1168 if(source.horizontalScrollBar != null)
\r
1169 source.horizontalScrollBar.FlowDirection = source.FlowDirection;
\r
1171 if (e.Property.Equals(DrawRulerProperty))
\r
1173 source.View.HideRuler = !source.DrawRuler;
\r
1174 source._Controller.JumpCaret(source.View.CaretPostion.row, source.View.CaretPostion.col);
\r
1182 /// コンテキストメニューが表示されるときに呼び出されます
\r
1184 public event EventHandler<FooContextMenuEventArgs> ContextMenuOpening;
\r
1190 internal Controller Controller
\r
1194 return this._Controller;
\r
1199 /// 文字列の描写に使用されるアンチエイリアシング モードを表します
\r
1201 public TextAntialiasMode TextAntialiasMode
\r
1205 return this.Render.TextAntialiasMode;
\r
1209 this.Render.TextAntialiasMode = value;
\r
1214 /// シンタックスハイライターを表す
\r
1216 public IHilighter Hilighter
\r
1220 return this.View.Hilighter;
\r
1224 this.View.Hilighter = value;
\r
1225 this.View.LayoutLines.ClearLayoutCache();
\r
1230 /// フォールティングを作成するインターフェイスを表す
\r
1232 public IFoldingStrategy FoldingStrategy
\r
1236 return this.View.LayoutLines.FoldingStrategy;
\r
1240 this.View.LayoutLines.FoldingStrategy = value;
\r
1241 if (value == null)
\r
1242 this.View.LayoutLines.FoldingCollection.Clear();
\r
1249 public Document Document
\r
1258 public LineToIndexTable LayoutLineCollection
\r
1260 get { return this.View.LayoutLines; }
\r
1266 public string SelectedText
\r
1270 return this._Controller.SelectedText;
\r
1274 int oldLength = this.Document.Length;
\r
1275 this._Controller.SelectedText = value;
\r
1283 /// Lengthが0の場合はキャレット位置を表します。
\r
1284 /// 矩形選択モードの場合、選択範囲の文字数ではなく、開始位置から終了位置までの長さとなります
\r
1286 public TextRange Selection
\r
1288 get { return (TextRange)GetValue(SelectionProperty); }
\r
1289 set { SetValue(SelectionProperty, value); }
\r
1293 /// Selectionの依存プロパティを表す
\r
1295 public static readonly DependencyProperty SelectionProperty =
\r
1296 DependencyProperty.Register("Selection", typeof(TextRange), typeof(FooTextBox), new PropertyMetadata(0));
\r
1301 public double MagnificationPower
\r
1303 get { return (double)GetValue(MagnificationPowerPropertyKey); }
\r
1304 set { SetValue(MagnificationPowerPropertyKey, value); }
\r
1310 public static readonly DependencyProperty MagnificationPowerPropertyKey =
\r
1311 DependencyProperty.Register("MagnificationPower", typeof(double), typeof(FooTextBox), new PropertyMetadata(1.0, OnPropertyChanged));
\r
1316 public TextPoint CaretPostion
\r
1318 get { return (TextPoint)GetValue(CaretPostionPropertyKey); }
\r
1319 set { SetValue(CaretPostionPropertyKey, value); }
\r
1322 static readonly DependencyProperty CaretPostionPropertyKey =
\r
1323 DependencyProperty.Register("CaretPostion", typeof(TextPoint), typeof(FooTextBox), new PropertyMetadata(new TextPoint(), OnPropertyChanged));
\r
1328 public new FlowDirection FlowDirection
\r
1330 get { return (FlowDirection)GetValue(FlowDirectionProperty); }
\r
1331 set { SetValue(FlowDirectionProperty, value); }
\r
1335 /// レタリング方向を表す。これは依存プロパティです
\r
1337 public new static readonly DependencyProperty FlowDirectionProperty =
\r
1338 DependencyProperty.Register("FlowDirection", typeof(FlowDirection), typeof(FooTextBox), new PropertyMetadata(FlowDirection.LeftToRight,OnPropertyChanged));
\r
1343 public new FontFamily FontFamily
\r
1345 get { return (FontFamily)GetValue(FontFamilyProperty); }
\r
1346 set { SetValue(FontFamilyProperty, value); }
\r
1350 /// FontFamilyの依存プロパティを表す
\r
1352 public new static readonly DependencyProperty FontFamilyProperty =
\r
1353 DependencyProperty.Register("FontFamily", typeof(FontFamily), typeof(FooTextBox), new PropertyMetadata(new FontFamily("Cambria"), OnPropertyChanged));
\r
1358 public new double FontSize
\r
1360 get { return (double)GetValue(FontSizeProperty); }
\r
1361 set { SetValue(FontSizeProperty, value); }
\r
1365 /// FontSizeの依存プロパティを表す
\r
1367 public new static readonly DependencyProperty FontSizeProperty =
\r
1368 DependencyProperty.Register("FontSize", typeof(double), typeof(FooTextBox), new PropertyMetadata(12.0,OnPropertyChanged));
\r
1373 public new FontStyle FontStyle
\r
1375 get { return (FontStyle)GetValue(FontStyleProperty); }
\r
1376 set { SetValue(FontStyleProperty, value); }
\r
1380 /// FontStyleの依存プロパティを表す
\r
1382 public new static readonly DependencyProperty FontStyleProperty =
\r
1383 DependencyProperty.Register("FontStyle", typeof(FontStyle), typeof(FooTextBox), new PropertyMetadata(FontStyle.Normal,OnPropertyChanged));
\r
1388 public new FontWeight FontWeight
\r
1390 get { return (FontWeight)GetValue(FontWeightProperty); }
\r
1391 set { SetValue(FontWeightProperty, value); }
\r
1395 /// FontWeigthの依存プロパティを表す
\r
1397 public new static readonly DependencyProperty FontWeightProperty =
\r
1398 DependencyProperty.Register("FontWeigth", typeof(FontWeight), typeof(FooTextBox), new PropertyMetadata(FontWeights.Normal,OnPropertyChanged));
\r
1401 /// デフォルトの文字色を表す。これは依存プロパティです
\r
1403 public new Windows.UI.Color Foreground
\r
1405 get { return (Windows.UI.Color)GetValue(ForegroundProperty); }
\r
1406 set { SetValue(ForegroundProperty, value); }
\r
1410 /// Foregroundの依存プロパティを表す
\r
1412 public new static readonly DependencyProperty ForegroundProperty =
\r
1413 DependencyProperty.Register("Foreground", typeof(Windows.UI.Color), typeof(FooTextBox), new PropertyMetadata(Colors.Black, OnPropertyChanged));
\r
1416 /// 背景色を表す。これは依存プロパティです
\r
1418 public new Windows.UI.Color Background
\r
1420 get { return (Windows.UI.Color)GetValue(BackgroundProperty); }
\r
1421 set { SetValue(BackgroundProperty, value); }
\r
1425 /// Backgroundの依存プロパティを表す
\r
1427 public new static readonly DependencyProperty BackgroundProperty =
\r
1428 DependencyProperty.Register("Background", typeof(Windows.UI.Color), typeof(FooTextBox), new PropertyMetadata(Colors.White, OnPropertyChanged));
\r
1431 /// コントロールコードの文字色を表す。これは依存プロパティです
\r
1433 public Windows.UI.Color ControlChar
\r
1435 get { return (Windows.UI.Color)GetValue(ControlCharProperty); }
\r
1436 set { SetValue(ControlCharProperty, value); }
\r
1440 /// ControlCharの依存プロパティを表す
\r
1442 public static readonly DependencyProperty ControlCharProperty =
\r
1443 DependencyProperty.Register("ControlChar", typeof(Windows.UI.Color), typeof(FooTextBox), new PropertyMetadata(Colors.Gray, OnPropertyChanged));
\r
1446 /// 選択時の背景色を表す。これは依存プロパティです
\r
1448 public Windows.UI.Color Hilight
\r
1450 get { return (Windows.UI.Color)GetValue(HilightProperty); }
\r
1451 set { SetValue(HilightProperty, value); }
\r
1455 /// Hilightの依存プロパティを表す
\r
1457 public static readonly DependencyProperty HilightProperty =
\r
1458 DependencyProperty.Register("Hilight", typeof(Windows.UI.Color), typeof(FooTextBox), new PropertyMetadata(Colors.DeepSkyBlue, OnPropertyChanged));
\r
1461 /// キーワード1の文字色を表す。これは依存プロパティです
\r
1463 public Windows.UI.Color Keyword1
\r
1465 get { return (Windows.UI.Color)GetValue(Keyword1Property); }
\r
1466 set { SetValue(Keyword1Property, value); }
\r
1470 /// Keyword1の依存プロパティを表す
\r
1472 public static readonly DependencyProperty Keyword1Property =
\r
1473 DependencyProperty.Register("Keyword1", typeof(Windows.UI.Color), typeof(FooTextBox), new PropertyMetadata(Colors.Blue, OnPropertyChanged));
\r
1476 /// キーワード2の文字色を表す。これは依存プロパティです
\r
1478 public Windows.UI.Color Keyword2
\r
1480 get { return (Windows.UI.Color)GetValue(Keyword2Property); }
\r
1481 set { SetValue(Keyword2Property, value); }
\r
1485 /// Keyword2の依存プロパティを表す
\r
1487 public static readonly DependencyProperty Keyword2Property =
\r
1488 DependencyProperty.Register("Keyword2", typeof(Windows.UI.Color), typeof(FooTextBox), new PropertyMetadata(Colors.DarkCyan, OnPropertyChanged));
\r
1491 /// コメントの文字色を表す。これは依存プロパティです
\r
1493 public Windows.UI.Color Comment
\r
1495 get { return (Windows.UI.Color)GetValue(CommentProperty); }
\r
1496 set { SetValue(CommentProperty, value); }
\r
1500 /// Commentの依存プロパティを表す
\r
1502 public static readonly DependencyProperty CommentProperty =
\r
1503 DependencyProperty.Register("Comment", typeof(Windows.UI.Color), typeof(FooTextBox), new PropertyMetadata(Colors.Green, OnPropertyChanged));
\r
1506 /// 文字リテラルの文字色を表す。これは依存プロパティです
\r
1508 public Windows.UI.Color Literal
\r
1510 get { return (Windows.UI.Color)GetValue(LiteralProperty); }
\r
1511 set { SetValue(LiteralProperty, value); }
\r
1515 /// Literalの依存プロパティを表す
\r
1517 public static readonly DependencyProperty LiteralProperty =
\r
1518 DependencyProperty.Register("Literal", typeof(Windows.UI.Color), typeof(FooTextBox), new PropertyMetadata(Colors.Brown, OnPropertyChanged));
\r
1521 /// URLの文字色を表す。これは依存プロパティです
\r
1523 public Windows.UI.Color URL
\r
1525 get { return (Windows.UI.Color)GetValue(URLProperty); }
\r
1526 set { SetValue(URLProperty, value); }
\r
1530 /// URLの依存プロパティを表す
\r
1532 public static readonly DependencyProperty URLProperty =
\r
1533 DependencyProperty.Register("URL", typeof(Windows.UI.Color), typeof(FooTextBox), new PropertyMetadata(Colors.Blue, OnPropertyChanged));
\r
1539 public Windows.UI.Color LineMarker
\r
1541 get { return (Windows.UI.Color)GetValue(LineMarkerProperty); }
\r
1542 set { SetValue(LineMarkerProperty, value); }
\r
1546 /// LineMarkerの依存プロパティを表す
\r
1548 public static readonly DependencyProperty LineMarkerProperty =
\r
1549 DependencyProperty.Register("LineMarker", typeof(Windows.UI.Color), typeof(FooTextBox), new PropertyMetadata(Colors.Gray, OnPropertyChanged));
\r
1552 /// 挿入モード時のキャレットの色を表す
\r
1554 public Windows.UI.Color InsertCaret
\r
1556 get { return (Windows.UI.Color)GetValue(InsertCaretProperty); }
\r
1557 set { SetValue(InsertCaretProperty, value); }
\r
1561 /// InsertCaretの依存プロパティを表す
\r
1563 public static readonly DependencyProperty InsertCaretProperty =
\r
1564 DependencyProperty.Register("InsertCaret", typeof(Windows.UI.Color), typeof(FooTextBox), new PropertyMetadata(Colors.Black, OnPropertyChanged));
\r
1567 /// 上書きモード時のキャレット職を表す
\r
1569 public Windows.UI.Color OverwriteCaret
\r
1571 get { return (Windows.UI.Color)GetValue(OverwriteCaretProperty); }
\r
1572 set { SetValue(OverwriteCaretProperty, value); }
\r
1576 /// OverwriteCaretの依存プロパティを表す
\r
1578 public static readonly DependencyProperty OverwriteCaretProperty =
\r
1579 DependencyProperty.Register("OverwriteCaret", typeof(Windows.UI.Color), typeof(FooTextBox), new PropertyMetadata(Colors.Black, OnPropertyChanged));
\r
1582 /// 挿入モードなら真を返し、そうでないなら、偽を返す。これは依存プロパティです
\r
1584 public bool InsertMode
\r
1586 get { return (bool)GetValue(InsertModeProperty); }
\r
1587 set { SetValue(InsertModeProperty, value); }
\r
1591 /// InsertModeの依存プロパティを表す
\r
1593 public static readonly DependencyProperty InsertModeProperty =
\r
1594 DependencyProperty.Register("InsertMode",
\r
1596 typeof(FooTextBox),
\r
1597 new PropertyMetadata(true, OnPropertyChanged));
\r
1600 /// タブの文字数を表す。これは依存プロパティです
\r
1602 public int TabChars
\r
1604 get { return (int)GetValue(TabCharsProperty); }
\r
1605 set { SetValue(TabCharsProperty, value); }
\r
1609 /// TabCharsの依存プロパティを表す
\r
1611 public static readonly DependencyProperty TabCharsProperty =
\r
1612 DependencyProperty.Register("TabChars",
\r
1614 typeof(FooTextBox),
\r
1615 new PropertyMetadata(4, OnPropertyChanged));
\r
1618 /// 矩形選択モードなら真を返し、そうでないなら偽を返す。これは依存プロパティです
\r
1620 public bool RectSelectMode
\r
1622 get { return (bool)GetValue(RectSelectModeProperty); }
\r
1623 set { SetValue(RectSelectModeProperty, value); }
\r
1627 /// RectSelectModeの依存プロパティを表す
\r
1629 public static readonly DependencyProperty RectSelectModeProperty =
\r
1630 DependencyProperty.Register("RectSelectMode", typeof(bool), typeof(FooTextBox), new PropertyMetadata(false, OnPropertyChanged));
\r
1636 /// 変更した場合、レイアウトの再構築を行う必要があります
\r
1638 public LineBreakMethod LineBreakMethod
\r
1640 get { return (LineBreakMethod)GetValue(LineBreakProperty); }
\r
1641 set { SetValue(LineBreakProperty, value); }
\r
1645 /// LineBreakMethodの依存プロパティを表す
\r
1647 public static readonly DependencyProperty LineBreakProperty =
\r
1648 DependencyProperty.Register("LineBreakMethod", typeof(LineBreakMethod), typeof(FooTextBox), new PropertyMetadata(LineBreakMethod.None, OnPropertyChanged));
\r
1652 /// 折り返しの幅を指定する。LineBreakMethod.CharUnit以外の時は無視されます
\r
1655 /// 変更した場合、レイアウトの再構築を行う必要があります
\r
1657 public int LineBreakCharCount
\r
1659 get { return (int)GetValue(LineBreakCharCountProperty); }
\r
1660 set { SetValue(LineBreakCharCountProperty, value); }
\r
1664 /// LineBreakCharCountの依存プロパティを表す
\r
1666 public static readonly DependencyProperty LineBreakCharCountProperty =
\r
1667 DependencyProperty.Register("LineBreakCharCount", typeof(int), typeof(FooTextBox), new PropertyMetadata(80));
\r
1670 /// キャレットを描くなら真。そうでないなら偽を返す。これは依存プロパティです
\r
1672 public bool DrawCaret
\r
1674 get { return (bool)GetValue(DrawCaretProperty); }
\r
1675 set { SetValue(DrawCaretProperty, value); }
\r
1679 /// DrawCaretの依存プロパティを表す
\r
1681 public static readonly DependencyProperty DrawCaretProperty =
\r
1682 DependencyProperty.Register("DrawCaret", typeof(bool), typeof(FooTextBox), new PropertyMetadata(true, OnPropertyChanged));
\r
1686 /// キャレットラインを描くなら真。そうでないなら偽を返す。これは依存プロパティです
\r
1688 public bool DrawCaretLine
\r
1690 get { return (bool)GetValue(DrawCaretLineProperty); }
\r
1691 set { SetValue(DrawCaretLineProperty, value); }
\r
1695 /// DrawCaretLineの依存プロパティを表す
\r
1697 public static readonly DependencyProperty DrawCaretLineProperty =
\r
1698 DependencyProperty.Register("DrawCaretLine", typeof(bool), typeof(FooTextBox), new PropertyMetadata(false, OnPropertyChanged));
\r
1701 /// 行番号を描くなら真。そうでなければ偽。これは依存プロパティです
\r
1703 public bool DrawLineNumber
\r
1705 get { return (bool)GetValue(DrawLineNumberProperty); }
\r
1706 set { SetValue(DrawLineNumberProperty, value); }
\r
1710 /// ルーラーを描くなら真。そうでなければ偽。これは依存プロパティです
\r
1712 public bool DrawRuler
\r
1714 get { return (bool)GetValue(DrawRulerProperty); }
\r
1715 set { SetValue(DrawRulerProperty, value); }
\r
1719 /// DrawRulerの依存プロパティを表す
\r
1721 public static readonly DependencyProperty DrawRulerProperty =
\r
1722 DependencyProperty.Register("DrawRuler", typeof(bool), typeof(FooTextBox), new PropertyMetadata(false, OnPropertyChanged));
\r
1726 /// DrawLineNumberの依存プロパティを表す
\r
1728 public static readonly DependencyProperty DrawLineNumberProperty =
\r
1729 DependencyProperty.Register("DrawLineNumber", typeof(bool), typeof(FooTextBox), new PropertyMetadata(false, OnPropertyChanged));
\r
1732 /// URLに下線を引くなら真。そうでないなら偽を表す。これは依存プロパティです
\r
1734 public bool MarkURL
\r
1736 get { return (bool)GetValue(MarkURLProperty); }
\r
1737 set { SetValue(MarkURLProperty, value); }
\r
1741 /// MarkURLの依存プロパティを表す
\r
1743 public static readonly DependencyProperty MarkURLProperty =
\r
1744 DependencyProperty.Register("MarkURL", typeof(bool), typeof(FooTextBox), new PropertyMetadata(false, OnPropertyChanged));
\r
1747 /// 全角スペースを表示するなら真。そうでないなら偽
\r
1749 public bool ShowFullSpace
\r
1751 get { return (bool)GetValue(ShowFullSpaceProperty); }
\r
1752 set { SetValue(ShowFullSpaceProperty, value); }
\r
1756 /// ShowFullSpaceの依存プロパティを表す
\r
1758 public static readonly DependencyProperty ShowFullSpaceProperty =
\r
1759 DependencyProperty.Register("ShowFullSpace", typeof(bool), typeof(FooTextBox), new PropertyMetadata(false, OnPropertyChanged));
\r
1762 /// 半角スペースを表示するなら真。そうでないなら偽
\r
1764 public bool ShowHalfSpace
\r
1766 get { return (bool)GetValue(ShowHalfSpaceProperty); }
\r
1767 set { SetValue(ShowHalfSpaceProperty, value); }
\r
1771 /// ShowHalfSpaceの依存プロパティを表す
\r
1773 public static readonly DependencyProperty ShowHalfSpaceProperty =
\r
1774 DependencyProperty.Register("ShowHalfSpace", typeof(bool), typeof(FooTextBox), new PropertyMetadata(false, OnPropertyChanged));
\r
1777 /// タブを表示するなら真。そうでないなら偽
\r
1779 public bool ShowTab
\r
1781 get { return (bool)GetValue(ShowTabProperty); }
\r
1782 set { SetValue(ShowTabProperty, value); }
\r
1786 /// ShowTabの依存プロパティを表す
\r
1788 public static readonly DependencyProperty ShowTabProperty =
\r
1789 DependencyProperty.Register("ShowTab", typeof(bool), typeof(FooTextBox), new PropertyMetadata(false, OnPropertyChanged));
\r
1792 /// 改行マークを表示するなら真。そうでないなら偽
\r
1794 public bool ShowLineBreak
\r
1796 get { return (bool)GetValue(ShowLineBreakProperty); }
\r
1797 set { SetValue(ShowLineBreakProperty, value); }
\r
1801 /// ShowLineBreakの依存プロパティを表す
\r
1803 public static readonly DependencyProperty ShowLineBreakProperty =
\r
1804 DependencyProperty.Register("ShowLineBreak", typeof(bool), typeof(FooTextBox), new PropertyMetadata(false,OnPropertyChanged));
\r
1811 /// コンテキストメニューのイベントデーターを表す
\r
1813 public class FooContextMenuEventArgs
\r
1816 /// 処理済みなら真。そうでないなら偽
\r
1818 public bool Handled = false;
\r
1820 /// コンテキストメニューを表示すべき座標を表す
\r
1822 public Windows.Foundation.Point Postion;
\r
1826 /// <param name="pos"></param>
\r
1827 public FooContextMenuEventArgs(Windows.Foundation.Point pos)
\r
1829 this.Postion = pos;
\r