this.textStore = new TextStore();\r
this.textStore.IsLoading += textStore_IsLoading;\r
this.textStore.IsReadOnly += textStore_IsReadOnly;\r
- this.textStore.GetDpi += textStore_GetDpi;\r
this.textStore.GetStringLength += () => this.Document.Length;\r
this.textStore.GetString += _textStore_GetString;\r
this.textStore.GetSelectionIndex += _textStore_GetSelectionIndex;\r
}\r
\r
/// <summary>\r
+ /// 指定行までスクロールする\r
+ /// </summary>\r
+ /// <param name="row">行</param>\r
+ /// <param name="alignTop">指定行を画面上に置くなら真。そうでないなら偽</param>\r
+ public void ScrollIntoView(int row, bool alignTop)\r
+ {\r
+ this.View.ScrollIntoView(row, alignTop);\r
+ }\r
+\r
+ /// <summary>\r
/// ストリームからドキュメントを構築する\r
/// </summary>\r
/// <param name="tr">TextReader</param>\r
{\r
WinFileReader fs = new WinFileReader(filepath, enc);\r
await this.LoadAsyncImpl(fs, token);\r
+ fs.Close();\r
}\r
\r
async Task LoadAsyncImpl(WinFileReader fs,System.Threading.CancellationTokenSource token)\r
WinFileWriter fs = new WinFileWriter(filepath, enc);\r
fs.NewLine = newLine;\r
await this.Document.SaveAsync(fs, token);\r
+ fs.Close();\r
}\r
\r
/// <summary>\r
\r
void Refresh(Rectangle updateRect)\r
{\r
- if (this.disposed)\r
+ if (this.disposed || this.Visibility == Visibility.Collapsed)\r
return;\r
\r
- this.timer.Stop();\r
-\r
this.Render.BegineDraw();\r
if (this.IsEnabled)\r
this.View.Draw(updateRect);\r
else\r
this.Render.FillBackground(updateRect);\r
this.Render.EndDraw();\r
-\r
- this.timer.Start();\r
}\r
\r
#region Commands\r
get { return this.textStore; }\r
}\r
\r
- double textStore_GetDpi()\r
- {\r
- float dpi;\r
- this.Render.GetDpi(out dpi, out dpi);\r
- return dpi;\r
- }\r
-\r
bool textStore_IsReadOnly()\r
{\r
return false;\r
Point startPos, endPos;\r
TextStoreHelper.GetStringExtent(this.Document, this.View, i_startIndex, i_endIndex, out startPos, out endPos);\r
\r
- startPos = PointToScreen(this.TranslatePoint(startPos, this));\r
- endPos = PointToScreen(this.TranslatePoint(endPos, this));\r
+ float dpi;\r
+ this.Render.GetDpi(out dpi, out dpi);\r
+ double scale = dpi / 96.0;\r
+ \r
+ startPos = PointToScreen(this.TranslatePoint(startPos.Scale(scale), this));\r
+ endPos = PointToScreen(this.TranslatePoint(endPos.Scale(scale), this));\r
\r
o_topLeft = new POINT((int)startPos.X, (int)startPos.Y);\r
o_bottomRight = new POINT((int)endPos.X, (int)endPos.Y);\r
this.Refresh();\r
}\r
\r
- void _textStore_InsertAtSelection(string i_value)\r
+ void _textStore_InsertAtSelection(string i_value, ref int o_startIndex, ref int o_endIndex)\r
{\r
TextStoreHelper.InsertTextAtSelection(this._Controller, i_value);\r
this.Refresh();\r
void FooTextBox_Loaded(object sender, RoutedEventArgs e)\r
{\r
this.Resize(this.image.ActualWidth, this.image.ActualHeight);\r
+ this.Focus();\r
+ this.timer.Start();\r
}\r
\r
bool Resize(double width, double height)\r
{\r
switch (e.Property.Name)\r
{\r
+ case "IndentMode":\r
+ this._Controller.IndentMode = this.IndentMode;\r
+ break;\r
case "Selection":\r
if(!this.nowCaretMove)\r
this.Select(this.Selection.Index, this.Selection.Length);\r
case "UpdateArea":\r
this.Render.UpdateArea = D2DRender.ToColor4(this.UpdateArea);\r
break;\r
+ case "LineNumber":\r
+ this.Render.LineNumber = D2DRender.ToColor4(this.LineNumber);\r
+ break;\r
}\r
base.OnPropertyChanged(e);\r
}\r
}\r
\r
/// <summary>\r
+ /// インデントの方法を表す\r
+ /// </summary>\r
+ public IndentMode IndentMode\r
+ {\r
+ get { return (IndentMode)GetValue(IndentModeProperty); }\r
+ set { SetValue(IndentModeProperty, value); }\r
+ }\r
+\r
+ /// <summary>\r
+ /// IndentModeの依存プロパティを表す\r
+ /// </summary>\r
+ public static readonly DependencyProperty IndentModeProperty =\r
+ DependencyProperty.Register("IndentMode", typeof(IndentMode), typeof(FooTextBox), new PropertyMetadata(IndentMode.Tab));\r
+\r
+ /// <summary>\r
/// 選択範囲を表す\r
/// </summary>\r
/// <remarks>\r
get { return (System.Windows.Media.Color)GetValue(OverwriteCaretProperty); }\r
set { SetValue(OverwriteCaretProperty, value); }\r
}\r
-\r
+ \r
/// <summary>\r
/// OverwriteCaretの依存プロパティを表す\r
/// </summary>\r
public static readonly DependencyProperty OverwriteCaretProperty =\r
DependencyProperty.Register("OverwriteCaret", typeof(System.Windows.Media.Color), typeof(FooTextBox), new FrameworkPropertyMetadata(SystemColors.WindowTextColor));\r
- \r
+\r
+ /// <summary>\r
+ /// 行番号の色を表す\r
+ /// </summary>\r
+ public System.Windows.Media.Color LineNumber\r
+ {\r
+ get { return (System.Windows.Media.Color)GetValue(LineNumberProperty); }\r
+ set { SetValue(LineNumberProperty, value); }\r
+ }\r
+\r
+ /// <summary>\r
+ /// Using a DependencyProperty as the backing store for LineNumber. This enables animation, styling, binding, etc...\r
+ /// </summary>\r
+ public static readonly DependencyProperty LineNumberProperty =\r
+ DependencyProperty.Register("LineNumber", typeof(System.Windows.Media.Color), typeof(FooTextBox), new PropertyMetadata(Colors.DimGray));\r
+\r
/// <summary>\r
/// 挿入モードなら真を返し、そうでないなら、偽を返す。これは依存プロパティです\r
/// </summary>\r