From 305410e5f8970312fb7d1bdb430fe353692dd021 Mon Sep 17 00:00:00 2001 From: Alexander Date: Mon, 21 Oct 2019 14:26:40 +0300 Subject: [PATCH] StatusPanel now does not work when disabled in settings --- Crypto Notepad/MainForm.cs | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/Crypto Notepad/MainForm.cs b/Crypto Notepad/MainForm.cs index 324c20b..51e1dca 100644 --- a/Crypto Notepad/MainForm.cs +++ b/Crypto Notepad/MainForm.cs @@ -430,21 +430,28 @@ private async void StatusPanelMessage(string type) private void StatusPanelTextInfo() { - int currentColumn = 1 + richTextBox.SelectionStart - richTextBox.GetFirstCharIndexOfCurrentLine(); - RichTextBox rtb = new RichTextBox(); - rtb.WordWrap = false; - rtb.Text = richTextBox.Text; - int currentLine = 1 + rtb.GetLineFromCharIndex(richTextBox.SelectionStart); - int linesCount = richTextBox.Lines.Count(); - if (linesCount == 0) + int currentColumn = 0; + int currentLine = 0; + int linesCount = 0; + if (statusPanel.Visible) { - linesCount = 1; + 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(); + if (linesCount == 0) + { + linesCount = 1; + } } statusPanelLengthLabel.Text = "Length: " + richTextBox.TextLength; statusPaneLinesLabel.Text = "Lines: " + linesCount; statusPaneLnLabel.Text = "Ln: " + currentLine; statusPaneColLabel.Text = "Col: " + currentColumn; - } private void LockFile()