Fixed glitch with line numbers width

This commit is contained in:
Alexander 2019-08-27 11:35:02 +03:00
parent f48eb3c7cf
commit e66b4bc2c3
4 changed files with 9 additions and 23 deletions

View file

@ -8,8 +8,8 @@ public class ExRichTextBox : RichTextBox
{ {
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)] [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)]
static extern IntPtr SendMessage(IntPtr hWnd, uint Msg, IntPtr wParam, IntPtr lParam); static extern IntPtr SendMessage(IntPtr hWnd, uint Msg, IntPtr wParam, IntPtr lParam);
const int WM_MOUSEWHEEL = 0x020A; private const int WM_VSCROLL = 0x115;
const int WM_VSCROLL = 0x115; private const int WM_MOUSEWHEEL = 0x20A;
protected override void WndProc(ref Message m) protected override void WndProc(ref Message m)
{ {
if (m.Msg == WM_MOUSEWHEEL) if (m.Msg == WM_MOUSEWHEEL)
@ -26,5 +26,6 @@ protected override void WndProc(ref Message m)
} }
base.WndProc(ref m); base.WndProc(ref m);
} }
} }
} }

View file

@ -892,7 +892,6 @@ public void InitializeComponent()
this.RichTextBox.LinkClicked += new System.Windows.Forms.LinkClickedEventHandler(this.RichTextBox_LinkClicked); this.RichTextBox.LinkClicked += new System.Windows.Forms.LinkClickedEventHandler(this.RichTextBox_LinkClicked);
this.RichTextBox.SelectionChanged += new System.EventHandler(this.RichTextBox_SelectionChanged); this.RichTextBox.SelectionChanged += new System.EventHandler(this.RichTextBox_SelectionChanged);
this.RichTextBox.Click += new System.EventHandler(this.RichTextBox_Click); 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.KeyDown += new System.Windows.Forms.KeyEventHandler(this.RichTextBox_KeyDown);
this.RichTextBox.KeyUp += new System.Windows.Forms.KeyEventHandler(this.RichTextBox_KeyUp); this.RichTextBox.KeyUp += new System.Windows.Forms.KeyEventHandler(this.RichTextBox_KeyUp);
// //

View file

@ -61,7 +61,6 @@ private void DecryptAES()
{ {
de = AES.Decrypt(opnfile, TypedPassword.Value, null, ps.HashAlgorithm, ps.PasswordIterations, ps.KeySize); de = AES.Decrypt(opnfile, TypedPassword.Value, null, ps.HashAlgorithm, ps.PasswordIterations, ps.KeySize);
} }
RichTextBox.Text = de; RichTextBox.Text = de;
Text = PublicVar.appName + " " + NameWithotPath; Text = PublicVar.appName + " " + NameWithotPath;
filePath = OpenFile.FileName; filePath = OpenFile.FileName;
@ -70,7 +69,6 @@ private void DecryptAES()
PublicVar.openFileName = Path.GetFileName(OpenFile.FileName); PublicVar.openFileName = Path.GetFileName(OpenFile.FileName);
PublicVar.encryptionKey.Set(TypedPassword.Value); PublicVar.encryptionKey.Set(TypedPassword.Value);
TypedPassword.Value = null; TypedPassword.Value = null;
LineNumbers_For_RichTextBox.Refresh();
} }
catch (CryptographicException) catch (CryptographicException)
{ {
@ -468,7 +466,6 @@ private void AutoLock(bool minimize)
return; return;
} }
PublicVar.okPressed = false; PublicVar.okPressed = false;
LineNumbers_For_RichTextBox.Refresh();
try try
{ {
RichTextBox.Clear(); RichTextBox.Clear();
@ -505,8 +502,6 @@ private void AutoLock(bool minimize)
} }
} }
} }
LineNumbers_For_RichTextBox.Refresh();
} }
protected override void WndProc(ref Message m) protected override void WndProc(ref Message m)
@ -666,7 +661,6 @@ private void MainWindow_Activated(object sender, EventArgs e)
ChangeKeyToolbarButton.Enabled = true; ChangeKeyToolbarButton.Enabled = true;
LockToolbarButton.Enabled = true; LockToolbarButton.Enabled = true;
} }
LineNumbers_For_RichTextBox.Refresh();
} }
private void MainWindow_FormClosing(object sender, FormClosingEventArgs e) private void MainWindow_FormClosing(object sender, FormClosingEventArgs e)
@ -788,8 +782,6 @@ private void MainWindow_Load(object sender, EventArgs e)
Size = ps.WindowSize; Size = ps.WindowSize;
WindowState = ps.WindowState; WindowState = ps.WindowState;
LineNumbers_For_RichTextBox.Refresh();
#if DEBUG #if DEBUG
DebugToolStripMenuItem.Visible = true; DebugToolStripMenuItem.Visible = true;
#endif #endif
@ -898,11 +890,6 @@ private void RichTextBox_KeyUp(object sender, KeyEventArgs e)
shiftPresed = false; shiftPresed = false;
} }
} }
private void RichTextBox_TextChanged(object sender, EventArgs e)
{
LineNumbers_For_RichTextBox.Refresh();
}
/*RichTextBox Events*/ /*RichTextBox Events*/
@ -994,7 +981,6 @@ private void OpenToolStripMenuItem_Click(object sender, EventArgs e)
LockToolbarButton.Enabled = true; LockToolbarButton.Enabled = true;
} }
} }
LineNumbers_For_RichTextBox.Refresh();
} }
private void SaveToolStripMenuItem_Click(object sender, EventArgs e) private void SaveToolStripMenuItem_Click(object sender, EventArgs e)

View file

@ -599,9 +599,8 @@ private void Update_SizeAndPosition()
/// <remarks></remarks> /// <remarks></remarks>
private void Update_VisibleLineNumberItems() private void Update_VisibleLineNumberItems()
{ {
// ################
// ################ int tmpY;
int tmpY;
// ############### // ###############
zLNIs.Clear(); zLNIs.Clear();
zAutoSizing_Size = new Size(0, 0); zAutoSizing_Size = new Size(0, 0);
@ -722,7 +721,7 @@ private void Update_VisibleLineNumberItems()
// 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. // 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) 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', 'W'), this.Font).Width, 0);
//zAutoSizing_Size = new Size(TextRenderer.MeasureText(zLineNumbers_Format.Replace("0".ToCharArray(), "W".ToCharArray()), this.Font).Width, 0); //zAutoSizing_Size = new Size(TextRenderer.MeasureText(zLineNumbers_Format.Replace("0".ToCharArray(), "W".ToCharArray()), this.Font).Width, 0);
} }
/// <summary> /// <summary>
@ -1083,7 +1082,7 @@ protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
private void zTimer_Tick(object sender, System.EventArgs e) private void zTimer_Tick(object sender, System.EventArgs e)
{ {
zParentIsScrolling = false; zParentIsScrolling = false;
zTimer.Stop(); zTimer.Stop();
this.Invalidate(); this.Invalidate();
} }
@ -1098,7 +1097,8 @@ private void zParent_Scroll(object sender, System.EventArgs e)
{ {
zParentIsScrolling = true; zParentIsScrolling = true;
this.Invalidate(); this.Invalidate();
} this.Refresh();
}
private void zParent_ContentsResized(object sender, System.Windows.Forms.ContentsResizedEventArgs e) private void zParent_ContentsResized(object sender, System.Windows.Forms.ContentsResizedEventArgs e)
{ {