This commit is contained in:
parent
368c85c98b
commit
a17a98fe57
@ -318,8 +318,8 @@ namespace Volian.Controls.Library
|
|||||||
}
|
}
|
||||||
private int FindTop(int bottom)
|
private int FindTop(int bottom)
|
||||||
{
|
{
|
||||||
int? lastBottomPrev = 0;
|
int lastBottomPrev = 0;
|
||||||
int? lastBottomParent = 0;
|
int lastBottomParent = 0;
|
||||||
if (_MyPreviousStepItem != null)
|
if (_MyPreviousStepItem != null)
|
||||||
lastBottomPrev = _MyPreviousStepItem.BottomMostStepItem.Bottom;
|
lastBottomPrev = _MyPreviousStepItem.BottomMostStepItem.Bottom;
|
||||||
else if(_MyParentStepItem != null)
|
else if(_MyParentStepItem != null)
|
||||||
@ -332,6 +332,9 @@ namespace Volian.Controls.Library
|
|||||||
// Console.WriteLine("{0}\t{1}\t{2}\t{3}\t{4}", MyID, lastBottomPrev,lastBottomParent, bottom, bottomRNO);
|
// Console.WriteLine("{0}\t{1}\t{2}\t{3}\t{4}", MyID, lastBottomPrev,lastBottomParent, bottom, bottomRNO);
|
||||||
//if (MyID == 2125)
|
//if (MyID == 2125)
|
||||||
// Console.WriteLine("Oops!");
|
// Console.WriteLine("Oops!");
|
||||||
|
if (lastBottomPrev > bottom) bottom = lastBottomPrev; // RHM 20090615 ES02 Step8
|
||||||
|
// Moving from Step 8 to the Note preceeding step 8 caused the step 9 to be positioned in the wrong place.
|
||||||
|
//if (lastBottomParent > bottom) bottom = lastBottomParent;
|
||||||
if (bottomRNO == null) return bottom;
|
if (bottomRNO == null) return bottom;
|
||||||
return (int) max(bottomRNO, bottom);
|
return (int) max(bottomRNO, bottom);
|
||||||
}
|
}
|
||||||
@ -1354,6 +1357,14 @@ namespace Volian.Controls.Library
|
|||||||
{
|
{
|
||||||
_MyStepPanel.OnAttachmentClicked(sender, new StepPanelAttachmentEventArgs(this));
|
_MyStepPanel.OnAttachmentClicked(sender, new StepPanelAttachmentEventArgs(this));
|
||||||
}
|
}
|
||||||
|
private void _MyStepRTB_CursorKeyPress(object sender, KeyEventArgs args)
|
||||||
|
{
|
||||||
|
_MyStepPanel.StepCursorKeys(sender as StepRTB, args);
|
||||||
|
}
|
||||||
|
private void _MyStepRTB_CursorMovement(object sender, StepRTBCursorMovementEventArgs args)
|
||||||
|
{
|
||||||
|
_MyStepPanel.CursorMovement(sender as StepRTB, args.CursorLocation, args.Key);
|
||||||
|
}
|
||||||
#endregion // Event Handlers
|
#endregion // Event Handlers
|
||||||
#region Private Methods
|
#region Private Methods
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -50,15 +50,19 @@ namespace Volian.Controls.Library
|
|||||||
| System.Windows.Forms.AnchorStyles.Right)));
|
| System.Windows.Forms.AnchorStyles.Right)));
|
||||||
this._MyStepRTB.BackColor = System.Drawing.Color.Linen;
|
this._MyStepRTB.BackColor = System.Drawing.Color.Linen;
|
||||||
this._MyStepRTB.BorderStyle = System.Windows.Forms.BorderStyle.None;
|
this._MyStepRTB.BorderStyle = System.Windows.Forms.BorderStyle.None;
|
||||||
this._MyStepRTB.ContentsRectangle = new System.Drawing.Rectangle(0, 0, 0, 0);
|
this._MyStepRTB.ContentsRectangle = new System.Drawing.Rectangle(0, 0, 234, 20);
|
||||||
this._MyStepRTB.EpMode = VEPROMS.CSLA.Library.E_EditPrintMode.Edit;
|
this._MyStepRTB.EpMode = VEPROMS.CSLA.Library.E_EditPrintMode.Edit;
|
||||||
this._MyStepRTB.Font = new System.Drawing.Font("Prestige Elite Tall", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(2)));
|
this._MyStepRTB.Font = new System.Drawing.Font("Prestige Elite Tall", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(2)));
|
||||||
this._MyStepRTB.Location = new System.Drawing.Point(80, 0);
|
this._MyStepRTB.Location = new System.Drawing.Point(80, 0);
|
||||||
this._MyStepRTB.MyClassName = "RichEdit20W";
|
this._MyStepRTB.MyClassName = "RichEdit20W";
|
||||||
this._MyStepRTB.MyItemInfo = null;
|
this._MyStepRTB.MyItemInfo = null;
|
||||||
this._MyStepRTB.MyLinkText = null;
|
this._MyStepRTB.MyLinkText = null;
|
||||||
|
this._MyStepRTB.MyStepItem = null;
|
||||||
this._MyStepRTB.Name = "_MyStepRTB";
|
this._MyStepRTB.Name = "_MyStepRTB";
|
||||||
|
this._MyStepRTB.ProcessKeystrokes = true;
|
||||||
|
this._MyStepRTB.RTBRangeStatus = Volian.Controls.Library.StepRTB.RangeStatus.NoContainedLinks;
|
||||||
this._MyStepRTB.ScrollBars = System.Windows.Forms.RichTextBoxScrollBars.None;
|
this._MyStepRTB.ScrollBars = System.Windows.Forms.RichTextBoxScrollBars.None;
|
||||||
|
this._MyStepRTB.ShowDebug = false;
|
||||||
this._MyStepRTB.Size = new System.Drawing.Size(234, 20);
|
this._MyStepRTB.Size = new System.Drawing.Size(234, 20);
|
||||||
this._MyStepRTB.TabIndex = 2;
|
this._MyStepRTB.TabIndex = 2;
|
||||||
this._MyStepRTB.Text = "";
|
this._MyStepRTB.Text = "";
|
||||||
@ -67,6 +71,8 @@ namespace Volian.Controls.Library
|
|||||||
this._MyStepRTB.Enter += new System.EventHandler(this._StepRTB_Enter);
|
this._MyStepRTB.Enter += new System.EventHandler(this._StepRTB_Enter);
|
||||||
this._MyStepRTB.HeightChanged += new Volian.Controls.Library.StepRTBEvent(this._StepRTB_HeightChanged);
|
this._MyStepRTB.HeightChanged += new Volian.Controls.Library.StepRTBEvent(this._StepRTB_HeightChanged);
|
||||||
this._MyStepRTB.LinkModifyTran += new Volian.Controls.Library.StepRTBLinkEvent(this._StepRTB_LinkModifyTran);
|
this._MyStepRTB.LinkModifyTran += new Volian.Controls.Library.StepRTBLinkEvent(this._StepRTB_LinkModifyTran);
|
||||||
|
this._MyStepRTB.CursorKeyPress += new Volian.Controls.Library.StepRTBCursorKeysEvent(this._MyStepRTB_CursorKeyPress);
|
||||||
|
this._MyStepRTB.CursorMovement += new Volian.Controls.Library.StepRTBCursorMovementEvent(this._MyStepRTB_CursorMovement);
|
||||||
this._MyStepRTB.LinkModifyRO += new Volian.Controls.Library.StepRTBLinkEvent(this._StepRTB_LinkModifyRO);
|
this._MyStepRTB.LinkModifyRO += new Volian.Controls.Library.StepRTBLinkEvent(this._StepRTB_LinkModifyRO);
|
||||||
//
|
//
|
||||||
// _MyvlnExpander
|
// _MyvlnExpander
|
||||||
|
@ -13,6 +13,9 @@ using VEPROMS.CSLA.Library;
|
|||||||
namespace Volian.Controls.Library
|
namespace Volian.Controls.Library
|
||||||
{
|
{
|
||||||
public delegate void StepRTBEvent(object sender, EventArgs args);
|
public delegate void StepRTBEvent(object sender, EventArgs args);
|
||||||
|
public delegate void StepRTBCursorKeysEvent(object sender, KeyEventArgs args);
|
||||||
|
public delegate void StepRTBCursorMovementEvent(object sender, StepRTBCursorMovementEventArgs args);
|
||||||
|
//public delegate void StepRTBMouseWheelEvent(object sender, MouseEventArgs args);
|
||||||
public partial class StepRTB : RichTextBox , IStepRTB
|
public partial class StepRTB : RichTextBox , IStepRTB
|
||||||
{
|
{
|
||||||
#region Events
|
#region Events
|
||||||
@ -31,6 +34,22 @@ namespace Volian.Controls.Library
|
|||||||
{
|
{
|
||||||
if (RTBRangeStatusChanged != null) RTBRangeStatusChanged(sender, args);
|
if (RTBRangeStatusChanged != null) RTBRangeStatusChanged(sender, args);
|
||||||
}
|
}
|
||||||
|
public event StepRTBCursorKeysEvent CursorKeyPress;
|
||||||
|
private void OnCursorKeyPress(object sender, KeyEventArgs args)
|
||||||
|
{
|
||||||
|
if (CursorKeyPress != null) CursorKeyPress(sender, args);
|
||||||
|
}
|
||||||
|
public event StepRTBCursorMovementEvent CursorMovement;
|
||||||
|
private void OnCursorMovement(object sender, StepRTBCursorMovementEventArgs args)
|
||||||
|
{
|
||||||
|
if (CursorMovement != null) CursorMovement(sender, args);
|
||||||
|
}
|
||||||
|
//public event StepRTBMouseWheelEvent MouseWheel;
|
||||||
|
//private void OnMouseWheel(object sender, MouseEventArgs args)
|
||||||
|
//{
|
||||||
|
// if (MouseWheel != null) MouseWheel(sender, args);
|
||||||
|
//}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// This event is not raised during all the in-between changes for link deletions
|
/// This event is not raised during all the in-between changes for link deletions
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -166,10 +185,15 @@ namespace Volian.Controls.Library
|
|||||||
get { return RTBAPI.GetScrollLocation(this); }
|
get { return RTBAPI.GetScrollLocation(this); }
|
||||||
set { RTBAPI.SetScrollLocation(this, value); }
|
set { RTBAPI.SetScrollLocation(this, value); }
|
||||||
}
|
}
|
||||||
private Rectangle _ContentsRectangle;
|
private Rectangle _ContentsRectangle = new Rectangle(0,0,0,0);
|
||||||
public Rectangle ContentsRectangle
|
public Rectangle ContentsRectangle
|
||||||
{
|
{
|
||||||
get { return _ContentsRectangle; }
|
get
|
||||||
|
{
|
||||||
|
if (_ContentsRectangle.X == 0 && _ContentsRectangle.Y == 0 && _ContentsRectangle.Width == 0 && _ContentsRectangle.Height == 0)
|
||||||
|
_ContentsRectangle = this.ClientRectangle;
|
||||||
|
return _ContentsRectangle;
|
||||||
|
}
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
_ContentsRectangle = value;
|
_ContentsRectangle = value;
|
||||||
@ -180,7 +204,7 @@ namespace Volian.Controls.Library
|
|||||||
{
|
{
|
||||||
get { return _ContentsRectangle.Size; }
|
get { return _ContentsRectangle.Size; }
|
||||||
}
|
}
|
||||||
private Size _AdjustSize; // if 0,0 puts text right next to bottom of box.
|
private Size _AdjustSize = new Size(0,0); // if 0,0 puts text right next to bottom of box.
|
||||||
public Size AdjustSize
|
public Size AdjustSize
|
||||||
{
|
{
|
||||||
get { return _AdjustSize; }
|
get { return _AdjustSize; }
|
||||||
@ -232,14 +256,16 @@ namespace Volian.Controls.Library
|
|||||||
_Container = container;
|
_Container = container;
|
||||||
SetUp();
|
SetUp();
|
||||||
}
|
}
|
||||||
protected override void OnMouseWheel(MouseEventArgs e)
|
//protected override void OnMouseWheel(MouseEventArgs e)
|
||||||
{
|
//{
|
||||||
_MyStepItem.MyStepPanel.MouseWheel(e);
|
// //_MyStepItem.MyStepPanel.MouseWheel(e);
|
||||||
//base.OnMouseWheel(e);
|
// OnMouseWheel(this,e);
|
||||||
}
|
// //base.OnMouseWheel(e);
|
||||||
|
//}
|
||||||
private void SetUp()
|
private void SetUp()
|
||||||
{
|
{
|
||||||
BorderStyle = System.Windows.Forms.BorderStyle.None;
|
BorderStyle = System.Windows.Forms.BorderStyle.None;
|
||||||
|
this.ScrollBars = RichTextBoxScrollBars.None;
|
||||||
this.DetectUrls = true;
|
this.DetectUrls = true;
|
||||||
ContentsResized += new ContentsResizedEventHandler(StepRTB_ContentsResized);
|
ContentsResized += new ContentsResizedEventHandler(StepRTB_ContentsResized);
|
||||||
this.LinkClicked += new LinkClickedEventHandler(StepRTB_LinkClicked);
|
this.LinkClicked += new LinkClickedEventHandler(StepRTB_LinkClicked);
|
||||||
@ -274,7 +300,8 @@ namespace Volian.Controls.Library
|
|||||||
void StepRTB_MouseUp(object sender, MouseEventArgs e)
|
void StepRTB_MouseUp(object sender, MouseEventArgs e)
|
||||||
{
|
{
|
||||||
_MouseDown = false;
|
_MouseDown = false;
|
||||||
HandleSelectionChange();
|
if(this.Focused) // Only HandleSelectionChange if this control has focus.
|
||||||
|
HandleSelectionChange();
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
#region ApplicationSupport
|
#region ApplicationSupport
|
||||||
@ -574,11 +601,79 @@ namespace Volian.Controls.Library
|
|||||||
}
|
}
|
||||||
private void AdjustSizeForContents()
|
private void AdjustSizeForContents()
|
||||||
{
|
{
|
||||||
// The client size should match the new rectangle.
|
|
||||||
// First, determine the offset
|
|
||||||
Size offset = Size - ClientSize;
|
Size offset = Size - ClientSize;
|
||||||
this.Size = ContentsSize + offset + AdjustSize;
|
int widthNew = ContentsSize.Width + offset.Width + AdjustSize.Width;
|
||||||
OnHeightChanged(this, new EventArgs());
|
int heightNew = ContentsSize.Height + offset.Height + AdjustSize.Height;
|
||||||
|
Size szNew = new Size(widthNew,heightNew);
|
||||||
|
if (this.Size != szNew)
|
||||||
|
{
|
||||||
|
this.Size = szNew;
|
||||||
|
OnHeightChanged(this, new EventArgs());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private float GetStringWidth(string strMeasureString)
|
||||||
|
{
|
||||||
|
using (Graphics g = Graphics.FromHwnd(Handle))
|
||||||
|
{
|
||||||
|
return g.MeasureString(strMeasureString, Font).Width;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private int Ceiling(float f)
|
||||||
|
{
|
||||||
|
return (int)(Math.Ceiling(f));
|
||||||
|
}
|
||||||
|
public void AdjustWidthForContent()
|
||||||
|
{
|
||||||
|
int widthNL = Ceiling(GetStringWidth("\n"));
|
||||||
|
int widthMax = 0;
|
||||||
|
int widthMaxWW = 0;
|
||||||
|
int indexStart = 0;
|
||||||
|
int lineCountFromLines = Lines.Length;
|
||||||
|
int lineCountFromGet = GetLineFromCharIndex(TextLength)+1;
|
||||||
|
for (int i = 0; i < Lines.Length; i++)
|
||||||
|
{
|
||||||
|
int lineStart = GetLineFromCharIndex(indexStart);
|
||||||
|
int indexEnd = indexStart + Lines[i].Length;
|
||||||
|
int lineEnd = GetLineFromCharIndex(indexEnd);
|
||||||
|
Point pointStart = GetPositionFromCharIndex(indexStart);
|
||||||
|
Point pointEnd = GetPositionFromCharIndex(indexEnd);
|
||||||
|
int indexEndPos = GetCharIndexFromPosition(pointEnd);
|
||||||
|
if (indexEndPos + 1 < indexEnd) // This indicates that the text is wider than the Rich Text Box
|
||||||
|
{
|
||||||
|
int w = pointEnd.X + (indexEnd - indexEndPos) * widthNL;
|
||||||
|
if (w > widthMaxWW)
|
||||||
|
{
|
||||||
|
widthMaxWW = w;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (lineEnd > lineStart)// this indicates that there was word-wrap on this line.
|
||||||
|
{
|
||||||
|
int w = pointEnd.X + Width * (lineEnd - lineStart);
|
||||||
|
if (w > widthMaxWW)
|
||||||
|
widthMaxWW = w;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (pointEnd.X > widthMax)
|
||||||
|
widthMax = pointEnd.X;
|
||||||
|
}
|
||||||
|
indexStart = indexEnd + 1;
|
||||||
|
}
|
||||||
|
if (widthMaxWW == 0)
|
||||||
|
{
|
||||||
|
int widthBorder = Width - ClientSize.Width;
|
||||||
|
int w = widthMax + widthNL + widthBorder;
|
||||||
|
if (Width != w)
|
||||||
|
{
|
||||||
|
Width = w;
|
||||||
|
AdjustWidthForContent();// Try one more time
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Width = widthMaxWW;
|
||||||
|
AdjustWidthForContent();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
public int CalculateHeight()
|
public int CalculateHeight()
|
||||||
{
|
{
|
||||||
@ -1129,17 +1224,20 @@ namespace Volian.Controls.Library
|
|||||||
if (MyItemInfo.IsProcedure || MyItemInfo.IsSection) return;
|
if (MyItemInfo.IsProcedure || MyItemInfo.IsSection) return;
|
||||||
// Cursor moves out of box only if control is pressed too - otherwise key is
|
// Cursor moves out of box only if control is pressed too - otherwise key is
|
||||||
// handled in rtb.
|
// handled in rtb.
|
||||||
if (keyargs.Control)_MyStepItem.MyStepPanel.StepCursorKeys(this, keyargs);
|
//if (keyargs.Control)_MyStepItem.MyStepPanel.StepCursorKeys(this, keyargs); // Replaced with an event
|
||||||
|
if (keyargs.Control) OnCursorKeyPress(this, keyargs);
|
||||||
}
|
}
|
||||||
private void StepRTB_PageKeyPressed(KeyEventArgs keyargs)
|
private void StepRTB_PageKeyPressed(KeyEventArgs keyargs)
|
||||||
{
|
{
|
||||||
if (MyItemInfo.IsProcedure || MyItemInfo.IsSection) return;
|
if (MyItemInfo.IsProcedure || MyItemInfo.IsSection) return;
|
||||||
_MyStepItem.MyStepPanel.StepCursorKeys(this, keyargs);
|
//_MyStepItem.MyStepPanel.StepCursorKeys(this, keyargs); Replaced with an event
|
||||||
|
OnCursorKeyPress(this, keyargs);
|
||||||
}
|
}
|
||||||
private void StepRTB_ArrowPressed(E_ArrowKeys key)
|
private void StepRTB_ArrowPressed(E_ArrowKeys key)
|
||||||
{
|
{
|
||||||
Point cp = PointToClient(Cursor.Position);
|
Point cp = PointToClient(Cursor.Position);
|
||||||
_MyStepItem.MyStepPanel.CursorMovement(this, cp, key);
|
//_MyStepItem.MyStepPanel.CursorMovement(this, cp, key); Replaced with an event
|
||||||
|
OnCursorMovement(this, new StepRTBCursorMovementEventArgs(cp, key));
|
||||||
}
|
}
|
||||||
private void StepRTB_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
|
private void StepRTB_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
|
||||||
{
|
{
|
||||||
@ -1698,6 +1796,26 @@ namespace Volian.Controls.Library
|
|||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
|
public class StepRTBCursorMovementEventArgs
|
||||||
|
{
|
||||||
|
private Point _CursorLocation;
|
||||||
|
public Point CursorLocation
|
||||||
|
{
|
||||||
|
get { return _CursorLocation; }
|
||||||
|
set { _CursorLocation = value; }
|
||||||
|
}
|
||||||
|
private E_ArrowKeys _Key;
|
||||||
|
public E_ArrowKeys Key
|
||||||
|
{
|
||||||
|
get { return _Key; }
|
||||||
|
set { _Key = value; }
|
||||||
|
}
|
||||||
|
public StepRTBCursorMovementEventArgs(Point pt, E_ArrowKeys key)
|
||||||
|
{
|
||||||
|
_CursorLocation = pt;
|
||||||
|
_Key = key;
|
||||||
|
}
|
||||||
|
}
|
||||||
#region LinkLocation Class
|
#region LinkLocation Class
|
||||||
public class LinkLocation
|
public class LinkLocation
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user