From 9de470dfa7800fbb76dd231ffcd9ff1780bc4d4f Mon Sep 17 00:00:00 2001 From: Alexander Date: Mon, 21 Oct 2019 15:20:40 +0300 Subject: [PATCH] Fixed bug when the status panel did not work --- Crypto Notepad/MainForm.Designer.cs | 1 + Crypto Notepad/MainForm.cs | 25 +++++++++++++++---------- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/Crypto Notepad/MainForm.Designer.cs b/Crypto Notepad/MainForm.Designer.cs index e12c622..2432f41 100644 --- a/Crypto Notepad/MainForm.Designer.cs +++ b/Crypto Notepad/MainForm.Designer.cs @@ -957,6 +957,7 @@ public void InitializeComponent() this.statusPanel.Name = "statusPanel"; this.statusPanel.Size = new System.Drawing.Size(484, 22); this.statusPanel.TabIndex = 18; + this.statusPanel.VisibleChanged += new System.EventHandler(this.StatusPanel_VisibleChanged); // // statusPanelLabel // diff --git a/Crypto Notepad/MainForm.cs b/Crypto Notepad/MainForm.cs index 51e1dca..d75301d 100644 --- a/Crypto Notepad/MainForm.cs +++ b/Crypto Notepad/MainForm.cs @@ -430,28 +430,25 @@ private async void StatusPanelMessage(string type) private void StatusPanelTextInfo() { - int currentColumn = 0; - int currentLine = 0; - int linesCount = 0; if (statusPanel.Visible) { - currentColumn = 1 + richTextBox.SelectionStart - richTextBox.GetFirstCharIndexOfCurrentLine(); + int currentColumn = 1 + richTextBox.SelectionStart - richTextBox.GetFirstCharIndexOfCurrentLine(); RichTextBox rtb = new RichTextBox { WordWrap = false, Text = richTextBox.Text }; - currentLine = 1 + rtb.GetLineFromCharIndex(richTextBox.SelectionStart); - linesCount = richTextBox.Lines.Count(); + int currentLine = 1 + rtb.GetLineFromCharIndex(richTextBox.SelectionStart); + int linesCount = richTextBox.Lines.Count(); if (linesCount == 0) { linesCount = 1; } + statusPanelLengthLabel.Text = "Length: " + richTextBox.TextLength; + statusPaneLinesLabel.Text = "Lines: " + linesCount; + statusPaneLnLabel.Text = "Ln: " + currentLine; + statusPaneColLabel.Text = "Col: " + currentColumn; } - statusPanelLengthLabel.Text = "Length: " + richTextBox.TextLength; - statusPaneLinesLabel.Text = "Lines: " + linesCount; - statusPaneLnLabel.Text = "Ln: " + currentLine; - statusPaneColLabel.Text = "Col: " + currentColumn; } private void LockFile() @@ -659,6 +656,13 @@ public void ToolbarIcons(bool oldIcons) #region Event Handlers + private void StatusPanel_VisibleChanged(object sender, EventArgs e) + { + if (statusPanel.Visible) + { + StatusPanelTextInfo(); + } + } private void LineNumbers_VisibleChanged(object sender, EventArgs e) { if (lineNumbers.Visible) @@ -1769,6 +1773,7 @@ private void VariablesMainMenu_Click(object sender, EventArgs e) Debug.WriteLine("EditorMenuStrip: " + contextMenu.Enabled); #endif } + #endregion