This commit is contained in:
Kathy Ruffing 2008-03-03 15:15:39 +00:00
parent ca755949d6
commit 341b9a41bf
7 changed files with 242 additions and 116 deletions

View File

@ -124,5 +124,17 @@ namespace VEPROMS.Properties {
this["MRIList"] = value; this["MRIList"] = value;
} }
} }
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("192, 255, 255")]
public global::System.Drawing.Color TransitionRangeColor {
get {
return ((global::System.Drawing.Color)(this["TransitionRangeColor"]));
}
set {
this["TransitionRangeColor"] = value;
}
}
} }
} }

View File

@ -977,5 +977,10 @@ namespace Volian.Controls.Library
{ {
_Panel.OnLinkModifyTran(sender, new DisplayLinkEventArgs(this, e)); _Panel.OnLinkModifyTran(sender, new DisplayLinkEventArgs(this, e));
} }
private void _DisplayRTB_LinkModifyRO(object sender, LinkClickedEventArgs e)
{
_Panel.OnLinkModifyRO(sender, new DisplayLinkEventArgs(this, e));
}
} }
} }

View File

@ -65,6 +65,7 @@ namespace Volian.Controls.Library
this._DisplayRTB.LinkGoTo += new Volian.Controls.Library.DisplayRTBLinkEvent(this._DisplayRTB_LinkGoTo); this._DisplayRTB.LinkGoTo += new Volian.Controls.Library.DisplayRTBLinkEvent(this._DisplayRTB_LinkGoTo);
this._DisplayRTB.HeightChanged += new Volian.Controls.Library.DisplayRTBEvent(this.veRichTextBoxText_HeightChanged); this._DisplayRTB.HeightChanged += new Volian.Controls.Library.DisplayRTBEvent(this.veRichTextBoxText_HeightChanged);
this._DisplayRTB.LinkModifyTran += new Volian.Controls.Library.DisplayRTBLinkEvent(this._DisplayRTB_LinkModifyTran); this._DisplayRTB.LinkModifyTran += new Volian.Controls.Library.DisplayRTBLinkEvent(this._DisplayRTB_LinkModifyTran);
this._DisplayRTB.LinkModifyRO += new Volian.Controls.Library.DisplayRTBLinkEvent(this._DisplayRTB_LinkModifyRO);
// //
// vlnExp // vlnExp
// //

View File

