private void GoTo_Executed(object sender, ExecutedRoutedEventArgs e) { InputDialog ind = new InputDialog("转到", "请输入行号:"); ind.Owner = this; if (ind.ShowDialog() != true) { return; } try { tbContent.CaretIndex = tbContent.GetCharacterIndexFromLineIndex(Convert.ToInt32(ind.Result) - 1); } catch (ArgumentOutOfRangeException) { }; tbContent.Focus(); }
private void SetPassword_Executed(object sender, ExecutedRoutedEventArgs e) { var ctx = DataContext as FileContext; InputDialog ind = new InputDialog("设置密码", "请输入密码(留空则使用默认密码):"); try { ind.Owner = this; } catch (System.InvalidOperationException) { ind.Title = "黑 色 高 级 记 事 本"; } if (ind.ShowDialog() != true || string.IsNullOrEmpty(ind.Result)) { ctx.Password = "******"; } else { ctx.Password = ind.Result; } if (ctx.Status == FcStatus.Modified || ctx.Status == FcStatus.Opened) { ApplicationCommands.Save.Execute(null, this); } }
private void Find_Executed(object sender, ExecutedRoutedEventArgs e) { var ctx = DataContext as FileContext; InputDialog ind = new InputDialog("查找", "请输入查找内容:", findstr); ind.Owner = this; if (ind.ShowDialog() != true || ctx.Content == null) { return; } findstr = ind.Result; findnow = ctx.Content.IndexOf(findstr); if (findnow < 0) { MessageBox.Show(this, "已完成对该文档的搜索。"); return; } tbContent.Select(findnow, findstr.Length); tbContent.ScrollToLine(tbContent.GetLineIndexFromCharacterIndex(findnow)); tbContent.Focus(); }