internal static void ClearHighlightsResults(Form1 form) { XtraTabControl pagesTabControl = form.pagesTabControl; if (form.IsOpening) { return; } RichTextBox tempRichTextBox = new RichTextBox(); //Temporary RichTextBox to avoid too much undo/redo into buffer try { foreach (XtraTabPage tabPage in pagesTabControl.TabPages) { CustomRichTextBox textBox = ProgramUtil.GetPageTextBox(tabPage); textBox.SuspendPainting(); tempRichTextBox.Rtf = textBox.Rtf; tempRichTextBox.SelectAll(); tempRichTextBox.Font = new Font(textBox.Font, FontStyle.Regular); tempRichTextBox.SelectionBackColor = tempRichTextBox.BackColor; RichTextBoxUtil.ReplaceRTFContent(textBox, tempRichTextBox); textBox.ResumePainting(); } } finally { tempRichTextBox.Dispose(); } TextManager.RefreshUndoRedoExternal(form); }
public static string FromRtfToHtmlString(ref CustomRichTextBox _textBox) { string returnString = ""; returnString += GetHeaderHtmlCode(); int textLength = _textBox.Text.Length; int charIndex = 0; HtmlTag?currentTag = null; while ((charIndex + 1) <= textLength) { _textBox.SelectionStart = charIndex; _textBox.SelectionLength = 1; if (MainContent.DoesFontExist(_textBox.SelectionFont, out Font outFont)) { charIndex++; continue; } outFont = _textBox.SelectionFont; if (outFont.Bold) { currentTag = HtmlTag.Bold; returnString += "<b>" + _textBox.SelectedText; } charIndex++; } returnString += GetFooterHtmlCode(); return(returnString); }
private static void Validate(Form1 form, String validation, String title) { CustomRichTextBox pageTextBox = ProgramUtil.GetPageTextBox(form.pagesTabControl.SelectedTabPage); if (String.IsNullOrEmpty(pageTextBox.Text)) { WindowManager.ShowInfoBox(form, LanguageUtil.GetCurrentLanguageString("NoContent", className)); return; } String fileName = String.Format("{0}.html", Guid.NewGuid()); String pathName = Path.Combine(ConstantUtil.ApplicationExecutionPath(), ConstantUtil.internetCacheDirectoryName); if (!Directory.Exists(pathName)) { Directory.CreateDirectory(pathName); } String text = String.Format(validation, title, pageTextBox.Text, LanguageUtil.GetCurrentLanguageString("Validate", className)); String fileAndPathName = Path.Combine(pathName, fileName); if (FileManager.SaveFileCoreWithEncoding(form, fileAndPathName, text) == false) { return; } OtherManager.StartProcessBrowser(form, fileAndPathName); }
private static void ReadInsertMode(Form1 form) { CustomRichTextBox pageTextBox = ProgramUtil.GetPageTextBox(form.pagesTabControl.SelectedTabPage); ToolStripStatusLabel insertModeToolStripStatusLabel = form.insertModeToolStripStatusLabel; insertModeToolStripStatusLabel.Text = pageTextBox.CustomInsertMode; }
private static void ReplaceAllInAllFiles(Form1 form) { XtraTabControl pagesTabControl = form.pagesTabControl; ToolStripStatusLabel toolStripStatusLabel = form.toolStripStatusLabel; bool valueFounded = false; for (int i = 0; i < pagesTabControl.TabPages.Count; i++) { pagesTabControl.SelectedTabPage = pagesTabControl.TabPages[i]; CustomRichTextBox textBox = ProgramUtil.GetPageTextBox(pagesTabControl.SelectedTabPage); textBox.SelectionStart = 0; textBox.SelectionLength = 0; bool tempValueFounded = ReplaceAllInOneFile(form, true); if (!valueFounded) { valueFounded = tempValueFounded; } } if (valueFounded) { return; } String notFoundMessage = LanguageUtil.GetCurrentLanguageString("NotFound", className); WindowManager.ShowInfoBox(form, notFoundMessage); toolStripStatusLabel.Text = notFoundMessage; }
internal static void ShowGoogleTranslation(Form1 form) { XtraTabControl pagesTabControl = form.pagesTabControl; CustomRichTextBox pageTextBox = ProgramUtil.GetPageTextBox(pagesTabControl.SelectedTabPage); if (String.IsNullOrEmpty(pageTextBox.SelectedText)) { WindowManager.ShowInfoBox(form, LanguageUtil.GetCurrentLanguageString("NoTextSelected", className)); return; } if (!ConfigUtil.GetBoolParameter("TranslationUseSelect")) { if (WindowManager.ShowTranslateText(form) == DialogResult.Cancel) { return; } } String languagePair = ConfigUtil.GetStringParameter("Translation"); bool success; String result = TranslateText(form, languagePair, out success); if (success) { WindowManager.ShowContent(form, result); } }
internal static bool IsCurrentTabInUse(Form1 form) { XtraTabControl pagesTabControl = form.pagesTabControl; CustomRichTextBox pageTextBox = ProgramUtil.GetPageTextBox(pagesTabControl.SelectedTabPage); return(!String.IsNullOrEmpty(pageTextBox.Text) || !String.IsNullOrEmpty(ProgramUtil.GetFilenameTabPage(pagesTabControl.SelectedTabPage))); }
internal static void FontPages(Form1 form) { XtraTabControl pagesTabControl = form.pagesTabControl; DialogResult dialogResult = WindowManager.ShowFontSelect(form); if (dialogResult == DialogResult.Cancel) { return; } foreach (XtraTabPage tabPage in pagesTabControl.TabPages) { CustomRichTextBox pageTextBox = ProgramUtil.GetPageTextBox(tabPage); pageTextBox.Font = form.TextFont; pageTextBox.ForeColor = form.TextFontColor; ProgramUtil.GetCustomLineNumbers(tabPage).Font = form.TextFont; } TypeConverter tc = TypeDescriptor.GetConverter(typeof(Font)); ConfigUtil.UpdateParameter("FontInUse", tc.ConvertToString(form.TextFont)); ConfigUtil.UpdateParameter("FontInUseColorARGB", FontManager.SetARGBString(form.TextFontColor)); }
internal static void RefreshStatistics(Form1 form) { ToolStripMenuItem charactersStatToolStripMenuItem = form.charactersStatToolStripMenuItem; ToolStripMenuItem rowsStatToolStripMenuItem = form.rowsStatToolStripMenuItem; ToolStripMenuItem columnsStatToolStripMenuItem = form.columnsStatToolStripMenuItem; ToolStripMenuItem wordsStatToolStripMenuItem = form.wordsStatToolStripMenuItem; CustomRichTextBox pageTextBox = ProgramUtil.GetPageTextBox(form.pagesTabControl.SelectedTabPage); charactersStatToolStripMenuItem.Text = LanguageUtil.GetCurrentLanguageString("charactersStatToolStripMenuItem", form.Name) + " " + pageTextBox.Text.Replace(ConstantUtil.newLine, String.Empty).Replace("\t", String.Empty).Length; int rowNumbers = pageTextBox.Lines.Length; if (rowNumbers == 0) { rowNumbers = 1; } rowsStatToolStripMenuItem.Text = LanguageUtil.GetCurrentLanguageString("rowsStatToolStripMenuItem", form.Name) + " " + rowNumbers; String[] separator = { ConstantUtil.newLine }; //String[] lines = pageTextBox.Text.Split(separator, StringSplitOptions.None); //foreach (String line in lines) //{ // if (line.Length > columnNumbers) // { // columnNumbers = line.Length; // } //} String[] lines = pageTextBox.Text.Split(separator, StringSplitOptions.None); int columnNumbers = lines.Select(line => line.Length).Concat(new[] { 0 }).Max(); columnsStatToolStripMenuItem.Text = LanguageUtil.GetCurrentLanguageString("columnsStatToolStripMenuItem", form.Name) + " " + columnNumbers; String[] separator2 = { " ", ConstantUtil.newLine }; wordsStatToolStripMenuItem.Text = LanguageUtil.GetCurrentLanguageString("wordsStatToolStripMenuItem", form.Name) + " " + pageTextBox.Text.Split(separator2, StringSplitOptions.RemoveEmptyEntries).Length; }
internal static void TabTextChange(Form1 form) { XtraTabControl pagesTabControl = form.pagesTabControl; CustomRichTextBox pageTextBox = ProgramUtil.GetPageTextBox(pagesTabControl.SelectedTabPage); if (pageTextBox.Text.GetHashCode().ToString() != pageTextBox.CustomOriginal && !TabUtil.IsTabPageModified(pagesTabControl.SelectedTabPage)) { pagesTabControl.SelectedTabPage.ImageIndex = pagesTabControl.SelectedTabPage.ImageIndex + 1; pagesTabControl.SelectedTabPage.Text = String.Format("*{0}", pagesTabControl.SelectedTabPage.Text); pageTextBox.CustomModified = true; } else if ((pageTextBox.Text.GetHashCode().ToString() == pageTextBox.CustomOriginal && TabUtil.IsTabPageModified(pagesTabControl.SelectedTabPage)) || String.IsNullOrEmpty(pageTextBox.Text) && String.IsNullOrEmpty(pageTextBox.CustomOriginal)) { switch (pagesTabControl.SelectedTabPage.ImageIndex) { case 1: pagesTabControl.SelectedTabPage.ImageIndex = 0; break; case 3: pagesTabControl.SelectedTabPage.ImageIndex = 2; break; } pagesTabControl.SelectedTabPage.Text = String.Format("{0}", pagesTabControl.SelectedTabPage.Text.Substring(1)); pageTextBox.CustomModified = false; } form.Text = String.Format("DtPad - {0}", pagesTabControl.SelectedTabPage.Text); }
internal static void ShowXmlEditor(Form1 form) { CustomRichTextBox pageTextBox = ProgramUtil.GetPageTextBox(form.pagesTabControl.SelectedTabPage); if (String.IsNullOrEmpty(pageTextBox.Text)) { ShowInfoBox(form, LanguageUtil.GetCurrentLanguageString("TextEmpty", className)); return; } String error; if (!XmlValidator.Validate(form, false, ValidationType.Schema, null, out error)) { ShowAlertBox(form, error); return; } XmlEditor fileRename = new XmlEditor { Owner = form }; fileRename.InitializeForm(); fileRename.Show(form); }
internal static void FormatXml(Form1 form, bool validationFirst = true, bool indentation = true) { XtraTabControl pagesTabControl = form.pagesTabControl; CustomRichTextBox pageTextBox = ProgramUtil.GetPageTextBox(pagesTabControl.SelectedTabPage); if (validationFirst && !XmlValidator.Validate(form, ValidationType.Schema, false)) { return; } int indentationNum = indentation ? 1 : 0; XmlDocument xd = new XmlDocument(); xd.LoadXml(pageTextBox.Text); //xd.LoadXml(EncodeHTMLTagsForXMLValidation(pageTextBox.Text)); StringBuilder builder = new StringBuilder(); using (StringWriter writer = new StringWriter(builder)) { using (XmlTextWriter xtw = new XmlTextWriter(writer)) { xtw.IndentChar = '\t'; xtw.Indentation = indentationNum; xtw.Formatting = Formatting.Indented; xd.WriteTo(xtw); } pageTextBox.SelectAll(); pageTextBox.SelectedText = builder.ToString(); //pageTextBox.SelectedText = DecodeHTMLTagsForXMLValidation(builder.ToString()); TextManager.RefreshUndoRedoExternal(form); } }
internal void InitializeForm() { InitializeComponent(); LookFeelUtil.SetLookAndFeel(contentContextMenuStrip); SetLanguage(); Form1 form = (Form1)Owner; String filename = ProgramUtil.GetFilenameTabPage(form.pagesTabControl.SelectedTabPage); CustomRichTextBox pageTextBox = ProgramUtil.GetPageTextBox(form.pagesTabControl.SelectedTabPage); String xmlString = pageTextBox.Text; //XmlUrlResolver resolver = new XmlUrlResolver(); //resolver.Credentials = CredentialCache.DefaultCredentials; XmlDocument xmldoc = new XmlDocument(); XmlReaderSettings settings = new XmlReaderSettings { IgnoreWhitespace = true, //XmlResolver = resolver, IgnoreComments = true, DtdProcessing = DtdProcessing.Parse //ProhibitDtd = false }; StringReader reader = new StringReader(xmlString); XmlReader render = !String.IsNullOrEmpty(filename) ? XmlReader.Create(reader, settings, filename) : XmlReader.Create(reader, settings); try { xmldoc.Load(render); } catch (Exception exception) { String error = String.Format(LanguageUtil.GetCurrentLanguageString("Error", Name), exception.Message); WindowManager.ShowAlertBox(form, error); reader.Dispose(); render.Close(); return; } reader.Dispose(); render.Close(); GridBuilder builder = new GridBuilder(); GridCellGroup xmlgroup = new GridCellGroup { Flags = GroupFlags.Overlapped | GroupFlags.Expanded }; builder.ParseNodes(xmlgroup, null, xmldoc.ChildNodes); root = new GridCellGroup(); root.Table.SetBounds(1, 2); root.Table[0, 0] = new GridHeadLabel { Text = "XML" }; root.Table[0, 1] = xmlgroup; xmlGridView.Cell = root; xmlGridView.Font = pageTextBox.Font; xmlGridView.ForeColor = pageTextBox.ForeColor; xmlGridView.BackColor = pageTextBox.BackColor; }
public void OpenNote(string a_filePath, string a_fileName, string a_course) { // Check to see if note is already open foreach (TabPage page in mainTabControl.TabPages) { if (page.Text == string.Format("[{0}] {1}", a_course, a_fileName)) { mainTabControl.SelectedTab = page; return; } } CustomRichTextBox newBox = new CustomRichTextBox(); newBox.Font = new Font(newBox.Font.FontFamily, 10.5f, FontStyle.Regular); newBox.LoadFile(a_filePath); newBox.Size = template_rtb.Size; newBox.Location = template_rtb.Location; newBox.HideSelection = false; newBox.ReadOnly = true; // Create new tab, make sure all TabPage values are srt to null CustomTab newTab = new CustomTab("", "", "", null); newTab.Text = string.Format("[{0}] {1}", a_course, a_fileName); newTab.Controls.Add(newBox); mainTabControl.TabPages.Add(newTab); ResizeTabControlAndChildren(); }
internal static void ExportNotes(Form1 form, ExportTypeEnum exportType) { XtraTabControl pagesTabControl = form.pagesTabControl; CustomRichTextBox pageTextBox = ProgramUtil.GetPageTextBox(pagesTabControl.SelectedTabPage); String content; switch (exportType) { case ExportTypeEnum.Xml: if (TabManager.IsCurrentTabInUse(form)) { form.TabIdentity = TabManager.AddNewPage(form, form.TabIdentity); pageTextBox = ProgramUtil.GetPageTextBox(pagesTabControl.SelectedTabPage); } content = FileUtil.ReadToEndWithStandardEncoding(Path.Combine(ConstantUtil.ApplicationExecutionPath(), ConstantUtil.noFile)); //Row number check WindowManager.CheckLineNumbersForTextLenght(form, content); pageTextBox.SelectedText = content; TextManager.RefreshUndoRedoExternal(form); break; case ExportTypeEnum.Txt: try { XmlDocument xmldoc = new XmlDocument(); xmldoc.Load(Path.Combine(ConstantUtil.ApplicationExecutionPath(), ConstantUtil.noFile)); XmlNodeList noteNodeList = xmldoc.GetElementsByTagName("note"); foreach (XmlNode noteNode in noteNodeList) { if (TabManager.IsCurrentTabInUse(form)) { form.TabIdentity = TabManager.AddNewPage(form, form.TabIdentity); pageTextBox = ProgramUtil.GetPageTextBox(pagesTabControl.SelectedTabPage); } content = noteNode.ChildNodes[0].InnerText + ConstantUtil.newLine + ConstantUtil.newLine + noteNode.ChildNodes[1].InnerText; //Row number check WindowManager.CheckLineNumbersForTextLenght(form, content); pageTextBox.SelectedText = content; TextManager.RefreshUndoRedoExternal(form); } } catch (XmlException exception) { ManageError(form, exception); } break; } }
private MatchCollection FindAllTextMatches(CustomRichTextBox aRtb) { string regexPattern = "(" + findInputBox.Text + ")"; MatchCollection matches = Regex.Matches(aRtb.Text, regexPattern); return(matches); }
public static string FormattedRtfToPlainText(string formattedRtf) { var box = new CustomRichTextBox(); box.RichText = formattedRtf; return(box.TextBox.Text); }
internal static void GoToLine(Form1 form, int row) { ToolStripStatusLabel rowToolStripStatusLabel1 = form.rowToolStripStatusLabel1; CustomRichTextBox pageTextBox = ProgramUtil.GetPageTextBox(form.pagesTabControl.SelectedTabPage); pageTextBox.Select(TextManager.ReadRTBFirstCharIndexFromLine(form, row - 1), 0); rowToolStripStatusLabel1.Text = row.ToString(); }
internal static void TabKeyUp(Form1 form) { ToolStripStatusLabel rowToolStripStatusLabel1 = form.rowToolStripStatusLabel1; CustomRichTextBox pageTextBox = ProgramUtil.GetPageTextBox(form.pagesTabControl.SelectedTabPage); rowToolStripStatusLabel1.Text = (TextManager.ReadRTBLineFromCharIndex(form, pageTextBox.GetFirstCharIndexOfCurrentLine()) + 1).ToString(); }
internal static void MergeTab(Form1 form, String[] selectedTabNames, bool indicateMerge, String markSeparation) { XtraTabControl pagesTabControl = form.pagesTabControl; ToolStripStatusLabel toolStripStatusLabel = form.toolStripStatusLabel; ToolStripProgressBar toolStripProgressBar = form.toolStripProgressBar; bool linesDisabled = false; int previousMaximum = toolStripProgressBar.Maximum; int previousStep = toolStripProgressBar.Step; toolStripProgressBar.Maximum = selectedTabNames.Length + 1; toolStripProgressBar.Step = 1; toolStripProgressBar.Value = 0; toolStripProgressBar.Visible = true; if (indicateMerge) { ConfigUtil.UpdateParameter("MergeTabSeparation", markSeparation.Replace(ConstantUtil.newLine, "\\r\\n")); } XtraTabPage firstTab = GetXtraTabPageFromName(pagesTabControl, selectedTabNames[0]); CustomRichTextBox pageTextBox = ProgramUtil.GetPageTextBox(firstTab); for (int i = 1; i < selectedTabNames.Length; i++) { String textPostMerge; if (indicateMerge) { textPostMerge = pageTextBox.Text + ConstantUtil.newLine + markSeparation + ConstantUtil.newLine + ProgramUtil.GetPageTextBox(GetXtraTabPageFromName(pagesTabControl, selectedTabNames[i])).Text; } else { textPostMerge = pageTextBox.Text + ConstantUtil.newLine + ProgramUtil.GetPageTextBox(GetXtraTabPageFromName(pagesTabControl, selectedTabNames[i])).Text; } if (linesDisabled != true) { linesDisabled = WindowManager.CheckLineNumbersForTextLenght(form, textPostMerge, true); } pageTextBox.Text = textPostMerge; pagesTabControl.TabPages.Remove(GetXtraTabPageFromName(pagesTabControl, selectedTabNames[i])); toolStripProgressBar.PerformStep(); } toolStripStatusLabel.Text = String.Format("{0} {1}", selectedTabNames.Length, LanguageUtil.GetCurrentLanguageString("TabMerged", className)); toolStripProgressBar.PerformStep(); toolStripProgressBar.Visible = false; toolStripProgressBar.Maximum = previousMaximum; toolStripProgressBar.Step = previousStep; pagesTabControl.SelectedTabPage = firstTab; if (linesDisabled) { WindowManager.ShowInfoBox(form, LanguageUtil.GetCurrentLanguageString("LineNumbersDisabled", className)); } }
internal static void Normalize(Form1 form) { XtraTabControl pagesTabControl = form.pagesTabControl; CustomRichTextBox pageTextBox = ProgramUtil.GetPageTextBox(pagesTabControl.SelectedTabPage); pageTextBox.SelectAll(); pageTextBox.SelectedText = FormatManager.EncodeHTMLTagsForXMLValidation(pageTextBox.Text); TextManager.RefreshUndoRedoExternal(form); }
private static bool ReplaceAllInOneFile(Form1 form, bool searchInAllFiles) { CustomRichTextBox textBox = ProgramUtil.GetPageTextBox(form.pagesTabControl.SelectedTabPage); TextBox searchTextBox = form.searchPanel.searchTextBox; TextBox replaceTextBox = form.searchPanel.replaceTextBox; ToolStripStatusLabel toolStripStatusLabel = form.toolStripStatusLabel; CheckBox caseCheckBox = form.searchPanel.caseCheckBox; CheckBox useRegularExpressionsCheckBox = form.searchPanel.regularExpressionsCheckBox; if (String.IsNullOrEmpty(searchTextBox.Text)) { return(false); } FileListManager.SetNewSearchHistory(form, searchTextBox.Text); String textWhereToSearch; String textToSearch; GetTextCaseNormalization(form, out textWhereToSearch, out textToSearch); int positionSearchedText; int selectionLength; SearchReplaceUtil.FindStringPositionAndLength(textWhereToSearch, textToSearch, SearchReplaceUtil.SearchType.First, useRegularExpressionsCheckBox.Checked, textBox, out positionSearchedText, out selectionLength); if (positionSearchedText != -1) { int counter = SearchReplaceUtil.SearchCountOccurency(form, false, true); textBox.SelectAll(); if (caseCheckBox.Checked) { textBox.SelectedText = Replace(useRegularExpressionsCheckBox.Checked, textBox.Text, GetTextNewLineNormalization(searchTextBox.Text), GetTextNewLineNormalization(replaceTextBox.Text), StringComparison.Ordinal); } else { textBox.SelectedText = Replace(useRegularExpressionsCheckBox.Checked, textBox.Text, GetTextNewLineNormalization(searchTextBox.Text), GetTextNewLineNormalization(replaceTextBox.Text), StringComparison.OrdinalIgnoreCase); } TextManager.RefreshUndoRedoExternal(form); textBox.Select(0, 0); toolStripStatusLabel.Text = String.Format("{0} {1}", counter, LanguageUtil.GetCurrentLanguageString("Replaced", className, counter)); return(true); } if (!searchInAllFiles) { String notFoundMessage = LanguageUtil.GetCurrentLanguageString("NotFound", className); WindowManager.ShowInfoBox(form, notFoundMessage); toolStripStatusLabel.Text = notFoundMessage; } return(false); }
public ColorButton(CustomRichTextBox customRichTextBox, GridPropertiesImageGeneral grid, Brush brush, StackPanel stackPanelRecentColor, Xceed.Wpf.Toolkit.DropDownButton dropButton, Rectangle rectangleColor) { GridProp = grid; CustomRichTextBox = customRichTextBox; Brush = brush; StackPanelRecentColor = stackPanelRecentColor; DropButton = dropButton; this.Background = brush; RectangleColor = rectangleColor; }
internal static void SetPageTextBoxContextMenu(Form1 form, IEnumerable <ToolStripMenuItem> items) { XtraTabControl pagesTabControl = form.pagesTabControl; CustomRichTextBox pageTextBox = ProgramUtil.GetPageTextBox(pagesTabControl.SelectedTabPage); foreach (ToolStripMenuItem item in items) { item.Enabled = !String.IsNullOrEmpty(pageTextBox.SelectedText); } }
internal static void ChangeSection(Form1 form, int index, bool active) { XtraTabControl pagesTabControl = form.pagesTabControl; CustomRichTextBox pageTextBox = ProgramUtil.GetPageTextBox(pagesTabControl.SelectedTabPage); CustomPanel sectionsPanel = ProgramUtil.GetSectionsPanel(pagesTabControl.SelectedTabPage); CheckedListBox sectionsCheckedListBox = (CheckedListBox)sectionsPanel.Controls["sectionsCheckedListBox"]; String content = pageTextBox.Text; String section = sectionsCheckedListBox.Items[index].ToString(); bool flag = false; StringBuilder builder = new StringBuilder(); foreach (String str in content.Split(new[] { Convert.ToChar(ConstantUtil.newLine) })) { if (builder.Length > 0) { builder.Append(ConstantUtil.newLine); //builder.AppendLine(); } if (String.IsNullOrEmpty(str)) { continue; } if (str.StartsWith("#SECTION ", StringComparison.OrdinalIgnoreCase)) { //flag = str.EndsWith(" " + section, StringComparison.OrdinalIgnoreCase); flag = (str == ("#SECTION " + section)); builder.Append(str); } else if (flag) { if (active) { builder.Append(str.StartsWith(ConstantUtil.hostsComments) ? str.Substring(ConstantUtil.hostsComments.Length) : str); } else if (!str.StartsWith(ConstantUtil.hostsComments)) { builder.Append(ConstantUtil.hostsComments).Append(str); } else { builder.Append(str); } } else { builder.Append(str); } } pageTextBox.SelectAll(); pageTextBox.SelectedText = builder.ToString(); TextManager.RefreshUndoRedoExternal(form); pageTextBox.ScrollToCaret(); }
private static void ColourComments(LanguageTheme a_theme, ref CustomRichTextBox a_richTextBox, int a_start, int a_end) { /* * int currentIndex = a_start; * int selectionEnd = a_end; * int stringStartIndex = -1; * bool lookingForNextSlash = false; * bool foundDoubleSlash = false; * string str = a_richTextBox.Text; * * while (currentIndex < selectionEnd) * { * // If you have found the first \ * if (str[currentIndex] == '/' && !lookingForNextSlash) * { * lookingForNextSlash = true; * foundDoubleSlash = false; * currentIndex++; * continue; * } * * // If you have found the second \ * if (str[currentIndex] == '/' && lookingForNextSlash) * { * lookingForNextSlash = false; * foundDoubleSlash = true; * stringStartIndex = currentIndex - 1; * currentIndex++; * continue; * } * * if ((str[currentIndex] == '\n' || str[currentIndex] == '\r') && foundDoubleSlash) * { * if (stringStartIndex > 0) * { * if (allLanguageThemes[activeThemeIndex].GetColourFromKeyword("__comment", out Color col)) * { * a_richTextBox.SelectionStart = stringStartIndex - 1; * a_richTextBox.SelectionLength = (currentIndex + 1) - stringStartIndex; * a_richTextBox.SelectionColor = col; * a_richTextBox.SelectionLength = 0; * a_richTextBox.SelectionColor = Color.Black; * } * } * * foundDoubleSlash = false; * stringStartIndex = -1; * currentIndex++; * continue; * } * * currentIndex++; * }*/ }
internal static CustomPrintDocument PageSetup(Form1 form, CustomPrintDocument customPrintDocument) { CustomRichTextBox pageTextBox = ProgramUtil.GetPageTextBox(form.pagesTabControl.SelectedTabPage); PageSetupDialog pageSetupDialog = form.pageSetupDialog; customPrintDocument = SetCustomPrintDocument(pageTextBox, customPrintDocument); pageSetupDialog.Document = customPrintDocument; pageSetupDialog.ShowDialog(); return(customPrintDocument); }
internal static void CompareTabText(FileCompare form, String[] itemValues) { Form1 form1 = (Form1)form.Owner; XtraTabControl pagesTabControl = form1.pagesTabControl; ListBox tabPagesListBox = form.tabPagesListBox; CheckBox caseSensitiveCheckBox = form.caseSensitiveCheckBox; if (tabPagesListBox.SelectedIndices.Count != 2) { throw new TabException(LanguageUtil.GetCurrentLanguageString("ErrorCompare", className)); } String[] selectedTabNames = new String[tabPagesListBox.SelectedIndices.Count]; for (int i = 0; i < tabPagesListBox.SelectedIndices.Count; i++) { selectedTabNames[i] = itemValues[tabPagesListBox.SelectedIndices[i]]; } XtraTabPage tabPage1 = GetXtraTabPageFromName(pagesTabControl, selectedTabNames[0]); XtraTabPage tabPage2 = GetXtraTabPageFromName(pagesTabControl, selectedTabNames[1]); CustomRichTextBox pageTextBox1 = ProgramUtil.GetPageTextBox(tabPage1); CustomRichTextBox pageTextBox2 = ProgramUtil.GetPageTextBox(tabPage2); String text1 = pageTextBox1.Text; String text2 = pageTextBox2.Text; if (!caseSensitiveCheckBox.Checked) { text1 = text1.ToLower(); text2 = text2.ToLower(); } if (text1 == text2) { WindowManager.ShowInfoBox(form1, LanguageUtil.GetCurrentLanguageString("TabEquals", className)); } else if (text1.Replace(ConstantUtil.newLine, String.Empty) == text2.Replace(ConstantUtil.newLine, String.Empty)) { WindowManager.ShowAlertBox(form1, LanguageUtil.GetCurrentLanguageString("TabAlmostEquals_Returns", className)); } else if (text1.Replace(" ", String.Empty).Replace("\t", String.Empty) == text2.Replace(" ", String.Empty).Replace("\t", String.Empty)) { WindowManager.ShowAlertBox(form1, LanguageUtil.GetCurrentLanguageString("TabAlmostEquals_Spaces", className)); } else if (text1.Replace(ConstantUtil.newLine, String.Empty).Replace(" ", String.Empty).Replace("\t", String.Empty) == text2.Replace(ConstantUtil.newLine, String.Empty).Replace(" ", String.Empty).Replace("\t", String.Empty)) { WindowManager.ShowAlertBox(form1, LanguageUtil.GetCurrentLanguageString("TabAlmostEquals_ReturnsAndSpaces", className)); } else { WindowManager.ShowAlertBox(form1, LanguageUtil.GetCurrentLanguageString("TabDifferents", className)); } }
private static void NoteModeOff(Form1 form) { MenuStrip menuStrip = form.menuStrip; ToolStrip toolStrip = form.toolStrip; XtraTabControl pagesTabControl = form.pagesTabControl; SplitContainer verticalSplitContainer = form.verticalSplitContainer; ToolStrip sessionToolStrip = form.sessionToolStrip; Panel searchReplacePanel = form.searchReplacePanel; StatusStrip statusStrip = form.statusStrip; PictureBox zoomPictureBox = form.zoomPictureBox; ZoomTrackBarControl zoomTrackBarControl = form.zoomTrackBarControl; ToolStripMenuItem closeToolStripMenuItem3 = form.closeToolStripMenuItem3; if (ConfigUtil.GetBoolParameter("NoteModeTabs")) { pagesTabControl.CustomHeaderButtons.AddRange(new[] { new CustomHeaderButton(ButtonPredefines.Ellipsis) }); } menuStrip.Visible = true; toolStrip.Visible = !ConfigUtil.GetBoolParameter("ToolbarInvisible"); pagesTabControl.ShowTabHeader = DefaultBoolean.True; pagesTabControl.ContextMenuStrip = form.pageContextMenuStrip; verticalSplitContainer.Panel1.Padding = new Padding(3, 0, 3, 0); sessionToolStrip.Visible = closeToolStripMenuItem3.Enabled; searchReplacePanel.Visible = !ConfigUtil.GetBoolParameter("SearchReplacePanelDisabled"); statusStrip.Visible = !ConfigUtil.GetBoolParameter("StatusBarInvisible"); zoomPictureBox.Visible = true; zoomTrackBarControl.Visible = true; form.TopMost = !ConfigUtil.GetBoolParameter("StayOnTopDisabled"); form.FormBorderStyle = FormBorderStyle.Sizable; #if Debug form.TopMost = false; #endif for (int i = 0; i < pagesTabControl.TabPages.Count; i++) { CustomLineNumbers customLineNumbers = ProgramUtil.GetCustomLineNumbers(pagesTabControl.TabPages[i]); CustomRichTextBox pageTextBox = ProgramUtil.GetPageTextBox(pagesTabControl.TabPages[i]); customLineNumbers.Visible = ConfigUtil.GetBoolParameter("LineNumbersVisible"); pageTextBox.WordWrap = !ConfigUtil.GetBoolParameter("WordWrapDisabled"); } if (CustomFilesManager.IsAnnotationPanelOpen(form)) { CustomFilesManager.ResumeAnnotationPanel(form); } form.WindowState = ConfigUtil.GetStringParameter("WindowState") == "Maximized" ? FormWindowState.Maximized : FormWindowState.Normal; form.Size = new Size(ConfigUtil.GetIntParameter("WindowSizeX"), ConfigUtil.GetIntParameter("WindowSizeY")); verticalSplitContainer.Panel2Collapsed = ConfigUtil.GetBoolParameter("InternalExplorerInvisible"); }
internal static bool OpenUrlSource(Form1 form, String url) { XtraTabControl pagesTabControl = form.pagesTabControl; CustomRichTextBox pageTextBox = ProgramUtil.GetPageTextBox(pagesTabControl.SelectedTabPage); if (!url.StartsWith("http://")) { url = "http://" + url; } WebClient webClient = null; String urlSource; try { webClient = ProxyUtil.InitWebClientProxy(); webClient.Encoding = EncodingUtil.GetDefaultEncoding(); urlSource = webClient.DownloadString(url); } catch (WebException) { WindowManager.ShowAlertBox(form, LanguageUtil.GetCurrentLanguageString("ErrorDownloading", className)); return(false); } finally { if (webClient != null) { webClient.Dispose(); } } if (String.IsNullOrEmpty(urlSource)) { WindowManager.ShowInfoBox(form, LanguageUtil.GetCurrentLanguageString("EmptySource", className)); return(false); } if (TabManager.IsCurrentTabInUse(form)) { form.TabIdentity = TabManager.AddNewPage(form, form.TabIdentity); pageTextBox = ProgramUtil.GetPageTextBox(pagesTabControl.SelectedTabPage); } //Row number check WindowManager.CheckLineNumbersForTextLenght_External(form, urlSource); pageTextBox.SelectedText = urlSource; TextManager.RefreshUndoRedoExternal(form); return(true); }