@ -36,6 +36,12 @@ namespace Volian.Controls.Library
if (LinkModifyTran != null) LinkModifyTran(sender, args); if (LinkModifyTran != null) LinkModifyTran(sender, args);
else MessageBox.Show(args.LinkInfo.LinkText, "Unhandled Link Modify Tran", MessageBoxButtons.OK, MessageBoxIcon.Information); else MessageBox.Show(args.LinkInfo.LinkText, "Unhandled Link Modify Tran", MessageBoxButtons.OK, MessageBoxIcon.Information);
} }
public event DisplayPanelLinkEvent LinkModifyRO;
internal void OnLinkModifyRO(object sender, DisplayLinkEventArgs args)
{
if (LinkModifyRO != null) LinkModifyRO(sender, args);
else MessageBox.Show(args.LinkInfo.LinkText, "Unhandled Link Modify RO", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
public event DisplayPanelAttachmentEvent AttachmentClicked; public event DisplayPanelAttachmentEvent AttachmentClicked;
internal void OnAttachmentClicked(object sender, DisplayPanelAttachmentEventArgs args) internal void OnAttachmentClicked(object sender, DisplayPanelAttachmentEventArgs args)
{ {
@ -167,7 +173,7 @@ namespace Volian.Controls.Library
if (_DisplayRTB != null) if (_DisplayRTB != null)
{ {
_DisplayRTB.BackColor = InactiveColor; _DisplayRTB.BackColor = InactiveColor;
//_DisplayRTB.SaveText(); // Save any changes to the text _DisplayRTB.SaveText(); // Save any changes to the text
} }
_DisplayRTB = value; _DisplayRTB = value;
if (_ItemSelected.ItemID != value.MyItem.ItemID) if (_ItemSelected.ItemID != value.MyItem.ItemID)

View File

@ -30,11 +30,14 @@ namespace Volian.Controls.Library
{ {
this.tvROFST = new System.Windows.Forms.TreeView(); this.tvROFST = new System.Windows.Forms.TreeView();
this.panelValue = new System.Windows.Forms.Panel(); this.panelValue = new System.Windows.Forms.Panel();
this.pnlROButtons = new System.Windows.Forms.Panel();
this.btnCancelRO = new DevComponents.DotNetBar.ButtonX();
this.btnSaveRO = new DevComponents.DotNetBar.ButtonX();
this.panelRoValue = new System.Windows.Forms.Panel(); this.panelRoValue = new System.Windows.Forms.Panel();
this.tbROValue = new DevComponents.DotNetBar.Controls.TextBoxX(); this.tbROValue = new DevComponents.DotNetBar.Controls.TextBoxX();
this.lblROValue = new DevComponents.DotNetBar.LabelX(); this.lblROValue = new DevComponents.DotNetBar.LabelX();
this.btnInsertRO = new DevComponents.DotNetBar.ButtonX();
this.panelValue.SuspendLayout(); this.panelValue.SuspendLayout();
this.pnlROButtons.SuspendLayout();
this.panelRoValue.SuspendLayout(); this.panelRoValue.SuspendLayout();
this.SuspendLayout(); this.SuspendLayout();
// //
@ -43,6 +46,7 @@ namespace Volian.Controls.Library
this.tvROFST.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) this.tvROFST.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right))); | System.Windows.Forms.AnchorStyles.Right)));
this.tvROFST.HideSelection = false;
this.tvROFST.Location = new System.Drawing.Point(0, 52); this.tvROFST.Location = new System.Drawing.Point(0, 52);
this.tvROFST.Name = "tvROFST"; this.tvROFST.Name = "tvROFST";
this.tvROFST.Size = new System.Drawing.Size(226, 455); this.tvROFST.Size = new System.Drawing.Size(226, 455);
@ -52,14 +56,48 @@ namespace Volian.Controls.Library
// //
// panelValue // panelValue
// //
this.panelValue.Controls.Add(this.pnlROButtons);
this.panelValue.Controls.Add(this.panelRoValue); this.panelValue.Controls.Add(this.panelRoValue);
this.panelValue.Controls.Add(this.btnInsertRO);
this.panelValue.Dock = System.Windows.Forms.DockStyle.Top; this.panelValue.Dock = System.Windows.Forms.DockStyle.Top;
this.panelValue.Location = new System.Drawing.Point(0, 0); this.panelValue.Location = new System.Drawing.Point(0, 0);
this.panelValue.Name = "panelValue"; this.panelValue.Name = "panelValue";
this.panelValue.Size = new System.Drawing.Size(226, 53); this.panelValue.Size = new System.Drawing.Size(226, 53);
this.panelValue.TabIndex = 7; this.panelValue.TabIndex = 7;
// //
// pnlROButtons
//
this.pnlROButtons.Controls.Add(this.btnCancelRO);
this.pnlROButtons.Controls.Add(this.btnSaveRO);
this.pnlROButtons.Dock = System.Windows.Forms.DockStyle.Fill;
this.pnlROButtons.Location = new System.Drawing.Point(0, 25);
this.pnlROButtons.Name = "pnlROButtons";
this.pnlROButtons.Size = new System.Drawing.Size(226, 28);
this.pnlROButtons.TabIndex = 9;
//
// btnCancelRO
//
this.btnCancelRO.AccessibleRole = System.Windows.Forms.AccessibleRole.PushButton;
this.btnCancelRO.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.btnCancelRO.ColorTable = DevComponents.DotNetBar.eButtonColor.OrangeWithBackground;
this.btnCancelRO.Location = new System.Drawing.Point(142, 0);
this.btnCancelRO.Name = "btnCancelRO";
this.btnCancelRO.Size = new System.Drawing.Size(84, 27);
this.btnCancelRO.TabIndex = 9;
this.btnCancelRO.Text = "Cancel";
this.btnCancelRO.Click += new System.EventHandler(this.btnCancelRO_Click);
//
// btnSaveRO
//
this.btnSaveRO.AccessibleRole = System.Windows.Forms.AccessibleRole.PushButton;
this.btnSaveRO.ColorTable = DevComponents.DotNetBar.eButtonColor.OrangeWithBackground;
this.btnSaveRO.Dock = System.Windows.Forms.DockStyle.Left;
this.btnSaveRO.Location = new System.Drawing.Point(0, 0);
this.btnSaveRO.Name = "btnSaveRO";
this.btnSaveRO.Size = new System.Drawing.Size(78, 28);
this.btnSaveRO.TabIndex = 8;
this.btnSaveRO.Text = "Save RO";
this.btnSaveRO.Click += new System.EventHandler(this.btnSaveRO_Click);
//
// panelRoValue // panelRoValue
// //
this.panelRoValue.Controls.Add(this.tbROValue); this.panelRoValue.Controls.Add(this.tbROValue);
@ -72,15 +110,14 @@ namespace Volian.Controls.Library
// //
// tbROValue // tbROValue
// //
this.tbROValue.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
// //
// //
// //
this.tbROValue.Border.Class = "TextBoxBorder"; this.tbROValue.Border.Class = "TextBoxBorder";
this.tbROValue.Location = new System.Drawing.Point(54, 0); this.tbROValue.Dock = System.Windows.Forms.DockStyle.Fill;
this.tbROValue.Location = new System.Drawing.Point(59, 0);
this.tbROValue.Name = "tbROValue"; this.tbROValue.Name = "tbROValue";
this.tbROValue.Size = new System.Drawing.Size(167, 25); this.tbROValue.Size = new System.Drawing.Size(167, 20);
this.tbROValue.TabIndex = 7; this.tbROValue.TabIndex = 7;
// //
// lblROValue // lblROValue
@ -92,17 +129,6 @@ namespace Volian.Controls.Library
this.lblROValue.TabIndex = 6; this.lblROValue.TabIndex = 6;
this.lblROValue.Text = "RO Value:"; this.lblROValue.Text = "RO Value:";
// //
// btnInsertRO
//
this.btnInsertRO.AccessibleRole = System.Windows.Forms.AccessibleRole.PushButton;
this.btnInsertRO.ColorTable = DevComponents.DotNetBar.eButtonColor.OrangeWithBackground;
this.btnInsertRO.Dock = System.Windows.Forms.DockStyle.Bottom;
this.btnInsertRO.Location = new System.Drawing.Point(0, 27);
this.btnInsertRO.Name = "btnInsertRO";
this.btnInsertRO.Size = new System.Drawing.Size(226, 26);
this.btnInsertRO.TabIndex = 7;
this.btnInsertRO.Text = "Select RO";
//
// DisplayRO // DisplayRO
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
@ -112,6 +138,7 @@ namespace Volian.Controls.Library
this.Name = "DisplayRO"; this.Name = "DisplayRO";
this.Size = new System.Drawing.Size(226, 507); this.Size = new System.Drawing.Size(226, 507);
this.panelValue.ResumeLayout(false); this.panelValue.ResumeLayout(false);
this.pnlROButtons.ResumeLayout(false);
this.panelRoValue.ResumeLayout(false); this.panelRoValue.ResumeLayout(false);
this.ResumeLayout(false); this.ResumeLayout(false);
@ -121,9 +148,11 @@ namespace Volian.Controls.Library
private System.Windows.Forms.TreeView tvROFST; private System.Windows.Forms.TreeView tvROFST;
private System.Windows.Forms.Panel panelValue; private System.Windows.Forms.Panel panelValue;
private DevComponents.DotNetBar.ButtonX btnInsertRO;
private System.Windows.Forms.Panel panelRoValue; private System.Windows.Forms.Panel panelRoValue;
private DevComponents.DotNetBar.Controls.TextBoxX tbROValue; private DevComponents.DotNetBar.Controls.TextBoxX tbROValue;
private DevComponents.DotNetBar.LabelX lblROValue; private DevComponents.DotNetBar.LabelX lblROValue;
private System.Windows.Forms.Panel pnlROButtons;
private DevComponents.DotNetBar.ButtonX btnCancelRO;
private DevComponents.DotNetBar.ButtonX btnSaveRO;
} }
} }

