This commit is contained in:
@@ -32,6 +32,8 @@ namespace Volian.Controls.Library
|
||||
// return prams;
|
||||
// }
|
||||
//}
|
||||
private bool _IsDirty = false;
|
||||
private bool _InitializingRTB;
|
||||
private IContainer _Container = null;
|
||||
private string _MyClassName=string.Empty;
|
||||
public string MyClassName
|
||||
@@ -60,12 +62,15 @@ namespace Volian.Controls.Library
|
||||
_MyItem = value;
|
||||
if (value != null)
|
||||
{
|
||||
_InitializingRTB = true;
|
||||
DisplayText vlntxt = new DisplayText(_MyItem, EpMode, VwMode);
|
||||
_origVlnText = vlntxt;
|
||||
Font = _origVlnText.TextFont.WindowsFont;
|
||||
AddRtfText(vlntxt);
|
||||
ReadOnly = !(EpMode == E_EditPrintMode.Edit && VwMode == E_ViewMode.Edit);
|
||||
RTBAPI.SetLineSpacing(this, RTBAPI.ParaSpacing.PFS_EXACT);
|
||||
_InitializingRTB = false;
|
||||
_IsDirty = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -121,22 +126,6 @@ namespace Volian.Controls.Library
|
||||
private RichTextBox _rtbTemp = new RichTextBox();
|
||||
private string _eLinkText;
|
||||
#endregion
|
||||
#region HeightSupport
|
||||
public event DisplayRTBEvent HeightChanged;
|
||||
private void OnHeightChanged(object sender, EventArgs args)
|
||||
{
|
||||
if (HeightChanged != null) HeightChanged(sender, args);
|
||||
}
|
||||
private void AdjustSizeForContents()
|
||||
{
|
||||
//Console.WriteLine("Size {0} Client {1} New {2}", Size, ClientRectangle, ContentsRectangle);
|
||||
// I want the client size to match the new rectangle.
|
||||
// First I need to determine the offset
|
||||
Size offset = Size - ClientSize;
|
||||
this.Size = ContentsSize + offset + AdjustSize;
|
||||
OnHeightChanged(this, new EventArgs());
|
||||
}
|
||||
#endregion
|
||||
#region Constructors
|
||||
/// <summary>
|
||||
/// vlnRichTextBox constructor:
|
||||
@@ -150,36 +139,6 @@ namespace Volian.Controls.Library
|
||||
/// E_EditPrintMode ep_mode - edit or print.
|
||||
/// E_ViewMode vw_mode - view or edit.
|
||||
/// </summary>
|
||||
public DisplayRTB(string txtbxname, ItemInfo itemInfo, int x, int y, int iwid, int tbindx, E_EditPrintMode epMode, E_ViewMode vwMode)
|
||||
{
|
||||
try
|
||||
{
|
||||
EpMode = epMode;
|
||||
VwMode = vwMode;
|
||||
DisplayText vlntxt = new DisplayText(itemInfo, epMode, vwMode);
|
||||
_origVlnText = vlntxt;
|
||||
InitializeComponent();
|
||||
Location = new System.Drawing.Point(x, y);
|
||||
Name = txtbxname;
|
||||
DetectUrls = false;
|
||||
// TODO: RHM20071115 Font = _origVlnText.TextFont.WindowsFont;
|
||||
ScrollBars = System.Windows.Forms.RichTextBoxScrollBars.None;
|
||||
Width = iwid;
|
||||
ContentsResized += new ContentsResizedEventHandler(vlnRichTextBox_ContentsResized);
|
||||
AddRtfText(vlntxt);
|
||||
//ContextMenuStrip = contextMenuStrip;
|
||||
ReadOnly = !(epMode == E_EditPrintMode.Edit && vwMode == E_ViewMode.Edit);
|
||||
RTBAPI.SetLineSpacing(this, RTBAPI.ParaSpacing.PFS_EXACT);
|
||||
this.LinkClicked += new LinkClickedEventHandler(onLinkClicked);
|
||||
this.KeyPress += new KeyPressEventHandler(onKeyPress);
|
||||
this.KeyDown += new KeyEventHandler(onKeyDown);
|
||||
//this.Leave += new EventHandler(DisplayRTB_Leave);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine("Error in creating vlnRichTextBox: " + ex.Message);
|
||||
}
|
||||
}
|
||||
public DisplayRTB()
|
||||
{
|
||||
InitializeComponent();
|
||||
@@ -197,11 +156,12 @@ namespace Volian.Controls.Library
|
||||
BorderStyle = System.Windows.Forms.BorderStyle.None;
|
||||
this.DetectUrls = true;
|
||||
ContextMenuStrip = contextMenuStrip;
|
||||
ContentsResized += new ContentsResizedEventHandler(vlnRichTextBox_ContentsResized);
|
||||
this.LinkClicked += new LinkClickedEventHandler(onLinkClicked);
|
||||
this.KeyPress += new KeyPressEventHandler(onKeyPress);
|
||||
this.KeyDown += new KeyEventHandler(onKeyDown);
|
||||
//this.Leave += new EventHandler(DisplayRTB_Leave);
|
||||
ContentsResized += new ContentsResizedEventHandler(DisplayRTB_ContentsResized);
|
||||
this.LinkClicked += new LinkClickedEventHandler(DisplayRTB_LinkClicked);
|
||||
this.KeyPress += new KeyPressEventHandler(DisplayRTB_KeyPress);
|
||||
this.KeyUp += new KeyEventHandler(DisplayRTB_KeyUp);
|
||||
this.KeyDown += new KeyEventHandler(DisplayRTB_KeyDown);
|
||||
this.TextChanged += new EventHandler(DisplayRTB_TextChanged);
|
||||
}
|
||||
#endregion
|
||||
#region ApplicationSupport
|
||||
@@ -229,9 +189,12 @@ namespace Volian.Controls.Library
|
||||
}
|
||||
#endregion
|
||||
#region SaveData
|
||||
public void Save()
|
||||
public void SaveText()
|
||||
{
|
||||
bool success = _origVlnText.Save((RichTextBox) this);
|
||||
if (ReadOnly) return;
|
||||
if (!_IsDirty) return;
|
||||
bool success = _origVlnText.Save((RichTextBox)this);
|
||||
if (!success) Console.WriteLine("Failed to save text: {0}", this.Text);
|
||||
}
|
||||
#endregion
|
||||
#region AddRtfText
|
||||
@@ -306,7 +269,21 @@ namespace Volian.Controls.Library
|
||||
this.SelectionLength = 0;
|
||||
}
|
||||
#endregion
|
||||
#region CalculateHeight
|
||||
#region HeightSupport
|
||||
public event DisplayRTBEvent HeightChanged;
|
||||
private void OnHeightChanged(object sender, EventArgs args)
|
||||
{
|
||||
if (HeightChanged != null) HeightChanged(sender, args);
|
||||
}
|
||||
private void AdjustSizeForContents()
|
||||
{
|
||||
//Console.WriteLine("Size {0} Client {1} New {2}", Size, ClientRectangle, ContentsRectangle);
|
||||
// I want the client size to match the new rectangle.
|
||||
// First I need to determine the offset
|
||||
Size offset = Size - ClientSize;
|
||||
this.Size = ContentsSize + offset + AdjustSize;
|
||||
OnHeightChanged(this, new EventArgs());
|
||||
}
|
||||
public int CalculateHeight()
|
||||
{
|
||||
if (this.CreateParams.ClassName == "RICHEDIT50W")
|
||||
@@ -363,12 +340,12 @@ namespace Volian.Controls.Library
|
||||
}
|
||||
#endregion
|
||||
#region EventSupport
|
||||
#region LinkEvents
|
||||
private LinkClickedEventArgs _LinkClickedEventArgs;
|
||||
public event DisplayRTBLinkEvent LinkGoTo;
|
||||
private void OnLinkGoTo(object sender, LinkClickedEventArgs args)
|
||||
{
|
||||
_LinkClickedEventArgs = args;
|
||||
Console.WriteLine("DisplayRTB " + _LinkClickedEventArgs.LinkText);
|
||||
if (LinkGoTo != null) LinkGoTo(sender, args);
|
||||
}
|
||||
public event DisplayRTBLinkEvent LinkModifyTran;
|
||||
@@ -377,22 +354,14 @@ namespace Volian.Controls.Library
|
||||
_LinkClickedEventArgs = args;
|
||||
if (LinkModifyTran != null) LinkModifyTran(sender, args);
|
||||
}
|
||||
//void DisplayRTB_Leave(object sender, EventArgs e)
|
||||
//{
|
||||
// // Save returns true if text was not changed or if change was saved successfully.
|
||||
// if (ReadOnly) return;
|
||||
// // if selecting another rtb, save. If selecting the info panel don't because
|
||||
// // we're still on a valid item.??
|
||||
|
||||
//}
|
||||
public void SaveText()
|
||||
public event DisplayRTBLinkEvent LinkModifyRO;
|
||||
private void OnLinkModifyRO(object sender, LinkClickedEventArgs args)
|
||||
{
|
||||
if (ReadOnly) return;
|
||||
bool success = _origVlnText.Save((RichTextBox)this);
|
||||
if (!success) Console.WriteLine("Failed to save text: {0}", this.Text);
|
||||
_LinkClickedEventArgs = args;
|
||||
if (LinkModifyRO != null) LinkModifyRO(sender, args);
|
||||
}
|
||||
private Point _savcurpos;
|
||||
private void onLinkClicked(object sender, System.Windows.Forms.LinkClickedEventArgs e)
|
||||
private void DisplayRTB_LinkClicked(object sender, System.Windows.Forms.LinkClickedEventArgs e)
|
||||
{
|
||||
if (ReadOnly) return;
|
||||
_LinkClickedEventArgs = e;
|
||||
@@ -411,20 +380,27 @@ namespace Volian.Controls.Library
|
||||
int iMin = index;
|
||||
Select(index, 0);
|
||||
|
||||
while (SelectionProtected)
|
||||
while (iMin > 0 && SelectionProtected)
|
||||
Select(--iMin, 0);
|
||||
|
||||
Select(iMin - 1, 1 + LinkText.Length);
|
||||
SelectionProtected = false;
|
||||
Select(iMin, LinkText.Length);
|
||||
}
|
||||
void vlnRichTextBox_ContentsResized(object sender, ContentsResizedEventArgs e)
|
||||
#endregion
|
||||
#region TextOrContents
|
||||
void DisplayRTB_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
_IsDirty = true;
|
||||
}
|
||||
void DisplayRTB_ContentsResized(object sender, ContentsResizedEventArgs e)
|
||||
{
|
||||
ContentsRectangle = e.NewRectangle;
|
||||
}
|
||||
#endregion
|
||||
#region KeyboardHandling
|
||||
private bool IsControlChar = false;
|
||||
private void onKeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
|
||||
void DisplayRTB_KeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
if (e.Modifiers == Keys.Control)
|
||||
{
|
||||
@@ -433,14 +409,46 @@ namespace Volian.Controls.Library
|
||||
{
|
||||
case Keys.V:
|
||||
string buff = Clipboard.GetText(TextDataFormat.UnicodeText);
|
||||
|
||||
|
||||
// check if insertable?
|
||||
Console.WriteLine(String.Format("in switch, keydata = {0}, keyvalue = {1}, buff = {2}", e.KeyData, e.KeyValue, buff));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
private void onKeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
|
||||
void DisplayRTB_KeyUp(object sender, KeyEventArgs e)
|
||||
{
|
||||
if (e.KeyCode == Keys.Left || e.KeyCode == Keys.Up || e.KeyCode == Keys.Down)
|
||||
{
|
||||
e.Handled = HandleLUDArrows();
|
||||
}
|
||||
else if (e.KeyCode == Keys.Right)
|
||||
{
|
||||
e.Handled = HandleRightArrow();
|
||||
}
|
||||
|
||||
}
|
||||
private bool HandleRightArrow()
|
||||
{
|
||||
if (!SelectionProtected) return false;
|
||||
int index = SelectionStart;
|
||||
int iMax = index;
|
||||
Select(index, 0);
|
||||
while (iMax < TextLength && SelectionProtected)
|
||||
Select(++iMax, 0);
|
||||
return true;
|
||||
}
|
||||
private bool HandleLUDArrows()
|
||||
{
|
||||
if (!SelectionProtected) return false;
|
||||
int index = this.SelectionStart;
|
||||
int iMin = index;
|
||||
Select(index, 0);
|
||||
while (iMin > 0 && SelectionProtected)
|
||||
Select(--iMin, 0);
|
||||
return true;
|
||||
}
|
||||
private void DisplayRTB_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
|
||||
{
|
||||
if (!ReadOnly)
|
||||
{
|
||||
@@ -632,10 +640,6 @@ namespace Volian.Controls.Library
|
||||
SelectLink(_eLinkText);
|
||||
SelectedText = "";
|
||||
}
|
||||
private void ModifyTransition()
|
||||
{
|
||||
Console.WriteLine("Modify Transition");
|
||||
}
|
||||
private void contextMenuStripTrans_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
|
||||
{
|
||||
if (e.ClickedItem.ToString() == "Delete Transition") DeleteTransition();
|
||||
@@ -666,14 +670,10 @@ namespace Volian.Controls.Library
|
||||
SelectLink(_eLinkText);
|
||||
SelectedText = "";
|
||||
}
|
||||
private void ModifyRefObj()
|
||||
{
|
||||
Console.WriteLine("ModifyRefObj");
|
||||
}
|
||||
private void contextMenuStripROs_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
|
||||
{
|
||||
if (e.ClickedItem.ToString() == "Delete RO") DeleteRefObj();
|
||||
else if (e.ClickedItem.ToString() == "Modify RO") ModifyRefObj();
|
||||
else if (e.ClickedItem.ToString() == "Modify RO") OnLinkModifyRO(sender, _LinkClickedEventArgs);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
Reference in New Issue
Block a user