diff --git a/Crypto Notepad/AboutFrom.Designer.cs b/Crypto Notepad/AboutFrom.Designer.cs index 7b1d7f8..a6b20b8 100644 --- a/Crypto Notepad/AboutFrom.Designer.cs +++ b/Crypto Notepad/AboutFrom.Designer.cs @@ -36,8 +36,8 @@ private void InitializeComponent() this.LicenseLinkLabel = new System.Windows.Forms.LinkLabel(); this.GithubLinkLabel = new System.Windows.Forms.LinkLabel(); this.ContributorsLabel = new System.Windows.Forms.Label(); - this.ContributorsRichTextBox = new Crypto_Notepad.CustomRichTextBox(); - this.TPDRichTextBox = new Crypto_Notepad.CustomRichTextBox(); + this.TPDRichTextBox = new System.Windows.Forms.RichTextBox(); + this.ContributorsRichTextBox = new System.Windows.Forms.RichTextBox(); ((System.ComponentModel.ISupportInitialize)(this.AppLogoPictureBox)).BeginInit(); this.SuspendLayout(); // @@ -142,29 +142,11 @@ private void InitializeComponent() this.ContributorsLabel.TabIndex = 4; this.ContributorsLabel.Text = "Contributors:"; // - // ContributorsRichTextBox - // - this.ContributorsRichTextBox.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(45)))), ((int)(((byte)(45)))), ((int)(((byte)(50))))); - this.ContributorsRichTextBox.BorderStyle = System.Windows.Forms.BorderStyle.None; - this.ContributorsRichTextBox.Font = new System.Drawing.Font("Consolas", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(204))); - this.ContributorsRichTextBox.ForeColor = System.Drawing.Color.White; - this.ContributorsRichTextBox.Location = new System.Drawing.Point(-1, 128); - this.ContributorsRichTextBox.Name = "ContributorsRichTextBox"; - this.ContributorsRichTextBox.ReadOnly = true; - this.ContributorsRichTextBox.RightMargin = 600; - this.ContributorsRichTextBox.ScrollBars = System.Windows.Forms.RichTextBoxScrollBars.None; - this.ContributorsRichTextBox.ShowSelectionMargin = true; - this.ContributorsRichTextBox.Size = new System.Drawing.Size(398, 19); - this.ContributorsRichTextBox.TabIndex = 8; - this.ContributorsRichTextBox.TabStop = false; - this.ContributorsRichTextBox.Text = "h5p9sl https://github.com/h5p9sl"; - this.ContributorsRichTextBox.WordWrap = false; - this.ContributorsRichTextBox.LinkClicked += new System.Windows.Forms.LinkClickedEventHandler(this.TPDRichTextBox_LinkClicked); - // // TPDRichTextBox // this.TPDRichTextBox.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(45)))), ((int)(((byte)(45)))), ((int)(((byte)(50))))); this.TPDRichTextBox.BorderStyle = System.Windows.Forms.BorderStyle.None; + this.TPDRichTextBox.Dock = System.Windows.Forms.DockStyle.Bottom; this.TPDRichTextBox.Font = new System.Drawing.Font("Consolas", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(204))); this.TPDRichTextBox.ForeColor = System.Drawing.Color.White; this.TPDRichTextBox.Location = new System.Drawing.Point(0, 181); @@ -173,24 +155,41 @@ private void InitializeComponent() this.TPDRichTextBox.RightMargin = 700; this.TPDRichTextBox.ScrollBars = System.Windows.Forms.RichTextBoxScrollBars.Horizontal; this.TPDRichTextBox.ShowSelectionMargin = true; - this.TPDRichTextBox.Size = new System.Drawing.Size(400, 121); - this.TPDRichTextBox.TabIndex = 8; - this.TPDRichTextBox.TabStop = false; + this.TPDRichTextBox.Size = new System.Drawing.Size(397, 103); + this.TPDRichTextBox.TabIndex = 10; this.TPDRichTextBox.Text = resources.GetString("TPDRichTextBox.Text"); this.TPDRichTextBox.WordWrap = false; this.TPDRichTextBox.LinkClicked += new System.Windows.Forms.LinkClickedEventHandler(this.TPDRichTextBox_LinkClicked); // + // ContributorsRichTextBox + // + this.ContributorsRichTextBox.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(45)))), ((int)(((byte)(45)))), ((int)(((byte)(50))))); + this.ContributorsRichTextBox.BorderStyle = System.Windows.Forms.BorderStyle.None; + this.ContributorsRichTextBox.Font = new System.Drawing.Font("Consolas", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(204))); + this.ContributorsRichTextBox.ForeColor = System.Drawing.Color.White; + this.ContributorsRichTextBox.Location = new System.Drawing.Point(0, 125); + this.ContributorsRichTextBox.Name = "ContributorsRichTextBox"; + this.ContributorsRichTextBox.ReadOnly = true; + this.ContributorsRichTextBox.RightMargin = 700; + this.ContributorsRichTextBox.ScrollBars = System.Windows.Forms.RichTextBoxScrollBars.None; + this.ContributorsRichTextBox.ShowSelectionMargin = true; + this.ContributorsRichTextBox.Size = new System.Drawing.Size(397, 18); + this.ContributorsRichTextBox.TabIndex = 11; + this.ContributorsRichTextBox.Text = "h5p9sl https://github.com/h5p9sl"; + this.ContributorsRichTextBox.WordWrap = false; + this.ContributorsRichTextBox.LinkClicked += new System.Windows.Forms.LinkClickedEventHandler(this.ContributorsRichTextBox_LinkClicked); + // // AboutFrom // 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(397, 302); + this.ClientSize = new System.Drawing.Size(397, 284); + this.Controls.Add(this.ContributorsRichTextBox); + this.Controls.Add(this.TPDRichTextBox); this.Controls.Add(this.GithubLinkLabel); this.Controls.Add(this.LicenseLinkLabel); this.Controls.Add(this.AuthorLinkLabel); - this.Controls.Add(this.ContributorsRichTextBox); - this.Controls.Add(this.TPDRichTextBox); this.Controls.Add(this.AppLogoPictureBox); this.Controls.Add(this.AppVersionLabel); this.Controls.Add(this.ContributorsLabel); @@ -215,11 +214,11 @@ private void InitializeComponent() private System.Windows.Forms.Label AppVersionLabel; private System.Windows.Forms.PictureBox AppLogoPictureBox; private System.Windows.Forms.Label TPDLabel; - private CustomRichTextBox TPDRichTextBox; private System.Windows.Forms.LinkLabel AuthorLinkLabel; private System.Windows.Forms.LinkLabel LicenseLinkLabel; private System.Windows.Forms.LinkLabel GithubLinkLabel; private System.Windows.Forms.Label ContributorsLabel; - private CustomRichTextBox ContributorsRichTextBox; + private System.Windows.Forms.RichTextBox TPDRichTextBox; + private System.Windows.Forms.RichTextBox ContributorsRichTextBox; } } \ No newline at end of file diff --git a/Crypto Notepad/AboutFrom.cs b/Crypto Notepad/AboutFrom.cs index 110f12c..156333f 100644 --- a/Crypto Notepad/AboutFrom.cs +++ b/Crypto Notepad/AboutFrom.cs @@ -68,6 +68,11 @@ private void TPDRichTextBox_LinkClicked(object sender, LinkClickedEventArgs e) { Process.Start(e.LinkText); } + + private void ContributorsRichTextBox_LinkClicked(object sender, LinkClickedEventArgs e) + { + Process.Start(e.LinkText); + } /*Perform open links*/ } diff --git a/Crypto Notepad/AboutFrom.resx b/Crypto Notepad/AboutFrom.resx index 1cff176..4327617 100644 --- a/Crypto Notepad/AboutFrom.resx +++ b/Crypto Notepad/AboutFrom.resx @@ -371,11 +371,9 @@ 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/Crypto Notepad.csproj b/Crypto Notepad/Crypto Notepad.csproj index ad5d99f..d823f6b 100644 --- a/Crypto Notepad/Crypto Notepad.csproj +++ b/Crypto Notepad/Crypto Notepad.csproj @@ -103,12 +103,6 @@ ChangeKeyForm.cs - - Component - - - CustomRichTextBox.cs - Component diff --git a/Crypto Notepad/CustomRichTextBox.Designer.cs b/Crypto Notepad/CustomRichTextBox.Designer.cs deleted file mode 100644 index e4b23c1..0000000 --- a/Crypto Notepad/CustomRichTextBox.Designer.cs +++ /dev/null @@ -1,36 +0,0 @@ -namespace Crypto_Notepad -{ - partial class CustomRichTextBox - { - /// - /// Требуется переменная конструктора. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Освободить все используемые ресурсы. - /// - /// истинно, если управляемый ресурс должен быть удален; иначе ложно. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Код, автоматически созданный конструктором компонентов - - /// - /// Обязательный метод для поддержки конструктора - не изменяйте - /// содержимое данного метода при помощи редактора кода. - /// - private void InitializeComponent() - { - components = new System.ComponentModel.Container(); - } - - #endregion - } -} diff --git a/Crypto Notepad/CustomRichTextBox.cs b/Crypto Notepad/CustomRichTextBox.cs deleted file mode 100644 index 14dfc61..0000000 --- a/Crypto Notepad/CustomRichTextBox.cs +++ /dev/null @@ -1,146 +0,0 @@ -/****************************** Module Header ******************************\ -* Module Name: CustomRichTextBox.cs -* Project: CSWinFormSearchAndHighlightText -* Copyright(c) Microsoft Corporation. -* -* Theclass is used to create custom RichTextBox -* The custom RichTextBox add custom Highlight and ClearHighlight method -* -* This source is subject to the Microsoft Public License. -* See http://www.microsoft.com/en-us/openness/licenses.aspx. -* All other rights reserved. -* -* THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, -* EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED -* WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. -\***************************************************************************/ - -using System.Drawing; -using System.Windows.Forms; -using System.Collections.Generic; -using System.Runtime.InteropServices; -using System; - -namespace Crypto_Notepad -{ - /// - /// Custom RichTextBox control - /// - public partial class CustomRichTextBox : RichTextBox - { - public CustomRichTextBox() - : base() - { - InitializeComponent(); - } - - [DllImport("user32.dll", CharSet = CharSet.Auto)] - private static extern int SendMessage(IntPtr hWnd, int wMsg, IntPtr wParam, IntPtr lParam); - - //this message is sent to the control when we scroll using the mouse - private const int WM_MOUSEWHEEL = 0x20A; - - //and this one issues the control to perform scrolling - private const int WM_VSCROLL = 0x115; - - protected override void OnHandleCreated(EventArgs e) - { - base.OnHandleCreated(e); - if (!base.AutoWordSelection) - { - base.AutoWordSelection = true; - base.AutoWordSelection = false; - } - } - - protected override void WndProc(ref Message m) - { - if (m.Msg == WM_MOUSEWHEEL) - { - int scrollLines = SystemInformation.MouseWheelScrollLines; - for (int i = 0; i < scrollLines; i++) - { - try - { - if ((int)m.WParam >= 0) // when wParam is greater than 0 - SendMessage(this.Handle, WM_VSCROLL, (IntPtr)0, IntPtr.Zero); // scroll up - else - SendMessage(this.Handle, WM_VSCROLL, (IntPtr)1, IntPtr.Zero); // scroll down - } - catch (OverflowException) - { - SendMessage(this.Handle, WM_VSCROLL, (IntPtr)1, IntPtr.Zero); // scroll down - } - } - return; - } - base.WndProc(ref m); - } - - /// - /// Search and Highlight all text in RichTextBox Control - /// - /// Find What - /// Highlight Color - /// Is Match Case - /// Is Match Whole Word - /// - public bool Highlight(string findWhat, Color highlightColor, bool ismatchCase, bool ismatchWholeWord) - { - // Clear all highlights before searching text again - ClearHighlight(); - - int startSearch = 0; - //int searchLength = findWhat.Length; - RichTextBoxFinds findoptions = default(RichTextBoxFinds); - - // Setup the search options. - if (ismatchCase && ismatchWholeWord) - { - findoptions = RichTextBoxFinds.MatchCase | RichTextBoxFinds.WholeWord; - } - else if (ismatchCase) - { - findoptions = RichTextBoxFinds.MatchCase; - } - else if (ismatchWholeWord) - { - findoptions = RichTextBoxFinds.WholeWord; - } - else - { - findoptions = RichTextBoxFinds.None; - } - - // detect whether search text exists in richtextbox - bool isfind = false; - int index = -1; - - // Search text in RichTextBox and highlight them with color. - - int max = this.TextLength; - while (startSearch < max && (index = this.Find(findWhat, startSearch, findoptions)) > -1) - { - isfind = true; - - this.SelectionBackColor = highlightColor; - - // Continue after the one we searched - startSearch = index + 1; - } - - // If the text exist in RichTextBox control, then return true, otherwise, return false - return isfind; - } - - /// - /// Clear all Highlights - /// - private void ClearHighlight() - { - Properties.Settings ps = Properties.Settings.Default; - this.SelectAll(); - this.SelectionBackColor = ps.RichBackColor; - } - } -} diff --git a/Crypto Notepad/MainForm.Designer.cs b/Crypto Notepad/MainForm.Designer.cs index f301586..2ea1506 100644 --- a/Crypto Notepad/MainForm.Designer.cs +++ b/Crypto Notepad/MainForm.Designer.cs @@ -102,8 +102,8 @@ public void InitializeComponent() this.FileLocationToolbarButton = new System.Windows.Forms.PictureBox(); this.SaveToolBarButton = new System.Windows.Forms.PictureBox(); this.OpenToolbarButton = new System.Windows.Forms.PictureBox(); - this.LineNumbers_For_RichTextBox = new LineNumbers.LineNumbers_For_RichTextBox(); this.RichTextBox = new System.Windows.Forms.RichTextBox(); + this.LineNumbers_For_RichTextBox = new LineNumbers.LineNumbers_For_RichTextBox(); this.MainMenu.SuspendLayout(); this.EditorMenuStrip.SuspendLayout(); this.SearchPanel.SuspendLayout(); @@ -858,6 +858,24 @@ public void InitializeComponent() this.OpenToolbarButton.TabStop = false; this.OpenToolbarButton.Click += new System.EventHandler(this.OpenToolbarButton_Click); // + // RichTextBox + // + this.RichTextBox.AcceptsTab = true; + this.RichTextBox.BorderStyle = System.Windows.Forms.BorderStyle.None; + this.RichTextBox.ContextMenuStrip = this.EditorMenuStrip; + this.RichTextBox.Dock = System.Windows.Forms.DockStyle.Fill; + this.RichTextBox.Location = new System.Drawing.Point(18, 47); + this.RichTextBox.Name = "RichTextBox"; + this.RichTextBox.Size = new System.Drawing.Size(495, 244); + this.RichTextBox.TabIndex = 16; + this.RichTextBox.Text = ""; + this.RichTextBox.LinkClicked += new System.Windows.Forms.LinkClickedEventHandler(this.RichTextBox_LinkClicked); + this.RichTextBox.SelectionChanged += new System.EventHandler(this.RichTextBox_SelectionChanged); + this.RichTextBox.Click += new System.EventHandler(this.RichTextBox_Click); + this.RichTextBox.TextChanged += new System.EventHandler(this.RichTextBox_TextChanged); + this.RichTextBox.KeyDown += new System.Windows.Forms.KeyEventHandler(this.RichTextBox_KeyDown); + this.RichTextBox.KeyUp += new System.Windows.Forms.KeyEventHandler(this.RichTextBox_KeyUp); + // // LineNumbers_For_RichTextBox // this.LineNumbers_For_RichTextBox._SeeThroughMode_ = false; @@ -899,24 +917,6 @@ public void InitializeComponent() this.LineNumbers_For_RichTextBox.Size = new System.Drawing.Size(18, 244); this.LineNumbers_For_RichTextBox.TabIndex = 15; // - // RichTextBox - // - this.RichTextBox.AcceptsTab = true; - this.RichTextBox.BorderStyle = System.Windows.Forms.BorderStyle.None; - this.RichTextBox.ContextMenuStrip = this.EditorMenuStrip; - this.RichTextBox.Dock = System.Windows.Forms.DockStyle.Fill; - this.RichTextBox.Location = new System.Drawing.Point(18, 47); - this.RichTextBox.Name = "RichTextBox"; - this.RichTextBox.Size = new System.Drawing.Size(495, 244); - this.RichTextBox.TabIndex = 16; - this.RichTextBox.Text = ""; - this.RichTextBox.LinkClicked += new System.Windows.Forms.LinkClickedEventHandler(this.RichTextBox_LinkClicked); - this.RichTextBox.SelectionChanged += new System.EventHandler(this.RichTextBox_SelectionChanged); - this.RichTextBox.Click += new System.EventHandler(this.RichTextBox_Click); - this.RichTextBox.TextChanged += new System.EventHandler(this.RichTextBox_TextChanged); - this.RichTextBox.KeyDown += new System.Windows.Forms.KeyEventHandler(this.RichTextBox_KeyDown); - this.RichTextBox.KeyUp += new System.Windows.Forms.KeyEventHandler(this.RichTextBox_KeyUp); - // // MainForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);