using System.Windows.Automation.Peers;
using System.Windows.Automation.Provider;
using System.Windows.Automation.Text;
+using FooEditEngine;
using FooEditEngine.WPF;
#endif
/// Text Pattern (ITextProvider) and Value Pattern (IValuePattern) interfaces. So Touch keyboard shows
/// automatically when user taps on the control with Touch or Pen.
/// </summary>
+#if METRO || WINDOWS_UWP
+ sealed class FooTextBoxAutomationPeer : FrameworkElementAutomationPeer, ITextProvider, ITextProvider2, IValueProvider
+#elif WPF
sealed class FooTextBoxAutomationPeer : FrameworkElementAutomationPeer, ITextProvider, IValueProvider
+#endif
{
private FooTextBox fooTextBox;
private string accClass = "FooTextBox";
{
return this;
}
+ else if (patternInterface == PatternInterface.Text2)
+ {
+ return this;
+ }
return base.GetPatternCore(patternInterface);
}
-#endif
-#if WPF
+#elif WPF
public override object GetPattern(PatternInterface patternInterface)
{
if (patternInterface == PatternInterface.Value)
protected override Windows.Foundation.Rect GetBoundingRectangleCore()
{
double scale = Util.GetScale();
- return new Windows.Foundation.Rect(0, 0, this.fooTextBox.ActualWidth * scale, this.fooTextBox.ActualHeight * scale);
- }
-#endif
-#if WPF
+ Point left = Util.GetPointInWindow(new Point(0, 0),this.fooTextBox).Scale(scale);
+ Point bottom = Util.GetPointInWindow(new Point(this.fooTextBox.ActualWidth, this.fooTextBox.ActualHeight),this.fooTextBox).Scale(scale);
+#elif WPF
protected override System.Windows.Rect GetBoundingRectangleCore()
{
- System.Windows.Point left = this.fooTextBox.PointToScreen(new System.Windows.Point(0, 0));
- System.Windows.Point bottom = this.fooTextBox.PointToScreen(new System.Windows.Point(this.fooTextBox.ActualWidth, this.fooTextBox.ActualHeight));
- return new System.Windows.Rect(left, bottom);
- }
+ Point left = Util.GetScreentPoint(new Point(0, 0), this.fooTextBox);
+ Point bottom = Util.GetScreentPoint(new Point(this.fooTextBox.ActualWidth, this.fooTextBox.ActualHeight), this.fooTextBox);
#endif
+ return new Rectangle(left,bottom);
+ }
- #region Implementation for ITextPattern interface
+ #region Implementation for ITextPattern and ITextPattern2 interface
// Complete implementation of the ITextPattern is beyond the scope of this sample. The implementation provided
// is specific to this sample's custom control, so it is unlikely that they are directly transferable to other
// custom control.
- ITextRangeProvider ITextProvider.DocumentRange
+ public ITextRangeProvider DocumentRange
{
// A real implementation of this method is beyond the scope of this sample.
// If your custom control has complex text involving both readonly and non-readonly ranges,
}
}
- ITextRangeProvider[] ITextProvider.GetSelection()
+ public ITextRangeProvider[] GetSelection()
{
ITextRangeProvider[] ret = new ITextRangeProvider[1];
int selStart = this.fooTextBox.Selection.Index;
return ret;
}
- ITextRangeProvider[] ITextProvider.GetVisibleRanges()
+ public ITextRangeProvider[] GetVisibleRanges()
{
ITextRangeProvider[] ret = new ITextRangeProvider[1];
if (this.fooTextBox.LayoutLineCollection.Count == 0)
}
else
{
-#if METRO || WINDOWS_UWP
- int startIndex = this.fooTextBox.GetIndexFromPostion(new Windows.Foundation.Point(0,0));
- int endIndex = this.fooTextBox.GetIndexFromPostion(new Windows.Foundation.Point(this.fooTextBox.ActualWidth, this.fooTextBox.ActualHeight));
-#endif
-#if WPF
- int startIndex = this.fooTextBox.GetIndexFromPostion(new System.Windows.Point(0, 0));
- int endIndex = this.fooTextBox.GetIndexFromPostion(new System.Windows.Point(this.fooTextBox.ActualWidth, this.fooTextBox.ActualHeight));
-#endif
+ EditView view = this.fooTextBox.View;
+
+ int startIndex = view.GetIndexFromLayoutLine(new TextPoint(view.Src.Row,0));
+ int endIndex = view.GetIndexFromLayoutLine(new TextPoint(view.Src.Row + view.LineCountOnScreen, 0));
ret[0] = new FooTextBoxRangeProvider(this.fooTextBox, startIndex, endIndex - startIndex, this);
}
return ret;
}
- ITextRangeProvider ITextProvider.RangeFromChild(IRawElementProviderSimple childElement)
+ public ITextRangeProvider RangeFromChild(IRawElementProviderSimple childElement)
{
return new FooTextBoxRangeProvider(this.fooTextBox,0,0, this);
}
#if METRO || WINDOWS_UWP
- ITextRangeProvider ITextProvider.RangeFromPoint(Windows.Foundation.Point screenLocation)
+ public ITextRangeProvider RangeFromPoint(Windows.Foundation.Point screenLocation)
+#elif WPF
+ public ITextRangeProvider RangeFromPoint(System.Windows.Point screenLocation)
+#endif
{
- Point pt = Util.GetClientPoint(screenLocation, this.fooTextBox);
+ Point pt = Util.GetClientPoint(screenLocation, fooTextBox);
+ EditView view = this.fooTextBox.View;
- int index = this.fooTextBox.GetIndexFromPostion(pt);
+ int index = view.GetIndexFromLayoutLine(view.GetTextPointFromPostion(pt));
int length = 1;
if (index == this.fooTextBox.Document.Length)
length = 0;
-
+
return new FooTextBoxRangeProvider(this.fooTextBox, index, length, this);
}
-#endif
-#if WPF
- ITextRangeProvider ITextProvider.RangeFromPoint(System.Windows.Point screenLocation)
+
+ public SupportedTextSelection SupportedTextSelection
{
- System.Windows.Point pt = this.fooTextBox.PointFromScreen(screenLocation);
+ get { return SupportedTextSelection.Single; }
+ }
- int index = this.fooTextBox.GetIndexFromPostion(pt);
+ public ITextRangeProvider RangeFromAnnotation(IRawElementProviderSimple annotationElement)
+ {
+ throw new NotImplementedException();
+ }
+
+ public ITextRangeProvider GetCaretRange(out bool isActive)
+ {
+
+ EditView view = this.fooTextBox.View;
+ Document doc = this.fooTextBox.Document;
+ isActive = true;
+ int index = view.GetIndexFromLayoutLine(doc.CaretPostion);
int length = 1;
if (index == this.fooTextBox.Document.Length)
length = 0;
return new FooTextBoxRangeProvider(this.fooTextBox, index, length, this);
}
-#endif
-
- SupportedTextSelection ITextProvider.SupportedTextSelection
- {
- get { return SupportedTextSelection.Single; }
- }
+ #endregion
- #endregion
-
- #region Implementation for IValueProvider interface
+ #region Implementation for IValueProvider interface
// Complete implementation of the IValueProvider is beyond the scope of this sample. The implementation provided
// is specific to this sample's custom control, so it is unlikely that they are directly transferable to other
// custom control.
/// The value needs to be false for the Touch keyboard to be launched automatically because Touch keyboard
/// does not appear when the input focus is in a readonly UI control.
/// </summary>
- bool IValueProvider.IsReadOnly
+ public bool IsReadOnly
{
get { return false; }
}
- void IValueProvider.SetValue(string value)
+ public void SetValue(string value)
{
string oldText = this.fooTextBox.Document.ToString(0);
this.fooTextBox.Document.Replace(0,this.fooTextBox.Document.Length,value);
this.RaisePropertyChangedEvent(ValuePatternIdentifiers.ValueProperty, oldText, this.fooTextBox.Document.ToString(0));
}
- string IValueProvider.Value
+ public string Value
{
get
{
{
return ProviderFromPeer(this);
}
+
}
#endif
using System.Windows.Automation.Peers;
using System.Windows.Automation.Provider;
using System.Windows.Automation.Text;
+using FooEditEngine;
using FooEditEngine.WPF;
#endif
Document doc = this.textbox.Document;
if (unit == TextUnit.Character)
{
+ this.end = this.start + 1;
+ if (this.end > doc.Length)
+ this.end = this.start;
return;
}
if (unit == TextUnit.Format || unit == TextUnit.Word)
return dpi / 96.0;
}
+ public static Point GetClientPoint(Point screen, System.Windows.FrameworkElement element)
+ {
+ return element.PointFromScreen(screen);
+ }
+
+ public static Point GetScreentPoint(Point client, System.Windows.FrameworkElement element)
+ {
+ return element.PointFromScreen(client);
+ }
+
public static IEnumerable<char> GetEnumrator(string s)
{
return s;
/// </summary>
public sealed class FooTextBox : Control,IDisposable
{
- EditView View;
+ EditView _View;
Controller _Controller;
#if !DUMMY_RENDER
D2DRender Render;
this.Document = new Document();
- this.View = new EditView(this.Document, this.Render, new Padding(5, 5, Gripper.HitAreaWidth / 2, Gripper.HitAreaWidth));
- this.View.SrcChanged += View_SrcChanged;
- this.View.InsertMode = this.InsertMode;
+ this._View = new EditView(this.Document, this.Render, new Padding(5, 5, Gripper.HitAreaWidth / 2, Gripper.HitAreaWidth));
+ this._View.SrcChanged += View_SrcChanged;
+ this._View.InsertMode = this.InsertMode;
this.Document.DrawLineNumber = this.DrawLineNumber;
- this.View.HideCaret = !this.DrawCaret;
- this.View.HideLineMarker = !this.DrawCaretLine;
+ this._View.HideCaret = !this.DrawCaret;
+ this._View.HideLineMarker = !this.DrawCaretLine;
this.Document.HideRuler = !this.DrawRuler;
this.Document.UrlMark = this.MarkURL;
this.Document.TabStops = this.TabChars;
- this._Controller = new Controller(this.Document, this.View);
+ this._Controller = new Controller(this.Document, this._View);
this.gestureRecongnizer.GestureSettings = GestureSettings.Drag |
GestureSettings.RightTap |
return;
if (disposing)
{
- this.View.Dispose();
+ this._View.Dispose();
this.Render.Dispose();
}
}
{
if (this.Document.FireUpdateEvent == false)
throw new InvalidOperationException("");
- return this.View.GetPostionFromTextPoint(tp);
+ return this._View.GetPostionFromTextPoint(tp);
}
/// <summary>
{
if (this.Document.FireUpdateEvent == false)
throw new InvalidOperationException("");
- return this.View.GetTextPointFromPostion(p);
+ return this._View.GetTextPointFromPostion(p);
}
/// <summary>
{
if (this.Document.FireUpdateEvent == false)
throw new InvalidOperationException("");
- return this.View.LayoutLines.GetLayout(row).Height; ;
+ return this._View.LayoutLines.GetLayout(row).Height; ;
}
/// <summary>
{
if (this.Document.FireUpdateEvent == false)
throw new InvalidOperationException("");
- TextPoint tp = this.View.GetLayoutLineFromIndex(index);
- return this.View.GetPostionFromTextPoint(tp);
+ TextPoint tp = this._View.GetLayoutLineFromIndex(index);
+ return this._View.GetPostionFromTextPoint(tp);
}
/// <summary>
{
if (this.Document.FireUpdateEvent == false)
throw new InvalidOperationException("");
- TextPoint tp = this.View.GetTextPointFromPostion(p);
- return this.View.GetIndexFromLayoutLine(tp);
+ TextPoint tp = this._View.GetTextPointFromPostion(p);
+ return this._View.GetIndexFromLayoutLine(tp);
}
public void Refresh(bool immidately=true)
{
if(immidately)
- this.Refresh(this.View.PageBound);
+ this.Refresh(this._View.PageBound);
else
this.Document.RequestRedraw();
}
/// <param name="alignTop">指定行を画面上に置くなら真。そうでないなら偽</param>
public void ScrollIntoView(int row, bool alignTop)
{
- this.View.ScrollIntoView(row, alignTop);
+ this._View.ScrollIntoView(row, alignTop);
}
/// <summary>
this.textEditContext.NotifyTextChanged(modified_range, this.Document.Length, modified_range);
if (this.verticalScrollBar != null)
- this.verticalScrollBar.Maximum = this.View.LayoutLines.Count;
+ this.verticalScrollBar.Maximum = this._View.LayoutLines.Count;
this.IsEnabled = true;
this.Refresh(false);
}
{
this.verticalScrollBar.SmallChange = 1;
this.verticalScrollBar.LargeChange = 10;
- this.verticalScrollBar.Maximum = this.View.LayoutLines.Count;
+ this.verticalScrollBar.Maximum = this._View.LayoutLines.Count;
this.verticalScrollBar.Scroll += new ScrollEventHandler(verticalScrollBar_Scroll);
}
}
System.Diagnostics.Debug.WriteLine("got focus");
- this.View.IsFocused = true;
+ this._View.IsFocused = true;
this.timer.Interval = new TimeSpan(0, 0, 0, 0, Interval);
this.Refresh(false);
}
System.Diagnostics.Debug.WriteLine("lost focus");
- this.View.IsFocused = false;
+ this._View.IsFocused = false;
this.Refresh(false);
this.timer.Interval = new TimeSpan(0, 0, 0, 0, IntervalWhenLostFocus);
}
isMovedCaret = true;
break;
case VirtualKey.PageUp:
- this._Controller.Scroll(ScrollDirection.Up, this.View.LineCountOnScreen, isShiftPressed, true);
+ this._Controller.Scroll(ScrollDirection.Up, this._View.LineCountOnScreen, isShiftPressed, true);
this.Refresh();
isMovedCaret = true;
break;
case VirtualKey.PageDown:
- this._Controller.Scroll(ScrollDirection.Down, this.View.LineCountOnScreen, isShiftPressed, true);
+ this._Controller.Scroll(ScrollDirection.Down, this._View.LineCountOnScreen, isShiftPressed, true);
this.Refresh();
isMovedCaret = true;
break;
e.Handled = true;
break;
case VirtualKey.Insert:
- if(this.View.InsertMode)
- this.View.InsertMode = false;
+ if(this._View.InsertMode)
+ this._View.InsertMode = false;
else
- this.View.InsertMode = true;
+ this._View.InsertMode = true;
this.Refresh();
e.Handled = true;
break;
e.Handled = true;
break;
}
-#if ENABLE_AUTMATION
- if (isMovedCaret && this.peer != null)
- this.peer.OnNotifyCaretChanged();
-#endif
base.OnKeyDown(e);
}
if (e.Pointer.PointerDeviceType == PointerDeviceType.Mouse)
{
Point p = e.GetCurrentPoint(this).Position;
- if (this.View.HitTextArea(p.X, p.Y))
+ if (this._View.HitTextArea(p.X, p.Y))
{
- TextPoint tp = this.View.GetTextPointFromPostion(p);
+ TextPoint tp = this._View.GetTextPointFromPostion(p);
if (this._Controller.IsMarker(tp, HilightType.Url))
Window.Current.CoreWindow.PointerCursor = new CoreCursor(CoreCursorType.Hand, 101);
else
if (args.Reason == CoreTextFormatUpdatingReason.CompositionTargetConverted)
{
- this.View.AdjustSrc(args.Range.StartCaretPosition);
+ this._View.AdjustSrc(args.Range.StartCaretPosition);
}
this.Refresh();
if (i_startIndex != -1 && i_endIndex != -1)
{
- TextStoreHelper.GetStringExtent(this.Document, this.View, i_startIndex, i_endIndex, out startPos, out endPos);
+ TextStoreHelper.GetStringExtent(this.Document, this._View, i_startIndex, i_endIndex, out startPos, out endPos);
double scale = Util.GetScale();
return;
}
TextRange currentSelection = new TextRange();
- TextStoreHelper.GetSelection(this._Controller, this.View.Selections, out currentSelection);
+ TextStoreHelper.GetSelection(this._Controller, this._View.Selections, out currentSelection);
CoreTextRange currentSelectionRange = new CoreTextRange();
currentSelectionRange.StartCaretPosition = currentSelection.Index;
}
CoreTextRange sel = args.Selection;
System.Diagnostics.Debug.WriteLine("update selection start:{0} end:{1}", sel.StartCaretPosition, sel.EndCaretPosition);
- TextStoreHelper.SetSelectionIndex(this.Controller, this.View, sel.StartCaretPosition, sel.EndCaretPosition);
+ TextStoreHelper.SetSelectionIndex(this.Controller, this._View, sel.StartCaretPosition, sel.EndCaretPosition);
args.Result = CoreTextSelectionUpdatingResult.Succeeded;
this.Refresh();
}
args.NewSelection.EndCaretPosition);
bool isTip = args.InputLanguage.Script == "Latan";
CoreTextRange sel = args.Range;
- TextStoreHelper.SetSelectionIndex(this.Controller, this.View, sel.StartCaretPosition, sel.EndCaretPosition);
+ TextStoreHelper.SetSelectionIndex(this.Controller, this._View, sel.StartCaretPosition, sel.EndCaretPosition);
TextStoreHelper.InsertTextAtSelection(this._Controller, args.Text, isTip);
this.Refresh();
args.Result = CoreTextTextUpdatingResult.Succeeded;
//こうしないと選択できなくなってしまう
this.nowCaretMove = true;
SetValue(SelectedTextProperty, this._Controller.SelectedText);
+ SetValue(SelectionProperty, new TextRange(this._Controller.SelectionStart, this._Controller.SelectionLength));
SetValue(CaretPostionPropertyKey, this.Document.CaretPostion);
this.nowCaretMove = false;
if(!this.nowCompstion)
{
TextRange currentSelection = new TextRange();
- TextStoreHelper.GetSelection(this._Controller, this.View.Selections, out currentSelection);
+ TextStoreHelper.GetSelection(this._Controller, this._View.Selections, out currentSelection);
CoreTextRange currentSelectionRange = new CoreTextRange();
currentSelectionRange.StartCaretPosition = currentSelection.Index;
if (this.textEditContext != null)
this.textEditContext.NotifySelectionChanged(currentSelectionRange);
}
+#if ENABLE_AUTMATION
+ if (this.peer != null)
+ this.peer.OnNotifyCaretChanged();
+#endif
}
Gripper hittedGripper;
void gestureRecongnizer_ManipulationStarted(GestureRecognizer sender, ManipulationStartedEventArgs e)
{
//Updateedの段階でヒットテストしてしまうとグリッパーを触ってもヒットしないことがある
- this.hittedGripper = this.View.HitGripperFromPoint(e.Position);
+ this.hittedGripper = this._View.HitGripperFromPoint(e.Position);
}
private void GestureRecongnizer_ManipulationInertiaStarting(GestureRecognizer sender, ManipulationInertiaStartingEventArgs args)
if (this._Controller.MoveCaretAndGripper(e.Position, this.hittedGripper))
{
-#if ENABLE_AUTMATION
- if (this.peer != null)
- this.peer.OnNotifyCaretChanged();
-#endif
this.Refresh();
return;
}
{
ResourceMap map = ResourceManager.Current.MainResourceMap.GetSubtree("FooEditEngine.UWP/Resources");
ResourceContext context = ResourceContext.GetForCurrentView();
- if (this.View.HitTextArea(e.Position.X, e.Position.Y))
+ if (this._View.HitTextArea(e.Position.X, e.Position.Y))
{
FooContextMenuEventArgs args = new FooContextMenuEventArgs(e.Position);
if (this.ContextMenuOpening != null)
void JumpCaret(Point p)
{
- TextPoint tp = this.View.GetTextPointFromPostion(p);
+ TextPoint tp = this._View.GetTextPointFromPostion(p);
if (tp == TextPoint.Null)
return;
- int index = this.View.LayoutLines.GetIndexFromTextPoint(tp);
+ int index = this._View.LayoutLines.GetIndexFromTextPoint(tp);
- FoldingItem foldingData = this.View.HitFoldingData(p.X, tp.row);
+ FoldingItem foldingData = this._View.HitFoldingData(p.X, tp.row);
if (foldingData != null)
{
if (foldingData.Expand)
- this.View.LayoutLines.FoldingCollection.Collapse(foldingData);
+ this._View.LayoutLines.FoldingCollection.Collapse(foldingData);
else
- this.View.LayoutLines.FoldingCollection.Expand(foldingData);
+ this._View.LayoutLines.FoldingCollection.Expand(foldingData);
this._Controller.JumpCaret(foldingData.Start, false);
}
else
{
this._Controller.JumpCaret(tp.row, tp.col, false);
}
-#if ENABLE_AUTMATION
- if (this.peer != null)
- this.peer.OnNotifyCaretChanged();
-#endif
- this.View.IsFocused = true;
+ this._View.IsFocused = true;
this.Focus(FocusState.Programmatic);
this.Refresh();
}
{
Point p = e.Position;
TextPointSearchRange searchRange;
- if (this.View.HitTextArea(p.X, p.Y))
+ if (this._View.HitTextArea(p.X, p.Y))
searchRange = TextPointSearchRange.TextAreaOnly;
else if (this._Controller.SelectionLength > 0)
searchRange = TextPointSearchRange.Full;
else
return;
- TextPoint tp = this.View.GetTextPointFromPostion(p, searchRange);
+ TextPoint tp = this._View.GetTextPointFromPostion(p, searchRange);
this._Controller.MoveCaretAndSelect(tp, this.IsModiferKeyPressed(VirtualKey.LeftControl));
-#if ENABLE_AUTMATION
- if (this.peer != null)
- this.peer.OnNotifyCaretChanged();
-#endif
this.Refresh();
}
if (this.rectangle.ActualWidth == 0 || this.rectangle.ActualHeight == 0 || this.Visibility == Windows.UI.Xaml.Visibility.Collapsed)
return;
- this.Render.DrawContent(this.View, this.IsEnabled, updateRect);
+ this.Render.DrawContent(this._View, this.IsEnabled, updateRect);
this.Document.IsRequestRedraw = false;
}
throw new ArgumentOutOfRangeException();
if (this.Render.Resize(this.rectangle, width, height))
{
- this.View.PageBound = new Rectangle(0, 0, width, height);
+ this._View.PageBound = new Rectangle(0, 0, width, height);
if (this.horizontalScrollBar != null)
{
- this.horizontalScrollBar.LargeChange = this.View.PageBound.Width;
- this.horizontalScrollBar.Maximum = this.View.LongestWidth + this.horizontalScrollBar.LargeChange + 1;
+ this.horizontalScrollBar.LargeChange = this._View.PageBound.Width;
+ this.horizontalScrollBar.Maximum = this._View.LongestWidth + this.horizontalScrollBar.LargeChange + 1;
}
if (this.verticalScrollBar != null)
{
- this.verticalScrollBar.LargeChange = this.View.LineCountOnScreen;
- this.verticalScrollBar.Maximum = this.View.LayoutLines.Count + this.verticalScrollBar.LargeChange + 1;
+ this.verticalScrollBar.LargeChange = this._View.LineCountOnScreen;
+ this.verticalScrollBar.Maximum = this._View.LayoutLines.Count + this.verticalScrollBar.LargeChange + 1;
}
return true;
}
{
if (this.horizontalScrollBar == null || this.verticalScrollBar == null)
return;
- EditView view = this.View;
+ EditView view = this._View;
if (view.Src.Row > this.verticalScrollBar.Maximum)
this.verticalScrollBar.Maximum = view.Src.Row + view.LineCountOnScreen + 1;
double absoulteX = Math.Abs(view.Src.X);
toX = this.horizontalScrollBar.Value;
else
toX = -this.horizontalScrollBar.Value;
- this._Controller.Scroll(toX, this.View.Src.Row, false, false);
+ this._Controller.Scroll(toX, this._View.Src.Row, false, false);
this.Refresh();
}
if (this.verticalScrollBar == null)
return;
int newRow = (int)this.verticalScrollBar.Value;
- if (newRow >= this.View.LayoutLines.Count)
+ if (newRow >= this._View.LayoutLines.Count)
return;
- this._Controller.Scroll(this.View.Src.X, newRow, false, false);
+ this._Controller.Scroll(this._View.Src.X, newRow, false, false);
this.Refresh();
}
oldTextRange.EndCaretPosition += e.removeLength;
TextRange currentSelection = new TextRange();
- TextStoreHelper.GetSelection(this._Controller, this.View.Selections, out currentSelection);
+ TextStoreHelper.GetSelection(this._Controller, this._View.Selections, out currentSelection);
CoreTextRange newSelection = new CoreTextRange();
newSelection.StartCaretPosition = e.startIndex;
if (this.Resize(this.rectangle.ActualWidth, this.rectangle.ActualHeight))
{
//普通に再描写するとちらつく
- this.Refresh(this.View.PageBound);
+ this.Refresh(this._View.PageBound);
}
this.requestSizeChange = false;
}
- else if (this.View.LayoutLines.HilightAll() || this.View.LayoutLines.GenerateFolding() || this.Document.IsRequestRedraw)
+ else if (this._View.LayoutLines.HilightAll() || this._View.LayoutLines.GenerateFolding() || this.Document.IsRequestRedraw)
{
- this.Refresh(this.View.PageBound);
+ this.Refresh(this._View.PageBound);
}
this.timer.Start();
}
if (this._Document.AutoComplete != null && this._Document.AutoComplete.GetPostion == null)
this._Document_AutoCompleteChanged(this._Document, null);
//初期化が終わっていればすべて存在する
- if (this.Controller != null && this.View != null)
+ if (this.Controller != null && this._View != null)
{
this.Controller.Document = value;
- this.View.Document = value;
+ this._View.Document = value;
this.Controller.AdjustCaret();
Document doc = (Document)sender;
doc.AutoComplete.GetPostion = (tp, e_doc) =>
{
- var p = this.View.GetPostionFromTextPoint(tp);
+ var p = this._View.GetPostionFromTextPoint(tp);
int height = (int)e_doc.LayoutLines.GetLayout(e_doc.CaretPostion.row).Height;
if (p.Y + AutoCompleteBox.CompleteListBoxHeight + height > e_doc.LayoutLines.Render.TextArea.Height)
if (e.Property.Equals(DocumentProperty))
source.SetDocument(source.Document);
if(e.Property.Equals(HilighterProperty))
- source.View.Hilighter = source.Hilighter;
+ source._View.Hilighter = source.Hilighter;
if (e.Property.Equals(FoldingStrategyProperty))
- source.View.LayoutLines.FoldingStrategy = source.FoldingStrategy;
+ source._View.LayoutLines.FoldingStrategy = source.FoldingStrategy;
if (e.Property.Equals(IndentModeProperty))
source.Controller.IndentMode = source.IndentMode;
if (e.Property.Equals(SelectionProperty) && !source.nowCaretMove)
if (e.Property.Equals(CaretPostionPropertyKey) && !source.nowCaretMove)
source.JumpCaret(source.CaretPostion.row, source.CaretPostion.col);
if (e.Property.Equals(InsertModeProperty))
- source.View.InsertMode = source.InsertMode;
+ source._View.InsertMode = source.InsertMode;
if (e.Property.Equals(TabCharsProperty))
source.Document.TabStops = source.TabChars;
if (e.Property.Equals(RectSelectModeProperty))
source._Controller.RectSelection = source.RectSelectMode;
if (e.Property.Equals(DrawCaretProperty))
- source.View.HideCaret = !source.DrawCaret;
+ source._View.HideCaret = !source.DrawCaret;
if (e.Property.Equals(DrawCaretLineProperty))
- source.View.HideLineMarker = !source.DrawCaretLine;
+ source._View.HideLineMarker = !source.DrawCaretLine;
if (e.Property.Equals(DrawLineNumberProperty))
source.Document.DrawLineNumber = source.DrawLineNumber;
if (e.Property.Equals(MarkURLProperty))
if (e.Property.Equals(OverwriteCaretProperty))
source.Render.OverwriteCaret = D2DRenderBase.ToColor4(source.OverwriteCaret);
if (e.Property.Equals(PaddingProperty))
- source.View.Padding = new Padding((int)source.Padding.Left, (int)source.Padding.Top, (int)source.Padding.Right, (int)source.Padding.Bottom);
+ source._View.Padding = new Padding((int)source.Padding.Left, (int)source.Padding.Top, (int)source.Padding.Right, (int)source.Padding.Bottom);
if (e.Property.Equals(LineMarkerProperty))
source.Render.LineMarker = D2DRenderBase.ToColor4(source.LineMarker);
if (e.Property.Equals(ShowFullSpaceProperty))
}
}
+ internal EditView View
+ {
+ get
+ {
+ return this._View;
+ }
+ }
+
/// <summary>
/// 文字列の描写に使用されるアンチエイリアシング モードを表します
/// </summary>
/// </summary>
public LineToIndexTable LayoutLineCollection
{
- get { return this.View.LayoutLines; }
+ get { return this._View.LayoutLines; }
}
/// <summary>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
- <DefineConstants>TRACE;DEBUG;WPF,ENABLE_AUTMATION</DefineConstants>
+ <DefineConstants>TRACE;DEBUG;WPF;ENABLE_AUTMATION</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<DocumentationFile>bin\Debug\FooEditEngine.WPF.XML</DocumentationFile>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
- <DefineConstants>TRACE;WPF,ENABLE_AUTMATION</DefineConstants>
+ <DefineConstants>TRACE;WPF;ENABLE_AUTMATION</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
const double MaxFontSize = 72.0f;
const double MinFontSize = 1;
- EditView View;
+ EditView _View;
Controller _Controller;
D2DRender Render;
Image image;
this.Document = new Document();
- this.View = new EditView(this.Document, this.Render, new Padding(5, 5, 5, 5));
- this.View.SrcChanged += View_SrcChanged;
- this.View.InsertMode = this.InsertMode;
+ this._View = new EditView(this.Document, this.Render, new Padding(5, 5, 5, 5));
+ this._View.SrcChanged += View_SrcChanged;
+ this._View.InsertMode = this.InsertMode;
this.Document.DrawLineNumber = this.DrawLineNumber;
- this.View.HideCaret = !this.DrawCaret;
- this.View.HideLineMarker = !this.DrawCaretLine;
+ this._View.HideCaret = !this.DrawCaret;
+ this._View.HideLineMarker = !this.DrawCaretLine;
this.Document.HideRuler = !this.DrawRuler;
this.Document.UrlMark = this.MarkURL;
this.Document.TabStops = this.TabChars;
this.Document.ShowHalfSpace = this.ShowHalfSpace;
this.Document.ShowTab = this.ShowTab;
- this._Controller = new Controller(this.Document, this.View);
+ this._Controller = new Controller(this.Document, this._View);
this._Document.SelectionChanged += new EventHandler(Controller_SelectionChanged);
this.CommandBindings.Add(new CommandBinding(ApplicationCommands.Copy, CopyCommand, CanExecute));
{
if (this.Document.FireUpdateEvent == false)
throw new InvalidOperationException("");
- return this.image.TranslatePoint(this.View.GetPostionFromTextPoint(tp),this);
+ return this.image.TranslatePoint(this._View.GetPostionFromTextPoint(tp),this);
}
/// <summary>
if (this.Document.FireUpdateEvent == false)
throw new InvalidOperationException("");
System.Windows.Point relP = this.TranslatePoint(p, this.image);
- return this.View.GetTextPointFromPostion(p);
+ return this._View.GetTextPointFromPostion(p);
}
/// <summary>
{
if (this.Document.FireUpdateEvent == false)
throw new InvalidOperationException("");
- return this.View.LayoutLines.GetLayout(row).Height;;
+ return this._View.LayoutLines.GetLayout(row).Height;;
}
/// <summary>
{
if (this.Document.FireUpdateEvent == false)
throw new InvalidOperationException("");
- TextPoint tp = this.View.GetLayoutLineFromIndex(index);
- return this.View.GetPostionFromTextPoint(tp);
+ TextPoint tp = this._View.GetLayoutLineFromIndex(index);
+ return this._View.GetPostionFromTextPoint(tp);
}
/// <summary>
{
if (this.Document.FireUpdateEvent == false)
throw new InvalidOperationException("");
- TextPoint tp = this.View.GetTextPointFromPostion(p);
- return this.View.GetIndexFromLayoutLine(tp);
+ TextPoint tp = this._View.GetTextPointFromPostion(p);
+ return this._View.GetIndexFromLayoutLine(tp);
}
/// <summary>
/// </summary>
public void Refresh()
{
- this.Refresh(this.View.PageBound);
+ this.Refresh(this._View.PageBound);
}
/// <summary>
/// </summary>
public void PerfomLayouts()
{
- this.View.PerfomLayouts();
+ this._View.PerfomLayouts();
}
/// <summary>
/// <param name="alignTop">指定行を画面上に置くなら真。そうでないなら偽</param>
public void ScrollIntoView(int row, bool alignTop)
{
- this.View.ScrollIntoView(row, alignTop);
+ this._View.ScrollIntoView(row, alignTop);
}
/// <summary>
{
TextStoreHelper.NotifyTextChanged(this.textStore, 0, 0, this.Document.Length);
if (this.verticalScrollBar != null)
- this.verticalScrollBar.Maximum = this.View.LayoutLines.Count;
- this.View.CalculateWhloeViewPort();
- this.View.CalculateLineCountOnScreen();
+ this.verticalScrollBar.Maximum = this._View.LayoutLines.Count;
+ this._View.CalculateWhloeViewPort();
+ this._View.CalculateLineCountOnScreen();
this.IsEnabled = true;
- this.Refresh(this.View.PageBound);
+ this.Refresh(this._View.PageBound);
}
}
{
this.textStore.Dispose();
this.timer.Stop();
- this.View.Dispose();
+ this._View.Dispose();
this.Render.Dispose();
}
SystemEvents.UserPreferenceChanged -= new UserPreferenceChangedEventHandler(SystemEvents_UserPreferenceChanged);
if (this.disposed || this.Visibility == Visibility.Collapsed)
return;
- this.Render.DrawContent(this.View, this.IsEnabled, updateRect);
+ this.Render.DrawContent(this._View, this.IsEnabled, updateRect);
this.Document.IsRequestRedraw = false;
}
void textStore_CompositionUpdated(int start, int end)
{
- if (TextStoreHelper.ScrollToCompstionUpdated(this.textStore, this.View, start, end))
+ if (TextStoreHelper.ScrollToCompstionUpdated(this.textStore, this._View, start, end))
this.Refresh();
}
bool textStore_CompositionStarted()
)
{
Point startPos, endPos;
- TextStoreHelper.GetStringExtent(this.Document, this.View, i_startIndex, i_endIndex, out startPos, out endPos);
+ TextStoreHelper.GetStringExtent(this.Document, this._View, i_startIndex, i_endIndex, out startPos, out endPos);
double scale = this.Render.GetScale();
void _textStore_GetSelectionIndex(int start_index, int max_count, out DotNetTextStore.TextSelection[] sels)
{
TextRange selRange;
- TextStoreHelper.GetSelection(this._Controller, this.View.Selections, out selRange);
+ TextStoreHelper.GetSelection(this._Controller, this._View.Selections, out selRange);
sels = new DotNetTextStore.TextSelection[1];
sels[0] = new DotNetTextStore.TextSelection();
void _textStore_SetSelectionIndex(DotNetTextStore.TextSelection[] sels)
{
- TextStoreHelper.SetSelectionIndex(this._Controller, this.View, sels[0].start, sels[0].end);
+ TextStoreHelper.SetSelectionIndex(this._Controller, this._View, sels[0].start, sels[0].end);
this.Refresh();
}
{
base.OnGotKeyboardFocus(e);
this.textStore.SetFocus();
- this.View.IsFocused = true;
+ this._View.IsFocused = true;
this.timer.Interval = new TimeSpan(0,0,0,0,Interval);
this.Refresh();
}
protected override void OnLostKeyboardFocus(KeyboardFocusChangedEventArgs e)
{
base.OnLostKeyboardFocus(e);
- this.View.IsFocused = false;
+ this._View.IsFocused = false;
this.timer.Interval = new TimeSpan(0, 0, 0, 0, IntervalWhenLostFocuse);
this.Refresh();
}
movedCaret = true;
break;
case Key.PageUp:
- this._Controller.Scroll(ScrollDirection.Up,this.View.LineCountOnScreen, this.IsPressedModifierKey(modiferKeys, ModifierKeys.Shift),true);
+ this._Controller.Scroll(ScrollDirection.Up,this._View.LineCountOnScreen, this.IsPressedModifierKey(modiferKeys, ModifierKeys.Shift),true);
this.Refresh();
movedCaret = true;
break;
case Key.PageDown:
- this._Controller.Scroll(ScrollDirection.Down,this.View.LineCountOnScreen, this.IsPressedModifierKey(modiferKeys, ModifierKeys.Shift),true);
+ this._Controller.Scroll(ScrollDirection.Down,this._View.LineCountOnScreen, this.IsPressedModifierKey(modiferKeys, ModifierKeys.Shift),true);
this.Refresh();
movedCaret = true;
break;
protected override void OnMouseDoubleClick(MouseButtonEventArgs e)
{
var p = this.GetDipFromPoint(e.GetPosition(this));
- TextPoint tp = this.View.GetTextPointFromPostion(p);
+ TextPoint tp = this._View.GetTextPointFromPostion(p);
if (tp == TextPoint.Null)
return;
- int index = this.View.LayoutLines.GetIndexFromTextPoint(tp);
+ int index = this._View.LayoutLines.GetIndexFromTextPoint(tp);
FooMouseButtonEventArgs newEventArgs = new FooMouseButtonEventArgs(e.MouseDevice,
e.Timestamp,
this.CaptureMouse();
var p = this.GetDipFromPoint(e.GetPosition(this));
- TextPoint tp = this.View.GetTextPointFromPostion(p);
+ TextPoint tp = this._View.GetTextPointFromPostion(p);
if (tp == TextPoint.Null)
return;
- int index = this.View.LayoutLines.GetIndexFromTextPoint(tp);
+ int index = this._View.LayoutLines.GetIndexFromTextPoint(tp);
FooMouseButtonEventArgs newEventArgs = new FooMouseButtonEventArgs(e.MouseDevice,
e.Timestamp,
if (e.LeftButton == MouseButtonState.Pressed)
{
- FoldingItem foldingData = this.View.HitFoldingData(p.X,tp.row);
+ FoldingItem foldingData = this._View.HitFoldingData(p.X,tp.row);
if (foldingData != null)
{
if (foldingData.Expand)
- this.View.LayoutLines.FoldingCollection.Collapse(foldingData);
+ this._View.LayoutLines.FoldingCollection.Collapse(foldingData);
else
- this.View.LayoutLines.FoldingCollection.Expand(foldingData);
+ this._View.LayoutLines.FoldingCollection.Expand(foldingData);
this._Controller.JumpCaret(foldingData.Start,false);
}
else
}
if (this.peer != null)
this.peer.OnNotifyCaretChanged();
- this.View.IsFocused = true;
+ this._View.IsFocused = true;
this.Focus();
this.Document.SelectGrippers.BottomLeft.Enabled = false;
this.Document.SelectGrippers.BottomRight.Enabled = false;
var p = this.GetDipFromPoint(e.GetPosition(this));
TextPointSearchRange searchRange;
- if (this.View.HitTextArea(p.X, p.Y))
+ if (this._View.HitTextArea(p.X, p.Y))
{
searchRange = TextPointSearchRange.TextAreaOnly;
}
return;
}
- TextPoint tp = this.View.GetTextPointFromPostion(p, searchRange);
+ TextPoint tp = this._View.GetTextPointFromPostion(p, searchRange);
if (tp == TextPoint.Null)
{
return;
}
- int index = this.View.GetIndexFromLayoutLine(tp);
+ int index = this._View.GetIndexFromLayoutLine(tp);
FooMouseEventArgs newEventArgs = new FooMouseEventArgs(e.MouseDevice, e.Timestamp, e.StylusDevice, index);
newEventArgs.RoutedEvent = e.RoutedEvent;
protected override void OnTouchDown(TouchEventArgs e)
{
var p = this.GetDipFromPoint(e.GetTouchPoint(this).Position);
- this.hittedGripper = this.View.HitGripperFromPoint(p);
+ this.hittedGripper = this._View.HitGripperFromPoint(p);
this.CaptureTouch(e.TouchDevice);
}
}
var p = this.GetDipFromPoint(e.GetTouchPoint(this).Position);
- TextPoint tp = this.View.GetTextPointFromPostion(p);
+ TextPoint tp = this._View.GetTextPointFromPostion(p);
if (tp == TextPoint.Null)
return;
- int index = this.View.LayoutLines.GetIndexFromTextPoint(tp);
+ int index = this._View.LayoutLines.GetIndexFromTextPoint(tp);
- FoldingItem foldingData = this.View.HitFoldingData(p.X, tp.row);
+ FoldingItem foldingData = this._View.HitFoldingData(p.X, tp.row);
if (foldingData != null)
{
if (foldingData.Expand)
- this.View.LayoutLines.FoldingCollection.Collapse(foldingData);
+ this._View.LayoutLines.FoldingCollection.Collapse(foldingData);
else
- this.View.LayoutLines.FoldingCollection.Expand(foldingData);
+ this._View.LayoutLines.FoldingCollection.Expand(foldingData);
this._Controller.JumpCaret(foldingData.Start, false);
}
else
}
if (this.peer != null)
this.peer.OnNotifyCaretChanged();
- this.View.IsFocused = true;
+ this._View.IsFocused = true;
this.Focus();
this.Document.SelectGrippers.BottomLeft.Enabled = false;
this.Document.SelectGrippers.BottomRight.Enabled = true;
if (e.Category == UserPreferenceCategory.Keyboard)
{
int blinkTime = (int)NativeMethods.GetCaretBlinkTime();
- this.View.CaretBlink = blinkTime >= 0;
- this.View.CaretBlinkTime = blinkTime * 2;
+ this._View.CaretBlink = blinkTime >= 0;
+ this._View.CaretBlinkTime = blinkTime * 2;
}
if (e.Category == UserPreferenceCategory.General)
{
- this.View.CaretWidthOnInsertMode = SystemParameters.CaretWidth;
+ this._View.CaretWidthOnInsertMode = SystemParameters.CaretWidth;
}
}
return;
if (this.Resize(this.image.ActualWidth, this.image.ActualHeight))
{
- this.Refresh(this.View.PageBound);
+ this.Refresh(this._View.PageBound);
return;
}
- bool updateAll = this.View.LayoutLines.HilightAll() || this.View.LayoutLines.GenerateFolding() || this.Document.IsRequestRedraw;
+ bool updateAll = this._View.LayoutLines.HilightAll() || this._View.LayoutLines.GenerateFolding() || this.Document.IsRequestRedraw;
if (updateAll)
- this.Refresh(this.View.PageBound);
+ this.Refresh(this._View.PageBound);
else
- this.Refresh(this.View.GetCurrentCaretRect());
+ this.Refresh(this._View.GetCurrentCaretRect());
}
void horizontalScrollBar_Scroll(object sender, ScrollEventArgs e)
{
if (this.horizontalScrollBar == null || this.verticalScrollBar == null)
return;
- EditView view = this.View;
+ EditView view = this._View;
if (view.Src.Row > this.Document.LayoutLines.Count)
this.verticalScrollBar.Maximum = this.Document.LayoutLines.Count - 1;
double absoulteX = Math.Abs(view.Src.X);
void Controller_SelectionChanged(object sender, EventArgs e)
{
- this.View.CaretBlink = this.View.CaretBlink;
+ this._View.CaretBlink = this._View.CaretBlink;
this.CaretMoved(this, null);
//こうしないと選択できなくなってしまう
this.isNotifyChanged = true;
{
double scale = this.Render.GetScale();
// RenderはレタリングはDIPだが、widthとheightの値はDPI依存なのでDIPに変換する
- this.View.PageBound = new Rectangle(0, 0, width / scale, height / scale);
+ this._View.PageBound = new Rectangle(0, 0, width / scale, height / scale);
if (this.horizontalScrollBar != null)
{
- this.horizontalScrollBar.LargeChange = this.View.PageBound.Width;
- this.horizontalScrollBar.Maximum = this.View.LongestWidth + this.horizontalScrollBar.LargeChange + 1;
+ this.horizontalScrollBar.LargeChange = this._View.PageBound.Width;
+ this.horizontalScrollBar.Maximum = this._View.LongestWidth + this.horizontalScrollBar.LargeChange + 1;
}
if (this.verticalScrollBar != null)
{
- this.verticalScrollBar.LargeChange = this.View.LineCountOnScreen;
- this.verticalScrollBar.Maximum = this.View.LayoutLines.Count + this.verticalScrollBar.LargeChange + 1;
+ this.verticalScrollBar.LargeChange = this._View.LineCountOnScreen;
+ this.verticalScrollBar.Maximum = this._View.LayoutLines.Count + this.verticalScrollBar.LargeChange + 1;
}
return true;
}
if (this._Document.AutoComplete != null && this.Document.AutoComplete.GetPostion == null)
this._Document_AutoCompleteChanged(this.Document, null);
//初期化が終わっていればすべて存在する
- if (this.Controller != null && this.View != null && this.textStore != null)
+ if (this.Controller != null && this._View != null && this.textStore != null)
{
this._Document.SelectionChanged += new EventHandler(Controller_SelectionChanged);
this.Controller.Document = value;
- this.View.Document = value;
+ this._View.Document = value;
this.Controller.AdjustCaret();
this.textStore.NotifyTextChanged(oldLength, value.Length);
((AutoCompleteBox)this._Document.AutoComplete).TargetPopup = this.popup;
this._Document.AutoComplete.GetPostion = (tp, edoc) =>
{
- var p = this.View.GetPostionFromTextPoint(tp);
+ var p = this._View.GetPostionFromTextPoint(tp);
int height = (int)this.Render.emSize.Height;
p.Y += height;
return PointToScreen(this.TranslatePoint(p.Scale(Util.GetScale()), this));
this.SetDocument(this.Document);
break;
case "Hilighter":
- this.View.Hilighter = this.Hilighter;
+ this._View.Hilighter = this.Hilighter;
break;
case "TextAntialiasMode":
this.Render.TextAntialiasMode = this.TextAntialiasMode;
break;
case "FoldingStrategy":
- this.View.LayoutLines.FoldingStrategy = this.FoldingStrategy;
+ this._View.LayoutLines.FoldingStrategy = this.FoldingStrategy;
break;
case "SelectedText":
if (!this.isNotifyChanged)
this.Document.LineBreakCharCount = this.LineBreakCharCount;
break;
case "InsertMode":
- this.View.InsertMode = this.InsertMode;
+ this._View.InsertMode = this.InsertMode;
break;
case "TabChars":
this.Document.TabStops = this.TabChars;
this._Controller.RectSelection = this.RectSelectMode;
break;
case "DrawCaret":
- this.View.HideCaret = !this.DrawCaret;
+ this._View.HideCaret = !this.DrawCaret;
break;
case "DrawCaretLine":
- this.View.HideLineMarker = !this.DrawCaretLine;
+ this._View.HideLineMarker = !this.DrawCaretLine;
break;
case "DrawLineNumber":
this.Document.DrawLineNumber = this.DrawLineNumber;
this.Render.OverwriteCaret = D2DRender.ToColor4(this.OverwriteCaret);
break;
case "Padding":
- this.View.Padding = new Padding((int)this.Padding.Left, (int)this.Padding.Top, (int)this.Padding.Right, (int)this.Padding.Bottom);
+ this._View.Padding = new Padding((int)this.Padding.Left, (int)this.Padding.Top, (int)this.Padding.Right, (int)this.Padding.Bottom);
break;
case "LineMarker":
this.Render.LineMarker = D2DRender.ToColor4(this.LineMarker);
#endregion
#region property
+ internal EditView View
+ {
+ get
+ {
+ return this._View;
+ }
+ }
+
internal Controller Controller
{
get
/// </summary>
public LineToIndexTable LayoutLineCollection
{
- get { return this.View.LayoutLines; }
+ get { return this._View.LayoutLines; }
}
/// <summary>