/// <summary> /// 发送消息的点击事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Button_Click(object sender, RoutedEventArgs e) { RichTextBoxUtil richTextBoxUtil = new RichTextBoxUtil(this.ChatingContentMsg); IndexUtil.SendData(richTextBoxUtil); SendData(richTextBoxUtil); }
/// <summary> /// 发送消息的回车事件即按下enter键就可以发送消息 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void ChatingContentMsg_KeyDown(object sender, KeyEventArgs e) { if (e.Key == Key.Return) { RichTextBoxUtil richTextBoxUtil = new RichTextBoxUtil(this.ChatingContentMsg); IndexUtil.SendData(richTextBoxUtil); SendData(richTextBoxUtil); } }
private void SendData(RichTextBoxUtil richTextBoxUtil) { CustoParam custoParam = new CustoParam() { Contpl = this.MsgRichTextBoxTemp.Template, Document = richTextBoxUtil.GetFlowDocument, Width = CommonUtil.GetRichTextBoxWidth(richTextBoxUtil.GetRichTextBoxToString, richTextBoxUtil.GetRichTextBoxCont), RTB = new RichTextBox(), Default = new DockPanel() }; ChatingContent.Children.Add(custoParam.Dock); ChatingContentMsg.Document.Blocks.Clear(); }
internal static void ClearTextCorrectness(CustomRichTextBox pageTextBox) { RichTextBox tempRichTextBox = new RichTextBox(); //Temporary RichTextBox to avoid too much undo/redo into buffer pageTextBox.SuspendPainting(); tempRichTextBox.Rtf = pageTextBox.Rtf; tempRichTextBox.SelectAll(); tempRichTextBox.Font = new Font(pageTextBox.Font, FontStyle.Regular); tempRichTextBox.SelectionBackColor = tempRichTextBox.BackColor; RichTextBoxUtil.ReplaceRTFContent(pageTextBox, tempRichTextBox); pageTextBox.ResumePainting(); tempRichTextBox.Dispose(); }
protected override void OnTextChanged(EventArgs e) { Form1 form = (Form1)FindForm(); if (form == null) { base.OnTextChanged(e); return; } if (!IsUndoingRedoing && RichTextBoxUtil.ContainsUnderlineText(this)) { if (IsUnderlining) { IsUnderlining = false; } else { DictionaryManager.ClearTextCorrectness(this); } } if (!IsUndoingRedoing && RichTextBoxUtil.ContainsHighlightText(this)) { if (IsHighlighting) { IsHighlighting = false; } else { StringUtil.ClearHighlightsResults(this); } } if (IsUndoingRedoing) { IsUndoingRedoing = false; } TabManager.TabTextChange(form); TextManager.RefreshUndoRedoExternal(form); base.OnTextChanged(e); }
internal static void CheckTextCorrectness(Form1 form, String languageSign) { if (!ExistsDictionary(languageSign)) { WindowManager.ShowInfoBox(form, LanguageUtil.GetCurrentLanguageString("NoDictionary", className) + ConstantUtil.dtPadURL + "wikipage?title=Dictionaries"); return; } CustomXtraTabControl pagesTabControl = form.pagesTabControl; CustomRichTextBox pageTextBox = ProgramUtil.GetPageTextBox(pagesTabControl.SelectedTabPage); if (RichTextBoxUtil.ContainsUnderlineText(pageTextBox)) { ClearTextCorrectness(pageTextBox); } bool textCorrectness = true; RichTextBox tempRichTextBox = new RichTextBox { BackColor = pageTextBox.BackColor }; //Temporary RichTextBox to avoid too much undo/redo into buffer pageTextBox.SuspendPainting(); tempRichTextBox.Rtf = pageTextBox.Rtf; //Method 1: char parse (more accurate, slower) using (Hunspell hunspell = new Hunspell(ConstantUtil.ApplicationExecutionPath() + "\\Languages\\" + languageSign + ".aff", ConstantUtil.ApplicationExecutionPath() + "\\Languages\\" + languageSign + ".dic")) { int wordStart = 0; StringBuilder word = new StringBuilder(String.Empty); StringBuilder text = new StringBuilder(pageTextBox.Text); for (int i = 0; i < text.Length; i++) { if (text[i] == '\'' || (!Char.IsWhiteSpace(text[i]) && !Char.IsPunctuation(text[i]) && !Char.IsSymbol(text[i]) && !Char.IsSeparator(text[i]))) { word.Append(text[i]); if (i < text.Length - 1) { continue; } } if (!hunspell.Spell(word.ToString()) && !String.IsNullOrEmpty(word.ToString().Trim())) { tempRichTextBox.Select(wordStart, word.Length); tempRichTextBox.SelectionFont = new Font(pageTextBox.Font, FontStyle.Underline); tempRichTextBox.SelectionColor = (pageTextBox.BackColor == Color.Red) ? Color.Yellow : Color.Red; textCorrectness = false; } word = new StringBuilder(String.Empty); wordStart = i + 1; } } //Method 2: word parse (less accurate, faster) //String[] wordsList = pageTextBox.Text.Split(new[] { ' ', Convert.ToChar(ConstantUtil.newLine), '\t', '/', '\\', '.', '?', ';', ',', ':', '(', ')', '[', ']', '{', '}', '\\', '|', '/', '!', '"', '\'', '=' }, StringSplitOptions.RemoveEmptyEntries); //List<String> wordsAlreadySeen = new List<String>(); //using (Hunspell hunspell = new Hunspell(ConstantUtil.ApplicationExecutionPath() + "\\Languages\\" + languageSign + ".aff", ConstantUtil.ApplicationExecutionPath() + "\\Languages\\" + languageSign + ".dic")) //{ // foreach (String word in wordsList) // { // if (wordsAlreadySeen.Contains(word)) // { // continue; // } // wordsAlreadySeen.Add(word); // if (hunspell.Spell(word)) // { // continue; // } // int i = 0; // while (i != -1 && (i = pageTextBox.Text.IndexOf(word, i)) != -1) // { // tempRichTextBox.Select(i, word.Length); // tempRichTextBox.SelectionFont = new Font(pageTextBox.Font, FontStyle.Underline); // tempRichTextBox.SelectionColor = (pageTextBox.BackColor == Color.Red) ? Color.Yellow : Color.Red; // i += word.Length; // } // } //} pageTextBox.IsUnderlining = true; RichTextBoxUtil.ReplaceRTFContent(pageTextBox, tempRichTextBox); pageTextBox.ResumePainting(); tempRichTextBox.Dispose(); TextManager.RefreshUndoRedoExternal(form); if (textCorrectness) { WindowManager.ShowInfoBox(form, LanguageUtil.GetCurrentLanguageString("TextCorrect", className)); } }
public NoticeForm() { InitializeComponent(); richTextBox_info.Clear(); RichTextBoxUtil.AppendFormatedLine(richTextBox_info, "欢迎使用 GNSS 数据并行处理软件 —— GNSSer(GNSS Data Paralell Processer) v 1.4\r\n", Color.FromArgb(100, 100, 250), 3); StringBuilder sb = new StringBuilder(); int i = 1; sb.Clear(); RichTextBoxUtil.AppendFormatedLine(richTextBox_info, "简介:", Color.Black, 2); sb.Append(" " + (i++) + ". "); sb.AppendLine("GNSSer 是一个中国国产科研型GNSS数据处理软件,系统从底层开发,具有完全自主的知识产权和多项首创技术,我们秉承“技术至上”的理念,不断探索、专研和发展;"); sb.Append(" " + (i++) + ". "); sb.AppendLine("GNSSer 致力于 全球导航卫星系统(GNSS) 高精度数据处理算法与应用研究;"); sb.Append(" " + (i++) + ". "); sb.AppendLine("GNSSer 的目标是 提供高精度、高效率、高度自动化、界面友好、性能稳定的 GNSS 数据处理解决方案,并提供云模式的 GNSS 计算服务;"); sb.Append(" " + (i++) + ". "); sb.AppendLine("GNSSer 的一个特点是大规模 GNSS 数据的分布式计算和并行算法。"); sb.AppendLine(); richTextBox_info.AppendText(sb.ToString()); i = 1; sb.Clear(); RichTextBoxUtil.AppendFormatedLine(richTextBox_info, "使用须知:", Color.Black, 2); sb.Append(" " + (i++) + ". "); sb.AppendLine("GNSSer 桌面公开版 提供免费的使用,任何人、任何组织、任何党派、都可以在非商业模式下,自由 使用、复制、拷贝 本版本软件;"); sb.Append(" " + (i++) + ". "); sb.AppendLine("未经许可,不可以将 GNSSer 的代码、组件、安装包,进行破解、反编译、嵌入系统、重新打包等" + ",GNSSer 保留版权和法律追究的权利;"); sb.Append(" " + (i++) + ". "); sb.AppendLine("GNSSer 欢迎以本软件为基础发表论文和著述,请引用我们公开发表的论文,论文目录将更新到网站上;"); sb.Append(" " + (i++) + ". "); sb.AppendLine("GNSSer 欢迎任何形式的合作、开发与应用;"); sb.AppendLine(); richTextBox_info.AppendText(sb.ToString()); sb.Clear(); RichTextBoxUtil.AppendFormatedLine(richTextBox_info, "GNSSer 1.x 标签:", Color.Black, 2); sb.AppendLine("自主研发,高精度,多系统,并行计算,AnyInfo,界面友好"); sb.AppendLine(); richTextBox_info.AppendText(sb.ToString()); i = 1; sb.Clear(); RichTextBoxUtil.AppendFormatedLine(richTextBox_info, "注意:", Color.Black, 2); sb.Append(" " + (i++) + ". "); sb.AppendLine("GNSSer 仍然在不断发展中,后继版本的变化可能会很大!"); sb.Append(" " + (i++) + ". "); sb.AppendLine("如果在软件使用过程中,出现了任何异常、错误、Bug等,请将状况反映到我们邮箱或网站;"); sb.AppendLine(); richTextBox_info.AppendText(sb.ToString()); sb.Clear(); RichTextBoxUtil.AppendFormatedLine(richTextBox_info, "致谢:", Color.Black, 2); sb.AppendLine("GNSSer 的研发中,参考比较了大量论文、书籍和已有成熟软件的算法和数据格式,以及对结果进行了比较,在此表示感谢,包括 Bernese、GAMIT、GPSTk、RTKLIB等;"); richTextBox_info.AppendText(sb.ToString()); sb.Clear(); sb.AppendLine(); sb.AppendLine("邮箱: [email protected]"); sb.AppendLine("网站: www.gnsser.com"); sb.AppendLine("GNSSer 开发组"); sb.AppendLine("2018 年 11 月 12 日 "); var info = sb.ToString(); this.richTextBox_info.AppendText(info); this.richTextBox_info.SelectionStart = 0; }
private static bool ReplaceNext(Form1 form, bool loopAtEOF, bool searchInAllFiles) { XtraTabControl pagesTabControl = form.pagesTabControl; TextBox searchTextBox = form.searchPanel.searchTextBox; CheckBox caseCheckBox = form.searchPanel.caseCheckBox; ToolStripStatusLabel toolStripStatusLabel = form.toolStripStatusLabel; TextBox replaceTextBox = form.searchPanel.replaceTextBox; CustomRichTextBox pageTextBox = ProgramUtil.GetPageTextBox(pagesTabControl.SelectedTabPage); CheckBox useRegularExpressionsCheckBox = form.searchPanel.regularExpressionsCheckBox; bool valueFounded = false; if (String.IsNullOrEmpty(searchTextBox.Text)) { return(false); } String textWhereToSearch = pageTextBox.Text; String textToSearch = searchTextBox.Text.Replace(ConstantUtil.newLineNotCompatible, ConstantUtil.newLine); FileListManager.SetNewSearchHistory(form, textToSearch); if (!caseCheckBox.Checked) { textWhereToSearch = textWhereToSearch.ToLower(); textToSearch = textToSearch.ToLower(); } RichTextBoxUtil.CheckAllTextSelected(pageTextBox); int positionSearchedText; int selectionLength; SearchReplaceUtil.FindStringPositionAndLength(textWhereToSearch, textToSearch, SearchReplaceUtil.SearchType.Next, useRegularExpressionsCheckBox.Checked, pageTextBox, out positionSearchedText, out selectionLength); if (positionSearchedText != -1) { toolStripStatusLabel.Text = String.Format("1 {0}", LanguageUtil.GetCurrentLanguageString("Replaced", className, 1)); pageTextBox.Focus(); pageTextBox.Select(positionSearchedText, selectionLength); pageTextBox.SelectedText = replaceTextBox.Text.Replace(ConstantUtil.newLineNotCompatible, ConstantUtil.newLine); TextManager.RefreshUndoRedoExternal(form); pageTextBox.ScrollToCaret(); valueFounded = true; } else if (!searchInAllFiles) { if (SearchReplaceUtil.GetNoMatchesInFile(textWhereToSearch, textToSearch, useRegularExpressionsCheckBox.Checked)) { String notFoundMessage = LanguageUtil.GetCurrentLanguageString("NotFound", className); WindowManager.ShowInfoBox(form, notFoundMessage); toolStripStatusLabel.Text = notFoundMessage; } else { if (loopAtEOF) { pageTextBox.SelectionStart = 0; return(ReplaceNext(form, false, false)); } if (WindowManager.ShowQuestionBox(form, LanguageUtil.GetCurrentLanguageString("EOF", className)) == DialogResult.Yes) { pageTextBox.SelectionStart = 0; return(ReplaceNext(form, false, false)); } } } return(valueFounded); }