View File

@ -12,6 +12,7 @@ namespace Volian.Controls.Library
public partial class DisplayRO : UserControl public partial class DisplayRO : UserControl
{ {
#region Properties #region Properties
private ROFST _CurROFST = null;
private ROFST _MyROFST; private ROFST _MyROFST;
public ROFST MyROFST public ROFST MyROFST
{ {
@ -22,12 +23,21 @@ namespace Volian.Controls.Library
LoadTree(); LoadTree();
} }
} }
private bool _Modify = false; private string _CurROLink;
public bool Modify public string CurROLink
{ {
get { return _Modify; } get { return _CurROLink; }
set { _Modify = value; } set
{
_CurROLink = value;
if (_CurROLink != null)
{
UpdateROTree();
_SavCurROLink = _CurROLink;
}
}
} }
private string _SavCurROLink;
private ItemInfo _CurItem; private ItemInfo _CurItem;
public ItemInfo CurItem public ItemInfo CurItem
{ {
@ -35,7 +45,6 @@ namespace Volian.Controls.Library
set { _CurItem = value; } set { _CurItem = value; }
} }
private DisplayRTB _MyRTB; private DisplayRTB _MyRTB;
public DisplayRTB MyRTB public DisplayRTB MyRTB
{ {
get { return _MyRTB; } get { return _MyRTB; }
@ -47,15 +56,14 @@ namespace Volian.Controls.Library
{ {
InitializeComponent(); InitializeComponent();
} }
public DisplayRO(ROFST rofst, ItemInfo curitm, bool modify, DisplayRTB rtb) //public DisplayRO(ROFST rofst, ItemInfo curitm, bool modify, DisplayRTB rtb)
{ //{
_MyROFST = rofst; // _MyROFST = rofst;
_CurItem = curitm; // _CurItem = curitm;
_Modify = modify; // _MyRTB = rtb;
_MyRTB = rtb; // InitializeComponent();
InitializeComponent(); // LoadTree();
LoadTree(); //}
}
#endregion #endregion
#region Events #region Events
private void tvROFST_AfterSelect(object sender, TreeViewEventArgs e) private void tvROFST_AfterSelect(object sender, TreeViewEventArgs e)
@ -77,6 +85,7 @@ namespace Volian.Controls.Library
private void LoadChildren(TreeNode tn) private void LoadChildren(TreeNode tn)
{ {
object tag = tn.Tag; object tag = tn.Tag;
if (tn.FirstNode != null && tn.FirstNode.Text != "VLN_DUMMY_FOR_TREE") return; // already loaded.
if (tn.FirstNode != null && tn.FirstNode.Text == "VLN_DUMMY_FOR_TREE") tn.FirstNode.Remove(); if (tn.FirstNode != null && tn.FirstNode.Text == "VLN_DUMMY_FOR_TREE") tn.FirstNode.Remove();
ROFST.rochild[] chld = null; ROFST.rochild[] chld = null;
@ -125,6 +134,8 @@ namespace Volian.Controls.Library
private void LoadTree() private void LoadTree()
{ {
if (_MyROFST == null) return; if (_MyROFST == null) return;
if (_MyROFST == _CurROFST) return;
_CurROFST = _MyROFST;
for (int i = 0; i < _MyROFST.myHdr.myDbs.Length; i++) for (int i = 0; i < _MyROFST.myHdr.myDbs.Length; i++)
{ {
TreeNode tn = new TreeNode(_MyROFST.myHdr.myDbs[i].dbiTitle); TreeNode tn = new TreeNode(_MyROFST.myHdr.myDbs[i].dbiTitle);
@ -141,7 +152,63 @@ namespace Volian.Controls.Library
tn.Nodes.Add(tmp); tn.Nodes.Add(tmp);
} }
} }
private void btnInsertRO_Click(object sender, EventArgs e) private void UpdateROTree()
{
// walk down from root of tree, expanding values in the string
// that represents the ro link.
string tmpstr = _CurROLink;
int sp = tmpstr.IndexOf(" "); // because parse of ro info is wrong!!
int rousageid = System.Convert.ToInt32(tmpstr.Substring(0, sp));
string roid = tmpstr.Substring(sp + 1, tmpstr.Length - sp - 1);
string db = roid.Substring(0, 4);
ROFST.rochild rochld = MyROFST.GetRoChild(roid.Substring(0, 12).ToUpper());
// use this to walk up tree until database - this is used to expand tree.
List<int> path = new List<int>();
int myid = rochld.ID;
while (myid > 0)
{
path.Insert(0,myid);
myid = rochld.ParentID;
rochld = MyROFST.GetRoChildFromID(myid);
if (rochld.ID == -1) myid = -1;
}
TreeNode tnExpand = null;
int titm = System.Convert.ToInt32(db);
// find database first
foreach (TreeNode tn in tvROFST.Nodes)
{
ROFST.rodbi thisdb = (ROFST.rodbi)tn.Tag;
if (thisdb.dbiID == titm)
{
LoadChildren(tn);
tnExpand = tn;
break;
}
}
if (tnExpand == null) return; // something went wrong?
// use the path id list to load/find the treeview's nodes.
foreach (int citm in path)
{
if (citm != System.Convert.ToInt32(db))
{
LoadChildren(tnExpand);
tnExpand.Expand();
foreach (TreeNode tn in tnExpand.Nodes)
{
ROFST.rochild chld = (ROFST.rochild)tn.Tag;
if (chld.ID == citm)
{
tnExpand = tn;
break;
}
}
}
}
if (tnExpand != null) tvROFST.SelectedNode = tnExpand;
}
private void btnSaveRO_Click(object sender, EventArgs e)
{ {
if (tbROValue.Text == null || tbROValue.Text == "") if (tbROValue.Text == null || tbROValue.Text == "")
{ {
@ -157,5 +224,11 @@ namespace Volian.Controls.Library
} }
} }
#endregion #endregion
private void btnCancelRO_Click(object sender, EventArgs e)
{
_CurROLink = _SavCurROLink;
UpdateROTree();
}
} }
} }

