internal static void CheckLineNumbers(Form1 form, bool checkStatus, bool refreshConfig) { XtraTabControl pagesTabControl = form.pagesTabControl; ToolStripMenuItem lineNumbersToolStripMenuItem = form.lineNumbersToolStripMenuItem; ToolStripButton lineNumbersToolStripButton = form.lineNumbersToolStripButton; foreach (XtraTabPage tabPage in pagesTabControl.TabPages) { CustomLineNumbers customLineNumbers = ProgramUtil.GetCustomLineNumbers(tabPage); customLineNumbers.Visible = checkStatus; ColumnRulerManager.UpdatePanelAppearance(tabPage, checkStatus); if (!checkStatus) { continue; } customLineNumbers.Size = new Size(customLineNumbers.Size.Width + 1, customLineNumbers.Size.Height); customLineNumbers.Size = new Size(customLineNumbers.Size.Width - 1, customLineNumbers.Size.Height); } lineNumbersToolStripMenuItem.Checked = checkStatus; lineNumbersToolStripButton.Checked = checkStatus; UpdateConfigParameter("LineNumbersVisible", checkStatus.ToString(), refreshConfig); }
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 void RestoreFormFromTray(Form1 form, FormWindowState previousWindowState) { NotifyIcon notifyIcon = form.notifyIcon; XtraTabControl pagesTabControl = form.pagesTabControl; CustomLineNumbers customLineNumbers = ProgramUtil.GetCustomLineNumbers(pagesTabControl.SelectedTabPage); if (form.Visible) { return; } form.Visible = true; notifyIcon.Visible = false; form.WindowState = previousWindowState; customLineNumbers.Refresh(); form.BringToFront(); }
internal static void UpdatePanelAppearance(XtraTabPage tabPage, bool customLineNumbersVisible) { CustomRichTextBox pageTextBox = ProgramUtil.GetPageTextBox(tabPage); CustomLineNumbers customLineNumbers = ProgramUtil.GetCustomLineNumbers(tabPage); CustomPanel columnRulerPanel = (CustomPanel)tabPage.Controls["columnRulerPanel"]; if (columnRulerPanel == null) { return; } pageTextBox.Size = new Size(pageTextBox.Size.Width + 1, pageTextBox.Size.Height); pageTextBox.Size = new Size(pageTextBox.Size.Width - 1, pageTextBox.Size.Height); RichTextBox columnRulerTextBox = (RichTextBox)columnRulerPanel.Controls["columnRulerTextBox"]; columnRulerTextBox.Width = pageTextBox.Width + 1; columnRulerTextBox.Left = customLineNumbersVisible ? customLineNumbers.Width : 0; //columnRulerPanel.MarginLeftHorizontalLine = tabPage.Width - columnRulerTextBox.Width - 5; columnRulerPanel.MarginLeftHorizontalLine = columnRulerTextBox.Left; columnRulerPanel.Refresh(); }
internal static void ResetTab(Form1 form) { XtraTabControl pagesTabControl = form.pagesTabControl; CustomRichTextBox pageTextBox = ProgramUtil.GetPageTextBox(pagesTabControl.SelectedTabPage); CustomLineNumbers customLineNumbers = ProgramUtil.GetCustomLineNumbers(pagesTabControl.SelectedTabPage); if (ColumnRulerManager.IsPanelOpen(form)) { ColumnRulerManager.TogglePanel(form); } String newTabTitle = LanguageUtil.GetCurrentLanguageString("tabPage1", form.Name); SetTabColor(pagesTabControl.SelectedTabPage, Color.Black); //pagesTabControl.SelectedTabPage.Appearance.Header.ForeColor = Color.Black; pagesTabControl.SelectedTabPage.Appearance.Header.Reset(); pageTextBox.Text = String.Empty; pagesTabControl.SelectedTabPage.ImageIndex = 0; pagesTabControl.SelectedTabPage.Text = newTabTitle; pagesTabControl.SelectedTabPage.Tooltip = newTabTitle; form.Text = String.Format("DtPad - {0}", newTabTitle); ProgramUtil.SetFilenameTabPage(pagesTabControl.SelectedTabPage, String.Empty); pageTextBox.CustomZoom = 100; pageTextBox.CustomModified = false; pageTextBox.CustomOriginal = String.Empty.GetHashCode().ToString(); pageTextBox.CustomEncoding = String.Empty; pageTextBox.CustomEncodingForced = false; customLineNumbers.Width = customLineNumbers.MinimumSize.Width; ZoomSelect(form, 100); pageTextBox.ClearUndo(); TextManager.RefreshUndoRedoExternal(form); if (String.IsNullOrEmpty(ProgramUtil.GetFilenameTabPage(pagesTabControl.SelectedTabPage))) { ToggleTabFileTools(form, false); } OtherManager.FocusOnEditor(form); }
internal static int AddNewPage(Form1 form, int tabIdentity) { XtraTabControl pagesTabControl = form.pagesTabControl; ToolStripMenuItem wordWrapToolStripMenuItem = form.wordWrapToolStripMenuItem; ToolStripMenuItem lineNumbersToolStripMenuItem = form.lineNumbersToolStripMenuItem; ContextMenuStrip textBoxContextMenuStrip = form.textBoxContextMenuStrip; bool rowNumbersVisibile = lineNumbersToolStripMenuItem.Checked; bool wordWrapEnabled = wordWrapToolStripMenuItem.Checked; if (form.WindowMode == CustomForm.WindowModeEnum.Note) { rowNumbersVisibile = false; wordWrapEnabled = true; } String newTabTitle = LanguageUtil.GetCurrentLanguageString("tabPage1", form.Name); tabIdentity++; String newTabPageName = String.Format("tabPage{0}", tabIdentity); XtraTabPage newTabPageControl = new XtraTabPage { ImageIndex = 0, Name = newTabPageName, Padding = new Padding(3), Text = newTabTitle, Tooltip = newTabTitle }; //newTabPageControl.Appearance.Header.ForeColor = Color.Black; //newTabPageControl.Appearance.PageClient.BackColor = Color.White; newTabPageControl.TextChanged += form.tabPage_TextChanged; CustomRichTextBox newTabPageTextBox = new CustomRichTextBox { AcceptsTab = true, AllowDrop = true, AutoWordSelection = false, BackColor = form.TextBackgroundColor, BorderStyle = BorderStyle.None, ContextMenuStrip = textBoxContextMenuStrip, CustomEncodingForced = false, CustomInsertMode = "INS", CustomModified = false, CustomOriginal = String.Empty.GetHashCode().ToString(), CustomZoom = 100, DetectUrls = ConfigUtil.GetBoolParameter("HighlightURL"), Dock = DockStyle.Fill, Font = form.TextFont, ForeColor = form.TextFontColor, HideSelection = false, //Multiline = true, Name = "pageTextBox", //ScrollBars = RichTextBoxScrollBars.Both, Text = String.Empty, WordWrap = wordWrapEnabled }; newTabPageControl.Controls.Add(newTabPageTextBox); CustomLineNumbers customLineNumbers = new CustomLineNumbers { AutoSizing = true, BackColor = form.TextBackgroundColor, BackgroundGradient_AlphaColor = Color.FromArgb(0, 0, 0, 0), BackgroundGradient_BetaColor = SystemColors.Window, BackgroundGradient_Direction = LinearGradientMode.Horizontal, BorderLines_Color = Color.DeepSkyBlue, BorderLines_Style = DashStyle.Solid, BorderLines_Thickness = 1F, Dock = DockStyle.Left, DockSide = CustomLineNumbers.LineNumberDockSide.Left, Font = form.TextFont, ForeColor = SystemColors.AppWorkspace, GridLines_Color = Color.DeepSkyBlue, GridLines_Style = DashStyle.Solid, GridLines_Thickness = 1F, LineNrs_Alignment = ContentAlignment.TopRight, LineNrs_AntiAlias = false, LineNrs_ClippedByItemRectangle = true, LineNrs_Offset = new Size(0, 0), Location = new Point(3, 3), Margin = new Padding(0), MarginLines_Color = Color.DeepSkyBlue, MarginLines_Side = CustomLineNumbers.LineNumberDockSide.Right, MarginLines_Style = DashStyle.Dash, MarginLines_Thickness = 1F, MinimumSize = new Size(47, 0), Name = "customLineNumbers", Padding = new Padding(0, 0, 7, 0), ParentRichTextBox = newTabPageTextBox, Show_LineNrs = true, Show_MarginLines = true, Size = new Size(47, 308), TabIndex = 2, Visible = rowNumbersVisibile }; newTabPageControl.Controls.Add(customLineNumbers); Label newTabPageLabel = new Label { AutoSize = true, Location = new Point(3, 3), Name = "filenameTabPage", Size = new Size(0, 13), Visible = false }; newTabPageLabel.TextChanged += form.filenameTabPage_TextChanged; newTabPageControl.Controls.Add(newTabPageLabel); pagesTabControl.TabPages.Add(newTabPageControl); pagesTabControl.SelectedTabPage = newTabPageControl; ExplorerManager.AddNodeToTabExplorer(form, newTabPageControl.Text, newTabPageControl.Name, 0, 0); OtherManager.FocusOnEditor(form); WindowModeManager.AddRelaxModeMargins(form); return(tabIdentity); }
private static void NoteModeOn(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; if (ConfigUtil.GetBoolParameter("NoteModeTabs")) { ContextMenuStrip smallPageContextMenuStrip = new ContextMenuStrip(); for (int i = 0; i < 2; i++) { smallPageContextMenuStrip.Items.Add( ((CustomToolStripMenuItem)form.pageContextMenuStrip.Items[i]).Clone()); } pagesTabControl.ContextMenuStrip = smallPageContextMenuStrip; pagesTabControl.CustomHeaderButtons.Clear(); } else { pagesTabControl.ContextMenuStrip = null; pagesTabControl.ShowTabHeader = DefaultBoolean.False; } menuStrip.Visible = false; toolStrip.Visible = false; verticalSplitContainer.Panel1.Padding = new Padding(0, 0, 0, 0); verticalSplitContainer.Panel2Collapsed = true; sessionToolStrip.Visible = false; searchReplacePanel.Visible = false; statusStrip.Visible = false; zoomPictureBox.Visible = false; zoomTrackBarControl.Visible = false; form.TopMost = true; form.FormBorderStyle = FormBorderStyle.SizableToolWindow; #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]); if (ColumnRulerManager.IsPanelOpen(pagesTabControl.TabPages[i])) { ColumnRulerManager.ClosePanel(pagesTabControl.TabPages[i]); } customLineNumbers.Visible = false; pageTextBox.WordWrap = true; } form.WindowState = FormWindowState.Normal; form.Size = new Size(ConfigUtil.GetIntParameter("NoteModeSizeX"), ConfigUtil.GetIntParameter("NoteModeSizeY")); if (CustomFilesManager.IsHostsSectionPanelOpen(form)) { form.Width += ConstantUtil.hostsPanelWidth; //ProgramUtil.GetSectionsPanel(pagesTabControl.SelectedTabPage).Width; } if (CustomFilesManager.IsAnnotationPanelOpen(form)) { CustomFilesManager.HideAnnotationPanel(form); } }
private static void OpenPanel(Form1 form, XtraTabPage tabPage) { CustomRichTextBox pageTextBox = ProgramUtil.GetPageTextBox(tabPage); CustomLineNumbers customLineNumbers = ProgramUtil.GetCustomLineNumbers(tabPage); bool wasHostsSectionOpen = false; if (CustomFilesManager.IsHostsSectionPanelOpen(form)) { wasHostsSectionOpen = true; CustomFilesManager.ToggleHostsSectionPanel(form, true); } String annotationText = String.Empty; if (CustomFilesManager.IsAnnotationPanelOpen(form)) { annotationText = CustomFilesManager.GetAnnotationPanelText(form); CustomFilesManager.ToggleAnnotationPanel(form, true); } int left = 0; if (ConfigUtil.GetBoolParameter("LineNumbersVisible")) { left = customLineNumbers.Width; } //Panel RichTextBox columnRulerTextBox = new RichTextBox { Anchor = AnchorStyles.Top | AnchorStyles.Right | AnchorStyles.Bottom | AnchorStyles.Left, BackColor = pageTextBox.BackColor, BorderStyle = BorderStyle.None, Font = pageTextBox.Font, //ForeColor = pageTextBox.ForeColor, ForeColor = SystemColors.AppWorkspace, Height = Convert.ToInt32(pageTextBox.Font.GetHeight() * 2 + 5), //35 Left = left, Multiline = true, Name = "columnRulerTextBox", ReadOnly = true, ScrollBars = RichTextBoxScrollBars.None, ShortcutsEnabled = false, Text = ConstantUtil.columnsHeader, Width = pageTextBox.Width + 1, WordWrap = false }; CustomPanel columnRulerPanel = new CustomPanel { Dock = DockStyle.Top, Height = columnRulerTextBox.Height + 1, Name = "columnRulerPanel", Width = tabPage.Width, HorizontalLine = true, MarginLeftHorizontalLine = tabPage.Width - columnRulerTextBox.Width - 5 }; columnRulerPanel.Controls.Add(columnRulerTextBox); tabPage.Controls.Add(columnRulerPanel); if (wasHostsSectionOpen) { CustomFilesManager.ToggleHostsSectionPanel(form, true); } if (!String.IsNullOrEmpty(annotationText)) { CustomFilesManager.ToggleAnnotationPanel(form); CustomFilesManager.SetAnnotationPanelText(form, annotationText); } pageTextBox.Focus(); }
internal static void RefreshOwner(Options form, bool closeOptionsAfterSave, Font previousFont, Font font, Color previousFontColor, Color fontColor, Color previousBackgroundColor, Color backgroundColor, bool previousHighlightURL, String previousLanguage, bool previousJumpListActivated) { Form1 form1 = (Form1)form.Owner; XtraTabControl pagesTabControl = form1.pagesTabControl; CheckBox caseCheckBox = form1.searchPanel.caseCheckBox; CheckBox loopCheckBox = form1.searchPanel.loopCheckBox; ToolStrip sessionToolStrip = form1.sessionToolStrip; ToolStripMenuItem useDefaultToolStripMenuItem = form1.useDefaultToolStripMenuItem; CheckBox showSearchPanelCheckBox = form.showSearchPanelCheckBox; CheckBox wordWrapCheckBox = form.wordWrapCheckBox; CheckBox stayOnTopCheckBox = form.stayOnTopCheckBox; CheckBox toolbarCheckBox = form.toolbarCheckBox; CheckBox statusBarCheckBox = form.statusBarCheckBox; CheckBox minimizeOnTrayIconCheckBox = form.minimizeOnTrayIconCheckBox; CheckBox caseSensitiveCheckBox = form.caseSensitiveCheckBox; CheckBox loopAtEOFCheckBox = form.loopAtEOFCheckBox; CheckBox urlsCheckBox = form.urlsCheckBox; ImageComboBoxEdit languageComboBox = form.languageComboBox; CheckBox internalExplorerCheckBox = form.internalExplorerCheckBox; ComboBox tabCloseButtonOnComboBox = form.tabCloseButtonOnComboBox; ComboBox tabPositionComboBox = form.tabPositionComboBox; ComboBox tabOrientationComboBox = form.tabOrientationComboBox; CheckBox tabMultilineCheckBox = form.tabMultilineCheckBox; CheckBox useExistingCheckBox = form.useExistingCheckBox; ComboBox defaultComboBox = form.defaultComboBox; CheckBox lineNumbersCheckBox = form.lineNumbersCheckBox; CheckBox keepInitialSpacesOnReturnCheckBox = form.keepInitialSpacesOnReturnCheckBox; CheckBox keepBulletListOnReturnCheckBox = form.keepBulletListOnReturnCheckBox; CheckBox jumpListCheckBox = form.jumpListCheckBox; WindowManager.CheckSearchReplacePanel(form1, showSearchPanelCheckBox.Checked, true); //form1.searchPanel.Visible WindowManager.CheckWordWrap(form1, !wordWrapCheckBox.Checked, false); if (form1.WindowMode == CustomForm.WindowModeEnum.Fullscreen) { WindowManager.CheckStayOnTop(form1, !stayOnTopCheckBox.Checked, false); } WindowManager.CheckToolbar(form1, !toolbarCheckBox.Checked, true, false); WindowManager.CheckStatusBar(form1, !statusBarCheckBox.Checked, true, false); WindowManager.CheckTrayIcon(form1, !minimizeOnTrayIconCheckBox.Checked, false); WindowManager.CheckSearchCaseSensitive(caseSensitiveCheckBox.Checked, caseCheckBox, false); WindowManager.CheckSearchLoop(loopAtEOFCheckBox.Checked, loopCheckBox, false); WindowManager.CheckInternalExplorer(form1, internalExplorerCheckBox.Checked, false); WindowManager.CheckDefaultEncoding(form1, useExistingCheckBox.Checked, false); WindowManager.CheckEncoding(form1, defaultComboBox.SelectedIndex, false); WindowManager.CheckLineNumbers(form1, lineNumbersCheckBox.Checked, false); FileListManager.RefreshRecentFiles(form1); FileListManager.RefreshSearchHistory(form1); if ((previousJumpListActivated != jumpListCheckBox.Checked) && !jumpListCheckBox.Checked) { SystemUtil.ClearWindowsJumpList(form1); } else if ((previousJumpListActivated != jumpListCheckBox.Checked) && jumpListCheckBox.Checked) { SystemUtil.SetWindowsJumpList(form1); } //If session is open and don't use default aspect, it will do nothing if (!sessionToolStrip.Visible || (sessionToolStrip.Visible && useDefaultToolStripMenuItem.Checked)) { CheckTabCloseButton(form1, tabCloseButtonOnComboBox.SelectedIndex); CheckTabPosition(form1, tabPositionComboBox.SelectedIndex); CheckTabOrientation(form1, tabOrientationComboBox.SelectedIndex); } CheckTabMultiline(form1, tabMultilineCheckBox.Checked); form1.KeepInitialSpacesOnReturn = keepInitialSpacesOnReturnCheckBox.Checked; form1.KeepBulletListOnReturn = keepBulletListOnReturnCheckBox.Checked; if (!previousFont.Equals(font) || previousFontColor != fontColor || previousBackgroundColor != backgroundColor || previousHighlightURL != urlsCheckBox.Checked) { foreach (XtraTabPage tabPage in pagesTabControl.TabPages) { CustomRichTextBox pageTextBox = ProgramUtil.GetPageTextBox(tabPage); CustomLineNumbers customLineNumbers = ProgramUtil.GetCustomLineNumbers(tabPage); pageTextBox.Font = font; customLineNumbers.Font = font; pageTextBox.ForeColor = fontColor; pageTextBox.BackColor = backgroundColor; customLineNumbers.BackColor = backgroundColor; pageTextBox.DetectUrls = urlsCheckBox.Checked; } form1.SetMainFont(font); form1.TextFontColor = fontColor; form1.TextBackgroundColor = backgroundColor; } LookFeelUtil.SetForm1LookAndFeel(form1); //if (!closeOptionsAfterSave) //{ // LookFeelUtil.SetOptionsLookAndFeel(form); //} if (previousLanguage == languageComboBox.SelectedItem.ToString()) { return; } ConfigUtil.UpdateParameter("RecreateJumpList", true.ToString()); if (!closeOptionsAfterSave) { form.SetLanguage(); } form1.SetLanguage(true); }