mirror of
https://github.com/Crypto-Notepad/Crypto-Notepad.git
synced 2026-03-11 08:55:25 +00:00
Added #29
This commit is contained in:
parent
c7992b0410
commit
5f433088ff
1 changed files with 38 additions and 3 deletions
|
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Windows.Forms;
|
||||
|
||||
|
|
@ -34,6 +35,41 @@ protected override void WndProc(ref Message m)
|
|||
base.WndProc(ref m);
|
||||
}
|
||||
|
||||
protected override void OnHandleCreated(EventArgs e)
|
||||
{
|
||||
base.OnHandleCreated(e);
|
||||
if (!AutoWordSelection)
|
||||
{
|
||||
AutoWordSelection = true;
|
||||
AutoWordSelection = false;
|
||||
}
|
||||
}
|
||||
|
||||
public event EventHandler CursorPositionChanged;
|
||||
|
||||
protected virtual void OnCursorPositionChanged(EventArgs e)
|
||||
{
|
||||
if (CursorPositionChanged != null)
|
||||
CursorPositionChanged(this, e);
|
||||
}
|
||||
|
||||
protected override void OnSelectionChanged(EventArgs e)
|
||||
{
|
||||
if (SelectionLength == 0)
|
||||
OnCursorPositionChanged(e);
|
||||
else
|
||||
base.OnSelectionChanged(e);
|
||||
}
|
||||
|
||||
protected override void OnKeyDown(KeyEventArgs e)
|
||||
{
|
||||
if (GetLineFromCharIndex(SelectionStart) == 0 && e.KeyData == Keys.Up ||
|
||||
GetLineFromCharIndex(SelectionStart) == GetLineFromCharIndex(TextLength) && e.KeyData == Keys.Down ||
|
||||
SelectionStart == TextLength && e.KeyData == Keys.Right ||
|
||||
SelectionStart == 0 && e.KeyData == Keys.Left
|
||||
) e.Handled = true;
|
||||
}
|
||||
}
|
||||
public static class RichTextBoxPadding
|
||||
{
|
||||
public static void SetInnerMargins(this TextBoxBase textBox, int left, int top, int right, int bottom)
|
||||
|
|
@ -88,5 +124,4 @@ private static Rectangle GetFormattingRect(this TextBoxBase textbox)
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue