- Restore the selection color after HideCaret
- Only show the pseudo caret if the StepRTB was active for the grid Add a property to track if the StepRTB was active for a grid Track if the StepRTB was active for a grid
This commit is contained in:
@@ -489,31 +489,44 @@ namespace Volian.Controls.Library
|
||||
{
|
||||
get { return _PnlCaret; }
|
||||
}
|
||||
private Color _OldForeColor = Color.Empty;
|
||||
private Color _OldBackColor = Color.Empty;
|
||||
public void ShowCaret()
|
||||
{
|
||||
if (_MyStepRTB != null)
|
||||
{
|
||||
if (!_MyStepRTB.Visible)
|
||||
_MyStepRTB.Visible = true;
|
||||
if (_MyStepRTB.SelectionLength == 0)
|
||||
if (_MyEditItem.RTBLastFocus)
|
||||
{
|
||||
Point pt = _MyStepRTB.GetPositionFromCharIndex(_MyStepRTB.SelectionStart);
|
||||
pt = _MyStepRTB.PointToScreen(pt);
|
||||
pt = this.PointToClient(pt);
|
||||
PnlCaret.Location = pt;
|
||||
PnlCaret.BackColor = _MyStepRTB.ForeColor;
|
||||
using (Graphics gr = this.CreateGraphics())
|
||||
if (!_MyStepRTB.Visible)
|
||||
_MyStepRTB.Visible = true;
|
||||
if (_MyStepRTB.SelectionLength == 0)
|
||||
{
|
||||
SizeF sf = gr.MeasureString("Mg", _MyStepRTB.SelectionFont);
|
||||
sf.Width = 1;
|
||||
PnlCaret.Size = sf.ToSize();
|
||||
Point pt = _MyStepRTB.GetPositionFromCharIndex(_MyStepRTB.SelectionStart);
|
||||
pt = _MyStepRTB.PointToScreen(pt);
|
||||
pt = this.PointToClient(pt);
|
||||
PnlCaret.Location = pt;
|
||||
PnlCaret.BackColor = _MyStepRTB.ForeColor;
|
||||
using (Graphics gr = this.CreateGraphics())
|
||||
{
|
||||
SizeF sf = gr.MeasureString("Mg", _MyStepRTB.SelectionFont);
|
||||
sf.Width = 1;
|
||||
PnlCaret.Size = sf.ToSize();
|
||||
}
|
||||
tmrCaret.Enabled = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_MyStepRTB.SelectionColor != Color.Empty && _OldForeColor == Color.Empty)
|
||||
{
|
||||
_OldForeColor = _MyStepRTB.SelectionColor;
|
||||
_MyStepRTB.SelectionColor = Color.White;
|
||||
}
|
||||
if (_MyStepRTB.SelectionBackColor != Color.Empty && _OldBackColor == Color.Empty)
|
||||
{
|
||||
_OldBackColor = _MyStepRTB.SelectionBackColor;
|
||||
_MyStepRTB.SelectionBackColor = Color.FromName("Highlight");
|
||||
}
|
||||
}
|
||||
tmrCaret.Enabled = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
_MyStepRTB.SelectionColor = Color.White;
|
||||
_MyStepRTB.SelectionBackColor = Color.FromName("Highlight");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -528,11 +541,23 @@ namespace Volian.Controls.Library
|
||||
}
|
||||
else
|
||||
{
|
||||
_MyStepRTB.SelectionColor = _MyStepRTB.ForeColor;
|
||||
_MyStepRTB.SelectionBackColor = _MyStepRTB.BackColor;
|
||||
if (_OldForeColor != Color.Empty)
|
||||
{
|
||||
_MyStepRTB.SelectionColor = _OldForeColor;
|
||||
_OldForeColor = Color.Empty;
|
||||
}
|
||||
if (_OldBackColor != Color.Empty)
|
||||
{
|
||||
_MyStepRTB.SelectionBackColor = _OldBackColor;
|
||||
_OldBackColor = Color.Empty;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
private void tmrCaret_Tick(object sender, EventArgs e)
|
||||
{
|
||||
PnlCaret.Visible = !PnlCaret.Visible;
|
||||
}
|
||||
#endregion
|
||||
#region Private Methods
|
||||
///// <summary>
|
||||
@@ -748,9 +773,5 @@ namespace Volian.Controls.Library
|
||||
myDisplayTabItem.Dispose();
|
||||
}
|
||||
#endregion
|
||||
private void tmrCaret_Tick(object sender, EventArgs e)
|
||||
{
|
||||
PnlCaret.Visible = !PnlCaret.Visible;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user