This commit is contained in:
@@ -124,7 +124,21 @@ namespace Volian.Controls.Library
|
||||
public System.Windows.Forms.AutoScaleMode AutoScaleMode;
|
||||
private DisplayText _origVlnText;
|
||||
private RichTextBox _rtbTemp = new RichTextBox();
|
||||
private string _eLinkText;
|
||||
private string _MyLinkText;
|
||||
|
||||
public string MyLinkText
|
||||
{
|
||||
get { return _MyLinkText; }
|
||||
set
|
||||
{
|
||||
if (value != _MyLinkText)
|
||||
{
|
||||
_MyLinkText = value;
|
||||
OnLinkChanged(this, new LinkClickedEventArgs(_MyLinkText));
|
||||
Console.WriteLine("DisplayRTB - MyLinkText changed {0}", _MyLinkText);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
#region Constructors
|
||||
/// <summary>
|
||||
@@ -158,10 +172,31 @@ namespace Volian.Controls.Library
|
||||
ContextMenuStrip = contextMenuStrip;
|
||||
ContentsResized += new ContentsResizedEventHandler(DisplayRTB_ContentsResized);
|
||||
this.LinkClicked += new LinkClickedEventHandler(DisplayRTB_LinkClicked);
|
||||
this.Click +=new EventHandler(DisplayRTB_Click);
|
||||
this.KeyPress += new KeyPressEventHandler(DisplayRTB_KeyPress);
|
||||
this.KeyUp += new KeyEventHandler(DisplayRTB_KeyUp);
|
||||
this.KeyDown += new KeyEventHandler(DisplayRTB_KeyDown);
|
||||
this.TextChanged += new EventHandler(DisplayRTB_TextChanged);
|
||||
//this.SelectionChanged += new EventHandler(DisplayRTB_SelectionChanged);
|
||||
}
|
||||
|
||||
private void DisplayRTB_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (ReadOnly) return;
|
||||
|
||||
if (!SelectionProtected)
|
||||
{
|
||||
MyLinkText = null;
|
||||
}
|
||||
}
|
||||
|
||||
void DisplayRTB_SelectionChanged(object sender, EventArgs e)
|
||||
{
|
||||
Console.WriteLine("SelectionStart {0}, SelectionLength {1}", SelectionStart, SelectionLength);
|
||||
if (!SelectionProtected && MyLinkText != null)
|
||||
MyLinkText = null;
|
||||
// TODO: Else Set mylinktext to what is currently selected (null if not on link, otherwise link info)
|
||||
// TODO: Raise event if moving on (modify) or moving off (insert)
|
||||
}
|
||||
#endregion
|
||||
#region ApplicationSupport
|
||||
@@ -342,6 +377,12 @@ namespace Volian.Controls.Library
|
||||
#region EventSupport
|
||||
#region LinkEvents
|
||||
private LinkClickedEventArgs _LinkClickedEventArgs;
|
||||
public event DisplayRTBLinkEvent LinkChanged; // TODO: ?
|
||||
private void OnLinkChanged(object sender, LinkClickedEventArgs args)
|
||||
{
|
||||
_LinkClickedEventArgs = args;
|
||||
if (LinkChanged != null) LinkChanged(sender, args);
|
||||
}
|
||||
public event DisplayRTBLinkEvent LinkGoTo;
|
||||
private void OnLinkGoTo(object sender, LinkClickedEventArgs args)
|
||||
{
|
||||
@@ -364,28 +405,38 @@ namespace Volian.Controls.Library
|
||||
private void DisplayRTB_LinkClicked(object sender, System.Windows.Forms.LinkClickedEventArgs e)
|
||||
{
|
||||
if (ReadOnly) return;
|
||||
|
||||
_LinkClickedEventArgs = e;
|
||||
_eLinkText = e.LinkText;
|
||||
_savcurpos = Cursor.Position;
|
||||
if (e.LinkText.IndexOf("ReferencedObject") > -1)
|
||||
this.contextMenuStripROs.Show(System.Windows.Forms.Cursor.Position);
|
||||
else
|
||||
this.contextMenuStripTrans.Show(System.Windows.Forms.Cursor.Position);
|
||||
SelectLink(e.LinkText);
|
||||
OnLinkChanged(sender, e);
|
||||
//_savcurpos = Cursor.Position;
|
||||
//if (e.LinkText.IndexOf("ReferencedObject") > -1)
|
||||
// this.contextMenuStripROs.Show(System.Windows.Forms.Cursor.Position);
|
||||
//else
|
||||
// this.contextMenuStripTrans.Show(System.Windows.Forms.Cursor.Position);
|
||||
}
|
||||
private void SelectLink(string LinkText)
|
||||
{
|
||||
Point cp = PointToClient(_savcurpos);
|
||||
int index = GetCharIndexFromPosition(cp);
|
||||
int iMax = index;
|
||||
//int iMax = index;
|
||||
//int iMin = index;
|
||||
//Select(index, 0);
|
||||
|
||||
//while (iMin > 0 && SelectionProtected)
|
||||
// Select(--iMin, 0);
|
||||
//Select(iMin + 1, 0);
|
||||
//SelectLink();
|
||||
////SelectionProtected = false; // unprotect link only if deleted
|
||||
//MyLinkText = SelectedText;
|
||||
//int index = SelectionStart;
|
||||
int iMin = index;
|
||||
Select(index, 0);
|
||||
|
||||
while (iMin > 0 && SelectionProtected)
|
||||
Select(--iMin, 0);
|
||||
|
||||
Select(iMin - 1, 1 + LinkText.Length);
|
||||
SelectionProtected = false;
|
||||
Select(iMin, LinkText.Length);
|
||||
Select(iMin + 1, 0);
|
||||
SelectLink();
|
||||
}
|
||||
#endregion
|
||||
#region TextOrContents
|
||||
@@ -426,26 +477,41 @@ namespace Volian.Controls.Library
|
||||
{
|
||||
e.Handled = HandleRightArrow();
|
||||
}
|
||||
|
||||
}
|
||||
private bool HandleRightArrow()
|
||||
private void SelectLink()
|
||||
{
|
||||
if (!SelectionProtected) return false;
|
||||
int index = SelectionStart;
|
||||
int iMax = index;
|
||||
Select(index, 0);
|
||||
while (iMax < TextLength && SelectionProtected)
|
||||
Select(++iMax, 0);
|
||||
Select(index - 1, SelectionStart + 1 - index);
|
||||
MyLinkText = SelectedText;
|
||||
}
|
||||
private bool HandleRightArrow()
|
||||
{
|
||||
if (!SelectionProtected)
|
||||
{
|
||||
MyLinkText = null;
|
||||
return false;
|
||||
}
|
||||
SelectLink();
|
||||
return true;
|
||||
}
|
||||
private bool HandleLUDArrows()
|
||||
{
|
||||
if (!SelectionProtected) return false;
|
||||
if (!SelectionProtected)
|
||||
{
|
||||
MyLinkText = null;
|
||||
return false;
|
||||
}
|
||||
int index = this.SelectionStart;
|
||||
int iMin = index;
|
||||
Select(index, 0);
|
||||
while (iMin > 0 && SelectionProtected)
|
||||
Select(--iMin, 0);
|
||||
Select(iMin + 1, 0);
|
||||
SelectLink();
|
||||
return true;
|
||||
}
|
||||
private void DisplayRTB_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
|
||||
@@ -639,7 +705,7 @@ namespace Volian.Controls.Library
|
||||
}
|
||||
private void DeleteTransition()
|
||||
{
|
||||
SelectLink(_eLinkText);
|
||||
SelectLink(_MyLinkText);
|
||||
SelectedText = "";
|
||||
}
|
||||
private void contextMenuStripTrans_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
|
||||
@@ -669,7 +735,7 @@ namespace Volian.Controls.Library
|
||||
}
|
||||
private void DeleteRefObj()
|
||||
{
|
||||
SelectLink(_eLinkText);
|
||||
SelectLink(_MyLinkText);
|
||||
SelectedText = "";
|
||||
}
|
||||
private void contextMenuStripROs_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
|
||||
|
Reference in New Issue
Block a user