This commit is contained in:
@@ -305,7 +305,7 @@ namespace Volian.Controls.Library
|
||||
}
|
||||
private void AddSymbol(string str)
|
||||
{
|
||||
MessageBox.Show(SelectedRtf);
|
||||
//MessageBox.Show(SelectedRtf);
|
||||
SelectedRtf = @"{\rtf1{\fonttbl{\f0\fcharset0 Arial Unicode MS;}}\f0\fs" + this.Font.SizeInPoints * 2 + " " + /* ConvertUnicodeChar(str) */ str + @"}";
|
||||
}
|
||||
private void AddRtfLink(displayLinkElement myDisplayLinkElement)
|
||||
@@ -435,6 +435,7 @@ namespace Volian.Controls.Library
|
||||
}
|
||||
#endregion
|
||||
#region EventSupport
|
||||
|
||||
#region LinkEvents
|
||||
private StepPanelLinkEventArgs _MyLinkClickedEventArgs;
|
||||
public event StepRTBLinkEvent LinkChanged;
|
||||
@@ -486,7 +487,7 @@ namespace Volian.Controls.Library
|
||||
private bool IsControlChar = false;
|
||||
void StepRTB_KeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
if (e.Modifiers == Keys.Control)
|
||||
if (e.Control)
|
||||
{
|
||||
IsControlChar = true;
|
||||
switch (e.KeyCode)
|
||||
@@ -496,59 +497,124 @@ namespace Volian.Controls.Library
|
||||
|
||||
// check if insertable?
|
||||
Console.WriteLine(String.Format("in switch, keydata = {0}, keyvalue = {1}, buff = {2}", e.KeyData, e.KeyValue, buff));
|
||||
return;
|
||||
case Keys.Home:
|
||||
StepRTB_HomeEndPressed(e);
|
||||
e.Handled = true;
|
||||
break;
|
||||
case Keys.End:
|
||||
StepRTB_HomeEndPressed(e);
|
||||
e.Handled = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
switch (e.KeyCode)
|
||||
{
|
||||
switch (e.KeyCode)
|
||||
{
|
||||
case Keys.Delete:
|
||||
// if it's just a link, delete the link. if the text has embedded links, i.e. text and links
|
||||
// use DeleteTextAndLink to delete it (just setting selectedrtf to "" fails because of the
|
||||
// embedded protected text. If it's just text, let the richtextbox handle the delete.
|
||||
if (_MyLinkText != null)
|
||||
case Keys.Left:
|
||||
if (e.Control || SelectionStart == 0)
|
||||
{
|
||||
StepRTB_ArrowPressed(e.Control ? E_ArrowKeys.CtrlLeft : E_ArrowKeys.Left);
|
||||
e.Handled = true;
|
||||
}
|
||||
break;
|
||||
case Keys.Up:
|
||||
int ln = GetLineFromCharIndex(SelectionStart);
|
||||
if (e.Control || ln == 0)
|
||||
{
|
||||
StepRTB_ArrowPressed(e.Control ? E_ArrowKeys.CtrlUp : E_ArrowKeys.Up);
|
||||
e.Handled = true;
|
||||
}
|
||||
break;
|
||||
case Keys.Right:
|
||||
if (e.Control || SelectionStart == this.Text.Length)
|
||||
{
|
||||
StepRTB_ArrowPressed(e.Control ? E_ArrowKeys.CtrlRight : E_ArrowKeys.Right);
|
||||
e.Handled = true;
|
||||
}
|
||||
break;
|
||||
case Keys.Down:
|
||||
int l = GetLineFromCharIndex(SelectionStart);
|
||||
Point pos = new Point();
|
||||
pos.X = ClientRectangle.Width;
|
||||
pos.Y = ClientRectangle.Height;
|
||||
int lastIndex = this.GetCharIndexFromPosition(pos);
|
||||
int lastLine = this.GetLineFromCharIndex(lastIndex);
|
||||
|
||||
if (e.Control || l == lastLine)
|
||||
{
|
||||
StepRTB_ArrowPressed(e.Control ? E_ArrowKeys.CtrlDown : E_ArrowKeys.Down);
|
||||
e.Handled = true;
|
||||
}
|
||||
break;
|
||||
case Keys.PageUp:
|
||||
StepRTB_PageKeyPressed(e);
|
||||
e.Handled = true;
|
||||
break;
|
||||
case Keys.PageDown:
|
||||
StepRTB_PageKeyPressed(e);
|
||||
e.Handled = true;
|
||||
break;
|
||||
case Keys.Delete:
|
||||
// if it's just a link, delete the link. if the text has embedded links, i.e. text and links
|
||||
// use DeleteTextAndLink to delete it (just setting selectedrtf to "" fails because of the
|
||||
// embedded protected text. If it's just text, let the richtextbox handle the delete.
|
||||
if (_MyLinkText != null)
|
||||
{
|
||||
DeleteLink();
|
||||
e.Handled = true;
|
||||
}
|
||||
else if (SelectedRtf.IndexOf(@"\protect") > -1)
|
||||
{
|
||||
// unprotect and then delete text & links.
|
||||
DeleteTextAndLink();
|
||||
e.Handled = true;
|
||||
}
|
||||
break;
|
||||
case Keys.Back:
|
||||
// if not a range, i.e. SelectionLength = 0, then see if backspacing a link
|
||||
// or just regular text. If link, need to select link, unprotect before delete.
|
||||
if (SelectionLength == 0 && SelectionStart > 0)
|
||||
{
|
||||
int tmpss = SelectionStart;
|
||||
Select(SelectionStart - 1, 0); // see if previous char is protected
|
||||
if (SelectionProtected)
|
||||
{
|
||||
SelectLinkFromIndex(SelectionStart);
|
||||
DeleteLink();
|
||||
e.Handled = true;
|
||||
}
|
||||
else if (SelectedRtf.IndexOf(@"\protect") > -1)
|
||||
{
|
||||
// unprotect and then delete text & links.
|
||||
DeleteTextAndLink();
|
||||
e.Handled = true;
|
||||
}
|
||||
break;
|
||||
case Keys.Back:
|
||||
// if not a range, i.e. SelectionLength = 0, then see if backspacing a link
|
||||
// or just regular text. If link, need to select link, unprotect before delete.
|
||||
if (SelectionLength == 0 && SelectionStart > 0)
|
||||
{
|
||||
int tmpss = SelectionStart;
|
||||
Select(SelectionStart - 1, 0); // see if previous char is protected
|
||||
if (SelectionProtected)
|
||||
{
|
||||
SelectLinkFromIndex(SelectionStart);
|
||||
DeleteLink();
|
||||
e.Handled = true;
|
||||
}
|
||||
else
|
||||
Select(tmpss, 0); // go back to original cursor position
|
||||
}
|
||||
// if a range, need to see if range includes protected text, if so this is a
|
||||
// special case, so use DeleteTextAndLink. Otherwise, just let the richtextbox
|
||||
// delete it.
|
||||
else if (SelectionLength > 0 && (SelectedRtf.IndexOf(@"\protect") > -1))
|
||||
{
|
||||
// unprotect and then delete text & links.
|
||||
DeleteTextAndLink();
|
||||
e.Handled = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
else
|
||||
Select(tmpss, 0); // go back to original cursor position
|
||||
}
|
||||
// if a range, need to see if range includes protected text, if so this is a
|
||||
// special case, so use DeleteTextAndLink. Otherwise, just let the richtextbox
|
||||
// delete it.
|
||||
else if (SelectionLength > 0 && (SelectedRtf.IndexOf(@"\protect") > -1))
|
||||
{
|
||||
// unprotect and then delete text & links.
|
||||
DeleteTextAndLink();
|
||||
e.Handled = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void StepRTB_HomeEndPressed(KeyEventArgs keyargs)
|
||||
{
|
||||
if (MyItemInfo.IsProcedure || MyItemInfo.IsSection) return;
|
||||
// Cursor moves out of box only if control is pressed too - otherwise key is
|
||||
// handled in rtb.
|
||||
if (keyargs.Control)_MyStepItem.MyStepPanel.StepCursorKeys(this, keyargs);
|
||||
}
|
||||
private void StepRTB_PageKeyPressed(KeyEventArgs keyargs)
|
||||
{
|
||||
if (MyItemInfo.IsProcedure || MyItemInfo.IsSection) return;
|
||||
_MyStepItem.MyStepPanel.StepCursorKeys(this, keyargs);
|
||||
}
|
||||
private void StepRTB_ArrowPressed(E_ArrowKeys key)
|
||||
{
|
||||
Point cp = PointToClient(Cursor.Position);
|
||||
_MyStepItem.MyStepPanel.CursorMovement(this, cp, key);
|
||||
}
|
||||
private void DeleteTextAndLink()
|
||||
{
|
||||
int start = SelectionStart;
|
||||
|
Reference in New Issue
Block a user