From bbd488875f347ca712ef8317e369ace27b030716 Mon Sep 17 00:00:00 2001 From: Alexander Date: Wed, 21 Aug 2019 12:23:51 +0300 Subject: [PATCH] Resolved #23 --- Crypto Notepad/AboutFrom.Designer.cs | 6 +- Crypto Notepad/AboutFrom.resx | 6 +- Crypto Notepad/App.config | 27 + Crypto Notepad/Crypto Notepad.csproj | 4 + Crypto Notepad/MainForm.Designer.cs | 62 +- Crypto Notepad/MainForm.cs | 29 +- .../Properties/Settings.Designer.cs | 118 +- Crypto Notepad/Properties/Settings.settings | 29 +- Crypto Notepad/SettingsForm.Designer.cs | 442 +++++-- Crypto Notepad/SettingsForm.cs | 103 ++ Crypto Notepad/linenum_rtf.cs | 1118 +++++++++++++++++ 11 files changed, 1845 insertions(+), 99 deletions(-) create mode 100644 Crypto Notepad/linenum_rtf.cs diff --git a/Crypto Notepad/AboutFrom.Designer.cs b/Crypto Notepad/AboutFrom.Designer.cs index b5346ba..7b1d7f8 100644 --- a/Crypto Notepad/AboutFrom.Designer.cs +++ b/Crypto Notepad/AboutFrom.Designer.cs @@ -170,10 +170,10 @@ private void InitializeComponent() this.TPDRichTextBox.Location = new System.Drawing.Point(0, 181); this.TPDRichTextBox.Name = "TPDRichTextBox"; this.TPDRichTextBox.ReadOnly = true; - this.TPDRichTextBox.RightMargin = 600; + this.TPDRichTextBox.RightMargin = 700; this.TPDRichTextBox.ScrollBars = System.Windows.Forms.RichTextBoxScrollBars.Horizontal; this.TPDRichTextBox.ShowSelectionMargin = true; - this.TPDRichTextBox.Size = new System.Drawing.Size(398, 100); + this.TPDRichTextBox.Size = new System.Drawing.Size(400, 121); this.TPDRichTextBox.TabIndex = 8; this.TPDRichTextBox.TabStop = false; this.TPDRichTextBox.Text = resources.GetString("TPDRichTextBox.Text"); @@ -185,7 +185,7 @@ private void InitializeComponent() this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(45)))), ((int)(((byte)(45)))), ((int)(((byte)(50))))); - this.ClientSize = new System.Drawing.Size(398, 281); + this.ClientSize = new System.Drawing.Size(397, 302); this.Controls.Add(this.GithubLinkLabel); this.Controls.Add(this.LicenseLinkLabel); this.Controls.Add(this.AuthorLinkLabel); diff --git a/Crypto Notepad/AboutFrom.resx b/Crypto Notepad/AboutFrom.resx index 8b387e8..1cff176 100644 --- a/Crypto Notepad/AboutFrom.resx +++ b/Crypto Notepad/AboutFrom.resx @@ -368,12 +368,14 @@ - CustomSettingsProvider: http://www.codeproject.com/Articles/20917/Settings-Provider + Line Numbers for RichTextBox: https://www.codeproject.com/Articles/38858/Line-Numbers-for-RichText-Control-in-C +CustomSettingsProvider: http://www.codeproject.com/Articles/20917/Settings-Provider MsgBoxCenterParent: http://stackoverflow.com/a/2576220/4430027 CustomRichTextBox: https://code.msdn.microsoft.com/windowsdesktop/How-to-find-the-text-and-e92b8d78 DotNetZip: https://www.nuget.org/packages/DotNetZip/ Icons: http://p.yusukekamiyamane.com/ -AES: http://www.codeproject.com/Answers/391219/AES#answer2 +AES: http://www.codeproject.com/Answers/391219/AES#answer2 + 44 diff --git a/Crypto Notepad/App.config b/Crypto Notepad/App.config index af4c303..fe63d01 100644 --- a/Crypto Notepad/App.config +++ b/Crypto Notepad/App.config @@ -84,6 +84,33 @@ False + + True + + + 53, 53, 53 + + + 164, 164, 164 + + + False + + + 164, 164, 164 + + + Solid + + + False + + + 164, 164, 164 + + + Solid + Enable diff --git a/Crypto Notepad/Crypto Notepad.csproj b/Crypto Notepad/Crypto Notepad.csproj index ee232b8..ad5d99f 100644 --- a/Crypto Notepad/Crypto Notepad.csproj +++ b/Crypto Notepad/Crypto Notepad.csproj @@ -76,6 +76,7 @@ false + @@ -109,6 +110,9 @@ CustomRichTextBox.cs + + Component + Form diff --git a/Crypto Notepad/MainForm.Designer.cs b/Crypto Notepad/MainForm.Designer.cs index 73f831c..c6efca3 100644 --- a/Crypto Notepad/MainForm.Designer.cs +++ b/Crypto Notepad/MainForm.Designer.cs @@ -101,6 +101,8 @@ public void InitializeComponent() this.SaveToolBarButton = new System.Windows.Forms.PictureBox(); this.OpenToolbarButton = new System.Windows.Forms.PictureBox(); this.CustomRTB = new Crypto_Notepad.CustomRichTextBox(); + this.LineNumbers_For_RichTextBox = new LineNumbers.LineNumbers_For_RichTextBox(); + this.insertToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.MainMenu.SuspendLayout(); this.EditorMenuStrip.SuspendLayout(); this.SearchPanel.SuspendLayout(); @@ -439,7 +441,8 @@ public void InitializeComponent() // this.DebugToolStripMenuItem.Alignment = System.Windows.Forms.ToolStripItemAlignment.Right; this.DebugToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.MainVariablesToolStripMenuItem}); + this.MainVariablesToolStripMenuItem, + this.insertToolStripMenuItem}); this.DebugToolStripMenuItem.Name = "DebugToolStripMenuItem"; this.DebugToolStripMenuItem.Size = new System.Drawing.Size(55, 24); this.DebugToolStripMenuItem.Text = "Debug"; @@ -673,7 +676,7 @@ public void InitializeComponent() this.CloseToolbar.Cursor = System.Windows.Forms.Cursors.Hand; this.CloseToolbar.Image = global::Crypto_Notepad.Properties.Resources.close_g; this.CloseToolbar.ImeMode = System.Windows.Forms.ImeMode.NoControl; - this.CloseToolbar.Location = new System.Drawing.Point(492, 5); + this.CloseToolbar.Location = new System.Drawing.Point(497, 5); this.CloseToolbar.Name = "CloseToolbar"; this.CloseToolbar.Size = new System.Drawing.Size(14, 14); this.CloseToolbar.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom; @@ -834,9 +837,9 @@ public void InitializeComponent() this.CustomRTB.Dock = System.Windows.Forms.DockStyle.Fill; this.CustomRTB.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F); this.CustomRTB.ForeColor = System.Drawing.SystemColors.WindowText; - this.CustomRTB.Location = new System.Drawing.Point(0, 47); + this.CustomRTB.Location = new System.Drawing.Point(18, 47); this.CustomRTB.Name = "CustomRTB"; - this.CustomRTB.Size = new System.Drawing.Size(513, 244); + this.CustomRTB.Size = new System.Drawing.Size(495, 244); this.CustomRTB.TabIndex = 10; this.CustomRTB.Text = ""; this.CustomRTB.LinkClicked += new System.Windows.Forms.LinkClickedEventHandler(this.СustomRTB_LinkClicked); @@ -845,12 +848,61 @@ public void InitializeComponent() this.CustomRTB.KeyDown += new System.Windows.Forms.KeyEventHandler(this.CustomRTB_KeyDown); this.CustomRTB.KeyUp += new System.Windows.Forms.KeyEventHandler(this.CustomRTB_KeyUp); // + // LineNumbers_For_RichTextBox + // + this.LineNumbers_For_RichTextBox._SeeThroughMode_ = false; + this.LineNumbers_For_RichTextBox.AutoSizing = true; + this.LineNumbers_For_RichTextBox.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(240)))), ((int)(((byte)(240)))), ((int)(((byte)(240))))); + this.LineNumbers_For_RichTextBox.BackgroundGradient_AlphaColor = System.Drawing.Color.FromArgb(((int)(((byte)(240)))), ((int)(((byte)(240)))), ((int)(((byte)(240))))); + this.LineNumbers_For_RichTextBox.BackgroundGradient_BetaColor = System.Drawing.Color.FromArgb(((int)(((byte)(240)))), ((int)(((byte)(240)))), ((int)(((byte)(240))))); + this.LineNumbers_For_RichTextBox.BackgroundGradient_Direction = System.Drawing.Drawing2D.LinearGradientMode.Horizontal; + this.LineNumbers_For_RichTextBox.BorderLines_Color = System.Drawing.Color.Transparent; + this.LineNumbers_For_RichTextBox.BorderLines_Style = System.Drawing.Drawing2D.DashStyle.Solid; + this.LineNumbers_For_RichTextBox.BorderLines_Thickness = 1F; + this.LineNumbers_For_RichTextBox.Dock = System.Windows.Forms.DockStyle.Left; + this.LineNumbers_For_RichTextBox.DockSide = LineNumbers.LineNumbers_For_RichTextBox.LineNumberDockSide.Left; + this.LineNumbers_For_RichTextBox.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(204))); + this.LineNumbers_For_RichTextBox.ForeColor = System.Drawing.SystemColors.ActiveCaptionText; + this.LineNumbers_For_RichTextBox.GridLines_Color = System.Drawing.Color.Transparent; + this.LineNumbers_For_RichTextBox.GridLines_Style = System.Drawing.Drawing2D.DashStyle.Solid; + this.LineNumbers_For_RichTextBox.GridLines_Thickness = 1F; + this.LineNumbers_For_RichTextBox.LineNrs_Alignment = System.Drawing.ContentAlignment.TopCenter; + this.LineNumbers_For_RichTextBox.LineNrs_AntiAlias = true; + this.LineNumbers_For_RichTextBox.LineNrs_AsHexadecimal = false; + this.LineNumbers_For_RichTextBox.LineNrs_ClippedByItemRectangle = true; + this.LineNumbers_For_RichTextBox.LineNrs_LeadingZeroes = false; + this.LineNumbers_For_RichTextBox.LineNrs_Offset = new System.Drawing.Size(0, 0); + this.LineNumbers_For_RichTextBox.Location = new System.Drawing.Point(0, 47); + this.LineNumbers_For_RichTextBox.Margin = new System.Windows.Forms.Padding(0); + this.LineNumbers_For_RichTextBox.MarginLines_Color = System.Drawing.Color.Transparent; + this.LineNumbers_For_RichTextBox.MarginLines_Side = LineNumbers.LineNumbers_For_RichTextBox.LineNumberDockSide.Height; + this.LineNumbers_For_RichTextBox.MarginLines_Style = System.Drawing.Drawing2D.DashStyle.Solid; + this.LineNumbers_For_RichTextBox.MarginLines_Thickness = 1F; + this.LineNumbers_For_RichTextBox.Name = "LineNumbers_For_RichTextBox"; + this.LineNumbers_For_RichTextBox.Padding = new System.Windows.Forms.Padding(0, 0, 2, 0); + this.LineNumbers_For_RichTextBox.ParentRichTextBox = this.CustomRTB; + this.LineNumbers_For_RichTextBox.Show_BackgroundGradient = false; + this.LineNumbers_For_RichTextBox.Show_BorderLines = true; + this.LineNumbers_For_RichTextBox.Show_GridLines = true; + this.LineNumbers_For_RichTextBox.Show_LineNrs = true; + this.LineNumbers_For_RichTextBox.Show_MarginLines = false; + this.LineNumbers_For_RichTextBox.Size = new System.Drawing.Size(18, 244); + this.LineNumbers_For_RichTextBox.TabIndex = 15; + // + // insertToolStripMenuItem + // + this.insertToolStripMenuItem.Name = "insertToolStripMenuItem"; + this.insertToolStripMenuItem.Size = new System.Drawing.Size(213, 22); + this.insertToolStripMenuItem.Text = "Insert"; + this.insertToolStripMenuItem.Visible = false; + // // MainForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(513, 318); this.Controls.Add(this.CustomRTB); + this.Controls.Add(this.LineNumbers_For_RichTextBox); this.Controls.Add(this.SearchPanel); this.Controls.Add(this.ToolbarPanel); this.Controls.Add(this.MainMenu); @@ -962,5 +1014,7 @@ public void InitializeComponent() private System.Windows.Forms.ToolStripMenuItem RedoEditorMenuStrip; private System.Windows.Forms.ToolStripMenuItem DebugToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem MainVariablesToolStripMenuItem; + private LineNumbers.LineNumbers_For_RichTextBox LineNumbers_For_RichTextBox; + private System.Windows.Forms.ToolStripMenuItem insertToolStripMenuItem; } } diff --git a/Crypto Notepad/MainForm.cs b/Crypto Notepad/MainForm.cs index cc87b8b..21137bb 100644 --- a/Crypto Notepad/MainForm.cs +++ b/Crypto Notepad/MainForm.cs @@ -1,4 +1,4 @@ -using IWshRuntimeLibrary; +using IWshRuntimeLibrary; using System; using System.ComponentModel; using System.Diagnostics; @@ -591,6 +591,19 @@ private void MainWindow_Activated(object sender, EventArgs e) CustomRTB.BackColor = ps.RichBackColor; BackColor = ps.RichBackColor; + LineNumbers_For_RichTextBox.Visible = bool.Parse(ps.LNVisible); + LineNumbers_For_RichTextBox.BackColor = ps.LNBackgroundColor; + LineNumbers_For_RichTextBox.ForeColor = ps.LNFontColorPanel; + LineNumbers_For_RichTextBox.Font = new Font(ps.RichTextFont, ps.RichTextSize); + + LineNumbers_For_RichTextBox.Show_BorderLines = bool.Parse(ps.BLShow); + LineNumbers_For_RichTextBox.BorderLines_Color = ps.BLColor; + LineNumbers_For_RichTextBox.BorderLines_Style = ps.BLStyle; + + LineNumbers_For_RichTextBox.Show_GridLines = bool.Parse(ps.GLShow); + LineNumbers_For_RichTextBox.GridLines_Color = ps.GLColor; + LineNumbers_For_RichTextBox.GridLines_Style = ps.GLStyle; + if (ps.InserKey == "Disable") { insertToolStripMenuItem.ShortcutKeys = Keys.Insert; @@ -599,6 +612,7 @@ private void MainWindow_Activated(object sender, EventArgs e) { insertToolStripMenuItem.ShortcutKeys = Keys.None; } + if (ps.SendTo) { SendToShortcut(); @@ -705,6 +719,19 @@ private void MainWindow_Load(object sender, EventArgs e) WordWrapToolStripMenuItem.Checked = ps.MenuWrap; CustomRTB.WordWrap = ps.RichWrap; ToolbarPanel.Visible = ps.ShowToolbar; + LineNumbers_For_RichTextBox.Visible = bool.Parse(ps.LNVisible); + LineNumbers_For_RichTextBox.ForeColor = ps.LNFontColorPanel; + LineNumbers_For_RichTextBox.BackColor = ps.LNBackgroundColor; + + LineNumbers_For_RichTextBox.Show_BorderLines = bool.Parse(ps.BLShow); + LineNumbers_For_RichTextBox.BorderLines_Color = ps.BLColor; + LineNumbers_For_RichTextBox.BorderLines_Style = ps.BLStyle; + + LineNumbers_For_RichTextBox.Show_GridLines = bool.Parse(ps.GLShow); + LineNumbers_For_RichTextBox.GridLines_Color = ps.GLColor; + LineNumbers_For_RichTextBox.GridLines_Style = ps.GLStyle; + + LineNumbers_For_RichTextBox.Font = new Font(ps.RichTextFont, ps.RichTextSize); if (ps.InserKey == "Disable") { diff --git a/Crypto Notepad/Properties/Settings.Designer.cs b/Crypto Notepad/Properties/Settings.Designer.cs index 1c45b7e..0b3b3c1 100644 --- a/Crypto Notepad/Properties/Settings.Designer.cs +++ b/Crypto Notepad/Properties/Settings.Designer.cs @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // Этот код создан программой. // Исполняемая версия:4.0.30319.42000 @@ -346,16 +346,124 @@ public bool ColoredToolbar { this["ColoredToolbar"] = value; } } - [global::System.Configuration.UserScopedSettingAttribute()] - [global::System.Configuration.UserScopedSettingAttribute()] - [global::System.Configuration.UserScopedSettingAttribute()] - [global::System.Configuration.SettingsProviderAttribute(typeof(PortableSettingsProvider))] + [global::System.Configuration.UserScopedSettingAttribute()] [global::System.Configuration.SettingsProviderAttribute(typeof(PortableSettingsProvider))] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("True")] + public string LNVisible { + get { + return ((string)(this["LNVisible"])); + } set { + this["LNVisible"] = value; + } + } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Configuration.SettingsProviderAttribute(typeof(PortableSettingsProvider))] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("53, 53, 53")] + public global::System.Drawing.Color LNBackgroundColor { + get { + return ((global::System.Drawing.Color)(this["LNBackgroundColor"])); + } + set { + this["LNBackgroundColor"] = value; + } + } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Configuration.SettingsProviderAttribute(typeof(PortableSettingsProvider))] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("164, 164, 164")] + public global::System.Drawing.Color LNFontColorPanel { + get { + return ((global::System.Drawing.Color)(this["LNFontColorPanel"])); + } + set { + this["LNFontColorPanel"] = value; + } + } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Configuration.SettingsProviderAttribute(typeof(PortableSettingsProvider))] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("False")] + public string BLShow { + get { + return ((string)(this["BLShow"])); + } + set { + this["BLShow"] = value; + } + } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Configuration.SettingsProviderAttribute(typeof(PortableSettingsProvider))] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("164, 164, 164")] + public global::System.Drawing.Color BLColor { + get { + return ((global::System.Drawing.Color)(this["BLColor"])); + } + set { + this["BLColor"] = value; + } + } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Configuration.SettingsProviderAttribute(typeof(PortableSettingsProvider))] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("Solid")] + public global::System.Drawing.Drawing2D.DashStyle BLStyle { + get { + return ((global::System.Drawing.Drawing2D.DashStyle)(this["BLStyle"])); + } + set { + this["BLStyle"] = value; + } + } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Configuration.SettingsProviderAttribute(typeof(PortableSettingsProvider))] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("False")] + public string GLShow { + get { + return ((string)(this["GLShow"])); + } + set { + this["GLShow"] = value; + } + } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Configuration.SettingsProviderAttribute(typeof(PortableSettingsProvider))] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("164, 164, 164")] + public global::System.Drawing.Color GLColor { + get { + return ((global::System.Drawing.Color)(this["GLColor"])); + } + set { + this["GLColor"] = value; + } + } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Configuration.SettingsProviderAttribute(typeof(PortableSettingsProvider))] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("Solid")] + public global::System.Drawing.Drawing2D.DashStyle GLStyle { + get { + return ((global::System.Drawing.Drawing2D.DashStyle)(this["GLStyle"])); + } + set { + this["GLStyle"] = value; + } + } + [global::System.Configuration.UserScopedSettingAttribute()] [global::System.Configuration.SettingsProviderAttribute(typeof(PortableSettingsProvider))] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] diff --git a/Crypto Notepad/Properties/Settings.settings b/Crypto Notepad/Properties/Settings.settings index 1717c44..f32051d 100644 --- a/Crypto Notepad/Properties/Settings.settings +++ b/Crypto Notepad/Properties/Settings.settings @@ -1,4 +1,4 @@ - + @@ -77,6 +77,33 @@ False + + True + + + 53, 53, 53 + + + 164, 164, 164 + + + False + + + 164, 164, 164 + + + Solid + + + False + + + 164, 164, 164 + + + Solid + Enable diff --git a/Crypto Notepad/SettingsForm.Designer.cs b/Crypto Notepad/SettingsForm.Designer.cs index fb54b8a..20f7a5f 100644 --- a/Crypto Notepad/SettingsForm.Designer.cs +++ b/Crypto Notepad/SettingsForm.Designer.cs @@ -1,4 +1,4 @@ -namespace Crypto_Notepad +namespace Crypto_Notepad { partial class SettingsForm { @@ -35,15 +35,35 @@ private void InitializeComponent() this.SaveSettingsButton = new System.Windows.Forms.Button(); this.FontNameLabel = new System.Windows.Forms.Label(); this.SettingsTabControl = new System.Windows.Forms.TabControl(); - this.EditorTabPage = new System.Windows.Forms.TabPage(); + this.MainTabPage = new System.Windows.Forms.TabPage(); + this.LineNumbersGroupBox = new System.Windows.Forms.GroupBox(); + this.GLStyleComboBox = new System.Windows.Forms.ComboBox(); + this.GLStyleLabel = new System.Windows.Forms.Label(); + this.GLColorPanel = new System.Windows.Forms.Panel(); + this.GLColorLabel = new System.Windows.Forms.Label(); + this.GLShowComboBox = new System.Windows.Forms.ComboBox(); + this.GLShowLabel = new System.Windows.Forms.Label(); + this.BLStyleComboBox = new System.Windows.Forms.ComboBox(); + this.BLStyleLabel = new System.Windows.Forms.Label(); + this.BLColorPanel = new System.Windows.Forms.Panel(); + this.BLColorLabel = new System.Windows.Forms.Label(); + this.BLShowСomboBox = new System.Windows.Forms.ComboBox(); + this.BLShowLabel = new System.Windows.Forms.Label(); + this.LNFontColorPanel = new System.Windows.Forms.Panel(); + this.LNBackgroundColorPanel = new System.Windows.Forms.Panel(); + this.LNVisibleComboBox = new System.Windows.Forms.ComboBox(); + this.LNFontColorLabel = new System.Windows.Forms.Label(); + this.LNBackgroundColor = new System.Windows.Forms.Label(); + this.LNVisibleLabel = new System.Windows.Forms.Label(); + this.EditorGroupBox = new System.Windows.Forms.GroupBox(); this.HighlightsColorPanel = new System.Windows.Forms.Panel(); + this.FontNameComboBox = new System.Windows.Forms.ComboBox(); this.HighlightsColorLabel = new System.Windows.Forms.Label(); + this.FontColorPanel = new System.Windows.Forms.Panel(); this.FontSizeComboBox = new System.Windows.Forms.ComboBox(); + this.BackgroundColorPanel = new System.Windows.Forms.Panel(); this.BackgroundColorLabel = new System.Windows.Forms.Label(); this.FontSizeLabel = new System.Windows.Forms.Label(); - this.BackgroundColorPanel = new System.Windows.Forms.Panel(); - this.FontColorPanel = new System.Windows.Forms.Panel(); - this.FontNameComboBox = new System.Windows.Forms.ComboBox(); this.ApplicationTabPage = new System.Windows.Forms.TabPage(); this.ToolbarColorCheckBox = new System.Windows.Forms.CheckBox(); this.MenuIconsCheckBox = new System.Windows.Forms.CheckBox(); @@ -69,7 +89,9 @@ private void InitializeComponent() this.InsertKeyLabel = new System.Windows.Forms.Label(); this.InserKeyComboBox = new System.Windows.Forms.ComboBox(); this.SettingsTabControl.SuspendLayout(); - this.EditorTabPage.SuspendLayout(); + this.MainTabPage.SuspendLayout(); + this.LineNumbersGroupBox.SuspendLayout(); + this.EditorGroupBox.SuspendLayout(); this.ApplicationTabPage.SuspendLayout(); this.IntegrationTabPage.SuspendLayout(); this.EncryptionTabPage.SuspendLayout(); @@ -78,7 +100,7 @@ private void InitializeComponent() // FontColorLabel // this.FontColorLabel.AutoSize = true; - this.FontColorLabel.Location = new System.Drawing.Point(7, 81); + this.FontColorLabel.Location = new System.Drawing.Point(9, 84); this.FontColorLabel.Name = "FontColorLabel"; this.FontColorLabel.Size = new System.Drawing.Size(61, 15); this.FontColorLabel.TabIndex = 0; @@ -92,9 +114,9 @@ private void InitializeComponent() // SaveSettingsButton // this.SaveSettingsButton.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(204))); - this.SaveSettingsButton.Location = new System.Drawing.Point(196, 268); + this.SaveSettingsButton.Location = new System.Drawing.Point(214, 269); this.SaveSettingsButton.Name = "SaveSettingsButton"; - this.SaveSettingsButton.Size = new System.Drawing.Size(64, 23); + this.SaveSettingsButton.Size = new System.Drawing.Size(68, 23); this.SaveSettingsButton.TabIndex = 4; this.SaveSettingsButton.TabStop = false; this.SaveSettingsButton.Text = "Save"; @@ -104,7 +126,7 @@ private void InitializeComponent() // FontNameLabel // this.FontNameLabel.AutoSize = true; - this.FontNameLabel.Location = new System.Drawing.Point(7, 13); + this.FontNameLabel.Location = new System.Drawing.Point(9, 26); this.FontNameLabel.Name = "FontNameLabel"; this.FontNameLabel.Size = new System.Drawing.Size(66, 15); this.FontNameLabel.TabIndex = 1; @@ -112,58 +134,305 @@ private void InitializeComponent() // // SettingsTabControl // - this.SettingsTabControl.Controls.Add(this.EditorTabPage); + this.SettingsTabControl.Controls.Add(this.MainTabPage); this.SettingsTabControl.Controls.Add(this.ApplicationTabPage); this.SettingsTabControl.Controls.Add(this.IntegrationTabPage); this.SettingsTabControl.Controls.Add(this.EncryptionTabPage); + this.SettingsTabControl.Dock = System.Windows.Forms.DockStyle.Top; this.SettingsTabControl.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(204))); - this.SettingsTabControl.Location = new System.Drawing.Point(0, 2); + this.SettingsTabControl.Location = new System.Drawing.Point(0, 0); this.SettingsTabControl.Multiline = true; this.SettingsTabControl.Name = "SettingsTabControl"; this.SettingsTabControl.SelectedIndex = 0; - this.SettingsTabControl.Size = new System.Drawing.Size(264, 264); + this.SettingsTabControl.Size = new System.Drawing.Size(286, 267); this.SettingsTabControl.TabIndex = 4; // - // EditorTabPage + // MainTabPage // - this.EditorTabPage.BackColor = System.Drawing.SystemColors.Window; - this.EditorTabPage.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; - this.EditorTabPage.Controls.Add(this.HighlightsColorPanel); - this.EditorTabPage.Controls.Add(this.HighlightsColorLabel); - this.EditorTabPage.Controls.Add(this.FontSizeComboBox); - this.EditorTabPage.Controls.Add(this.BackgroundColorLabel); - this.EditorTabPage.Controls.Add(this.FontSizeLabel); - this.EditorTabPage.Controls.Add(this.BackgroundColorPanel); - this.EditorTabPage.Controls.Add(this.FontColorPanel); - this.EditorTabPage.Controls.Add(this.FontNameComboBox); - this.EditorTabPage.Controls.Add(this.FontNameLabel); - this.EditorTabPage.Controls.Add(this.FontColorLabel); - this.EditorTabPage.Location = new System.Drawing.Point(4, 24); - this.EditorTabPage.Name = "EditorTabPage"; - this.EditorTabPage.Padding = new System.Windows.Forms.Padding(3); - this.EditorTabPage.Size = new System.Drawing.Size(256, 236); - this.EditorTabPage.TabIndex = 0; - this.EditorTabPage.Text = "Editor"; + this.MainTabPage.AutoScroll = true; + this.MainTabPage.BackColor = System.Drawing.SystemColors.Window; + this.MainTabPage.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.MainTabPage.Controls.Add(this.LineNumbersGroupBox); + this.MainTabPage.Controls.Add(this.EditorGroupBox); + this.MainTabPage.Location = new System.Drawing.Point(4, 24); + this.MainTabPage.Name = "MainTabPage"; + this.MainTabPage.Padding = new System.Windows.Forms.Padding(3); + this.MainTabPage.Size = new System.Drawing.Size(278, 239); + this.MainTabPage.TabIndex = 0; + this.MainTabPage.Text = "Main"; + // + // LineNumbersGroupBox + // + this.LineNumbersGroupBox.Controls.Add(this.GLStyleComboBox); + this.LineNumbersGroupBox.Controls.Add(this.GLStyleLabel); + this.LineNumbersGroupBox.Controls.Add(this.GLColorPanel); + this.LineNumbersGroupBox.Controls.Add(this.GLColorLabel); + this.LineNumbersGroupBox.Controls.Add(this.GLShowComboBox); + this.LineNumbersGroupBox.Controls.Add(this.GLShowLabel); + this.LineNumbersGroupBox.Controls.Add(this.BLStyleComboBox); + this.LineNumbersGroupBox.Controls.Add(this.BLStyleLabel); + this.LineNumbersGroupBox.Controls.Add(this.BLColorPanel); + this.LineNumbersGroupBox.Controls.Add(this.BLColorLabel); + this.LineNumbersGroupBox.Controls.Add(this.BLShowСomboBox); + this.LineNumbersGroupBox.Controls.Add(this.BLShowLabel); + this.LineNumbersGroupBox.Controls.Add(this.LNFontColorPanel); + this.LineNumbersGroupBox.Controls.Add(this.LNBackgroundColorPanel); + this.LineNumbersGroupBox.Controls.Add(this.LNVisibleComboBox); + this.LineNumbersGroupBox.Controls.Add(this.LNFontColorLabel); + this.LineNumbersGroupBox.Controls.Add(this.LNBackgroundColor); + this.LineNumbersGroupBox.Controls.Add(this.LNVisibleLabel); + this.LineNumbersGroupBox.Location = new System.Drawing.Point(2, 236); + this.LineNumbersGroupBox.Name = "LineNumbersGroupBox"; + this.LineNumbersGroupBox.Size = new System.Drawing.Size(249, 283); + this.LineNumbersGroupBox.TabIndex = 14; + this.LineNumbersGroupBox.TabStop = false; + this.LineNumbersGroupBox.Text = "Line Numbers"; + // + // GLStyleComboBox + // + this.GLStyleComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.GLStyleComboBox.FormattingEnabled = true; + this.GLStyleComboBox.Items.AddRange(new object[] { + "Solid", + "Dash", + "Dot", + "DashDot", + "DashDotDot"}); + this.GLStyleComboBox.Location = new System.Drawing.Point(137, 250); + this.GLStyleComboBox.Name = "GLStyleComboBox"; + this.GLStyleComboBox.Size = new System.Drawing.Size(100, 23); + this.GLStyleComboBox.TabIndex = 26; + // + // GLStyleLabel + // + this.GLStyleLabel.AutoSize = true; + this.GLStyleLabel.Location = new System.Drawing.Point(9, 250); + this.GLStyleLabel.Name = "GLStyleLabel"; + this.GLStyleLabel.Size = new System.Drawing.Size(86, 15); + this.GLStyleLabel.TabIndex = 25; + this.GLStyleLabel.Text = "Grid lines style"; + // + // GLColorPanel + // + this.GLColorPanel.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.GLColorPanel.Cursor = System.Windows.Forms.Cursors.Hand; + this.GLColorPanel.Location = new System.Drawing.Point(137, 223); + this.GLColorPanel.Name = "GLColorPanel"; + this.GLColorPanel.Size = new System.Drawing.Size(100, 21); + this.GLColorPanel.TabIndex = 24; + this.GLColorPanel.Click += new System.EventHandler(this.GLColorPanel_Click); + // + // GLColorLabel + // + this.GLColorLabel.AutoSize = true; + this.GLColorLabel.Location = new System.Drawing.Point(9, 223); + this.GLColorLabel.Name = "GLColorLabel"; + this.GLColorLabel.Size = new System.Drawing.Size(89, 15); + this.GLColorLabel.TabIndex = 23; + this.GLColorLabel.Text = "Grid lines color"; + // + // GLShowComboBox + // + this.GLShowComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.GLShowComboBox.FormattingEnabled = true; + this.GLShowComboBox.Items.AddRange(new object[] { + "True", + "False"}); + this.GLShowComboBox.Location = new System.Drawing.Point(137, 194); + this.GLShowComboBox.Name = "GLShowComboBox"; + this.GLShowComboBox.Size = new System.Drawing.Size(100, 23); + this.GLShowComboBox.TabIndex = 22; + // + // GLShowLabel + // + this.GLShowLabel.AutoSize = true; + this.GLShowLabel.Location = new System.Drawing.Point(9, 194); + this.GLShowLabel.Name = "GLShowLabel"; + this.GLShowLabel.Size = new System.Drawing.Size(91, 15); + this.GLShowLabel.TabIndex = 21; + this.GLShowLabel.Text = "Show grid lines"; + // + // BLStyleComboBox + // + this.BLStyleComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.BLStyleComboBox.FormattingEnabled = true; + this.BLStyleComboBox.Items.AddRange(new object[] { + "Solid", + "Dash", + "Dot", + "DashDot", + "DashDotDot"}); + this.BLStyleComboBox.Location = new System.Drawing.Point(137, 165); + this.BLStyleComboBox.Name = "BLStyleComboBox"; + this.BLStyleComboBox.Size = new System.Drawing.Size(100, 23); + this.BLStyleComboBox.TabIndex = 20; + // + // BLStyleLabel + // + this.BLStyleLabel.AutoSize = true; + this.BLStyleLabel.Location = new System.Drawing.Point(9, 165); + this.BLStyleLabel.Name = "BLStyleLabel"; + this.BLStyleLabel.Size = new System.Drawing.Size(100, 15); + this.BLStyleLabel.TabIndex = 19; + this.BLStyleLabel.Text = "Border lines style"; + // + // BLColorPanel + // + this.BLColorPanel.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.BLColorPanel.Cursor = System.Windows.Forms.Cursors.Hand; + this.BLColorPanel.Location = new System.Drawing.Point(137, 138); + this.BLColorPanel.Name = "BLColorPanel"; + this.BLColorPanel.Size = new System.Drawing.Size(100, 21); + this.BLColorPanel.TabIndex = 18; + this.BLColorPanel.Click += new System.EventHandler(this.BLColorPanel_Click); + // + // BLColorLabel + // + this.BLColorLabel.AutoSize = true; + this.BLColorLabel.Location = new System.Drawing.Point(9, 138); + this.BLColorLabel.Name = "BLColorLabel"; + this.BLColorLabel.Size = new System.Drawing.Size(103, 15); + this.BLColorLabel.TabIndex = 17; + this.BLColorLabel.Text = "Border lines color"; + // + // BLShowСomboBox + // + this.BLShowСomboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.BLShowСomboBox.FormattingEnabled = true; + this.BLShowСomboBox.Items.AddRange(new object[] { + "True", + "False"}); + this.BLShowСomboBox.Location = new System.Drawing.Point(137, 109); + this.BLShowСomboBox.Name = "BLShowСomboBox"; + this.BLShowСomboBox.Size = new System.Drawing.Size(100, 23); + this.BLShowСomboBox.TabIndex = 16; + // + // BLShowLabel + // + this.BLShowLabel.AutoSize = true; + this.BLShowLabel.Location = new System.Drawing.Point(9, 109); + this.BLShowLabel.Name = "BLShowLabel"; + this.BLShowLabel.Size = new System.Drawing.Size(106, 15); + this.BLShowLabel.TabIndex = 15; + this.BLShowLabel.Text = "Show border lines"; + // + // LNFontColorPanel + // + this.LNFontColorPanel.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.LNFontColorPanel.Cursor = System.Windows.Forms.Cursors.Hand; + this.LNFontColorPanel.Location = new System.Drawing.Point(137, 82); + this.LNFontColorPanel.Name = "LNFontColorPanel"; + this.LNFontColorPanel.Size = new System.Drawing.Size(100, 21); + this.LNFontColorPanel.TabIndex = 14; + this.LNFontColorPanel.Click += new System.EventHandler(this.LNFontColorPanel_Click); + // + // LNBackgroundColorPanel + // + this.LNBackgroundColorPanel.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.LNBackgroundColorPanel.Cursor = System.Windows.Forms.Cursors.Hand; + this.LNBackgroundColorPanel.Location = new System.Drawing.Point(137, 55); + this.LNBackgroundColorPanel.Name = "LNBackgroundColorPanel"; + this.LNBackgroundColorPanel.Size = new System.Drawing.Size(100, 21); + this.LNBackgroundColorPanel.TabIndex = 13; + this.LNBackgroundColorPanel.Click += new System.EventHandler(this.LNBackgroundColorPanel_Click); + // + // LNVisibleComboBox + // + this.LNVisibleComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.LNVisibleComboBox.FormattingEnabled = true; + this.LNVisibleComboBox.Items.AddRange(new object[] { + "True", + "False"}); + this.LNVisibleComboBox.Location = new System.Drawing.Point(137, 26); + this.LNVisibleComboBox.Name = "LNVisibleComboBox"; + this.LNVisibleComboBox.Size = new System.Drawing.Size(100, 23); + this.LNVisibleComboBox.TabIndex = 3; + // + // LNFontColorLabel + // + this.LNFontColorLabel.AutoSize = true; + this.LNFontColorLabel.Location = new System.Drawing.Point(9, 82); + this.LNFontColorLabel.Name = "LNFontColorLabel"; + this.LNFontColorLabel.Size = new System.Drawing.Size(61, 15); + this.LNFontColorLabel.TabIndex = 2; + this.LNFontColorLabel.Text = "Font color"; + // + // LNBackgroundColor + // + this.LNBackgroundColor.AutoSize = true; + this.LNBackgroundColor.Location = new System.Drawing.Point(9, 55); + this.LNBackgroundColor.Name = "LNBackgroundColor"; + this.LNBackgroundColor.Size = new System.Drawing.Size(103, 15); + this.LNBackgroundColor.TabIndex = 1; + this.LNBackgroundColor.Text = "Background color"; + // + // LNVisibleLabel + // + this.LNVisibleLabel.AutoSize = true; + this.LNVisibleLabel.Location = new System.Drawing.Point(9, 26); + this.LNVisibleLabel.Name = "LNVisibleLabel"; + this.LNVisibleLabel.Size = new System.Drawing.Size(43, 15); + this.LNVisibleLabel.TabIndex = 0; + this.LNVisibleLabel.Text = "Visible"; + // + // EditorGroupBox + // + this.EditorGroupBox.Controls.Add(this.InserKeyComboBox); + this.EditorGroupBox.Controls.Add(this.InsertKeyLabel); + this.EditorGroupBox.Controls.Add(this.FontNameLabel); + this.EditorGroupBox.Controls.Add(this.FontColorLabel); + this.EditorGroupBox.Controls.Add(this.HighlightsColorPanel); + this.EditorGroupBox.Controls.Add(this.FontNameComboBox); + this.EditorGroupBox.Controls.Add(this.HighlightsColorLabel); + this.EditorGroupBox.Controls.Add(this.FontColorPanel); + this.EditorGroupBox.Controls.Add(this.FontSizeComboBox); + this.EditorGroupBox.Controls.Add(this.BackgroundColorPanel); + this.EditorGroupBox.Controls.Add(this.BackgroundColorLabel); + this.EditorGroupBox.Controls.Add(this.FontSizeLabel); + this.EditorGroupBox.Location = new System.Drawing.Point(6, 12); + this.EditorGroupBox.Name = "EditorGroupBox"; + this.EditorGroupBox.Size = new System.Drawing.Size(249, 205); + this.EditorGroupBox.TabIndex = 13; + this.EditorGroupBox.TabStop = false; + this.EditorGroupBox.Text = "Editor"; // // HighlightsColorPanel // this.HighlightsColorPanel.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.HighlightsColorPanel.Cursor = System.Windows.Forms.Cursors.Hand; - this.HighlightsColorPanel.Location = new System.Drawing.Point(136, 146); + this.HighlightsColorPanel.Location = new System.Drawing.Point(137, 138); this.HighlightsColorPanel.Name = "HighlightsColorPanel"; this.HighlightsColorPanel.Size = new System.Drawing.Size(100, 21); this.HighlightsColorPanel.TabIndex = 12; this.HighlightsColorPanel.Click += new System.EventHandler(this.HighlightsColorPanel_Click); // + // FontNameComboBox + // + this.FontNameComboBox.FormattingEnabled = true; + this.FontNameComboBox.Location = new System.Drawing.Point(137, 26); + this.FontNameComboBox.Name = "FontNameComboBox"; + this.FontNameComboBox.Size = new System.Drawing.Size(100, 23); + this.FontNameComboBox.TabIndex = 5; + // // HighlightsColorLabel // this.HighlightsColorLabel.AutoSize = true; - this.HighlightsColorLabel.Location = new System.Drawing.Point(7, 149); + this.HighlightsColorLabel.Location = new System.Drawing.Point(9, 138); this.HighlightsColorLabel.Name = "HighlightsColorLabel"; this.HighlightsColorLabel.Size = new System.Drawing.Size(92, 15); this.HighlightsColorLabel.TabIndex = 11; this.HighlightsColorLabel.Text = "Highlights color"; // + // FontColorPanel + // + this.FontColorPanel.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.FontColorPanel.Cursor = System.Windows.Forms.Cursors.Hand; + this.FontColorPanel.Location = new System.Drawing.Point(137, 84); + this.FontColorPanel.Name = "FontColorPanel"; + this.FontColorPanel.Size = new System.Drawing.Size(100, 21); + this.FontColorPanel.TabIndex = 7; + this.FontColorPanel.Click += new System.EventHandler(this.FontColorPanel_Click_1); + // // FontSizeComboBox // this.FontSizeComboBox.FormattingEnabled = true; @@ -184,15 +453,25 @@ private void InitializeComponent() "36", "48", "72"}); - this.FontSizeComboBox.Location = new System.Drawing.Point(136, 44); + this.FontSizeComboBox.Location = new System.Drawing.Point(137, 55); this.FontSizeComboBox.Name = "FontSizeComboBox"; this.FontSizeComboBox.Size = new System.Drawing.Size(100, 23); this.FontSizeComboBox.TabIndex = 6; // + // BackgroundColorPanel + // + this.BackgroundColorPanel.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.BackgroundColorPanel.Cursor = System.Windows.Forms.Cursors.Hand; + this.BackgroundColorPanel.Location = new System.Drawing.Point(137, 111); + this.BackgroundColorPanel.Name = "BackgroundColorPanel"; + this.BackgroundColorPanel.Size = new System.Drawing.Size(100, 21); + this.BackgroundColorPanel.TabIndex = 8; + this.BackgroundColorPanel.Click += new System.EventHandler(this.BackgroundColorPanel_Click); + // // BackgroundColorLabel // this.BackgroundColorLabel.AutoSize = true; - this.BackgroundColorLabel.Location = new System.Drawing.Point(7, 115); + this.BackgroundColorLabel.Location = new System.Drawing.Point(9, 111); this.BackgroundColorLabel.Name = "BackgroundColorLabel"; this.BackgroundColorLabel.Size = new System.Drawing.Size(103, 15); this.BackgroundColorLabel.TabIndex = 10; @@ -201,40 +480,12 @@ private void InitializeComponent() // FontSizeLabel // this.FontSizeLabel.AutoSize = true; - this.FontSizeLabel.Location = new System.Drawing.Point(7, 47); + this.FontSizeLabel.Location = new System.Drawing.Point(9, 55); this.FontSizeLabel.Name = "FontSizeLabel"; this.FontSizeLabel.Size = new System.Drawing.Size(56, 15); this.FontSizeLabel.TabIndex = 9; this.FontSizeLabel.Text = "Font size"; // - // BackgroundColorPanel - // - this.BackgroundColorPanel.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; - this.BackgroundColorPanel.Cursor = System.Windows.Forms.Cursors.Hand; - this.BackgroundColorPanel.Location = new System.Drawing.Point(136, 112); - this.BackgroundColorPanel.Name = "BackgroundColorPanel"; - this.BackgroundColorPanel.Size = new System.Drawing.Size(100, 21); - this.BackgroundColorPanel.TabIndex = 8; - this.BackgroundColorPanel.Click += new System.EventHandler(this.BackgroundColorPanel_Click); - // - // FontColorPanel - // - this.FontColorPanel.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; - this.FontColorPanel.Cursor = System.Windows.Forms.Cursors.Hand; - this.FontColorPanel.Location = new System.Drawing.Point(136, 78); - this.FontColorPanel.Name = "FontColorPanel"; - this.FontColorPanel.Size = new System.Drawing.Size(100, 21); - this.FontColorPanel.TabIndex = 7; - this.FontColorPanel.Click += new System.EventHandler(this.FontColorPanel_Click_1); - // - // FontNameComboBox - // - this.FontNameComboBox.FormattingEnabled = true; - this.FontNameComboBox.Location = new System.Drawing.Point(136, 10); - this.FontNameComboBox.Name = "FontNameComboBox"; - this.FontNameComboBox.Size = new System.Drawing.Size(100, 23); - this.FontNameComboBox.TabIndex = 5; - // // ApplicationTabPage // this.ApplicationTabPage.BackColor = System.Drawing.SystemColors.Window; @@ -248,7 +499,7 @@ private void InitializeComponent() this.ApplicationTabPage.Location = new System.Drawing.Point(4, 24); this.ApplicationTabPage.Name = "ApplicationTabPage"; this.ApplicationTabPage.Padding = new System.Windows.Forms.Padding(3); - this.ApplicationTabPage.Size = new System.Drawing.Size(256, 236); + this.ApplicationTabPage.Size = new System.Drawing.Size(278, 213); this.ApplicationTabPage.TabIndex = 2; this.ApplicationTabPage.Text = "Application"; // @@ -322,7 +573,7 @@ private void InitializeComponent() this.IntegrationTabPage.Location = new System.Drawing.Point(4, 24); this.IntegrationTabPage.Name = "IntegrationTabPage"; this.IntegrationTabPage.Padding = new System.Windows.Forms.Padding(3); - this.IntegrationTabPage.Size = new System.Drawing.Size(256, 236); + this.IntegrationTabPage.Size = new System.Drawing.Size(278, 213); this.IntegrationTabPage.TabIndex = 3; this.IntegrationTabPage.Text = "Integration"; this.IntegrationTabPage.UseVisualStyleBackColor = true; @@ -372,13 +623,13 @@ private void InitializeComponent() this.EncryptionTabPage.Location = new System.Drawing.Point(4, 24); this.EncryptionTabPage.Name = "EncryptionTabPage"; this.EncryptionTabPage.Padding = new System.Windows.Forms.Padding(3); - this.EncryptionTabPage.Size = new System.Drawing.Size(256, 236); + this.EncryptionTabPage.Size = new System.Drawing.Size(278, 213); this.EncryptionTabPage.TabIndex = 1; this.EncryptionTabPage.Text = "Encryption"; // // PwdIterationsTextBox // - this.PwdIterationsTextBox.Location = new System.Drawing.Point(136, 78); + this.PwdIterationsTextBox.Location = new System.Drawing.Point(162, 68); this.PwdIterationsTextBox.Name = "PwdIterationsTextBox"; this.PwdIterationsTextBox.Size = new System.Drawing.Size(100, 21); this.PwdIterationsTextBox.TabIndex = 7; @@ -393,7 +644,7 @@ private void InitializeComponent() "SHA256", "SHA384", "SHA512"}); - this.HashComboBox.Location = new System.Drawing.Point(136, 10); + this.HashComboBox.Location = new System.Drawing.Point(162, 10); this.HashComboBox.Name = "HashComboBox"; this.HashComboBox.Size = new System.Drawing.Size(100, 23); this.HashComboBox.TabIndex = 5; @@ -402,7 +653,7 @@ private void InitializeComponent() // this.PwdIterationsLabel.AutoSize = true; this.PwdIterationsLabel.BackColor = System.Drawing.Color.Transparent; - this.PwdIterationsLabel.Location = new System.Drawing.Point(7, 81); + this.PwdIterationsLabel.Location = new System.Drawing.Point(13, 71); this.PwdIterationsLabel.Name = "PwdIterationsLabel"; this.PwdIterationsLabel.Size = new System.Drawing.Size(114, 15); this.PwdIterationsLabel.TabIndex = 6; @@ -410,7 +661,7 @@ private void InitializeComponent() // // SaltTextBox // - this.SaltTextBox.Location = new System.Drawing.Point(136, 111); + this.SaltTextBox.Location = new System.Drawing.Point(162, 95); this.SaltTextBox.Margin = new System.Windows.Forms.Padding(10, 3, 3, 3); this.SaltTextBox.Name = "SaltTextBox"; this.SaltTextBox.ReadOnly = true; @@ -426,7 +677,7 @@ private void InitializeComponent() "128", "192", "256"}); - this.KeySizeComboBox.Location = new System.Drawing.Point(136, 44); + this.KeySizeComboBox.Location = new System.Drawing.Point(162, 39); this.KeySizeComboBox.Name = "KeySizeComboBox"; this.KeySizeComboBox.Size = new System.Drawing.Size(100, 23); this.KeySizeComboBox.TabIndex = 3; @@ -434,7 +685,7 @@ private void InitializeComponent() // SaltLabel // this.SaltLabel.AutoSize = true; - this.SaltLabel.Location = new System.Drawing.Point(7, 114); + this.SaltLabel.Location = new System.Drawing.Point(13, 101); this.SaltLabel.Name = "SaltLabel"; this.SaltLabel.Size = new System.Drawing.Size(52, 15); this.SaltLabel.TabIndex = 2; @@ -444,7 +695,7 @@ private void InitializeComponent() // KeySizeLabel // this.KeySizeLabel.AutoSize = true; - this.KeySizeLabel.Location = new System.Drawing.Point(7, 47); + this.KeySizeLabel.Location = new System.Drawing.Point(13, 42); this.KeySizeLabel.Name = "KeySizeLabel"; this.KeySizeLabel.Size = new System.Drawing.Size(52, 15); this.KeySizeLabel.TabIndex = 1; @@ -453,7 +704,7 @@ private void InitializeComponent() // HashLabel // this.HashLabel.AutoSize = true; - this.HashLabel.Location = new System.Drawing.Point(7, 13); + this.HashLabel.Location = new System.Drawing.Point(13, 13); this.HashLabel.Name = "HashLabel"; this.HashLabel.Size = new System.Drawing.Size(94, 15); this.HashLabel.TabIndex = 0; @@ -462,9 +713,9 @@ private void InitializeComponent() // ResetSettingsButton // this.ResetSettingsButton.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(204))); - this.ResetSettingsButton.Location = new System.Drawing.Point(123, 268); + this.ResetSettingsButton.Location = new System.Drawing.Point(4, 269); this.ResetSettingsButton.Name = "ResetSettingsButton"; - this.ResetSettingsButton.Size = new System.Drawing.Size(64, 23); + this.ResetSettingsButton.Size = new System.Drawing.Size(68, 23); this.ResetSettingsButton.TabIndex = 5; this.ResetSettingsButton.Text = "Reset"; this.ResetSettingsButton.UseVisualStyleBackColor = true; @@ -490,13 +741,14 @@ private void InitializeComponent() this.InserKeyComboBox.Name = "InserKeyComboBox"; this.InserKeyComboBox.Size = new System.Drawing.Size(100, 23); this.InserKeyComboBox.TabIndex = 14; + // // SettingsForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(264, 296); - this.Controls.Add(this.SaveSettingsButton); + this.ClientSize = new System.Drawing.Size(286, 297); this.Controls.Add(this.ResetSettingsButton); + this.Controls.Add(this.SaveSettingsButton); this.Controls.Add(this.SettingsTabControl); this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); @@ -507,8 +759,11 @@ private void InitializeComponent() this.Text = "Settings"; this.Load += new System.EventHandler(this.SettingsForm_Load); this.SettingsTabControl.ResumeLayout(false); - this.EditorTabPage.ResumeLayout(false); - this.EditorTabPage.PerformLayout(); + this.MainTabPage.ResumeLayout(false); + this.LineNumbersGroupBox.ResumeLayout(false); + this.LineNumbersGroupBox.PerformLayout(); + this.EditorGroupBox.ResumeLayout(false); + this.EditorGroupBox.PerformLayout(); this.ApplicationTabPage.ResumeLayout(false); this.ApplicationTabPage.PerformLayout(); this.IntegrationTabPage.ResumeLayout(false); @@ -525,7 +780,7 @@ private void InitializeComponent() private System.Windows.Forms.Button SaveSettingsButton; private System.Windows.Forms.Label FontNameLabel; private System.Windows.Forms.TabControl SettingsTabControl; - private System.Windows.Forms.TabPage EditorTabPage; + private System.Windows.Forms.TabPage MainTabPage; private System.Windows.Forms.TabPage EncryptionTabPage; private System.Windows.Forms.TabPage ApplicationTabPage; private System.Windows.Forms.CheckBox AssociateCheckBox; @@ -557,6 +812,27 @@ private void InitializeComponent() private System.Windows.Forms.CheckBox MenuIconsCheckBox; private System.Windows.Forms.TabPage IntegrationTabPage; private System.Windows.Forms.CheckBox ToolbarColorCheckBox; + private System.Windows.Forms.GroupBox LineNumbersGroupBox; + private System.Windows.Forms.GroupBox EditorGroupBox; + private System.Windows.Forms.Label LNFontColorLabel; + private System.Windows.Forms.Label LNBackgroundColor; + private System.Windows.Forms.Label LNVisibleLabel; + private System.Windows.Forms.ComboBox LNVisibleComboBox; + private System.Windows.Forms.Panel LNFontColorPanel; + private System.Windows.Forms.Panel LNBackgroundColorPanel; + private System.Windows.Forms.ComboBox BLStyleComboBox; + private System.Windows.Forms.Label BLStyleLabel; + private System.Windows.Forms.Panel BLColorPanel; + private System.Windows.Forms.Label BLColorLabel; + private System.Windows.Forms.ComboBox BLShowСomboBox; + private System.Windows.Forms.Label BLShowLabel; + private System.Windows.Forms.ComboBox GLStyleComboBox; + private System.Windows.Forms.Label GLStyleLabel; + private System.Windows.Forms.Panel GLColorPanel; + private System.Windows.Forms.Label GLColorLabel; + private System.Windows.Forms.ComboBox GLShowComboBox; + private System.Windows.Forms.Label GLShowLabel; + private System.Windows.Forms.ComboBox InserKeyComboBox; private System.Windows.Forms.Label InsertKeyLabel; } } \ No newline at end of file diff --git a/Crypto Notepad/SettingsForm.cs b/Crypto Notepad/SettingsForm.cs index a9e10d4..c759326 100644 --- a/Crypto Notepad/SettingsForm.cs +++ b/Crypto Notepad/SettingsForm.cs @@ -1,6 +1,7 @@ using Microsoft.Win32; using System; using System.Drawing; +using System.Drawing.Drawing2D; using System.Reflection; using System.Windows.Forms; @@ -55,7 +56,53 @@ private void SetSettings(string value) ps.MenuIntegrate = IntegrateCheckBox.Checked; ps.MenuIcons = MenuIconsCheckBox.Checked; ps.ColoredToolbar = ToolbarColorCheckBox.Checked; + ps.LNVisible = LNVisibleComboBox.Text; + ps.LNBackgroundColor = LNBackgroundColorPanel.BackColor; + ps.LNFontColorPanel = LNFontColorPanel.BackColor; + ps.BLColor = BLColorPanel.BackColor; + ps.BLShow = BLShowСomboBox.Text; + ps.GLColor = GLColorPanel.BackColor; + ps.GLShow = GLShowComboBox.Text; ps.InserKey = InserKeyComboBox.Text; + + switch (BLStyleComboBox.Text) + { + case "Solid": + ps.BLStyle = DashStyle.Solid; + break; + case "Dash": + ps.BLStyle = DashStyle.Dash; + break; + case "Dot": + ps.BLStyle = DashStyle.Dot; + break; + case "DashDot": + ps.BLStyle = DashStyle.DashDot; + break; + case "DashDotDot": + ps.BLStyle = DashStyle.DashDotDot; + break; + } + + switch (GLStyleComboBox.Text) + { + case "Solid": + ps.GLStyle = DashStyle.Solid; + break; + case "Dash": + ps.GLStyle = DashStyle.Dash; + break; + case "Dot": + ps.GLStyle = DashStyle.Dot; + break; + case "DashDot": + ps.GLStyle = DashStyle.DashDot; + break; + case "DashDotDot": + ps.GLStyle = DashStyle.DashDotDot; + break; + } + ps.Save(); PublicVar.settingsChanged = true; @@ -78,6 +125,12 @@ private void SetSettings(string value) IntegrateCheckBox.Checked = false; MenuIconsCheckBox.Checked = false; ToolbarColorCheckBox.Checked = false; + LNVisibleComboBox.Text = "True"; + LNBackgroundColorPanel.BackColor = Color.FromArgb(53, 53, 53); + LNFontColorPanel.BackColor = Color.FromArgb(164, 164, 164); + BLShowСomboBox.Text = "False"; + BLColorPanel.BackColor = Color.FromArgb(164, 164, 164); + BLStyleComboBox.Text = "Solid"; InserKeyComboBox.Text = "Enable"; } } @@ -177,6 +230,15 @@ private void SettingsForm_Load(object sender, EventArgs e) IntegrateCheckBox.Checked = ps.MenuIntegrate; MenuIconsCheckBox.Checked = ps.MenuIcons; ToolbarColorCheckBox.Checked = ps.ColoredToolbar; + LNVisibleComboBox.Text = ps.LNVisible; + LNBackgroundColorPanel.BackColor = ps.LNBackgroundColor; + LNFontColorPanel.BackColor = ps.LNFontColorPanel; + BLShowСomboBox.Text = ps.BLShow; + BLColorPanel.BackColor = ps.BLColor; + BLStyleComboBox.Text = ps.BLStyle.ToString(); + GLShowComboBox.Text = ps.GLShow; + GLColorPanel.BackColor = ps.GLColor; + GLStyleComboBox.Text = ps.GLStyle.ToString(); InserKeyComboBox.Text = ps.InserKey; if (!ps.ShowToolbar) @@ -258,6 +320,47 @@ private void ToolbarCheckBox_CheckedChanged(object sender, EventArgs e) ToolbarColorCheckBox.Enabled = true; } } + + private void LNBackgroundColorPanel_Click(object sender, EventArgs e) + { + colorDialog1.Color = LNBackgroundColorPanel.BackColor; + using (new CenterWinDialog(this)) + { + colorDialog1.ShowDialog(); + } + LNBackgroundColorPanel.BackColor = colorDialog1.Color; + } + + private void LNFontColorPanel_Click(object sender, EventArgs e) + { + colorDialog1.Color = LNFontColorPanel.BackColor; + using (new CenterWinDialog(this)) + { + colorDialog1.ShowDialog(); + } + LNFontColorPanel.BackColor = colorDialog1.Color; + } + + private void BLColorPanel_Click(object sender, EventArgs e) + { + colorDialog1.Color = BLColorPanel.BackColor; + using (new CenterWinDialog(this)) + { + colorDialog1.ShowDialog(); + } + BLColorPanel.BackColor = colorDialog1.Color; + } + + private void GLColorPanel_Click(object sender, EventArgs e) + { + colorDialog1.Color = GLColorPanel.BackColor; + using (new CenterWinDialog(this)) + { + colorDialog1.ShowDialog(); + } + GLColorPanel.BackColor = colorDialog1.Color; + } + /*Settings Section*/ } } diff --git a/Crypto Notepad/linenum_rtf.cs b/Crypto Notepad/linenum_rtf.cs new file mode 100644 index 0000000..e59a47e --- /dev/null +++ b/Crypto Notepad/linenum_rtf.cs @@ -0,0 +1,1118 @@ +using Microsoft.VisualBasic; +using System; +using System.Collections; +using System.Collections.Generic; +using System.Data; +using System.Drawing; +using System.Drawing.Drawing2D; + +using System.Diagnostics; +using System.Windows.Forms; + + +namespace LineNumbers +{ + [System.ComponentModel.DefaultProperty("ParentRichTextBox")] + public class LineNumbers_For_RichTextBox : System.Windows.Forms.Control + { + + private class LineNumberItem + { + internal int LineNumber; + internal Rectangle Rectangle; + internal LineNumberItem(int zLineNumber, Rectangle zRectangle) + { + this.LineNumber = zLineNumber; + this.Rectangle = zRectangle; + } + } + + public enum LineNumberDockSide : byte + { + None = 0, + Left = 1, + Right = 2, + Height = 4 + } + private RichTextBox withEventsField_zParent = null; + + private RichTextBox zParent { + get { return withEventsField_zParent; } + set { + if (withEventsField_zParent != null) { + withEventsField_zParent.LocationChanged -= zParent_Changed; + withEventsField_zParent.Move -= zParent_Changed; + withEventsField_zParent.Resize -= zParent_Changed; + withEventsField_zParent.DockChanged -= zParent_Changed; + withEventsField_zParent.TextChanged -= zParent_Changed; + withEventsField_zParent.MultilineChanged -= zParent_Changed; + withEventsField_zParent.HScroll -= zParent_Scroll; + withEventsField_zParent.VScroll -= zParent_Scroll; + withEventsField_zParent.ContentsResized -= zParent_ContentsResized; + withEventsField_zParent.Disposed -= zParent_Disposed; + } + withEventsField_zParent = value; + if (withEventsField_zParent != null) { + withEventsField_zParent.LocationChanged += zParent_Changed; + withEventsField_zParent.Move += zParent_Changed; + withEventsField_zParent.Resize += zParent_Changed; + withEventsField_zParent.DockChanged += zParent_Changed; + withEventsField_zParent.TextChanged += zParent_Changed; + withEventsField_zParent.MultilineChanged += zParent_Changed; + withEventsField_zParent.HScroll += zParent_Scroll; + withEventsField_zParent.VScroll += zParent_Scroll; + withEventsField_zParent.ContentsResized += zParent_ContentsResized; + withEventsField_zParent.Disposed += zParent_Disposed; + } + } + } + + //private Windows.Forms.Timer withEventsField_zTimer = new Windows.Forms.Timer(); + //private Windows.Forms.Timer zTimer { + //private Timer withEventsField_zTimer = new Windows.Forms.Timer(); + private Timer withEventsField_zTimer = new Timer(); + private Timer zTimer + { + get { return withEventsField_zTimer; } + set { + if (withEventsField_zTimer != null) { + withEventsField_zTimer.Tick -= zTimer_Tick; + } + withEventsField_zTimer = value; + if (withEventsField_zTimer != null) { + withEventsField_zTimer.Tick += zTimer_Tick; + } + } + + } + private bool zAutoSizing = true; + private Size zAutoSizing_Size = new Size(0, 0); + //private Rectangle zContentRectangle = null; + private Rectangle zContentRectangle; + private LineNumberDockSide zDockSide = LineNumberDockSide.Left; + private bool zParentIsScrolling = false; + + private bool zSeeThroughMode = false; + private bool zGradient_Show = true; + private System.Drawing.Drawing2D.LinearGradientMode zGradient_Direction = System.Drawing.Drawing2D.LinearGradientMode.Horizontal; + private Color zGradient_StartColor = Color.FromArgb(0, 0, 0, 0); + + private Color zGradient_EndColor = Color.Transparent; + private bool zGridLines_Show = true; + private float zGridLines_Thickness = 1; + private System.Drawing.Drawing2D.DashStyle zGridLines_Style = System.Drawing.Drawing2D.DashStyle.Dot; + + private Color zGridLines_Color = Color.SlateGray; + private bool zBorderLines_Show = true; + private float zBorderLines_Thickness = 1; + private System.Drawing.Drawing2D.DashStyle zBorderLines_Style = System.Drawing.Drawing2D.DashStyle.Dot; + + private Color zBorderLines_Color = Color.SlateGray; + private bool zMarginLines_Show = true; + private LineNumberDockSide zMarginLines_Side = LineNumberDockSide.Right; + private float zMarginLines_Thickness = 1; + private System.Drawing.Drawing2D.DashStyle zMarginLines_Style = System.Drawing.Drawing2D.DashStyle.Solid; + + private Color zMarginLines_Color = Color.SlateGray; + private bool zLineNumbers_Show = true; + private bool zLineNumbers_ShowLeadingZeroes = true; + private bool zLineNumbers_ShowAsHexadecimal = false; + private bool zLineNumbers_ClipByItemRectangle = true; + private Size zLineNumbers_Offset = new Size(0, 0); + private string zLineNumbers_Format = "0"; + private System.Drawing.ContentAlignment zLineNumbers_Alignment = ContentAlignment.TopRight; + + private bool zLineNumbers_AntiAlias = true; + + private List zLNIs = new List(); + private Point zPointInParent = new Point(0, 0); + private Point zPointInMe = new Point(0, 0); + private int zParentInMe = 0; + //////////////////////////////////////////////////////////////////////////////////////////////////// + + public LineNumbers_For_RichTextBox() + { + { + this.SetStyle(ControlStyles.OptimizedDoubleBuffer, true); + this.SetStyle(ControlStyles.ResizeRedraw, true); + this.SetStyle(ControlStyles.SupportsTransparentBackColor, true); + this.SetStyle(ControlStyles.UserPaint, true); + this.SetStyle(ControlStyles.AllPaintingInWmPaint, true); + this.Margin = new Padding(0); + this.Padding = new Padding(0, 0, 2, 0); + } + { + zTimer.Enabled = true; + zTimer.Interval = 200; + zTimer.Stop(); + } + this.Update_SizeAndPosition(); + this.Invalidate(); + } + + protected override void OnHandleCreated(System.EventArgs e) + { + base.OnHandleCreated(e); + this.AutoSize = false; + } + + + //////////////////////////////////////////////////////////////////////////////////////////////////// + + [System.ComponentModel.Browsable(false)] + public override bool AutoSize { + get { return base.AutoSize; } + set { + base.AutoSize = value; + this.Invalidate(); + } + } + + [System.ComponentModel.Description("Use this property to automatically resize the control (and reposition it if needed).")] + [System.ComponentModel.Category("Additional Behavior")] + public bool AutoSizing { + get { return zAutoSizing; } + set { + zAutoSizing = value; + this.Refresh(); + this.Invalidate(); + } + } + + [System.ComponentModel.Description("Use this property to enable LineNumbers for the chosen RichTextBox.")] + [System.ComponentModel.Category("Add LineNumbers to")] + public RichTextBox ParentRichTextBox { + get { return zParent; } + set { + zParent = value; + if (zParent != null) { + this.Parent = zParent.Parent; + zParent.Refresh(); + } + this.Text = ""; + this.Refresh(); + this.Invalidate(); + } + } + + [System.ComponentModel.Description("Use this property to dock the LineNumbers to a chosen side of the chosen RichTextBox.")] + [System.ComponentModel.Category("Additional Behavior")] + public LineNumberDockSide DockSide { + get { return zDockSide; } + set { + zDockSide = value; + this.Refresh(); + this.Invalidate(); + } + } + + [System.ComponentModel.Description("Use this property to enable the control to act as an overlay ontop of the RichTextBox.")] + [System.ComponentModel.Category("Additional Behavior")] + public bool _SeeThroughMode_ { + get { return zSeeThroughMode; } + set { + zSeeThroughMode = value; + this.Invalidate(); + } + } + + [System.ComponentModel.Description("BorderLines are shown on all sides of the LineNumber control.")] + [System.ComponentModel.Category("Additional Behavior")] + public bool Show_BorderLines { + get { return zBorderLines_Show; } + set { + zBorderLines_Show = value; + this.Invalidate(); + } + } + + [System.ComponentModel.Category("Additional Appearance")] + public Color BorderLines_Color { + get { return zBorderLines_Color; } + set { + zBorderLines_Color = value; + this.Invalidate(); + } + } + + [System.ComponentModel.Category("Additional Appearance")] + public float BorderLines_Thickness { + get { return zBorderLines_Thickness; } + set { + zBorderLines_Thickness = Math.Max(1, Math.Min(255, value)); + this.Invalidate(); + } + } + + [System.ComponentModel.Category("Additional Appearance")] + public System.Drawing.Drawing2D.DashStyle BorderLines_Style + { + get { return zBorderLines_Style; } + set { + if (value == System.Drawing.Drawing2D.DashStyle.Custom) + value = System.Drawing.Drawing2D.DashStyle.Solid; + zBorderLines_Style = value; + this.Invalidate(); + } + } + + [System.ComponentModel.Description("GridLines are the horizontal divider-lines shown above each LineNumber.")] + [System.ComponentModel.Category("Additional Behavior")] + public bool Show_GridLines { + get { return zGridLines_Show; } + set { + zGridLines_Show = value; + this.Invalidate(); + } + } + + [System.ComponentModel.Category("Additional Appearance")] + public Color GridLines_Color { + get { return zGridLines_Color; } + set { + zGridLines_Color = value; + this.Invalidate(); + } + } + + [System.ComponentModel.Category("Additional Appearance")] + public float GridLines_Thickness { + get { return zGridLines_Thickness; } + set { + zGridLines_Thickness = Math.Max(1, Math.Min(255, value)); + this.Invalidate(); + } + } + + [System.ComponentModel.Category("Additional Appearance")] + public System.Drawing.Drawing2D.DashStyle GridLines_Style + { + get { return zGridLines_Style; } + set { + if (value == System.Drawing.Drawing2D.DashStyle.Custom) + value = System.Drawing.Drawing2D.DashStyle.Solid; + zGridLines_Style = value; + this.Invalidate(); + } + } + + [System.ComponentModel.Description("MarginLines are shown on the Left or Right (or both in Height-mode) of the LineNumber control.")] + [System.ComponentModel.Category("Additional Behavior")] + public bool Show_MarginLines { + get { return zMarginLines_Show; } + set { + zMarginLines_Show = value; + this.Invalidate(); + } + } + + [System.ComponentModel.Category("Additional Appearance")] + public LineNumberDockSide MarginLines_Side { + get { return zMarginLines_Side; } + set { + zMarginLines_Side = value; + this.Invalidate(); + } + } + + [System.ComponentModel.Category("Additional Appearance")] + public Color MarginLines_Color { + get { return zMarginLines_Color; } + set { + zMarginLines_Color = value; + this.Invalidate(); + } + } + + [System.ComponentModel.Category("Additional Appearance")] + public float MarginLines_Thickness { + get { return zMarginLines_Thickness; } + set { + zMarginLines_Thickness = Math.Max(1, Math.Min(255, value)); + this.Invalidate(); + } + } + + [System.ComponentModel.Category("Additional Appearance")] + public System.Drawing.Drawing2D.DashStyle MarginLines_Style + { + get { return zMarginLines_Style; } + set { + if (value == System.Drawing.Drawing2D.DashStyle.Custom) + value = System.Drawing.Drawing2D.DashStyle.Solid; + zMarginLines_Style = value; + this.Invalidate(); + } + } + + [System.ComponentModel.Description("The BackgroundGradient is a gradual blend of two colors, shown in the back of each LineNumber's item-area.")] + [System.ComponentModel.Category("Additional Behavior")] + public bool Show_BackgroundGradient { + get { return zGradient_Show; } + set { + zGradient_Show = value; + this.Invalidate(); + } + } + + [System.ComponentModel.Category("Additional Appearance")] + public Color BackgroundGradient_AlphaColor { + get { return zGradient_StartColor; } + set { + zGradient_StartColor = value; + this.Invalidate(); + } + } + + [System.ComponentModel.Category("Additional Appearance")] + public Color BackgroundGradient_BetaColor { + get { return zGradient_EndColor; } + set { + zGradient_EndColor = value; + this.Invalidate(); + } + } + + [System.ComponentModel.Category("Additional Appearance")] + public System.Drawing.Drawing2D.LinearGradientMode BackgroundGradient_Direction + { + get { return zGradient_Direction; } + set { + zGradient_Direction = value; + this.Invalidate(); + } + } + + [System.ComponentModel.Category("Additional Behavior")] + public bool Show_LineNrs { + get { return zLineNumbers_Show; } + set { + zLineNumbers_Show = value; + this.Invalidate(); + } + } + + [System.ComponentModel.Description("Use this to set whether the LineNumbers are allowed to spill out of their item-area, or should be clipped by it.")] + [System.ComponentModel.Category("Additional Behavior")] + public bool LineNrs_ClippedByItemRectangle { + get { return zLineNumbers_ClipByItemRectangle; } + set { + zLineNumbers_ClipByItemRectangle = value; + this.Invalidate(); + } + } + + [System.ComponentModel.Description("Use this to set whether the LineNumbers should have leading zeroes (based on the total amount of textlines).")] + [System.ComponentModel.Category("Additional Behavior")] + public bool LineNrs_LeadingZeroes { + get { return zLineNumbers_ShowLeadingZeroes; } + set { + zLineNumbers_ShowLeadingZeroes = value; + this.Refresh(); + this.Invalidate(); + } + } + + [System.ComponentModel.Description("Use this to set whether the LineNumbers should be shown as hexadecimal values.")] + [System.ComponentModel.Category("Additional Behavior")] + public bool LineNrs_AsHexadecimal { + get { return zLineNumbers_ShowAsHexadecimal; } + set { + zLineNumbers_ShowAsHexadecimal = value; + this.Refresh(); + this.Invalidate(); + } + } + + [System.ComponentModel.Description("Use this property to manually reposition the LineNumbers, relative to their current location.")] + [System.ComponentModel.Category("Additional Behavior")] + public Size LineNrs_Offset { + get { return zLineNumbers_Offset; } + set { + zLineNumbers_Offset = value; + this.Invalidate(); + } + } + + [System.ComponentModel.Description("Use this to align the LineNumbers to a chosen corner (or center) within their item-area.")] + [System.ComponentModel.Category("Additional Behavior")] + public System.Drawing.ContentAlignment LineNrs_Alignment { + get { return zLineNumbers_Alignment; } + set { + zLineNumbers_Alignment = value; + this.Invalidate(); + } + } + + [System.ComponentModel.Description("Use this to apply Anti-Aliasing to the LineNumbers (high quality). Some fonts will look better without it, though.")] + [System.ComponentModel.Category("Additional Behavior")] + public bool LineNrs_AntiAlias { + get { return zLineNumbers_AntiAlias; } + set { + zLineNumbers_AntiAlias = value; + this.Refresh(); + this.Invalidate(); + } + } + + [System.ComponentModel.Browsable(true)] + public override System.Drawing.Font Font { + get { return base.Font; } + set { + base.Font = value; + this.Refresh(); + this.Invalidate(); + } + } + + [System.ComponentModel.DefaultValue("")] + [System.ComponentModel.AmbientValue("")] + [System.ComponentModel.Browsable(false)] + public override string Text { + get { return base.Text; } + set { + base.Text = ""; + this.Invalidate(); + } + } + + + //////////////////////////////////////////////////////////////////////////////////////////////////// + + protected override void OnSizeChanged(System.EventArgs e) + { + if (this.DesignMode == true) + this.Refresh(); + base.OnSizeChanged(e); + this.Invalidate(); + } + + protected override void OnLocationChanged(System.EventArgs e) + { + if (this.DesignMode == true) + this.Refresh(); + base.OnLocationChanged(e); + this.Invalidate(); + } + + public override void Refresh() + { + // Note: don't change the order here, first the Mybase.Refresh, then the Update_SizeAndPosition. + base.Refresh(); + this.Update_SizeAndPosition(); + } + + /// + /// This Sub will run whenever Me.Refresh() is called. It applies the AutoSizing and DockSide settings. + /// + /// + private void Update_SizeAndPosition() + { + if (this.AutoSize == true) + return; + if (this.Dock == DockStyle.Bottom | this.Dock == DockStyle.Fill | this.Dock == DockStyle.Top) + return; + Point zNewLocation = this.Location; + Size zNewSize = this.Size; + + if (zAutoSizing == true) { + //switch (true) { + // case zParent == null: + if (zParent == null ){ + // --- ReminderMessage sizing + if (zAutoSizing_Size.Width > 0) + zNewSize.Width = zAutoSizing_Size.Width; + if (zAutoSizing_Size.Height > 0) + zNewSize.Height = zAutoSizing_Size.Height; + this.Size = zNewSize; + + // break; + }else if (this.Dock == DockStyle.Left | this.Dock == DockStyle.Right){ + //--- zParent isNot Nothing for the following cases + //case this.Dock == DockStyle.Left | this.Dock == DockStyle.Right: + if (zAutoSizing_Size.Width > 0) + zNewSize.Width = zAutoSizing_Size.Width; + this.Width = zNewSize.Width; + + //break; + }else if (zDockSide != LineNumberDockSide.None){ + // --- DockSide is active L/R/H + //case zDockSide != LineNumberDockSide.None: + if (zAutoSizing_Size.Width > 0) + zNewSize.Width = zAutoSizing_Size.Width; + zNewSize.Height = zParent.Height; + if (zDockSide == LineNumberDockSide.Left) + zNewLocation.X = zParent.Left - zNewSize.Width - 1; + if (zDockSide == LineNumberDockSide.Right) + zNewLocation.X = zParent.Right + 1; + zNewLocation.Y = zParent.Top; + this.Location = zNewLocation; + this.Size = zNewSize; + + //break; + } else if (zDockSide == LineNumberDockSide.None) { + // --- DockSide = None, but AutoSizing is still setting the Width + //case zDockSide == LineNumberDockSide.None: + if (zAutoSizing_Size.Width > 0) + zNewSize.Width = zAutoSizing_Size.Width; + this.Size = zNewSize; + + //break; + } + + } else { + // --- No AutoSizing + //switch (true) { + if (zParent == null){ + //case zParent == null: + // --- ReminderMessage sizing + if (zAutoSizing_Size.Width > 0) + zNewSize.Width = zAutoSizing_Size.Width; + if (zAutoSizing_Size.Height > 0) + zNewSize.Height = zAutoSizing_Size.Height; + this.Size = zNewSize; + + //break; + }else if (zDockSide != LineNumberDockSide.None){ + // --- No AutoSizing, but DockSide L/R/H is active so height and position need updates. + //case zDockSide != LineNumberDockSide.None: + zNewSize.Height = zParent.Height; + if (zDockSide == LineNumberDockSide.Left) + zNewLocation.X = zParent.Left - zNewSize.Width - 1; + if (zDockSide == LineNumberDockSide.Right) + zNewLocation.X = zParent.Right + 1; + zNewLocation.Y = zParent.Top; + this.Location = zNewLocation; + this.Size = zNewSize; + + //break; + } + } + + } + + + /// + /// This Sub determines which textlines are visible in the ParentRichTextBox, and makes LineNumberItems (LineNumber + ItemRectangle) + /// for each visible line. They are put into the zLNIs List that will be used by the OnPaint event to draw the LineNumberItems. + /// + /// + private void Update_VisibleLineNumberItems() + { + + // ################ + int tmpY; + // ############### + zLNIs.Clear(); + zAutoSizing_Size = new Size(0, 0); + zLineNumbers_Format = "0"; + //initial setting + // To measure the LineNumber's width, its Format 0 is replaced by w as that is likely to be one of the widest characters in non-monospace fonts. + if (zAutoSizing == true) + zAutoSizing_Size = new Size(TextRenderer.MeasureText(zLineNumbers_Format.Replace('0', 'W'), this.Font).Width, 0); + //zAutoSizing_Size = new Size(TextRenderer.MeasureText(zLineNumbers_Format.Replace("0".ToCharArray(), "W".ToCharArray()), this.Font).Width, 0); + + if (zParent == null || string.IsNullOrEmpty(zParent.Text)) + return; + + // --- Make sure the LineNumbers are aligning to the same height as the zParent textlines by converting to screencoordinates + // and using that as an offset that gets added to the points for the LineNumberItems + zPointInParent = zParent.PointToScreen(zParent.ClientRectangle.Location); + zPointInMe = this.PointToScreen(new Point(0, 0)); + // zParentInMe is the vertical offset to make the LineNumberItems line up with the textlines in zParent. + zParentInMe = zPointInParent.Y - zPointInMe.Y + 1; + // The first visible LineNumber may not be the first visible line of text in the RTB if the LineNumbercontrol's .Top is lower on the form than + // the .Top of the parent RichTextBox. Therefor, zPointInParent will now be used to find zPointInMe's equivalent height in zParent, + // which is needed to find the best StartIndex later on. + zPointInParent = zParent.PointToClient(zPointInMe); + + // --- NOTES: + // Additional complication is the fact that when wordwrap is enabled on the RTB, the wordwrapped text spills into the RTB.Lines collection, + // so we need to split the text into lines ourselves, and use the Index of each zSplit-line's first character instead of the RTB's. + string[] zSplit = zParent.Text.Split(Constants.vbCrLf.ToCharArray()); + + if (zSplit.Length < 2) { + // Just one line in the text = one linenumber + // NOTE: zContentRectangle is built by the zParent.ContentsResized event. + Point zPoint = zParent.GetPositionFromCharIndex(0); + zLNIs.Add(new LineNumberItem(1, new Rectangle(new Point(0, zPoint.Y - 1 + zParentInMe), new Size(this.Width, zContentRectangle.Height - zPoint.Y)))); + + + } else { + // Multiple lines, but store only those LineNumberItems for lines that are visible. + TimeSpan zTimeSpan = new TimeSpan(DateAndTime.Now.Ticks); + Point zPoint = new Point(0, 0); + int zStartIndex = 0; + int zSplitStartLine = 0; + int zA = zParent.Text.Length - 1; + // ######################### + + //this.FindStartIndex(ref zStartIndex, ref zA, ref zPointInParent.Y); + tmpY = zPointInParent.Y; + this.FindStartIndex(ref zStartIndex, ref zA, ref tmpY); + zPointInParent.Y = tmpY; + + // ################ + + + // zStartIndex now holds the index of a character in the first visible line from zParent.Text + // Now it will be pointed at the first character of that line (chr(10) = Linefeed part of the vbCrLf constant) + zStartIndex = Math.Max(0, Math.Min(zParent.Text.Length - 1, zParent.Text.Substring(0, zStartIndex).LastIndexOf(Strings.Chr(10)) + 1)); + + // We now need to find out which zSplit-line that character is in, by counting the vbCrlf appearances that come before it. + zSplitStartLine = Math.Max(0, zParent.Text.Substring(0, zStartIndex).Split(Constants.vbCrLf.ToCharArray()).Length - 1); + + // zStartIndex starts off pointing at the first character of the first visible line, and will be then be pointed to + // the index of the first character on the next line. + for (zA = zSplitStartLine; zA <= zSplit.Length - 1; zA++) { + zPoint = zParent.GetPositionFromCharIndex(zStartIndex); + zStartIndex += Math.Max(1, zSplit[zA].Length + 1); + if (zPoint.Y + zParentInMe > this.Height) + break; // TODO: might not be correct. Was : Exit For + // For performance reasons, the list of LineNumberItems (zLNIs) is first built with only the location of its + // itemrectangle being used. The height of those rectangles will be computed afterwards by comparing the items' Y coordinates. + zLNIs.Add(new LineNumberItem(zA + 1, new Rectangle(0, zPoint.Y - 1 + zParentInMe, this.Width, 1))); + if (zParentIsScrolling == true && DateAndTime.Now.Ticks > zTimeSpan.Ticks + 500000) { + // The more lines there are in the RTB, the slower the RTB's .GetPositionFromCharIndex() method becomes + // To avoid those delays from interfering with the scrollingspeed, this speedbased exit for is applied (0.05 sec) + // zLNIs will have at least 1 item, and if that's the only one, then change its location to 0,0 to make it readable + if (zLNIs.Count == 1) + zLNIs[0].Rectangle.Y = 0; + // zLNIs(0).Rectangle.Y = 0; + + zParentIsScrolling = false; + zTimer.Start(); + break; // TODO: might not be correct. Was : Exit For + } + } + + if (zLNIs.Count == 0) + return; + + // Add an extra placeholder item to the end, to make the heightcomputation easier + if (zA < zSplit.Length) { + // getting here means the for/next loop was exited before reaching the last zSplit textline + // zStartIndex will still be pointing to the startcharacter of the next line, so we can use that: + zPoint = zParent.GetPositionFromCharIndex(Math.Min(zStartIndex, zParent.Text.Length - 1)); + zLNIs.Add(new LineNumberItem(-1, new Rectangle(0, zPoint.Y - 1 + zParentInMe, 0, 0))); + } else { + // getting here means the for/next loop ran to the end (zA is now zSplit.Length). + zLNIs.Add(new LineNumberItem(-1, new Rectangle(0, zContentRectangle.Bottom, 0, 0))); + } + + // And now we can easily compute the height of the LineNumberItems by comparing each item's Y coordinate with that of the next line. + // There's at least two items in the list, and the last item is a "nextline-placeholder" that will be removed. + for (zA = 0; zA <= zLNIs.Count - 2; zA++) { + zLNIs[zA].Rectangle.Height = Math.Max(1, zLNIs[zA + 1].Rectangle.Y - zLNIs[zA].Rectangle.Y); + //zLNIs(zA).Rectangle.Height = Math.Max(1, zLNIs(zA + 1).Rectangle.Y - zLNIs(zA).Rectangle.Y); + } + // Removing the placeholder item + zLNIs.RemoveAt(zLNIs.Count - 1); + + // Set the Format to the width of the highest possible number so that LeadingZeroes shows the correct amount of zeroes. + if (zLineNumbers_ShowAsHexadecimal == true) { + //zLineNumbers_Format = "".PadRight(zSplit.Length.ToString("X").Length, "0"); + zLineNumbers_Format = "".PadRight(zSplit.Length.ToString("X").Length, '0'); + } else { + //zLineNumbers_Format = "".PadRight(zSplit.Length.ToString().Length, "0"); + zLineNumbers_Format = "".PadRight(zSplit.Length.ToString().Length, '0'); + } + } + + // To measure the LineNumber's width, its Format 0 is replaced by w as that is likely to be one of the widest characters in non-monospace fonts. + if (zAutoSizing == true) + zAutoSizing_Size = new Size(TextRenderer.MeasureText(zLineNumbers_Format.Replace('0', 'W'), this.Font).Width, 0); + //zAutoSizing_Size = new Size(TextRenderer.MeasureText(zLineNumbers_Format.Replace("0".ToCharArray(), "W".ToCharArray()), this.Font).Width, 0); + } + + /// + /// FindStartIndex is a recursive Sub (one that calls itself) to compute the first visible line that should have a LineNumber. + /// + /// this will hold the eventual BestStartIndex when the Sub has completed its run. + /// + /// + /// + private void FindStartIndex(ref int zMin, ref int zMax, ref int zTarget) + { + // Recursive Sub to compute best starting index - only run when zParent is known to exist + if (zMax == zMin + 1 | zMin == (zMax + zMin) / 2) + return; + + if(zParent.GetPositionFromCharIndex((zMax + zMin) / 2).Y == zTarget){ + //switch (zParent.GetPositionFromCharIndex((zMax + zMin) / 2).Y) { + // case // ERROR: Case labels with binary operators are unsupported : Equality + // BestStartIndex found + zMin = (zMax + zMin) / 2; + //break; + } + else if (zParent.GetPositionFromCharIndex((zMax + zMin) / 2).Y > zTarget) + { + //case // ERROR: Case labels with binary operators are unsupported : GreaterThan + //zTarget: + // Look again, in lower half + zMax = (zMax + zMin) / 2; + FindStartIndex(ref zMin, ref zMax, ref zTarget); + //break; + } + else if (zParent.GetPositionFromCharIndex((zMax + zMin) / 2).Y < 0) + { + // case // ERROR: Case labels with binary operators are unsupported : LessThan + //0: + // Look again, in top half + zMin = (zMax + zMin) / 2; + FindStartIndex(ref zMin, ref zMax, ref zTarget); + //break; + } + + } + + + /// + /// OnPaint will go through the enabled elements (vertical ReminderMessage, GridLines, LineNumbers, BorderLines, MarginLines) and will + /// draw them if enabled. At the same time, it will build GraphicsPaths for each of those elements (that are enabled), which will be used + /// in SeeThroughMode (if it's active): the figures in the GraphicsPaths will form a customized outline for the control by setting them as the + /// Region of the LineNumber control. Note: the vertical ReminderMessages are only drawn during designtime. + /// + /// + /// + protected override void OnPaint(System.Windows.Forms.PaintEventArgs e) + { + // Build the list of visible LineNumberItems (= zLNIs) first. (doesn't take long, so it can stay in OnPaint) + this.Update_VisibleLineNumberItems(); + base.OnPaint(e); + + // --- QualitySettings + if (zLineNumbers_AntiAlias == true) { + e.Graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias; + } else { + e.Graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.SystemDefault; + } + + // --- Local Declarations + string zTextToShow = ""; + string zReminderToShow = ""; + StringFormat zSF = new StringFormat(); + SizeF zTextSize = default(SizeF); + Pen zPen = new Pen(this.ForeColor); + SolidBrush zBrush = new SolidBrush(this.ForeColor); + Point zPoint = new Point(0, 0); + Rectangle zItemClipRectangle = new Rectangle(0, 0, 0, 0); + + // NOTE: The GraphicsPaths are only used for SeeThroughMode + // FillMode.Winding: combined outline ( Alternate: XOR'ed outline ) + System.Drawing.Drawing2D.GraphicsPath zGP_GridLines = new System.Drawing.Drawing2D.GraphicsPath(System.Drawing.Drawing2D.FillMode.Winding); + System.Drawing.Drawing2D.GraphicsPath zGP_BorderLines = new System.Drawing.Drawing2D.GraphicsPath(System.Drawing.Drawing2D.FillMode.Winding); + System.Drawing.Drawing2D.GraphicsPath zGP_MarginLines = new System.Drawing.Drawing2D.GraphicsPath(System.Drawing.Drawing2D.FillMode.Winding); + System.Drawing.Drawing2D.GraphicsPath zGP_LineNumbers = new System.Drawing.Drawing2D.GraphicsPath(System.Drawing.Drawing2D.FillMode.Winding); + Region zRegion = new Region(base.ClientRectangle); + + + // ---------------------------------------------- + // --- DESIGNTIME / NO VISIBLE ITEMS + if (this.DesignMode == true) { + // Show a vertical reminder message + if (zParent == null) { + zReminderToShow = "-!- Set ParentRichTextBox -!-"; + } else { + if (zLNIs.Count == 0) + zReminderToShow = "LineNrs ( " + zParent.Name + " )"; + } + if (zReminderToShow.Length > 0) { + // --- Centering and Rotation for the reminder message + e.Graphics.TranslateTransform(this.Width / 2, this.Height / 2); + e.Graphics.RotateTransform(-90); + zSF.Alignment = StringAlignment.Center; + zSF.LineAlignment = StringAlignment.Center; + // --- Show the reminder message (with small shadow) + zTextSize = e.Graphics.MeasureString(zReminderToShow, this.Font, zPoint, zSF); + e.Graphics.DrawString(zReminderToShow, this.Font, Brushes.WhiteSmoke, 1, 1, zSF); + e.Graphics.DrawString(zReminderToShow, this.Font, Brushes.Firebrick, 0, 0, zSF); + e.Graphics.ResetTransform(); + + //Rectangle zReminderRectangle = new Rectangle(this.Width / 2 - zTextSize.Height / 2, this.Height / 2 - zTextSize.Width / 2, zTextSize.Height, zTextSize.Width); + Rectangle zReminderRectangle = new Rectangle((int)(this.Width / 2 - zTextSize.Height / 2), (int)(this.Height / 2 - zTextSize.Width / 2), (int)(zTextSize.Height), (int)(zTextSize.Width)); + zGP_LineNumbers.AddRectangle(zReminderRectangle); + zGP_LineNumbers.CloseFigure(); + + if (zAutoSizing == true) { + zReminderRectangle.Inflate((int)(zTextSize.Height * 0.2), (int)(zTextSize.Width * 0.1)); + //zReminderRectangle.Inflate(zTextSize.Height * 0.2, zTextSize.Width * 0.1); + zAutoSizing_Size = new Size(zReminderRectangle.Width, zReminderRectangle.Height); + } + } + } + + + // ---------------------------------------------- + // --- DESIGN OR RUNTIME / WITH VISIBLE ITEMS (which means zParent exists) + if (zLNIs.Count > 0) { + // The visible LineNumberItems with their BackgroundGradient and GridLines + // Loop through every visible LineNumberItem + System.Drawing.Drawing2D.LinearGradientBrush zLGB = null; + zPen = new Pen(zGridLines_Color, zGridLines_Thickness); + zPen.DashStyle = zGridLines_Style; + zSF.Alignment = StringAlignment.Near; + zSF.LineAlignment = StringAlignment.Near; + //zSF.FormatFlags = StringFormatFlags.FitBlackBox + StringFormatFlags.NoClip + StringFormatFlags.NoWrap; + zSF.FormatFlags = StringFormatFlags.FitBlackBox | StringFormatFlags.NoClip | StringFormatFlags.NoWrap; + + + for (int zA = 0; zA <= zLNIs.Count - 1; zA++) { + // --- BackgroundGradient + if (zGradient_Show == true) { + //zLGB = new Drawing2D.LinearGradientBrush(zLNIs(zA).Rectangle, zGradient_StartColor, zGradient_EndColor, zGradient_Direction); + zLGB = new System.Drawing.Drawing2D.LinearGradientBrush(zLNIs[zA].Rectangle, zGradient_StartColor, zGradient_EndColor, zGradient_Direction); + e.Graphics.FillRectangle(zLGB, zLNIs[zA].Rectangle); + //e.Graphics.FillRectangle(zLGB, zLNIs(zA).Rectangle); + } + + // --- GridLines + if (zGridLines_Show == true) { + e.Graphics.DrawLine(zPen, new Point(0, zLNIs[zA].Rectangle.Y), new Point(this.Width, zLNIs[zA].Rectangle.Y)); + //e.Graphics.DrawLine(zPen, new Point(0, zLNIs(zA).Rectangle.Y), new Point(this.Width, zLNIs(zA).Rectangle.Y)); + + // NOTE: Every item in a GraphicsPath is a closed figure, so instead of adding gridlines as lines, we'll add them + // as rectangles that loop out of sight. Their height uses the zContentRectangle which is the maxsize of + // the ParentRichTextBox's contents. + // NOTE: Slight adjustment needed when the first item has a negative Y coordinate. + // This explains the " - zLNIs(0).Rectangle.Y" (which adds the negative size to the height + // to make sure the rectangle's bottompart stays out of sight) + //zGP_GridLines.AddRectangle(new Rectangle(-zGridLines_Thickness, zLNIs(zA).Rectangle.Y, this.Width + zGridLines_Thickness * 2, this.Height - zLNIs(0).Rectangle.Y + zGridLines_Thickness)); + zGP_GridLines.AddRectangle(new Rectangle( (int)(-zGridLines_Thickness), + (int)(zLNIs[zA].Rectangle.Y), + (int)(this.Width + zGridLines_Thickness * 2), + (int)(this.Height - zLNIs[zA].Rectangle.Y + zGridLines_Thickness) + )); + zGP_GridLines.CloseFigure(); + } + + // --- LineNumbers + if (zLineNumbers_Show == true) { + // TextFormatting + if (zLineNumbers_ShowLeadingZeroes == true) { + zTextToShow = (zLineNumbers_ShowAsHexadecimal ? zLNIs[zA].LineNumber.ToString("X") : zLNIs[zA].LineNumber.ToString(zLineNumbers_Format)); + //zTextToShow = (zLineNumbers_ShowAsHexadecimal ? zLNIs(zA).LineNumber.ToString("X") : zLNIs(zA).LineNumber.ToString(zLineNumbers_Format)); + } else { + zTextToShow = (zLineNumbers_ShowAsHexadecimal ? zLNIs[zA].LineNumber.ToString("X") : zLNIs[zA].LineNumber.ToString()); + //zTextToShow = (zLineNumbers_ShowAsHexadecimal ? zLNIs(zA).LineNumber.ToString("X") : zLNIs(zA).LineNumber.ToString); + } + + // TextSizing + zTextSize = e.Graphics.MeasureString(zTextToShow, this.Font, zPoint, zSF); + // TextAlignment and positioning (zPoint = TopLeftCornerPoint of the text) + // TextAlignment, padding, manual offset (via LineNrs_Offset) and zTextSize are all included in the calculation of zPoint. + switch (zLineNumbers_Alignment) { + case ContentAlignment.TopLeft: + zPoint = new Point((int)(zLNIs[zA].Rectangle.Left + this.Padding.Left + zLineNumbers_Offset.Width), (int)(zLNIs[zA].Rectangle.Top + this.Padding.Top + zLineNumbers_Offset.Height)); + break; + case ContentAlignment.MiddleLeft: + zPoint = new Point((int)(zLNIs[zA].Rectangle.Left + this.Padding.Left + zLineNumbers_Offset.Width), (int)(zLNIs[zA].Rectangle.Top + (zLNIs[zA].Rectangle.Height / 2) + zLineNumbers_Offset.Height - zTextSize.Height / 2)); + break; + case ContentAlignment.BottomLeft: + zPoint = new Point((int)(zLNIs[zA].Rectangle.Left + this.Padding.Left + zLineNumbers_Offset.Width), (int)(zLNIs[zA].Rectangle.Bottom - this.Padding.Bottom + 1 + zLineNumbers_Offset.Height - zTextSize.Height)); + break; + case ContentAlignment.TopCenter: + zPoint = new Point((int)(zLNIs[zA].Rectangle.Width / 2 + zLineNumbers_Offset.Width - zTextSize.Width / 2), (int)(zLNIs[zA].Rectangle.Top + this.Padding.Top + zLineNumbers_Offset.Height)); + break; + case ContentAlignment.MiddleCenter: + zPoint = new Point((int)(zLNIs[zA].Rectangle.Width / 2 + zLineNumbers_Offset.Width - zTextSize.Width / 2), (int)(zLNIs[zA].Rectangle.Top + (zLNIs[zA].Rectangle.Height / 2) + zLineNumbers_Offset.Height - zTextSize.Height / 2)); + break; + case ContentAlignment.BottomCenter: + zPoint = new Point((int)(zLNIs[zA].Rectangle.Width / 2 + zLineNumbers_Offset.Width - zTextSize.Width / 2), (int)(zLNIs[zA].Rectangle.Bottom - this.Padding.Bottom + 1 + zLineNumbers_Offset.Height - zTextSize.Height)); + break; + case ContentAlignment.TopRight: + zPoint = new Point((int)(zLNIs[zA].Rectangle.Right - this.Padding.Right + zLineNumbers_Offset.Width - zTextSize.Width), (int)(zLNIs[zA].Rectangle.Top + this.Padding.Top + zLineNumbers_Offset.Height)); + break; + case ContentAlignment.MiddleRight: + zPoint = new Point((int)(zLNIs[zA].Rectangle.Right - this.Padding.Right + zLineNumbers_Offset.Width - zTextSize.Width), (int)(zLNIs[zA].Rectangle.Top + (zLNIs[zA].Rectangle.Height / 2) + zLineNumbers_Offset.Height - zTextSize.Height / 2)); + break; + case ContentAlignment.BottomRight: + zPoint = new Point((int)(zLNIs[zA].Rectangle.Right - this.Padding.Right + zLineNumbers_Offset.Width - zTextSize.Width), (int)(zLNIs[zA].Rectangle.Bottom - this.Padding.Bottom + 1 + zLineNumbers_Offset.Height - zTextSize.Height)); + break; + } + // TextClipping + zItemClipRectangle = new Rectangle(zPoint, zTextSize.ToSize()); + if (zLineNumbers_ClipByItemRectangle == true) { + // If selected, the text will be clipped so that it doesn't spill out of its own LineNumberItem-area. + // Only the part of the text inside the LineNumberItem.Rectangle should be visible, so intersect with the ItemRectangle + // The SetClip method temporary restricts the drawing area of the control for whatever is drawn next. + zItemClipRectangle.Intersect(zLNIs[zA].Rectangle); + e.Graphics.SetClip(zItemClipRectangle); + } + // TextDrawing + e.Graphics.DrawString(zTextToShow, this.Font, zBrush, zPoint, zSF); + e.Graphics.ResetClip(); + // The GraphicsPath for the LineNumber is just a rectangle behind the text, to keep the paintingspeed high and avoid ugly artifacts. + zGP_LineNumbers.AddRectangle(zItemClipRectangle); + zGP_LineNumbers.CloseFigure(); + } + } + + // --- GridLinesThickness and Linestyle in SeeThroughMode. All GraphicsPath lines are drawn as solid to keep the paintingspeed high. + if (zGridLines_Show == true) { + zPen.DashStyle = System.Drawing.Drawing2D.DashStyle.Solid; + zGP_GridLines.Widen(zPen); + } + + // --- Memory CleanUp + if (zLGB != null) + zLGB.Dispose(); + } + + + // ---------------------------------------------- + // --- DESIGN OR RUNTIME / ALWAYS + //Point zP_Left = new Point(Math.Floor(zBorderLines_Thickness / 2), Math.Floor(zBorderLines_Thickness / 2)); + //Point zP_Right = new Point(this.Width - Math.Ceiling(zBorderLines_Thickness / 2), this.Height - Math.Ceiling(zBorderLines_Thickness / 2)); + + Point zP_Left = new Point( + (int)(Math.Floor(zBorderLines_Thickness / 2)), + (int)(Math.Floor(zBorderLines_Thickness / 2)) + ); + Point zP_Right = new Point( + (int)(this.Width - Math.Ceiling(zBorderLines_Thickness / 2)), + (int)(this.Height - Math.Ceiling(zBorderLines_Thickness / 2)) + ); + + // --- BorderLines + Point[] zBorderLines_Points = { + new Point(zP_Left.X, zP_Left.Y), + new Point(zP_Right.X, zP_Left.Y), + new Point(zP_Right.X, zP_Right.Y), + new Point(zP_Left.X, zP_Right.Y), + new Point(zP_Left.X, zP_Left.Y) + }; + if (zBorderLines_Show == true) { + zPen = new Pen(zBorderLines_Color, zBorderLines_Thickness); + zPen.DashStyle = zBorderLines_Style; + e.Graphics.DrawLines(zPen, zBorderLines_Points); + zGP_BorderLines.AddLines(zBorderLines_Points); + zGP_BorderLines.CloseFigure(); + // BorderThickness and Style for SeeThroughMode + zPen.DashStyle = System.Drawing.Drawing2D.DashStyle.Solid; + zGP_BorderLines.Widen(zPen); + } + + + // --- MarginLines + if (zMarginLines_Show == true && zMarginLines_Side > LineNumberDockSide.None) { + zP_Left = new Point((int)(-zMarginLines_Thickness), (int)(-zMarginLines_Thickness)); + zP_Right = new Point((int)(this.Width + zMarginLines_Thickness), (int)(this.Height + zMarginLines_Thickness)); + zPen = new Pen(zMarginLines_Color, zMarginLines_Thickness); + zPen.DashStyle = zMarginLines_Style; + if (zMarginLines_Side == LineNumberDockSide.Left | zMarginLines_Side == LineNumberDockSide.Height) { + e.Graphics.DrawLine(zPen, new Point( + (int)(Math.Floor(zMarginLines_Thickness / 2)), 0), + new Point( + (int)(Math.Floor(zMarginLines_Thickness / 2)), + this.Height - 1) + ); + zP_Left = new Point( + (int)(Math.Ceiling(zMarginLines_Thickness / 2)), + (int)(-zMarginLines_Thickness)); + } + if (zMarginLines_Side == LineNumberDockSide.Right | zMarginLines_Side == LineNumberDockSide.Height) { + e.Graphics.DrawLine(zPen, new Point( + (int)(this.Width - Math.Ceiling(zMarginLines_Thickness / 2)), 0), + new Point( + (int)(this.Width - Math.Ceiling(zMarginLines_Thickness / 2)), + (int)(this.Height - 1)) + ); + + zP_Right = new Point( + (int)(this.Width - Math.Ceiling(zMarginLines_Thickness / 2)), + (int)(this.Height + zMarginLines_Thickness) + ); + } + // GraphicsPath for the MarginLines(s): + // MarginLines(s) are drawn as a rectangle connecting the zP_Left and zP_Right points, which are either inside or + // outside of sight, depending on whether the MarginLines at that side is visible. zP_Left: TopLeft and ZP_Right: BottomRight + zGP_MarginLines.AddRectangle(new Rectangle(zP_Left, new Size(zP_Right.X - zP_Left.X, zP_Right.Y - zP_Left.Y))); + zPen.DashStyle = System.Drawing.Drawing2D.DashStyle.Solid; + zGP_MarginLines.Widen(zPen); + } + + + // ---------------------------------------------- + // --- SeeThroughMode + // combine all the GraphicsPaths (= zGP_... ) and set them as the region for the control. + if (zSeeThroughMode == true) { + zRegion.MakeEmpty(); + zRegion.Union(zGP_BorderLines); + zRegion.Union(zGP_MarginLines); + zRegion.Union(zGP_GridLines); + zRegion.Union(zGP_LineNumbers); + } + + // --- Region + if (zRegion.GetBounds(e.Graphics).IsEmpty == true) { + // Note: If the control is in a condition that would show it as empty, then a border-region is still drawn regardless of it's borders on/off state. + // This is added to make sure that the bounds of the control are never lost (it would remain empty if this was not done). + zGP_BorderLines.AddLines(zBorderLines_Points); + zGP_BorderLines.CloseFigure(); + zPen = new Pen(zBorderLines_Color, 1); + zPen.DashStyle = System.Drawing.Drawing2D.DashStyle.Solid; + zGP_BorderLines.Widen(zPen); + + zRegion = new Region(zGP_BorderLines); + } + this.Region = zRegion; + + + // ---------------------------------------------- + // --- Memory CleanUp + if (zPen != null) + zPen.Dispose(); + if (zBrush != null) + zPen.Dispose(); + if (zRegion != null) + zRegion.Dispose(); + if (zGP_GridLines != null) + zGP_GridLines.Dispose(); + if (zGP_BorderLines != null) + zGP_BorderLines.Dispose(); + if (zGP_MarginLines != null) + zGP_MarginLines.Dispose(); + if (zGP_LineNumbers != null) + zGP_LineNumbers.Dispose(); + + } + + + //////////////////////////////////////////////////////////////////////////////////////////////////// + + private void zTimer_Tick(object sender, System.EventArgs e) + { + zParentIsScrolling = false; + zTimer.Stop(); + this.Invalidate(); + } + + private void zParent_Changed(object sender, System.EventArgs e) + { + this.Refresh(); + this.Invalidate(); + } + + private void zParent_Scroll(object sender, System.EventArgs e) + { + zParentIsScrolling = true; + this.Invalidate(); + } + + private void zParent_ContentsResized(object sender, System.Windows.Forms.ContentsResizedEventArgs e) + { + zContentRectangle = e.NewRectangle; + this.Refresh(); + this.Invalidate(); + } + + private void zParent_Disposed(object sender, System.EventArgs e) + { + this.ParentRichTextBox = null; + this.Refresh(); + this.Invalidate(); + } + + } +}