/// </summary>
public partial class MainWindow : Window
{
+ System.Threading.CancellationTokenSource cancleTokenSrc = new System.Threading.CancellationTokenSource();
public MainWindow()
{
InitializeComponent();
this.fooTextBox.MouseDoubleClick += new System.Windows.Input.MouseButtonEventHandler(fooTextBox_MouseDoubleClick);
this.fooTextBox.ShowTab = true;
this.fooTextBox.ShowFullSpace = true;
+ this.fooTextBox.ShowLineBreak = true;
this.fooTextBox.FoldingStrategy = new CharFoldingMethod('{', '}');
+ this.Enable.IsChecked = true;
+ this.URLMark.IsChecked = true;
+
this.Closed += MainWindow_Closed;
}
void MainWindow_Closed(object sender, System.EventArgs e)
{
- this.fooTextBox.Document.Cancel();
+ this.cancleTokenSrc.Cancel();
+ this.fooTextBox.Dispose();
}
void fooTextBox_MouseDoubleClick(object sender, System.Windows.Input.MouseButtonEventArgs e)
bool result = (bool)ofd.ShowDialog(this);
if (result == true)
{
- await this.fooTextBox.Document.LoadAsync(ofd.FileName, Encoding.Default);
+ await this.fooTextBox.Document.LoadAsync(ofd.FileName, Encoding.Default,this.cancleTokenSrc);
this.fooTextBox.Refresh();
}
}
private void MenuItem_Click_4(object sender, RoutedEventArgs e)
{
if (this.fooTextBox.LineBreakMethod == LineBreakMethod.None)
- this.fooTextBox.LineBreakMethod = LineBreakMethod.PageBound;
+ this.fooTextBox.LineBreakMethod = LineBreakMethod.CharUnit;
else
this.fooTextBox.LineBreakMethod = LineBreakMethod.None;
+ this.fooTextBox.LineBreakCharCount = 10;
this.fooTextBox.PerfomLayouts();
this.fooTextBox.Refresh();
}
bool result = (bool)sfd.ShowDialog(this);
if (result == true)
{
- await this.fooTextBox.Document.SaveAsync(sfd.FileName,Encoding.Default,"\r\n");
+ await this.fooTextBox.Document.SaveAsync(sfd.FileName,Encoding.Default,"\r\n",cancleTokenSrc);
MessageBox.Show("complete");
}
}
+
+ private void ReplaceAll_Click(object sender, RoutedEventArgs e)
+ {
+ System.Diagnostics.Stopwatch time = new System.Diagnostics.Stopwatch();
+ time.Start();
+ this.fooTextBox.Document.FireUpdateEvent = false;
+ this.fooTextBox.Document.ReplaceAll2(this.FindPattern.Text, this.ReplacePattern.Text,true);
+ this.fooTextBox.Document.FireUpdateEvent = true;
+ time.Stop();
+ this.fooTextBox.Refresh();
+ MessageBox.Show(string.Format("complete elpased time:{0}s",time.ElapsedMilliseconds/1000.0f));
+ }
+
+ private void URLMark_Click(object sender, RoutedEventArgs e)
+ {
+ if (this.fooTextBox.MarkURL)
+ {
+ this.fooTextBox.MarkURL = false;
+ this.URLMark.IsChecked = false;
+ }
+ else
+ {
+ this.fooTextBox.MarkURL = true;
+ this.URLMark.IsChecked = true;
+ }
+ this.fooTextBox.Refresh();
+ }
+
+ private void ShowLineMarker_Click(object sender, RoutedEventArgs e)
+ {
+ if (this.fooTextBox.DrawCaretLine)
+ {
+ this.fooTextBox.DrawCaretLine = false;
+ this.ShowLineMarker.IsEnabled = false;
+ }
+ else
+ {
+ this.fooTextBox.DrawCaretLine = true;
+ this.ShowLineMarker.IsEnabled = true;
+ }
+ this.fooTextBox.Refresh();
+ }
}
}