View File

@ -32,6 +32,8 @@ namespace Volian.Controls.Library
// return prams; // return prams;
// } // }
//} //}
private bool _IsDirty = false;
private bool _InitializingRTB;
private IContainer _Container = null; private IContainer _Container = null;
private string _MyClassName=string.Empty; private string _MyClassName=string.Empty;
public string MyClassName public string MyClassName
@ -60,12 +62,15 @@ namespace Volian.Controls.Library
_MyItem = value; _MyItem = value;
if (value != null) if (value != null)
{ {
_InitializingRTB = true;
DisplayText vlntxt = new DisplayText(_MyItem, EpMode, VwMode); DisplayText vlntxt = new DisplayText(_MyItem, EpMode, VwMode);
_origVlnText = vlntxt; _origVlnText = vlntxt;
Font = _origVlnText.TextFont.WindowsFont; Font = _origVlnText.TextFont.WindowsFont;
AddRtfText(vlntxt); AddRtfText(vlntxt);
ReadOnly = !(EpMode == E_EditPrintMode.Edit && VwMode == E_ViewMode.Edit); ReadOnly = !(EpMode == E_EditPrintMode.Edit && VwMode == E_ViewMode.Edit);
RTBAPI.SetLineSpacing(this, RTBAPI.ParaSpacing.PFS_EXACT); 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 RichTextBox _rtbTemp = new RichTextBox();
private string _eLinkText; private string _eLinkText;
#endregion #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 #region Constructors
/// <summary> /// <summary>
/// vlnRichTextBox constructor: /// vlnRichTextBox constructor:
@ -150,36 +139,6 @@ namespace Volian.Controls.Library
/// E_EditPrintMode ep_mode - edit or print. /// E_EditPrintMode ep_mode - edit or print.
/// E_ViewMode vw_mode - view or edit. /// E_ViewMode vw_mode - view or edit.
/// </summary> /// </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() public DisplayRTB()
{ {
InitializeComponent(); InitializeComponent();
@ -197,11 +156,12 @@ namespace Volian.Controls.Library
BorderStyle = System.Windows.Forms.BorderStyle.None; BorderStyle = System.Windows.Forms.BorderStyle.None;
this.DetectUrls = true; this.DetectUrls = true;
ContextMenuStrip = contextMenuStrip; ContextMenuStrip = contextMenuStrip;
ContentsResized += new ContentsResizedEventHandler(vlnRichTextBox_ContentsResized); ContentsResized += new ContentsResizedEventHandler(DisplayRTB_ContentsResized);
this.LinkClicked += new LinkClickedEventHandler(onLinkClicked); this.LinkClicked += new LinkClickedEventHandler(DisplayRTB_LinkClicked);
this.KeyPress += new KeyPressEventHandler(onKeyPress); this.KeyPress += new KeyPressEventHandler(DisplayRTB_KeyPress);
this.KeyDown += new KeyEventHandler(onKeyDown); this.KeyUp += new KeyEventHandler(DisplayRTB_KeyUp);
//this.Leave += new EventHandler(DisplayRTB_Leave); this.KeyDown += new KeyEventHandler(DisplayRTB_KeyDown);
this.TextChanged += new EventHandler(DisplayRTB_TextChanged);
} }
#endregion #endregion
#region ApplicationSupport #region ApplicationSupport
@ -229,9 +189,12 @@ namespace Volian.Controls.Library
} }
#endregion #endregion
#region SaveData #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 #endregion
#region AddRtfText #region AddRtfText
@ -306,7 +269,21 @@ namespace Volian.Controls.Library
this.SelectionLength = 0; this.SelectionLength = 0;
} }
#endregion #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() public int CalculateHeight()
{ {
if (this.CreateParams.ClassName == "RICHEDIT50W") if (this.CreateParams.ClassName == "RICHEDIT50W")
@ -363,12 +340,12 @@ namespace Volian.Controls.Library
} }
#endregion #endregion
#region EventSupport #region EventSupport
#region LinkEvents
private LinkClickedEventArgs _LinkClickedEventArgs; private LinkClickedEventArgs _LinkClickedEventArgs;
public event DisplayRTBLinkEvent LinkGoTo; public event DisplayRTBLinkEvent LinkGoTo;
private void OnLinkGoTo(object sender, LinkClickedEventArgs args) private void OnLinkGoTo(object sender, LinkClickedEventArgs args)
{ {
_LinkClickedEventArgs = args; _LinkClickedEventArgs = args;
Console.WriteLine("DisplayRTB " + _LinkClickedEventArgs.LinkText);
if (LinkGoTo != null) LinkGoTo(sender, args); if (LinkGoTo != null) LinkGoTo(sender, args);
} }
public event DisplayRTBLinkEvent LinkModifyTran; public event DisplayRTBLinkEvent LinkModifyTran;
@ -377,22 +354,14 @@ namespace Volian.Controls.Library
_LinkClickedEventArgs = args; _LinkClickedEventArgs = args;
if (LinkModifyTran != null) LinkModifyTran(sender, args); if (LinkModifyTran != null) LinkModifyTran(sender, args);
} }
//void DisplayRTB_Leave(object sender, EventArgs e) public event DisplayRTBLinkEvent LinkModifyRO;
//{ private void OnLinkModifyRO(object sender, LinkClickedEventArgs args)
// // 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()
{ {
if (ReadOnly) return; _LinkClickedEventArgs = args;
bool success = _origVlnText.Save((RichTextBox)this); if (LinkModifyRO != null) LinkModifyRO(sender, args);
if (!success) Console.WriteLine("Failed to save text: {0}", this.Text);
} }
private Point _savcurpos; 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; if (ReadOnly) return;
_LinkClickedEventArgs = e; _LinkClickedEventArgs = e;
@ -411,20 +380,27 @@ namespace Volian.Controls.Library
int iMin = index; int iMin = index;
Select(index, 0); Select(index, 0);
while (SelectionProtected) while (iMin > 0 && SelectionProtected)
Select(--iMin, 0); Select(--iMin, 0);
Select(iMin - 1, 1 + LinkText.Length); Select(iMin - 1, 1 + LinkText.Length);
SelectionProtected = false; SelectionProtected = false;
Select(iMin, LinkText.Length); 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; ContentsRectangle = e.NewRectangle;
} }
#endregion
#region KeyboardHandling #region KeyboardHandling
private bool IsControlChar = false; 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) if (e.Modifiers == Keys.Control)
{ {
@ -433,14 +409,46 @@ namespace Volian.Controls.Library
{ {
case Keys.V: case Keys.V:
string buff = Clipboard.GetText(TextDataFormat.UnicodeText); string buff = Clipboard.GetText(TextDataFormat.UnicodeText);
// check if insertable? // check if insertable?
Console.WriteLine(String.Format("in switch, keydata = {0}, keyvalue = {1}, buff = {2}", e.KeyData, e.KeyValue, buff)); Console.WriteLine(String.Format("in switch, keydata = {0}, keyvalue = {1}, buff = {2}", e.KeyData, e.KeyValue, buff));
break; 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) if (!ReadOnly)
{ {
@ -632,10 +640,6 @@ namespace Volian.Controls.Library
SelectLink(_eLinkText); SelectLink(_eLinkText);
SelectedText = ""; SelectedText = "";
} }
private void ModifyTransition()
{
Console.WriteLine("Modify Transition");
}
private void contextMenuStripTrans_ItemClicked(object sender, ToolStripItemClickedEventArgs e) private void contextMenuStripTrans_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
{ {
if (e.ClickedItem.ToString() == "Delete Transition") DeleteTransition(); if (e.ClickedItem.ToString() == "Delete Transition") DeleteTransition();
@ -666,14 +670,10 @@ namespace Volian.Controls.Library
SelectLink(_eLinkText); SelectLink(_eLinkText);
SelectedText = ""; SelectedText = "";
} }
private void ModifyRefObj()
{
Console.WriteLine("ModifyRefObj");
}
private void contextMenuStripROs_ItemClicked(object sender, ToolStripItemClickedEventArgs e) private void contextMenuStripROs_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
{ {
if (e.ClickedItem.ToString() == "Delete RO") DeleteRefObj(); 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 #endregion