diff --git a/PROMS/Volian.Controls.Library/RTBItem.cs b/PROMS/Volian.Controls.Library/RTBItem.cs index 09f3efaf..c23490fe 100644 --- a/PROMS/Volian.Controls.Library/RTBItem.cs +++ b/PROMS/Volian.Controls.Library/RTBItem.cs @@ -4,21 +4,13 @@ using System.ComponentModel; using System.Drawing; using System.Data; using System.Text; +using System.Text.RegularExpressions; using System.Windows.Forms; using VEPROMS.CSLA.Library; -using System.Text.RegularExpressions; -using Volian.Base.Library; namespace Volian.Controls.Library { #region Enums - public enum ChildRelation : int - { - None = 0, - After = 1, - Before = 2, - RNO = 3 - } public enum ExpandingStatus : int { No = 0, @@ -28,370 +20,42 @@ namespace Volian.Controls.Library Showing = 8, Done = 16 } - public enum E_ChangeBarPosition : int - { - Left = 0, - Right = 1 - } #endregion - public partial class RTBItem : UserControl + public partial class RTBItem : EditItem { - //private static int _RTBItemUnique = 0; - //private static int RTBItemUnique - //{ - // get - // { - // if (_RTBItemUnique == 3) - // Console.WriteLine("here"); - // return ++_RTBItemUnique; - // } - //} - //private int _MyRTBItemUnique = RTBItemUnique; - - //public int MyRTBItemUnique - //{ - // get {return _MyRTBItemUnique; } - //} - #region Private Fields - private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); - private StepPanel _MyStepPanel; - - public StepPanel MyStepPanel - { - get { return _MyStepPanel; } - set { _MyStepPanel = value; } - } - private ChildRelation _MyChildRelation; - private RTBItem _MyParentRTBItem = null; - private RTBItem _MySectionRTBItem; - private RTBItem _MyPreviousRTBItem = null; - private RTBItem _MyNextRTBItem = null; - private bool _ChildrenLoaded = false; - public bool HasChildren - { - get {return _MyBeforeRTBItems != null || _MyRNORTBItems != null || _MyAfterRTBItems != null;} - } - private List _MyBeforeRTBItems; - - public List MyBeforeRTBItems - { - get { return _MyBeforeRTBItems; } - set { _MyBeforeRTBItems = value; } - } - private List _MyAfterRTBItems; - - public List MyAfterRTBItems - { - get { return _MyAfterRTBItems; } - set { _MyAfterRTBItems = value; } - } - private List _MyRNORTBItems; - - public List MyRNORTBItems - { - get { return _MyRNORTBItems; } - set { _MyRNORTBItems = value; } - } + public Label MyLabel - { get { return lblTab; } } - private StepSectionLayoutData _MyStepSectionLayoutData; - public StepSectionLayoutData MyStepSectionLayoutData - { - get { return _MyStepSectionLayoutData; } - set { _MyStepSectionLayoutData = value; } - } - private bool _Loading = true; - private StepData _MyStepData; - public StepData MyStepData - { - get { return _MyStepData; } - set { _MyStepData = value; } - } - private ItemInfo _MyItemInfo; - private static int _WidthAdjust = 3; - - private int _ExpandPrefix = 0; - private int _ExpandSuffix = 0; - private ExpandingStatus _MyExpandingStatus = ExpandingStatus.No; - private bool _Colapsing = false; - private bool _Moving = false; - private int _RNOLevel = 0; - private int _SeqLevel = 0; - private int _Type; - private bool _Circle = false; - private bool _CheckOff = false; - private bool _ChangeBar = false; - - #endregion - #region Properties - /// - /// This returns the section or procedure for the current item. - /// If the item is a step or section, it returns the section - /// If it is a procedure, it returns the procedure - /// - public RTBItem MySectionRTBItem - { - get - { - if (_MySectionRTBItem == null) - { - if (MyItemInfo.IsSection || MyItemInfo.IsProcedure) _MySectionRTBItem = this; - else _MySectionRTBItem = _MyParentRTBItem.MySectionRTBItem; - } - return _MySectionRTBItem; - } - set { _MySectionRTBItem = value; } - } - /// - /// Gets or Sets ItemInfo - /// - public ItemInfo MyItemInfo - { - get { return _MyItemInfo; } - set - { - _MyItemInfo = value; - if (VlnSettings.StepTypeToolType)SetToolTip(_MyItemInfo.ToolTip); - ChangeBar = _MyItemInfo.HasChangeBar; - value.MyContent.Changed += new ContentInfoEvent(MyContent_Changed); - value.OrdinalChanged += new ItemInfoEvent(value_OrdinalChanged); - } - } - void value_OrdinalChanged(object sender) - { - TabFormat = null; // Reset Tab - } - private void SetToolTip(string tip) - { - DevComponents.DotNetBar.SuperTooltipInfo tpi = new DevComponents.DotNetBar.SuperTooltipInfo("", "", tip, null, null, DevComponents.DotNetBar.eTooltipColor.Lemon); - _MyToolTip.MinimumTooltipSize = new Size(0, 24); - _MyToolTip.TooltipDuration = 3; - _MyToolTip.SetSuperTooltip(MyStepRTB, tpi); - } - - public RTBItem ActiveParent - { - get { return _MyParentRTBItem!=null ? _MyParentRTBItem : _MyPreviousRTBItem.ActiveParent; } - } - void MyContent_Changed(object sender) - { - // Update the text to reflect the content change - MyStepRTB.MyItemInfo.RefreshItemAnnotations(); - MyStepRTB.MyItemInfo=MyStepRTB.MyItemInfo; // Reset Text - SetExpandAndExpander(MyItemInfo); - // TODO: Need code to update tabs ? not sure what this is - maybe for - // transitions? - } + { get { return lblTab; } } /// /// Used to connect the RichTextBox with the menus and toolbars /// - public StepRTB MyStepRTB + public override StepRTB MyStepRTB { get { return _MyStepRTB; } } - /// - /// Return the Parent RTBItem - /// - private RTBItem UpOneRTBItem - { - get - { - RTBItem tmp = this; - while (tmp != null && tmp.MyParentRTBItem == null) tmp = tmp.MyPreviousRTBItem; - if (tmp != null) return tmp.MyParentRTBItem; - return null; - } - } - /// - /// Sets the parent and postions the item with respect to the parent - /// - public RTBItem MyParentRTBItem - { - get { return _MyParentRTBItem; } - set - { - LastMethodsPush("set_MyParentRTBItem"); - _MyParentRTBItem = value; - if (_MyParentRTBItem != null) - { - switch (_MyChildRelation) - { - case ChildRelation.None: // Same as after - case ChildRelation.After: // Procedures, sections, substeps, and tables/figures - // The size depends upon the parent type - int iType = (int)_MyParentRTBItem._Type; - - switch (iType / 10000) - { - case 0: // Procedure - ItemLocation = new Point(_MyParentRTBItem.ItemLocation.X + 20, _MyParentRTBItem.Bottom); - ItemWidth = _MyStepPanel.ToDisplay(_MyStepSectionLayoutData.ColT) + _MyStepPanel.ToDisplay(_MyStepSectionLayoutData.WidT); - break; - case 1: // Section - if(this == TopMostRTBItem) - ItemLocation = new Point(_MyParentRTBItem.ItemLocation.X + 20, _MyParentRTBItem.Bottom); - else - TopMostRTBItem.ItemLocation = new Point(TopMostRTBItem.ItemLocation.X, _MyParentRTBItem.Bottom); - int borderWidth = _MyStepRTB.Width - _MyStepRTB.ClientRectangle.Width; - //TextWidth = _WidthAdjust + borderWidth + _MyStepPanel.ToDisplay(_MyStepSectionLayoutData.WidSTableEdit, Convert.ToInt32(_MyStepSectionLayoutData.PMode) - 1); - TextWidth = _WidthAdjust + borderWidth + _MyStepPanel.ToDisplay(_MyStepSectionLayoutData.WidSTableEdit, MyItemInfo.ColumnMode); - break; - case 2: // Step - // if Table then determine width and location based upon it's parent's location - if (_MyStepData.Type == "Table" || _MyStepData.ParentType == "Table") - { - _MyStepRTB.Font = _MyStepData.Font.WindowsFont; - ItemWidth = (int)TableWidth(_MyStepRTB.Font, _MyItemInfo.MyContent.Text, true); - ItemLocation = new Point(50, _MyParentRTBItem.Bottom); - ItemLocation = TableLocation(_MyParentRTBItem, _MyStepSectionLayoutData, ItemWidth); - } - else - { - ItemLocation = new Point(_MyParentRTBItem.TextLeft, _MyParentRTBItem.Bottom); - ItemWidth = _MyParentRTBItem.TextWidth; - } - break; - } - break; - case ChildRelation.RNO: - // this is set so that TextWidth command below will be correct. TextWidth uses - // the tab start & tab width to calculate the overall width. - TabFormat = ""; // this is set so that TextWidth command below will be correct - _IgnoreResize = true; - TextWidth = _MyParentRTBItem.TextWidth; - _IgnoreResize = false; - if (RNOLevel <= _MyItemInfo.ColumnMode) - { - //int colR = _MyStepPanel.ToDisplay(_MyStepSectionLayoutData.ColRTable, Convert.ToInt32(_MyStepSectionLayoutData.PMode) - 1); - int colR = _MyStepPanel.ToDisplay(_MyStepSectionLayoutData.ColRTable, MyItemInfo.ColumnMode); - if (colR - _MyParentRTBItem.Width < 0) colR = _MyParentRTBItem.Width + 0; - _MyStepPanel.ItemMoving++; - //Left = _MyParentRTBItem.ItemLeft + RNOLevel * colR; - //ItemLocation = new Point(_MyParentRTBItem.ItemLeft + RNOLevel * colR, _MyParentRTBItem.Top); - LastMethodsPush(string.Format("set_MyParentRTBItem RNO Right {0}", MyID)); - ItemLocation = new Point(_MyParentRTBItem.ItemLeft + RNOLevel * colR, _MyParentRTBItem.Top); - int top = _MyParentRTBItem.FindTop(_MyParentRTBItem.Top); - if (top != _MyParentRTBItem.Top) - { - _MyParentRTBItem.LastMethodsPush(string.Format("set_MyParentRTBItem RNO Right {0}", MyID)); - _MyParentRTBItem.Top = top; - _MyParentRTBItem.LastMethodsPop(); - Top = top; - } - LastMethodsPop(); - _MyStepPanel.ItemMoving--; - } - else - { - _MyStepPanel.ItemMoving++; - LastMethodsPush(string.Format("set_MyParentRTBItem RNO Below {0} {1} {2}", MyID, _MyParentRTBItem.BottomMostRTBItem.MyID, _MyParentRTBItem.BottomMostRTBItem.Bottom)); - TextLocation = new Point(_MyParentRTBItem.TextLeft, _MyParentRTBItem.BottomMostRTBItem.Bottom); - LastMethodsPop(); - //TextLocation = new Point(_MyParentRTBItem.TextLeft, FindTop(_MyParentRTBItem.Top)); - _MyStepPanel.ItemMoving--; - } - // Same size as the Parent - break; - case ChildRelation.Before: // Cautions and Notes - //if(_WatchThis > 0 && MyID > 2111) - // Console.WriteLine("Setting MyParent: \r\n\tParent {0},{1} \r\n\tTopMostItem {2},{3} \r\n\tNext {4}, {5}", _MyParentRTBItem.MyID, _MyParentRTBItem - // ,_MyParentRTBItem.TopMostRTBItem.MyID,_MyParentRTBItem.TopMostRTBItem - // , _MyNextRTBItem == null ? 0 : _MyNextRTBItem.MyID, _MyNextRTBItem == null ? "None" : _MyNextRTBItem.ToString()); - - //Location = new Point(_MyParentRTBItem.Left + 20, max(_MyParentRTBItem.Top, (_MyNextRTBItem == null ? 0 : _MyNextRTBItem.Top )) ?? 0); - _IgnoreResize = true; - Width = _MyStepPanel.ToDisplay(_MyStepSectionLayoutData.WidT); - _IgnoreResize = false; - _MyStepPanel.ItemMoving++; - //Location = new Point(_MyParentRTBItem.Left + 20, FindTop(_MyParentRTBItem.Top)); - int myTop = MyNextRTBItem == null ? _MyParentRTBItem.Top : MyNextRTBItem.Top; - Location = new Point(_MyParentRTBItem.Left + 20, FindTop(myTop)); - _MyStepPanel.ItemMoving--; - //_MyParentRTBItem.Top = Bottom; - // Could be a Caution or Note - Need to get WidT - break; - } - } - LastMethodsPop(); - } - } - private Stack _LastMethods= new Stack(); - //private string _LastMethod = ""; - private void LastMethodsPush(string str) - { - _MyStepPanel._LastAdjust = str; - _LastMethods.Push(str); - } - private string LastMethodsPop() - { - //_MyStepPanel._LastAdjust = ""; - return _LastMethods.Pop(); - } - private bool LastMethodsEmpty - { - get { return _LastMethods.Count == 0; } - } - /// - /// This should find the item that precedes the current item vertically - /// and then return the Bottom of that item. - /// - /// - private int FindTop(int bottom) - { - int lastBottomPrev = bottom; // This is necessary if the value of bottom can be negative. - if (_MyPreviousRTBItem != null) - lastBottomPrev = _MyPreviousRTBItem.BottomMostRTBItem.Bottom; - int? bottomRNO = BottomOfParentRNO(); - if (lastBottomPrev > bottom) bottom = (int)(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; - return (int) max(bottomRNO, bottom); - } + public override int TableWidth { get { return (int)GetTableWidth(_MyStepRTB.Font, MyItemInfo.MyContent.Text, true); } } + /// /// The left edge of the Tab /// - public int ItemLeft + public override int ItemLeft { get { return Left + lblTab.Left; } set { Left = value - lblTab.Left; } } /// - /// The Top of the RTBItem - /// - public int ItemTop - { - get { return Top; } - set - { - _MyStepPanel.ItemMoving++; - Top = value; - _MyStepPanel.ItemMoving--; - } - } - /// /// The Location of the Tab /// - public Point ItemLocation + public override Point ItemLocation { get { return new Point(Location.X + lblTab.Left, Location.Y); } set { Location = new Point(value.X - lblTab.Left, value.Y); } } - private int _RTBMargin = 3; - /// - /// Margin between the RTBItem and the StepRTB. Appears on the Right. - /// Will allow space to draw a Change Bar on the right side of the RTBItem. - /// - public int RTBMargin - { - get { return _RTBMargin; } - set { _RTBMargin = value; } - } /// /// Width of the Tab and RTB /// - public int ItemWidth + public override int ItemWidth { get { return Width - lblTab.Left; } set @@ -402,7 +66,7 @@ namespace Volian.Controls.Library /// /// Width of the RichTextBox /// - public int TextWidth + public override int ContentWidth { get { return _MyStepRTB.Width; } set @@ -410,10 +74,11 @@ namespace Volian.Controls.Library Width = value + lblTab.Left + lblTab.Width; } } + public override int BorderWidth { get {return (_MyStepRTB.Width - _MyStepRTB.ClientRectangle.Width);} } /// /// Location of the RichTextBox /// - public Point TextLocation + public override Point ContentLocation { get { return new Point(Location.X + _MyStepRTB.Left, Location.Y); } set { Location = new Point(value.X - _MyStepRTB.Left, value.Y); } @@ -421,499 +86,223 @@ namespace Volian.Controls.Library /// /// Left edge of the RichTextBox /// - public int TextLeft + public override int ContentLeft { get { return Left + _MyStepRTB.Left; } } /// - /// Tab Format used for outputing the Tab - /// - private string _TabFormat; - public string TabFormat - { - get - { - if (_TabFormat == null) TabFormat = null; // execute 'set' code. - return _TabFormat; - } - set - { - if (_MyItemInfo != null) - { - ItemInfo.ResetTabString(MyID); - string tabString = _MyItemInfo.MyTab.CleanText; - lblTab.Text = tabString; - lblTab.Width = tabString.Length * 8 * MyStepPanel.DPI / 96;// Adjust width for DPI - Invalidate(); - _MyStepRTB.Left = lblTab.Left + lblTab.Width;// +2; - _MyStepRTB.Width = Width - _MyStepRTB.Left - RTBMargin; - _TabFormat = value; // tabString; - } - } - } - /// - /// This is the "number" of the item (1, 2, 3 etc.) for Substeps - /// - public int Ordinal - { - get - { - int count = 1; - for (RTBItem tmp = this; tmp.MyPreviousRTBItem != null; tmp = tmp.MyPreviousRTBItem) count++; - return count; - } - } - // hardcode to right for HLP. The change bar location from the format will need to be used to set this. - private E_ChangeBarPosition _ChangeBarPosition = E_ChangeBarPosition.Right; - public E_ChangeBarPosition ChangeBarPosition - { - get { return _ChangeBarPosition; } - set { _ChangeBarPosition = value; } - } - /// - /// Sets the previous item and adjusts locations - /// - public RTBItem MyPreviousRTBItem - { - get { return _MyPreviousRTBItem; } - set - { - LastMethodsPush("set_MyPreviousRTBItem"); - _MyPreviousRTBItem = value; - if (_MyPreviousRTBItem != null) - { - _IgnoreResize=true; - if (_MyStepData != null && (_MyStepData.Type.ToLower().Contains("table") || _MyStepData.ParentType.ToLower().Contains("table"))) - { - ItemWidth = (int)TableWidth(_MyStepRTB.Font, _MyItemInfo.MyContent.Text, true); - Location = new Point(_MyPreviousRTBItem.Left, FindTop(_MyPreviousRTBItem.BottomMostRTBItem.Bottom)); - } - else if (value.MyItemInfo.IsTablePart) - { - ItemLocation = new Point(value.MyParentRTBItem.TextLeft, value.MyParentRTBItem.Bottom); - ItemWidth = value.MyParentRTBItem.TextWidth; - } - else - { - Width = MyPreviousRTBItem.Width; - if (TopMostRTBItem == this) - Location = new Point(_MyPreviousRTBItem.Left, FindTop(_MyPreviousRTBItem.BottomMostRTBItem.Bottom)); - else - TopMostRTBItem.Location = new Point(TopMostRTBItem.Left, FindTop(_MyPreviousRTBItem.BottomMostRTBItem.Bottom)); - } - _IgnoreResize=false; - //ShowMe(""); - //if (MyID > _StartingID) - // Console.WriteLine("{0}-->Setting MyPreviousRTBItem {1},{2},{3},{4},{5},{6},{7}", WatchThisIndent, MyID, this - // , _MyPreviousRTBItem - // ,Top - // , _MyPreviousRTBItem.BottomMostRTBItem.Bottom - // , FindTop(_MyPreviousRTBItem.BottomMostRTBItem.Bottom) - // , _MyPreviousRTBItem.Bottom); - //Location = new Point(_MyPreviousRTBItem.Left, _MyPreviousRTBItem.BottomMostRTBItem.Bottom); - switch (_MyChildRelation) - { - case ChildRelation.None: - break; - case ChildRelation.After: - break; - case ChildRelation.RNO: - break; - case ChildRelation.Before: - //_MyStepPanel.ItemMoving++; - //UpOneRTBItem.Top = BottomMostRTBItem.Bottom; - //_MyStepPanel.ItemMoving--; - break; - } - if (_MyPreviousRTBItem.MyNextRTBItem != this) _MyPreviousRTBItem.MyNextRTBItem = this; - } - LastMethodsPop(); - } - } - /// - /// Sets the next item and adjusts the location, - /// This also sets the previous for the "next" item - /// which adjusts other locations. - /// - public RTBItem MyNextRTBItem - { - get { return _MyNextRTBItem; } - set - { - _MyNextRTBItem = value; - if (_MyNextRTBItem != null) - { - if (_MyNextRTBItem.MyPreviousRTBItem != this) - { - _MyNextRTBItem.MyPreviousRTBItem = this; - MyNextRTBItem.Location = new Point(Left, Bottom); - } - } - } - } - /// - /// returns the TopMostChild - /// - public RTBItem TopMostRTBItem - { - get - { - if (Expanded && _MyBeforeRTBItems != null) return _MyBeforeRTBItems[0].TopMostRTBItem; - return this; - } - } - /// - /// Returns the bottom location (Top + Height) - /// - public new int Bottom - { - get - { - return Top + (Hidden ? 0 : Height); - } - } - private bool _Hidden = false; - public bool Hidden - { - get { return _Hidden; } - set { _Hidden = value; Visible = !value; } - } - /// - /// Bottom most child - /// - public RTBItem BottomMostRTBItem - { - get - { - RTBItem tmpr = null; // BottomMost RNO - //int rnoOffset = 0; - if ((MyExpandingStatus != ExpandingStatus.No || Expanded) && _MyRNORTBItems != null) - { - //rnoOffset = this.Top - _MyRNORTBItems[0].Top; - tmpr = _MyRNORTBItems[_MyRNORTBItems.Count - 1].BottomMostRTBItem; - } - RTBItem tmpa = this; // BottomMost After - if ((MyExpandingStatus != ExpandingStatus.No || Expanded) & _MyAfterRTBItems != null) - tmpa = _MyAfterRTBItems[_MyAfterRTBItems.Count - 1].BottomMostRTBItem; - // return the bottom most of the two results - if (tmpr == null) - return tmpa; - //if (rnoOffset > 0) - //Console.WriteLine("RNO Bottom Offset {0}", rnoOffset); - //if (tmpa.Bottom >= (tmpr.Bottom + rnoOffset)) - if (tmpa.Bottom >= (tmpr.Bottom)) - return tmpa; - return tmpr; - } - } - /// - /// Bottom most child excluding RNOs - /// - public RTBItem BottomMostRTBItemNoRNOs - { - get - { - RTBItem tmpa = this; // BottomMost After - if ((MyExpandingStatus != ExpandingStatus.No || Expanded) & _MyAfterRTBItems != null) - tmpa = _MyAfterRTBItems[_MyAfterRTBItems.Count - 1].BottomMostRTBItem; - // return the bottom most - return tmpa; - } - } - /// - /// First sibling - /// - private RTBItem FirstSiblingRTBItem - { - get - { - RTBItem tmp = this; - while (tmp.MyPreviousRTBItem != null) - tmp = tmp.MyPreviousRTBItem; - return tmp; - } - } - /// - /// Last sibling - /// - private RTBItem LastSiblingRTBItem - { - get - { - RTBItem tmp = this; - while (tmp.MyNextRTBItem != null) - tmp = tmp.MyNextRTBItem; - return tmp; - } - } - /// /// Returns the status of the vlnExpander unless it is in the process of expanding or collapsing /// If it is colapsing it returns false /// If it is expanding it returns true /// - public bool Expanded + public override bool Expanded { - get - { - return !_Colapsing && (MyExpandingStatus != ExpandingStatus.No || _MyvlnExpander.Expanded); + get + { + return !Colapsing && (MyExpandingStatus != ExpandingStatus.No || _MyvlnExpander.Expanded); } - set - { - _MyvlnExpander.Expanded = value; - } - } - /// - /// Sets or Gets expanding status - /// - public ExpandingStatus MyExpandingStatus - { - get { return _MyExpandingStatus; } - set { _MyExpandingStatus = value; } - } - /// - /// Gets or sets colapsing - /// - public bool Colapsing - { - get { return _Colapsing; } - set { _Colapsing = value; } - } - /// - /// Gets or Sets the ability to expand - /// - public bool CanExpand - { - get { return _MyvlnExpander.Visible; } - set { _MyvlnExpander.Visible = value; } - } - /// - /// Gets the text from the content - /// - public string MyText - { - get { return _MyItemInfo == null ? null : _MyItemInfo.MyContent.Text; } - } - /// - /// Gets the ItemID from the ItemInfo - /// - public int MyID - { - get { return _MyItemInfo == null ? 0 : _MyItemInfo.ItemID; } - } - /// - /// Tracks when a RTBItem is moving - /// - public bool Moving - { - get { return _Moving; } - set { _Moving = value; } - } - /// - /// The RNO (Contingency) Level - /// - public int RNOLevel - { - get { return _RNOLevel; } - set { _RNOLevel = value; } - } - /// - /// Sequential Level - Only counts levels of Sequential substeps - /// - public int SeqLevel - { - get { return _SeqLevel; } - set { _SeqLevel = value; } - } - // TODO: This should be changed to get the Circle format from the data - /// - /// Show a circle or not - /// - public bool Circle - { - get { return _Circle; } - set { _Circle = value; } - } - // TODO: This should be changed to get the Checkoff status from the data - /// - /// Has a check-off or not - /// - public bool CheckOff - { - get { return _CheckOff; } - set { _CheckOff = value; } - } - // TODO: This should be changed to get the ChangeBar status from the data - /// - /// Has a changebar or not - /// - public bool ChangeBar - { - get { return _ChangeBar; } set { - _ChangeBar = value; - this.Invalidate(); + _MyvlnExpander.Expanded = value; } } - #endregion // Properties + + #endregion + #region IEditItem + override public void AdjustTableWidthAndLocation() + { + _MyStepRTB.Font = MyStepData.Font.WindowsFont; + ItemWidth = (int)GetTableWidth(_MyStepRTB.Font, MyItemInfo.MyContent.Text, true); + ItemLocation = new Point(50, _MyParentEditItem.Bottom); + ItemLocation = TableLocation(_MyParentEditItem, MyStepSectionLayoutData, ItemWidth); + } + + override public void SetToolTip(string tip) + { + DevComponents.DotNetBar.SuperTooltipInfo tpi = new DevComponents.DotNetBar.SuperTooltipInfo("", "", tip, null, null, DevComponents.DotNetBar.eTooltipColor.Lemon); + _MyToolTip.MinimumTooltipSize = new Size(0, 24); + _MyToolTip.TooltipDuration = 3; + _MyToolTip.SetSuperTooltip(MyStepRTB, tpi); + } + public override void RefreshContent() + { + MyStepRTB.RefreshDisplay(); + IdentifyMe(false); + SetExpandAndExpander(MyItemInfo); + } + public override void RefreshOrdinal() + { + TabFormat = null; // Reset Tab + } + /// + /// Tab Format used for outputing the Tab + /// + + public override string TabFormat + { + get + { + if (_TabFormat == null) TabFormat = null; // execute 'set' code. + return _TabFormat; + } + set + { + if (MyItemInfo != null) + { + ItemInfo.ResetTabString(MyID); + string tabString = MyItemInfo.MyTab.CleanText; + lblTab.Text = tabString; + lblTab.Width = tabString.Length * 8 * MyStepPanel.DPI / 96;// Adjust width for DPI + Invalidate(); + _MyStepRTB.Left = lblTab.Left + lblTab.Width;// +2; + _MyStepRTB.Width = Width - _MyStepRTB.Left - RTBMargin; + _TabFormat = value; // tabString; + } + } + } + + #endregion + #region Properties + private int _RTBMargin = 3; + /// + /// Margin between the EditItem and the StepRTB. Appears on the Right. + /// Will allow space to draw a Change Bar on the right side of the EditItem. + /// + public int RTBMargin + { + get { return _RTBMargin; } + set { _RTBMargin = value; } + } + #endregion #region Constructors - public RTBItem(ItemInfo itemInfo, StepPanel myStepPanel, RTBItem myParentRTBItem, ChildRelation myChildRelation, bool expand) + public RTBItem(ItemInfo itemInfo, StepPanel myStepPanel, EditItem myParentEditItem, ChildRelation myChildRelation, bool expand) { //// TIMING: DisplayItem.TimeIt("CSLARTB Top"); InitializeComponent();// TODO: Performance 25% - SetupRTBItem(itemInfo, myStepPanel, myParentRTBItem, myChildRelation, expand, null); + SetupEditItem(itemInfo, myStepPanel, myParentEditItem, myChildRelation, expand, null); } - public RTBItem(ItemInfo itemInfo, StepPanel myStepPanel, RTBItem myParentRTBItem, ChildRelation myChildRelation, bool expand, RTBItem nextRTBItem) + public RTBItem(ItemInfo itemInfo, StepPanel myStepPanel, EditItem myParentEditItem, ChildRelation myChildRelation, bool expand, EditItem nextEditItem) { //// TIMING: DisplayItem.TimeIt("CSLARTB Top"); InitializeComponent();// TODO: Performance 25% - SetupRTBItem(itemInfo, myStepPanel, myParentRTBItem, myChildRelation, expand, nextRTBItem); - } - private void SetupRTBItem(ItemInfo itemInfo, StepPanel myStepPanel, RTBItem myParentRTBItem, ChildRelation myChildRelation, bool expand, RTBItem nextRTBItem) - { - //if (itemInfo.ItemID == 225) _MyStepRTB.Resize += new EventHandler(_MyStepRTB_Resize); - _MyStepRTB.MyRTBItem = this; - //// TIMING: DisplayItem.TimeIt("CSLARTB InitComp"); - BackColor = myStepPanel.PanelColor; - //_MyStepRTB.BackColor = myStepPanel.InactiveColor; - // TODO: Adjust top based upon format - // TODO: Remove Label and just output ident on the paint event - lblTab.Left = 20; - SetupHeader(itemInfo); - this.Paint += new PaintEventHandler(RTBItem_Paint); - this.BackColorChanged += new EventHandler(RTBItem_BackColorChanged); - if (itemInfo != null) - { - _Type = (int)itemInfo.MyContent.Type; - switch (_Type / 10000) - { - case 0: // Procedure - _MyStepRTB.Font = myStepPanel.ProcFont;// lblTab.Font = myStepPanel.ProcFont; - lblTab.Font = itemInfo.MyTab.MyFont.WindowsFont; - break; - case 1: // Section - _MyStepRTB.Font = myStepPanel.SectFont;// lblTab.Font = myStepPanel.SectFont; - lblTab.Font = itemInfo.MyTab.MyFont.WindowsFont; - break; - case 2: // Steps - _MyStepRTB.Font = myStepPanel.StepFont;//lblTab.Font = myStepPanel.StepFont; - lblTab.Font = itemInfo.MyTab.MyFont.WindowsFont; - _MyStepData = itemInfo.ActiveFormat.PlantFormat.FormatData.StepDataList[_Type % 10000]; - break; - } - //this.Move += new EventHandler(DisplayItem_Move); - } - else - { - if (myStepPanel.MyFont != null) _MyStepRTB.Font = lblTab.Font = myStepPanel.MyFont; - } - if (expand) _MyvlnExpander.ShowExpanded(); - _MyStepPanel = myStepPanel; - if (itemInfo != null) myStepPanel._LookupRTBItems.Add(itemInfo.ItemID, this); - _MyChildRelation = myChildRelation; - if (myParentRTBItem != null) RNOLevel = myParentRTBItem.RNOLevel; - if (itemInfo != null) - { - //// TIMING: DisplayItem.TimeIt("CSLARTB before _Layout"); - _MyStepSectionLayoutData = itemInfo.ActiveFormat.MyStepSectionLayoutData; - //// TIMING: DisplayItem.TimeIt("CSLARTB _Layout"); - if (myParentRTBItem != null) - SeqLevel = myParentRTBItem.SeqLevel + ((myChildRelation == ChildRelation.After || myChildRelation == ChildRelation.Before) && itemInfo.IsSequential ? 1 : 0); - //// TIMING: DisplayItem.TimeIt("CSLARTB seqLevel"); - MyItemInfo = itemInfo; - } - //// TIMING: DisplayItem.TimeIt("CSLARTB MyItem"); - myStepPanel.Controls.Add(this); - - switch (myChildRelation) - { - case ChildRelation.After: - AddItem(myParentRTBItem, ref myParentRTBItem._MyAfterRTBItems,nextRTBItem); - break; - case ChildRelation.Before: - AddItem(myParentRTBItem, ref myParentRTBItem._MyBeforeRTBItems, nextRTBItem); - break; - case ChildRelation.RNO: - RNOLevel = myParentRTBItem.RNOLevel + 1; - AddItem(myParentRTBItem, ref myParentRTBItem._MyRNORTBItems, nextRTBItem); - break; - case ChildRelation.None: - break; - } - if (itemInfo != null) - { - if (myChildRelation == ChildRelation.None) - { - if (_Type == 0 && _MyStepSectionLayoutData != null) - { - LastMethodsPush(string.Format("SetupRTBItem {0}", MyID)); - Width = _MyStepPanel.ToDisplay(_MyStepSectionLayoutData.WidT); - } - } - } - //// TIMING: DisplayItem.TimeIt("CSLARTB Parent"); - SetText(); - //// TIMING: DisplayItem.TimeIt("CSLARTB SetText"); - if (itemInfo != null) - { - Name = string.Format("Item-{0}", itemInfo.ItemID); - SetExpandAndExpander(itemInfo); - if (expand && (itemInfo.MyContent.ContentPartCount != 0)) // If it should expand and it can expand - Expand(true); - else - if (myParentRTBItem == null)// If it is the top node - if (_Type >= 20000) // and it is a step - fully expand - Expand(true); - else // otherwise only expand one level - Expand(false); - } - //// TIMING: DisplayItem.TimeIt("CSLARTB before Controls Add"); - //myStepPanel.Controls.Add(this); - int top = FindTop(0); - if (Top < top) - { - LastMethodsPush("SetupRTBItem"); - _MyStepPanel.ItemMoving++; - Top = top; - _MyStepPanel.ItemMoving--; - LastMethodsPop(); - } - _Loading = false; - //// TIMING: DisplayItem.TimeIt("CSLARTB Controls Add"); - } - private void SetExpandAndExpander(ItemInfo itemInfo) - { - // Don't allow substeps to expand - switch (_Type / 10000) - { - case 1: // Section can expand - CanExpand = true; - // If a word document set the expander to attachment - _MyvlnExpander.Attachment = !(itemInfo.IsStepSection); - //OLD: _MyvlnExpander.Attachment = (itemInfo.MyContent.ContentPartCount == 0); - break; - case 2: // High level steps with children can expand - CanExpand = itemInfo.IsHigh && itemInfo.HasChildren; // TemporaryFormat.IsHigh(item); ; - break; - default://Procedures cannot expand, because they automatically expand - CanExpand = false; - break; - } - } - private void SetupHeader(ItemInfo itemInfo) - { - lblTab.Top = 3 + ((itemInfo.HasHeader) ? 23 : 0); - _MyStepRTB.Top = lblTab.Top; // 3 + ((itemInfo.HasHeader) ? 23 : 0); - //lblTab.Move += new EventHandler(lblTab_Move); - if (itemInfo.HasHeader) - SetupHeaderFooter(ref lblHeader, "Header", itemInfo.MyHeader); - else - { - // remove header from screen if it exists: - this.Controls.Remove(lblHeader); - lblHeader = null; - } + SetupEditItem(itemInfo, myStepPanel, myParentEditItem, myChildRelation, expand, nextEditItem); } + //private void SetupRTBItem(ItemInfo itemInfo, StepPanel myStepPanel, EditItem myParentEditItem, ChildRelation myChildRelation, bool expand, EditItem nextEditItem) + //{ + // //if (itemInfo.ItemID == 225) _MyStepRTB.Resize += new EventHandler(_MyStepRTB_Resize); + // //_MyStepRTB.MyRTBItem = this; + // //// TIMING: DisplayItem.TimeIt("CSLARTB InitComp"); + // BackColor = myStepPanel.PanelColor; + // //_MyStepRTB.BackColor = myStepPanel.InactiveColor; + // // TODO: Adjust top based upon format + // // TODO: Remove Label and just output ident on the paint event + // lblTab.Left = 20; + // SetupHeader(itemInfo); + // this.Paint += new PaintEventHandler(RTBItem_Paint); + // this.BackColorChanged += new EventHandler(RTBItem_BackColorChanged); + // if (itemInfo != null) + // { + // ContentType = (int)itemInfo.MyContent.Type; + // switch (ContentType / 10000) + // { + // case 0: // Procedure + // _MyStepRTB.Font = myStepPanel.ProcFont;// lblTab.Font = myStepPanel.ProcFont; + // lblTab.Font = itemInfo.MyTab.MyFont.WindowsFont; + // break; + // case 1: // Section + // _MyStepRTB.Font = myStepPanel.SectFont;// lblTab.Font = myStepPanel.SectFont; + // lblTab.Font = itemInfo.MyTab.MyFont.WindowsFont; + // break; + // case 2: // Steps + // _MyStepRTB.Font = myStepPanel.StepFont;//lblTab.Font = myStepPanel.StepFont; + // lblTab.Font = itemInfo.MyTab.MyFont.WindowsFont; + // MyStepData = itemInfo.ActiveFormat.PlantFormat.FormatData.StepDataList[ContentType % 10000]; + // break; + // } + // //this.Move += new EventHandler(DisplayItem_Move); + // } + // else + // { + // if (myStepPanel.MyFont != null) _MyStepRTB.Font = lblTab.Font = myStepPanel.MyFont; + // } + // if (expand) _MyvlnExpander.ShowExpanded(); + // MyStepPanel = myStepPanel; + // if (itemInfo != null) myStepPanel._LookupEditItems.Add(itemInfo.ItemID, this); + // _MyChildRelation = myChildRelation; + // if (myParentEditItem != null) RNOLevel = myParentEditItem.RNOLevel; + // if (itemInfo != null) + // { + // //// TIMING: DisplayItem.TimeIt("CSLARTB before _Layout"); + // MyStepSectionLayoutData = itemInfo.ActiveFormat.MyStepSectionLayoutData; + // //// TIMING: DisplayItem.TimeIt("CSLARTB _Layout"); + // if (myParentEditItem != null) + // SeqLevel = myParentEditItem.SeqLevel + ((myChildRelation == ChildRelation.After || myChildRelation == ChildRelation.Before) && itemInfo.IsSequential ? 1 : 0); + // //// TIMING: DisplayItem.TimeIt("CSLARTB seqLevel"); + // MyItemInfo = itemInfo; + // MyItemInfo.MyConfig.PropertyChanged += new PropertyChangedEventHandler(MyConfig_PropertyChanged); + // } + // //// TIMING: DisplayItem.TimeIt("CSLARTB MyItem"); + // myStepPanel.Controls.Add(this); + + // switch (myChildRelation) + // { + // case ChildRelation.After: + // AddItem(myParentEditItem, ref myParentEditItem._MyAfterEditItems, nextEditItem); + // break; + // case ChildRelation.Before: + // AddItem(myParentEditItem, ref myParentEditItem._MyBeforeEditItems, nextEditItem); + // break; + // case ChildRelation.RNO: + // RNOLevel = myParentEditItem.RNOLevel + 1; + // AddItem(myParentEditItem, ref myParentEditItem._MyRNOEditItems, nextEditItem); + // break; + // case ChildRelation.None: + // break; + // } + // if (itemInfo != null) + // { + // if (myChildRelation == ChildRelation.None) + // { + // if (ContentType == 0 && MyStepSectionLayoutData != null) + // { + // LastMethodsPush(string.Format("SetupRTBItem {0}", MyID)); + // Width = MyStepPanel.ToDisplay(MyStepSectionLayoutData.WidT); + // } + // } + // } + // //// TIMING: DisplayItem.TimeIt("CSLARTB Parent"); + // SetText(); + // //// TIMING: DisplayItem.TimeIt("CSLARTB SetText"); + // if (itemInfo != null) + // { + // Name = string.Format("Item-{0}", itemInfo.ItemID); + // SetExpandAndExpander(itemInfo); + // if (expand && (itemInfo.MyContent.ContentPartCount != 0)) // If it should expand and it can expand + // Expand(true); + // else + // if (myParentEditItem == null)// If it is the top node + // if (ContentType >= 20000) // and it is a step - fully expand + // Expand(true); + // else // otherwise only expand one level + // Expand(false); + // } + // //// TIMING: DisplayItem.TimeIt("CSLARTB before Controls Add"); + // //myStepPanel.Controls.Add(this); + // int top = FindTop(0); + // if (Top < top) + // { + // LastMethodsPush("SetupRTBItem"); + // MyStepPanel.ItemMoving++; + // Top = top; + // MyStepPanel.ItemMoving--; + // LastMethodsPop(); + // } + // _Loading = false; + // //// TIMING: DisplayItem.TimeIt("CSLARTB Controls Add"); + //} + + + private void SetupHeader() { SetupHeader(MyItemInfo); @@ -942,649 +331,42 @@ namespace Volian.Controls.Library this.Controls.Add(lbl); } #endregion - #region AddItem - /// - /// Adds an item to a list - /// - /// Parent Container - /// RTBItem List - public void AddItem(RTBItem parentRTBItem, ref List siblingRTBItems, RTBItem nextRTBItem) - { - if (siblingRTBItems == null) // Create a list of siblings - { - siblingRTBItems = new List(); - siblingRTBItems.Add(this); - MyParentRTBItem = parentRTBItem; - } - else // Add to the existing list - { - if (nextRTBItem == null) // Add to the end of the list - { - RTBItem lastChild = LastChild(siblingRTBItems); - siblingRTBItems.Add(this); - MyPreviousRTBItem = lastChild; - } - else // Add to the middle of the list before a particular item - { - RTBItem prevChild = nextRTBItem.MyPreviousRTBItem; - RTBItem parent = nextRTBItem.MyParentRTBItem; - siblingRTBItems.Insert(siblingRTBItems.IndexOf(nextRTBItem), this); - MyStepPanel.ItemMoving++; - _MyNextRTBItem = nextRTBItem; - nextRTBItem._MyPreviousRTBItem = this; - MyPreviousRTBItem = prevChild;// If a previous exists - this will adjust the location and width of the RTBItem - nextRTBItem.MyParentRTBItem = null; - MyParentRTBItem = parent; // If a parent exists - this will adjust the location and width of the RTBItem - //nextRTBItem.MyPreviousRTBItem = this; - MyStepPanel.ItemMoving--; - } - } - if (MyItemInfo.IsCaution || MyItemInfo.IsNote) - { - RTBItem prev = this; - while (prev.MyPreviousRTBItem != null) prev = prev.MyPreviousRTBItem; - prev.SetAllTabs(); - } - else - SetAllTabs(); - } - // clear tabs, clears then all so that next 'get' will calculate new. - public void SetAllTabs() - { - TabFormat = null; // reset TabFormat - SetupHeader(); - if (_MyAfterRTBItems != null) foreach (RTBItem chld in _MyAfterRTBItems) chld.SetAllTabs(); - if (_MyNextRTBItem != null) _MyNextRTBItem.SetAllTabs(); - // Update the RNO tab if it exists - RHM 20100106 - if (_MyRNORTBItems != null) foreach (RTBItem chld in _MyRNORTBItems) chld.SetAllTabs(); - } - /// - /// Add the next item to a list - /// - /// - /// - /// - //public RTBItem AddNext(ItemInfo myItemInfo, bool expand) - //{ - // RTBItem tmp = new RTBItem(myItemInfo, _MyStepPanel, MyParentRTBItem, ChildRelation.None, expand); - // MyNextRTBItem = tmp; - // return tmp; - //} - #endregion - #region RemoveItem - protected void ShowTops(string title) - { - int TopMostY = TopMostRTBItem.Top; - int? TopMostParentY = (MyParentRTBItem == null ? null : (int?)(MyParentRTBItem.TopMostRTBItem.Top)); - int? ParentY = (MyParentRTBItem == null ? null : (int?)(MyParentRTBItem.Top)); - //Console.Write("{0}: TopMostY={1}, TopMostParentY={2}, ParentY = {3}",title, TopMostY, TopMostParentY, ParentY); - Console.Write("{0}{1},{2},{3}", title, TopMostY, TopMostParentY.ToString() ?? "null", ParentY.ToString() ?? "null"); - } - private bool _BeingRemoved = false; - public bool BeingRemoved - { - get { return _BeingRemoved; } - set { _BeingRemoved = value; } - } - public void RemoveItem() - { - BeingRemoved = true; - MyStepPanel.SelectedStepRTB = null; // Unselect the item to be deleted - //ShowTops("\r\n"); - int TopMostYBefore = TopMostRTBItem.Top; - RTBItem newFocus = DeleteItem(); - if (newFocus == null) return; - newFocus.MyStepRTB.Focus(); - Dispose(); - newFocus.SetAllTabs(); - int TopMostYAfter = newFocus.TopMostRTBItem.Top; - if (TopMostYAfter > TopMostYBefore) - newFocus.TopMostRTBItem.Top = TopMostYBefore; - newFocus.AdjustLocation(); - //newFocus.ShowTops(""); - } - public RTBItem DeleteItem() - { - RTBItem newFocus = null; - int? TopMostParentY = (MyParentRTBItem == null ? null : (int?)(MyParentRTBItem.TopMostRTBItem.Top)); - int? ParentY = (MyParentRTBItem == null ? null : (int?)(MyParentRTBItem.Top)); - try - { - Item.DeleteItemAndChildren(MyItemInfo); - } - catch (System.Data.SqlClient.SqlException ex) - { - HandleSqlExceptionOnDelete(ex); - return null; - } - // Remove RTBItems - RemoveFromParentsChildList(); - if (MyNextRTBItem != null) - { - if (MyPreviousRTBItem != null) - { - MyNextRTBItem.MyPreviousRTBItem = MyPreviousRTBItem; - MyPreviousRTBItem = null; - newFocus = MyNextRTBItem; - } - else - { - MyNextRTBItem.MyParentRTBItem = MyParentRTBItem; - MyParentRTBItem = null; - MyNextRTBItem.MyPreviousRTBItem = null; - newFocus = MyNextRTBItem; - } - // Adjust the vertical locations of all of the items below the item deleted - MyNextRTBItem.TopMostRTBItem.AdjustLocation(); - MyNextRTBItem = null; - } - else if (MyPreviousRTBItem != null) - { - MyPreviousRTBItem.MyNextRTBItem = null; - newFocus = MyPreviousRTBItem; - MyPreviousRTBItem = null; - //Console.Write(",\"Previous\","); - } - else - { - newFocus = MyParentRTBItem; - MyParentRTBItem = null; - //Console.Write(",\"Parent\","); - } - return newFocus; - } - - private void HandleSqlExceptionOnDelete(System.Data.SqlClient.SqlException ex) - { - if (ex.Message.Contains("has External Transitions and has no next step")) - { - using (TransitionInfoList exTrans = TransitionInfoList.GetExternalTransitions(MyID)) - { - DialogResult ans = MessageBox.Show("Transitions exist to this step and cannot be adjusted automatically." + - "\r\n\r\nDo you want to be placed on the " + (exTrans.Count > 1 ? "first " : "") + "substep with the problem Transition?" + - "\r\n\r\nSubsteps with Problem Transitions" + - exTrans.Summarize(), - "Cannot Delete This Step", MessageBoxButtons.YesNo, MessageBoxIcon.Question); - if (ans == DialogResult.Yes) - { - MyStepPanel.MyStepTabPanel.MyDisplayTabControl.OpenItem(exTrans[0].MyContent.ContentItems[0]); - - } - else - this.MyStepRTB.Focus(); - } - } - else if (ex.Message.Contains("has External Transitions to it's children")) - { - using (TransitionInfoList exTrans = TransitionInfoList.GetExternalTransitionsToChildren(MyID)) - { - DialogResult ans = MessageBox.Show("Transitions exist to substeps of this step and cannot be adjusted automatically." + - "\r\n\r\nDo you want to be placed on the " + (exTrans.Count > 1 ? "first " : "") + "substep with the problem Transition?" + - "\r\n\r\nSubsteps with Problem Transitions:" + - exTrans.Summarize(), - "Cannot Delete This Step", MessageBoxButtons.YesNo, MessageBoxIcon.Question); - if (ans == DialogResult.Yes) - { - MyStepPanel.MyStepTabPanel.MyDisplayTabControl.OpenItem(exTrans[0].MyContent.ContentItems[0]); - } - } - } - else - MessageBox.Show(ex.Message, "SQL Exception", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); - } - private void RemoveFromParentsChildList() - { - RTBItem top = this; - while (top.MyPreviousRTBItem != null) top = top.MyPreviousRTBItem; - RTBItem parentRTBItem = top.MyParentRTBItem; - if (parentRTBItem == null) return; // No parent, nothing to remove. - if (parentRTBItem.MyAfterRTBItems != null && parentRTBItem.MyAfterRTBItems.Contains(this)) - { - parentRTBItem.MyAfterRTBItems.Remove(this); - if (parentRTBItem.MyAfterRTBItems.Count == 0) - parentRTBItem.MyAfterRTBItems = null; - } - else if (parentRTBItem.MyBeforeRTBItems != null && parentRTBItem.MyBeforeRTBItems.Contains(this)) - { - parentRTBItem.MyBeforeRTBItems.Remove(this); - if(parentRTBItem.MyBeforeRTBItems.Count == 0) - parentRTBItem.MyBeforeRTBItems = null; - } - else if (parentRTBItem.MyRNORTBItems != null && parentRTBItem.MyRNORTBItems.Contains(this)) - { - parentRTBItem.MyRNORTBItems.Remove(this); - if(parentRTBItem.MyRNORTBItems.Count == 0) - parentRTBItem.MyRNORTBItems = null; - } - if (parentRTBItem.MyAfterRTBItems == null && parentRTBItem.MyBeforeRTBItems == null && parentRTBItem.MyRNORTBItems == null) - parentRTBItem.CanExpand = false; - } - //private void ShowSiblings(string title) - //{ - // Console.WriteLine("---{0} {1}---",title,MyID); - // RTBItem top = this; - // while (top.MyPreviousRTBItem != null) top = top.MyPreviousRTBItem; - // do - // { - // Console.WriteLine("{0} RTBItem - {1} {2}", top.MyID == MyID ? "*" : " ", top.MyID, top.MyItemInfo.MyContent.Text); - // top = top.MyNextRTBItem; - // } while (top != null); - //} - #endregion - #region Add Children - /// - /// Add a child before (Notes, Cautions, etc.) - /// - /// - /// - public void AddChildBefore(ItemInfo myItemInfo, bool expand) - { - RTBItem child = new RTBItem(myItemInfo, _MyStepPanel, this, ChildRelation.Before, expand); - } - /// - /// Add a list of children before - /// - /// - /// - public void AddChildBefore(ItemInfoList myItemInfoList, bool expand) - { - if (myItemInfoList != null) - foreach (ItemInfo item in myItemInfoList) - AddChildBefore(item, expand); - } - /// - /// Add an RNO (Contingency) child - /// - /// - /// - public void AddChildRNO(ItemInfo myItemInfo, bool expand) - { - RTBItem child = new RTBItem(myItemInfo, _MyStepPanel, this, ChildRelation.RNO, expand); - } - /// - /// Add a list of RNO (Contingency) children - /// - /// - /// - public void AddChildRNO(ItemInfoList myItemInfoList, bool expand) - { - if (myItemInfoList != null) - foreach (ItemInfo item in myItemInfoList) - AddChildRNO(item, expand); - } - /// - /// Add a child after - /// - /// - /// - public RTBItem AddChildAfter(ItemInfo MyItemInfo, bool expand) - { - RTBItem child = new RTBItem(MyItemInfo, _MyStepPanel, this, ChildRelation.After, expand); - return child; - } - public RTBItem AddChildAfter(ItemInfo MyItemInfo, RTBItem nextRTBItem) - { - RTBItem child = new RTBItem(MyItemInfo, _MyStepPanel, this, ChildRelation.After, true, nextRTBItem); - return child; - } - public RTBItem AddChildBefore(ItemInfo MyItemInfo, RTBItem nextRTBItem) - { - RTBItem child = new RTBItem(MyItemInfo, _MyStepPanel, this, ChildRelation.Before, true, nextRTBItem); - return child; - } - public RTBItem AddChildRNO(ItemInfo MyItemInfo, RTBItem nextRTBItem) - { - RTBItem child = new RTBItem(MyItemInfo, _MyStepPanel, this, ChildRelation.RNO, true, nextRTBItem); - return child; - } - /// - /// Adds a sibling after the current RTBItem - /// - public void AddSiblingAfter() - { - AddSiblingAfter("",true); - } - public void AddSiblingAfter(string text,bool updateStatus) - { - MyStepRTB.SaveText(); - ItemInfo newItemInfo = MyItemInfo.InsertSiblingAfter(text); - DoAddSiblingAfter(newItemInfo, updateStatus); - } - public void AddSiblingAfter(int? type, bool updateStatus) - { - MyStepRTB.SaveText(); - ItemInfo newItemInfo = MyItemInfo.InsertSiblingAfter("","",type); - DoAddSiblingAfter(newItemInfo,updateStatus); - } - private void DoAddSiblingAfter(ItemInfo newItemInfo, bool updateStatus) - { - RTBItem newRTBItem = null; - switch (_MyChildRelation) - { - case ChildRelation.After: - newRTBItem = ActiveParent.AddChildAfter(newItemInfo, MyNextRTBItem); - break; - case ChildRelation.Before: - newRTBItem = ActiveParent.AddChildBefore(newItemInfo, MyNextRTBItem); - break; - case ChildRelation.RNO: - newRTBItem = ActiveParent.AddChildRNO(newItemInfo, MyNextRTBItem); - break; - default: // Need debug - break; - } - //RTBItem newRTBItem = ActiveParent.AddChildAfter(newItemInfo, ); - if(updateStatus) - _MyStepPanel.SelectedStepRTB = newRTBItem.MyStepRTB;//Update Screen - } - private static int _WatchThis = 1; - public void AddSiblingBefore() - { - AddSiblingBefore("",true); - } - public void AddSiblingBefore(string text, bool updateSelection) - { - // Save RTB text before creating a new item because the process of creating - // a new item will save a change to iteminfo excluding text changes. This - // shouldn't be necessary for adding sibling after because the current step - // doesn't get saved during the insert after because of the MyPrevious field - // is only set on an insert before, which is what saves the item without - // any updates from the richtextbox text. - _MyStepRTB.SaveText(); - ItemInfo newItemInfo = MyItemInfo.InsertSiblingBefore(text); - RTBItem newRTBItem=null; - switch (_MyChildRelation) - { - case ChildRelation.After: - newRTBItem = ActiveParent.AddChildAfter(newItemInfo, this); - break; - case ChildRelation.Before: - newRTBItem = ActiveParent.AddChildBefore(newItemInfo, this); - break; - case ChildRelation.RNO: - newRTBItem = ActiveParent.AddChildRNO(newItemInfo, this); - break; - default: // Need debug - break; - } - if(updateSelection) - _MyStepPanel.SelectedStepRTB = newRTBItem.MyStepRTB;//Update Screen - } - public void AddChild(E_FromType fromType, int type) - { - AddChild("",fromType, type); - } - public void AddChild(string text, E_FromType fromType, int type) - { - if (_MyItemInfo.IsHigh || _MyItemInfo.IsSection) - this.CanExpand = true; - this.Expanded = true; - _WatchThis = 1; - ItemInfo newItemInfo = MyItemInfo.InsertChild(fromType, type, text); - // TODO: We need to determine where this will go in the stack of children - RTBItem nextItem = null; - if (newItemInfo.NextItem != null) - nextItem = MyStepPanel.FindItem(newItemInfo.NextItem); - else if (fromType == E_FromType.Table && MyAfterRTBItems != null) - nextItem = MyAfterRTBItems[0]; - // Cautions come before notes, so if this is a Caution and there are Notes, put this first - else if (fromType == E_FromType.Caution && ((ItemInfo)newItemInfo.ActiveParent).Notes != null - && ((ItemInfo)newItemInfo.ActiveParent).Notes.Count > 0) - nextItem = MyStepPanel.FindItem(((ItemInfo)newItemInfo.ActiveParent).Notes[0]); - // TODO: May need similar logic if a Table is being added to a step that has substeps - // else if (fromType == E_FromType.Table && ((ItemInfo)newItemInfo.ActiveParent).Steps != null - //&& ((ItemInfo)newItemInfo.ActiveParent).Steps.Count > 0) - // nextItem = MyStepPanel.FindItem(((ItemInfo)newItemInfo.ActiveParent).Steps[0]); - RTBItem newRTBItem; - switch (fromType) - { - case E_FromType.Caution: - newRTBItem = this.AddChildBefore(newItemInfo, nextItem); - break; - case E_FromType.Note: - newRTBItem = this.AddChildBefore(newItemInfo, nextItem); - break; - case E_FromType.Procedure: - newRTBItem = this.AddChildAfter(newItemInfo, nextItem); - break; - case E_FromType.RNO: - newRTBItem = this.AddChildRNO(newItemInfo, nextItem); - break; - case E_FromType.Section: - newRTBItem = this.AddChildAfter(newItemInfo, nextItem); - break; - case E_FromType.Step: - newRTBItem = this.AddChildAfter(newItemInfo, nextItem); - break; - case E_FromType.Table: - newRTBItem = this.AddChildAfter(newItemInfo, nextItem); - break; - default: - newRTBItem = this.AddChildAfter(newItemInfo, nextItem); - break; - } - _MyStepPanel.SelectedStepRTB = newRTBItem.MyStepRTB;//Update Screen - } - /// - /// Add a list of children after - /// - /// - /// - public RTBItem AddChildAfter(ItemInfoList myItemInfoList, bool expand) - { - RTBItem child = null; - if (myItemInfoList != null) - foreach (ItemInfo item in myItemInfoList) - child = AddChildAfter(item, expand); - return child; - } - #endregion - #region CopyPaste - public void PasteSiblingBefore(int copyStartID) - { - ItemInfo newItemInfo = MyItemInfo.PasteSiblingBefore(copyStartID); - RTBItem newRTBItem = null; - switch (_MyChildRelation) - { - case ChildRelation.After: - newRTBItem = ActiveParent.AddChildAfter(newItemInfo, this); - break; - case ChildRelation.Before: - newRTBItem = ActiveParent.AddChildBefore(newItemInfo, this); - break; - case ChildRelation.RNO: - newRTBItem = ActiveParent.AddChildRNO(newItemInfo, this); - break; - default: // Need debug - break; - } - if (newRTBItem != null) _MyStepPanel.SelectedStepRTB = newRTBItem.MyStepRTB;//Update Screen - _MyStepPanel.MyStepTabPanel.MyDisplayTabControl.OnItemPaste(this, new vlnTreeItemInfoPasteEventArgs(newItemInfo, copyStartID, ItemInfo.EAddpingPart.Before, newItemInfo.MyContent.Type)); - - } - public void PasteSiblingAfter(int copyStartID) - { - ItemInfo newItemInfo = MyItemInfo.PasteSiblingAfter(copyStartID); - RTBItem newRTBItem = null; - switch (_MyChildRelation) - { - case ChildRelation.After: - newRTBItem = ActiveParent.AddChildAfter(newItemInfo, MyNextRTBItem); - break; - case ChildRelation.Before: - newRTBItem = ActiveParent.AddChildBefore(newItemInfo, MyNextRTBItem); - break; - case ChildRelation.RNO: - newRTBItem = ActiveParent.AddChildRNO(newItemInfo, MyNextRTBItem); - break; - default: // Need debug - break; - } - _MyStepPanel.SelectedStepRTB = newRTBItem.MyStepRTB;//Update Screen - _MyStepPanel.MyStepTabPanel.MyDisplayTabControl.OnItemPaste(this, new vlnTreeItemInfoPasteEventArgs(newItemInfo, copyStartID, ItemInfo.EAddpingPart.After, newItemInfo.MyContent.Type)); - - } - public RTBItem PasteReplace(int copyStartID) - { - // To allow a Paste Step into an empty (new) step/substep, we need to add a character to the the Text field - // to simulate replacing an existing step - otherwise we will get null references. - if (MyStepPanel.SelectedStepRTB.Text == "") - MyStepPanel.SelectedStepRTB.Text = " "; - MyStepPanel.SelectedStepRTB = null; // Unselect the item to be deleted - ChildRelation childRelation = _MyChildRelation; - RTBItem newFocus = null; - RTBItem nextRTBItem = MyNextRTBItem; - RTBItem prevRTBItem = MyPreviousRTBItem; - RTBItem parentRTBItem = ActiveParent; - - int TopMostYBefore = TopMostRTBItem.Top; - int? TopMostParentY = (MyParentRTBItem == null ? null : (int?)(MyParentRTBItem.TopMostRTBItem.Top)); - int? ParentY = (MyParentRTBItem == null ? null : (int?)(MyParentRTBItem.Top)); - ItemInfo newItemInfo = null; - try - { - newItemInfo = Item.PasteReplace(MyItemInfo, copyStartID); - } - catch (System.Data.SqlClient.SqlException ex) - { - HandleSqlExceptionOnDelete(ex); - return this; - } - // Remove the RTBItem that was the replaced item. - RemoveFromParentsChildList(); - - if (MyNextRTBItem != null) - { - if (MyPreviousRTBItem != null) - { - MyNextRTBItem.MyPreviousRTBItem = MyPreviousRTBItem; - MyPreviousRTBItem = null; - } - else - { - MyNextRTBItem.MyParentRTBItem = MyParentRTBItem; - MyParentRTBItem = null; - MyNextRTBItem.MyPreviousRTBItem = null; - } - MyNextRTBItem = null; - } - else if (MyPreviousRTBItem != null) - { - MyPreviousRTBItem.MyNextRTBItem = null; - newFocus = MyPreviousRTBItem; - MyPreviousRTBItem = null; - } - else - { - newFocus = MyParentRTBItem; - MyParentRTBItem = null; - } - - // add copied item to ui where the replaced item was. - RTBItem newRTBItem = null; - switch (childRelation) - { - case ChildRelation.After: - newRTBItem = parentRTBItem.AddChildAfter(newItemInfo, nextRTBItem); - break; - case ChildRelation.Before: - newRTBItem = parentRTBItem.AddChildBefore(newItemInfo, nextRTBItem); - break; - case ChildRelation.RNO: - newRTBItem = parentRTBItem.AddChildRNO(newItemInfo, nextRTBItem); - break; - default: // Need debug - break; - } - _MyStepPanel.SelectedStepRTB = newRTBItem.MyStepRTB;//Update Screen - _MyStepPanel.MyStepTabPanel.MyDisplayTabControl.OnItemPaste(this, new vlnTreeItemInfoPasteEventArgs(newItemInfo, copyStartID, ItemInfo.EAddpingPart.Replace, newItemInfo.MyContent.Type)); - return newRTBItem; - } - public void HighlightBackColor() - { - // Highlight all of the rtb's within this RTBItem: - if (MyAfterRTBItems != null) - { - foreach (RTBItem sia in MyAfterRTBItems) - { - sia.MyStepRTB.HighlightBackColor(); - sia.HighlightBackColor(); - } - } - if (MyBeforeRTBItems != null) - { - foreach (RTBItem sib in MyBeforeRTBItems) - { - sib.MyStepRTB.HighlightBackColor(); - sib.HighlightBackColor(); - } - } - if (MyRNORTBItems != null) - { - foreach (RTBItem sir in MyRNORTBItems) - { - sir.MyStepRTB.HighlightBackColor(); - sir.HighlightBackColor(); - } - } - } - public void SetBackColor() - { - // Set (removing highlighting) all of the rtb's within this RTBItem: - if (MyAfterRTBItems != null) - { - foreach (RTBItem sia in MyAfterRTBItems) - { - sia.MyStepRTB.SetBackColor(); - sia.SetBackColor(); - } - } - if (MyBeforeRTBItems != null) - { - foreach (RTBItem sib in MyBeforeRTBItems) - { - sib.MyStepRTB.SetBackColor(); - sib.SetBackColor(); - } - } - if (MyRNORTBItems != null) - { - foreach (RTBItem sir in MyRNORTBItems) - { - sir.MyStepRTB.SetBackColor(); - sir.SetBackColor(); - } - } - } - #endregion - #region Event Handlers - /// - /// If the background changes, change the background of the RichTextBox - /// - /// - /// - void RTBItem_BackColorChanged(object sender, EventArgs e) - { - //_MyStepRTB.BackColor = BackColor; - _MyStepRTB.SetBackColor(); - } + #region EventHandlers /// /// When the RichTextBox height changes, change the height of the control to match /// /// /// - private void _StepRTB_HeightChanged(object sender, EventArgs args) + private void _MyStepRTB_HeightChanged(object sender, EventArgs args) { - if (this.Height != _MyStepRTB.Height+_MyStepRTB.Top+7) // add in 7 to make it look good // + 10) + if (this.Height != _MyStepRTB.Height + _MyStepRTB.Top + 7) // add in 7 to make it look good // + 10) { - //if (MyID == 2131 || MyID == 2132) - // Console.WriteLine("oops!"); LastMethodsPush(string.Format("_StepRTB_HeightChanged {0}", _MyStepRTB.Height)); this.Height = _MyStepRTB.Height + _MyStepRTB.Top + 7; LastMethodsPop(); } } /// + /// When a RichTextBox is entered, the selected StepRTB is set + /// + /// + /// + private void _StepRTB_Enter(object sender, EventArgs e) + { + if (MyStepPanel.DisplayItemChanging) return; + //vlnStackTrace.ShowStack("_StepRTB_Enter {0}",this.MyID); + MyStepPanel.SelectedEditItem = this; + } + /// + /// Pass the AttachmentClick event to the StepPanel control. + /// + /// + /// + private void vlnExp_AttachmentClick(object sender, vlnExpanderEventArgs args) + { + MyStepPanel.OnAttachmentClicked(sender, new StepPanelAttachmentEventArgs(this)); + } + /// /// Handle the colape event /// /// @@ -1593,25 +375,25 @@ namespace Volian.Controls.Library { Cursor tmp = Cursor.Current; Cursor.Current = Cursors.WaitCursor; - int top = TopMostRTBItem.Top;// This does'nt work - this is since the last time it was expanded. - _Colapsing = true; + int top = TopMostEditItem.Top;// This does'nt work - this is since the last time it was expanded. + Colapsing = true; // Hide Children HideChildren(); // Adjust Positions - _ExpandPrefix = Top - top; - _ExpandSuffix = BottomMostRTBItem.Bottom - Bottom; + ExpandPrefix = Top - top; + ExpandSuffix = BottomMostEditItem.Bottom - Bottom; if (Top != top) { LastMethodsPush(string.Format("Colapse {0}", MyID)); - _MyStepPanel.ItemMoving++; + MyStepPanel.ItemMoving++; Top = top; - _MyStepPanel.ItemMoving--; + MyStepPanel.ItemMoving--; LastMethodsPop(); } else AdjustLocation(); - BottomMostRTBItem.AdjustLocation(); - _Colapsing = false; + BottomMostEditItem.AdjustLocation(); + Colapsing = false; Cursor.Current = tmp; } /// @@ -1624,158 +406,10 @@ namespace Volian.Controls.Library Cursor tmp = Cursor.Current; Cursor.Current = Cursors.WaitCursor; if (!_Loading && MyExpandingStatus == ExpandingStatus.No) - Expand(_Type >= 20000); + Expand(ContentType >= 20000); Cursor.Current = tmp; } - bool _IgnoreResize = false; - /// - /// Adjust the locations when the RTBItem is resized - /// - /// - /// - private void RTBItem_Resize(object sender, EventArgs e) - { - if (_MyItemInfo == null) return; - if (_IgnoreResize) return; - AdjustLocation(); - if (lblHeader != null) lblHeader.Width = this.Width; - } - private string WatchThisIndent - { - get { return "".PadLeft(_WatchThis, '\t'); } - } - /// - /// Handles movement of the RTBItems - /// - /// - /// - private void RTBItem_Move(object sender, EventArgs e) - { - int watchThis = _WatchThis; - //if (MyID == _lookForID || MyID == 2111) - //{ - // //vlnStackTrace.ShowStack("{0} Move TO {1} - {2}, BottomMost {3}", MyID, Top, MyPath, BottomMostRTBItem.MyPath); - // Console.WriteLine("{0} Move TO {1} - {2}, BottomMost {3}", MyID, Top, MyPath, BottomMostRTBItem.MyPath); - //} - //if (MyID > _StartingID) - // Console.WriteLine("{0}--------------- {1} Top = {2} Bottom {3}", WatchThisIndent, MyID, Top, Bottom); - if (_MyStepPanel.ItemMoving == 0) - { - //vlnStackTrace.ScrollInStack(); - return; // If 0 - Indicates scrolling which requires no action. - } - //ShowMe("Move"); - if (_MyItemInfo == null) - return; - //if (_WatchThis > 0 && MyID > _StartingID) - //{ - - // Console.WriteLine("{0}Start Move {1},{2}", WatchThisIndent, MyID, this); - // if (MyID == _LookForID) - // Console.WriteLine("{0}---------------", WatchThisIndent,MyID, this); - // _WatchThis++; - //} - if (MyExpandingStatus == ExpandingStatus.Expanding) - { - _WatchThis=watchThis; - return; - } - Moving = true; - RTBItem tmp = (RTBItem)sender; - if (tmp._MyPreviousRTBItem == null && tmp._MyParentRTBItem == null) - { - _WatchThis=watchThis; - return; - } - if (RNOBelow) // Adjust substeps first - { - //Console.WriteLine("RNOBelow"); - AdjustLocation(); - MoveRNO(); - } - else // Adjust RNO First - { - if (RNORight) - { - //Console.WriteLine("RNORight"); - MoveRNO(); - } - AdjustLocation(); - } - Moving = false; - RTBItem btm = BottomMostRTBItem; - if(this != btm) - btm.AdjustLocation(); - //if (_WatchThis > 0 && MyID > _StartingID) - //{ - // Console.WriteLine("{0}Finish Move {1},{2}",WatchThisIndent, MyID, this); - //} - _WatchThis=watchThis; - } - private bool RNOBelow - { - get - { - if (_MyRNORTBItems != null) - { - return _MyRNORTBItems[0].RNOLevel > _MyItemInfo.ColumnMode; - //return _MyRNORTBItems[0].Left == Left; - } - return false; - } - } - private bool RNORight - { - get - { - if (_MyRNORTBItems != null) - { - return _MyRNORTBItems[0].RNOLevel <= _MyItemInfo.ColumnMode; - //return _MyRNORTBItems[0].Left != Left; - } - return false; - } - } - private void MoveRNO() - { - if (_MyRNORTBItems != null) - { - if (_MyRNORTBItems[0].TopMostRTBItem.Top != Top) - { - //if(_MyLog.IsDebugEnabled)_MyLog.DebugFormat("\r\n'Adjust RNO',{0},'Move',{1}", MyID, _RNO[0].MyID); - RTBItem rnoTop = _MyRNORTBItems[0].TopMostRTBItem; - if (rnoTop.RNOLevel <= _MyItemInfo.ColumnMode) - { - //RTBItem tmpBottom = this; - //if (_MyAfterRTBItems != null) tmpBottom = _MyAfterRTBItems[_MyAfterRTBItems.Count - 1].BottomMostRTBItem; - _MyStepPanel.ItemMoving++; - rnoTop.LastMethodsPush(string.Format("RTBItem_Move RNO Right {0}", rnoTop.MyID)); - //rnoTop.Top = tmpBottom.Bottom; - rnoTop.Top = Top; - rnoTop.LastMethodsPop(); - _MyStepPanel.ItemMoving--; - } - else - { - _MyStepPanel.ItemMoving++; - rnoTop.LastMethodsPush(string.Format("RTBItem_Move RNO Below {0} {1} {2}", rnoTop.MyID, BottomMostRTBItemNoRNOs.MyID, BottomMostRTBItemNoRNOs.Bottom)); - rnoTop.Top = BottomMostRTBItemNoRNOs.Bottom; - rnoTop.LastMethodsPop(); - _MyStepPanel.ItemMoving--; - } - } - } - } - /// - /// Handle the LinkGoTO event - /// - /// - /// - private void _StepRTB_LinkGoTo(object sender, StepPanelLinkEventArgs args) - { - _MyLog.DebugFormat("_DisplayRTB_LinkGoTo " + args.LinkInfoText); - _MyStepPanel.OnLinkClicked(sender, args); - } + /// /// Raises an ItemClick event when the user clicks on the Tab /// @@ -1783,68 +417,87 @@ namespace Volian.Controls.Library /// private void lblTab_MouseDown(object sender, MouseEventArgs e) { - _MyStepPanel.OnItemClick(this, new StepPanelEventArgs(this, e)); + MyStepPanel.OnItemClick(this, new StepPanelEventArgs(this, e)); } /// - /// When a RichTextBox is entered, the selected StepRTB is set + /// Handle the LinkGoTO event /// /// - /// - private void _StepRTB_Enter(object sender, EventArgs e) + /// + private void _MyStepRTB_LinkGoTo(object sender, StepPanelLinkEventArgs args) { - if (_MyStepPanel.DisplayItemChanging) return; - //vlnStackTrace.ShowStack("_StepRTB_Enter {0}",this.MyID); - _MyStepPanel.SelectedStepRTB = _MyStepRTB; + _MyLog.DebugFormat("_DisplayRTB_LinkGoTo " + args.LinkInfoText); + MyStepPanel.OnLinkClicked(sender, args); } + /// /// Raise a OnLinkModifyTran event, when the user chooses to Modify a transition /// /// /// - private void _StepRTB_LinkModifyTran(object sender, StepPanelLinkEventArgs args) + private void _MyStepRTB_LinkModifyTran(object sender, StepPanelLinkEventArgs args) { - _MyStepPanel.OnLinkModifyTran(sender, args); + MyStepPanel.OnLinkModifyTran(sender, args); } /// /// Raise a OnLinkModifyRO event, when the user chooses to modify an RO /// /// /// - private void _StepRTB_LinkModifyRO(object sender, StepPanelLinkEventArgs args) + private void _MyStepRTB_LinkModifyRO(object sender, StepPanelLinkEventArgs args) { - _MyStepPanel.OnLinkModifyRO(sender, args); - } - /// - /// Pass the AttachmentClick event to the StepPanel control. - /// - /// - /// - private void vlnExp_AttachmentClick(object sender, vlnExpanderEventArgs args) - { - _MyStepPanel.OnAttachmentClicked(sender, new StepPanelAttachmentEventArgs(this)); + MyStepPanel.OnLinkModifyRO(sender, args); } private void _MyStepRTB_CursorKeyPress(object sender, KeyEventArgs args) { - _MyStepPanel.StepCursorKeys(sender as StepRTB, args); + MyStepPanel.StepCursorKeys(this, args); } private void _MyStepRTB_CursorMovement(object sender, StepRTBCursorMovementEventArgs args) { - _MyStepPanel.CursorMovement(sender as StepRTB, args.CursorLocation, args.Key); + MyStepPanel.CursorMovement(this, args.CursorLocation, args.Key); } - private void _MyStepRTB_ModeChange(object sender, StepRTBModeChangeEventArgs args) + //private void _MyStepRTB_ModeChange(object sender, StepRTBModeChangeEventArgs args) + //{ + // MyStepPanel.OnModeChange(sender as StepRTB, args); + //} + void _MyStepRTB_SetMenu(object sender, StepRTBMenuEventArgs args) { - _MyStepPanel.OnModeChange(sender as StepRTB, args); + if (args.MenuGroup == null) + MyStepPanel.MyStepTabPanel.MyStepTabRibbon.ClearContextMenu(); + else if (args.MenuGroup == "OpenContextMenu") + MyStepPanel.MyStepTabPanel.MyStepTabRibbon.SetContextMenu(); + else + MyStepPanel.MyStepTabPanel.MyStepTabRibbon.SetShortCutContextMenu(args.MenuGroup); } - #endregion // Event Handlers - #region Private Methods - /// - /// Finds the last child in a list - /// - /// - /// - private static RTBItem LastChild(List childRTBItems) + void _MyStepRTB_AdjustTableWidth(object sender, StepRTBTableWidthEventArgs args) { - return childRTBItems[childRTBItems.Count - 1]; + //if ((!_MyItemInfo.IsSection && !_MyItemInfo.IsProcedure) && (_MyItemInfo.IsTable || _MyItemInfo.IsFigure)) + if (MyItemInfo.IsTable || MyItemInfo.IsFigure) + { + if (args.EditMode) + { + // First get ColR + int colR = MyStepPanel.ToDisplay(MyStepSectionLayoutData.ColRTable, MyItemInfo.ColumnMode); + // Second get WidS + int widS = /* _WidthAdjust + borderWidth + */ MyStepPanel.ToDisplay(MyStepSectionLayoutData.WidSTableEdit, MyItemInfo.ColumnMode); + //int wNew = MyRTBItem.MyStepPanel.ToDisplay(MyRTBItem.MyStepSectionLayoutData.WidT); + int wNew = 70 + widS + colR * MyItemInfo.ColumnMode; + if (wNew > ItemWidth) + { + ItemWidth = wNew; + ItemLocation = TableLocation(MyParentEditItem, MyStepSectionLayoutData, wNew); + } + } + else + { + int newwidth = (int)GetTableWidth(MyStepRTB.Font, MyStepRTB.Text, false); + if (ItemWidth != newwidth) + { + ItemWidth = newwidth; + ItemLocation = TableLocation(MyParentEditItem, MyStepSectionLayoutData, newwidth); + } + } + } } /// /// Calculate TableWidth based upon the the contents @@ -1853,7 +506,7 @@ namespace Volian.Controls.Library /// /// /// - public float TableWidth(Font myFont, string txt, bool addBorder) + private float GetTableWidth(Font myFont, string txt, bool addBorder) { string[] lines = txt.Split("\n".ToCharArray()); float max = 0; @@ -1875,309 +528,118 @@ namespace Volian.Controls.Library } } } - float widLimit = (float) _MyStepPanel.ToDisplay(_MyStepSectionLayoutData.WidSTableEdit, MyItemInfo.ColumnMode); - widLimit += (float)_MyStepPanel.ToDisplay(_MyStepSectionLayoutData.ColS); - widLimit += (float) _MyStepPanel.ToDisplay(_MyStepSectionLayoutData.ColRTable, MyItemInfo.ColumnMode); - max += _MyStepPanel.MyStepPanelSettings.TableWidthAdjust; - return Math.Min(max,widLimit); + float widLimit = (float)MyStepPanel.ToDisplay(MyStepSectionLayoutData.WidSTableEdit, MyItemInfo.ColumnMode); + widLimit += (float)MyStepPanel.ToDisplay(MyStepSectionLayoutData.ColS); + widLimit += (float)MyStepPanel.ToDisplay(MyStepSectionLayoutData.ColRTable, MyItemInfo.ColumnMode); + max += MyStepPanel.MyStepPanelSettings.TableWidthAdjust; + return Math.Min(max, widLimit); } - /// - /// Calculates the table location - /// - /// - /// - /// - /// - public Point TableLocation(RTBItem myParentRTBItem, StepSectionLayoutData myStepSectionLayoutData, int width) + bool _MyStepRTB_IsNotCurrentSelection(object sender, System.EventArgs args) { - // Should center on parent unless it is a centered table in the AER column - int center = myParentRTBItem.TextLeft + myParentRTBItem.TextWidth / 2; - int rightLimit = myParentRTBItem.Right; - // Then should center on the wid Limit - if (MyItemInfo.FormatStepData.Type.Contains("AER") == false && MyItemInfo.RNOLevel == 0) + return MyStepPanel.SelectedEditItem != this; + } + void _MyStepRTB_OpenAnnotations(object sender, System.EventArgs args) + { + OpenAnnotations(); + } + void _MyStepRTB_InsertPgBrk(object sender, System.EventArgs args) + { + InsertPgBrk(); + } + void _MyStepRTB_EnterKeyPressed(object sender, System.Windows.Forms.KeyEventArgs args) + { + if (!MyItemInfo.IsTablePart) { - int colR = _MyStepPanel.ToDisplay(_MyStepSectionLayoutData.ColRTable, MyItemInfo.ColumnMode); - rightLimit += colR * MyItemInfo.ColumnMode; - center += (colR * MyItemInfo.ColumnMode) / 2; - center -= (myParentRTBItem.TextLeft - (int)MyItemInfo.MyDocStyle.Layout.LeftMargin) / 2; + args.Handled = true; + MyStepPanel.MyStepTabPanel.MyStepTabRibbon.ProcessEnterKey(); } - - // Calulate the x location - //int x = myParentRTBItem.TextLeft; - int x = center - width / 2; - if (x + width > rightLimit) x = rightLimit - width; - int colT = _MyStepPanel.ToDisplay(myStepSectionLayoutData.ColT); - if (x < colT) x = colT; - int y = FindTop(myParentRTBItem.Bottom); - return new Point(x, y); } - /// - /// Sets the Item and as a result the text for the RichTextBox - /// - private void SetText() + bool _MyStepRTB_CheckClipboard(object sender, System.EventArgs args) { - LastMethodsPush("SetText"); - if (_MyItemInfo != null) - this._MyStepRTB.MyItemInfo = _MyItemInfo; - LastMethodsPop(); + return CheckClipboard(); } - /// - /// If the selected RTBItem is within the window leave it as it is. - /// If not, scroll so that the selected window is centered. - /// - private void ScrollToCenter() + void _MyStepRTB_CopyStep(object sender, System.EventArgs args) { - //vlnStackTrace.ShowStack("CenterScroll {0} Current {1} Top {2} Bottom {3} Limit {4}", _MyItem.ItemID, _Panel.VerticalScroll.Value, Top, Bottom, _Panel.Height);// Show StackTrace - //Console.WriteLine("CenterScroll {0} Current {1} Top {2} Bottom {3} Limit {4}", _MyItem.ItemID, _Panel.VerticalScroll.Value, Top, Bottom, _Panel.Height); - if (Top >= 0 && Bottom <= _MyStepPanel.Height) return;// Don't move if within screen. - int scrollValue = _MyStepPanel.VerticalScroll.Value + (Top - (_MyStepPanel.Height / 2)); // calculate scroll center for the item - //Console.WriteLine("CenterScroll {0} Current {1} New {2} Min {3} Max {4}", _MyItem.ItemID, _Panel.VerticalScroll.Value, scrollValue, _Panel.VerticalScroll.Minimum, _Panel.VerticalScroll.Maximum); - if (scrollValue >= _MyStepPanel.VerticalScroll.Minimum && scrollValue <= _MyStepPanel.VerticalScroll.Maximum) // If it is within range - _MyStepPanel.VerticalScroll.Value = scrollValue; // Center the item + CopyStep(); } - // TODO: the format of the circles, Checkoffs and Changebars should come from the format file - /// - /// This adds drawing items to the RTBItem as needed including - /// Circle around the Tab Number - /// Check-Offs - /// Change Bars - /// - /// - /// - private void RTBItem_Paint(object sender, PaintEventArgs e) + void _MyStepRTB_OpenContextMenu(object sender, StepRTBLocationEventArgs args) { - Graphics g = e.Graphics; - g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias; - //g.DrawString(lblTab.Text, MyItemInfo.MyTab.MyFont.WindowsFont, Brushes.Red, new RectangleF(new PointF(_MyStepPanel.MyStepPanelSettings.NumberLocationX, _MyStepPanel.MyStepPanelSettings.NumberLocationY), _MyStepPanel.MyStepPanelSettings.NumberSize), StringFormat.GenericDefault); - // adjust x location of label by 7, to position correctly. - //g.DrawString(lblTab.Text, MyItemInfo.MyTab.MyFont.WindowsFont, Brushes.Blue, new RectangleF(new PointF(Convert.ToSingle(lblTab.Location.X-7), Convert.ToSingle(lblTab.Location.Y)), _MyStepPanel.MyStepPanelSettings.NumberSize), StringFormat.GenericDefault); - //g.DrawLine(Pens.DarkGreen, lblTab.Location.X-7, 0, lblTab.Location.X-7, this.Height); - //g.DrawLine(Pens.DarkGreen, MyStepRTB.Location.X - 7, 0, MyStepRTB.Location.X - 7, this.Height); - g.DrawString(lblTab.Text, MyItemInfo.MyTab.MyFont.WindowsFont, Brushes.Black, new RectangleF(new PointF(Convert.ToSingle(lblTab.Location.X), Convert.ToSingle(lblTab.Location.Y)), _MyStepPanel.MyStepPanelSettings.NumberSize), StringFormat.GenericDefault); - //g.DrawLine(Pens.DarkGreen, lblTab.Location.X, 0, lblTab.Location.X, this.Height); - //g.DrawLine(Pens.DarkGreen, MyStepRTB.Location.X, 0, MyStepRTB.Location.X, this.Height); - if (Circle) + MyStepPanel.MyStepTabPanel.MyStepTabRibbon.OpenContextMenu(args.Location); + } + void _MyStepRTB_DoMouseWheel(object sender, System.Windows.Forms.MouseEventArgs args) + { + DoMouseWheel(args); + } + void _MyStepRTB_DoSaveContents(object sender, System.EventArgs args) + { + SaveContents(); + } + #endregion + #region override methods + public override void RefreshTab() + { + TabFormat = null; + SetupHeader(); + } + public override void SetFocus() + { + MyStepRTB.Focus(); + } + public override void SaveContents() + { + SaveText(); + SaveConfig(); // This may be redundant + } + public void SaveText() + { + if (MyStepRTB.ReadOnly) return; + if (!MyStepRTB.ActiveMode) return; + if (!MyStepRTB.IsDirty && MyStepRTB.Text.Contains("(Resolved Transition Text)") == false) return; + bool success = MyStepRTB.OrigDisplayText.Save((RichTextBox)MyStepRTB); + if (success) { - Pen penC = new Pen(_MyStepPanel.MyStepPanelSettings.CircleColor, _MyStepPanel.MyStepPanelSettings.CircleWeight); - g.DrawArc(penC, lblTab.Left + 1, 0, _MyStepPanel.MyStepPanelSettings.CircleDiameter, _MyStepPanel.MyStepPanelSettings.CircleDiameter, 0F, 360F); + MyStepRTB.FindAllLinks(); + MyStepRTB.OrigRTF = MyStepRTB.Rtf; + MyStepRTB.ClearUndo(); } - if (CheckOff) + } + //public override void SetBackgroundColor() + //{ + // MyStepRTB.SetBackColor(); + //} + public override void IdentifyMe(bool highlight) + { + if (highlight) + MyStepRTB.BackColor = Color.Gray; + else { - Pen penCO = new Pen(_MyStepPanel.MyStepPanelSettings.CheckOffColor, _MyStepPanel.MyStepPanelSettings.CheckOffWeight); - g.DrawRectangle(penCO, _MyStepPanel.MyStepPanelSettings.CheckOffX, _MyStepPanel.MyStepPanelSettings.CheckOffY, _MyStepPanel.MyStepPanelSettings.CheckOffSize, _MyStepPanel.MyStepPanelSettings.CheckOffSize); - } - if (ChangeBar) - { - Pen penCB = new Pen(_MyStepPanel.MyStepPanelSettings.ChangeBarColor, _MyStepPanel.MyStepPanelSettings.ChangeBarWeight); - if (ChangeBarPosition == E_ChangeBarPosition.Left) - g.DrawLine(penCB, 0, _MyStepRTB.Top, 0, Height); // left, top, right, bottom. - else - { - g.DrawLine(penCB, Width-2, _MyStepRTB.Top, Width-2, Height); - } + if (MyStepRTB.Focused) // If active Set BackColor to the active color + MyStepRTB.BackColor = MyStepPanel.ActiveColor; + else // Otherwise Set the BackColor to either the InactiveColor or the AnnotationColor + MyStepRTB.BackColor = MyItemInfo.ItemAnnotationCount == 0 ? MyStepPanel.InactiveColor : MyStepPanel.AnnotationColor; } } /// - /// Hide a Items Children - Part of colapsing + /// Gets or Sets the ability to expand /// - protected void HideChildren() + public override bool CanExpand { - HideChildren(_MyBeforeRTBItems); - HideChildren(_MyRNORTBItems); - HideChildren(_MyAfterRTBItems); + get { return _MyvlnExpander.Visible; } + set { _MyvlnExpander.Visible = value; } } - /// - /// Hide a list of children - Part of colapsing - /// - /// - private void HideChildren(List childRTBItems) + public override void HandleResize() { - if (childRTBItems != null) - { - foreach (RTBItem child in childRTBItems) - { - if (child.Expanded) child.HideChildren(); - child.Hidden = true; - } - } + if (lblHeader != null) lblHeader.Width = this.Width; } - /// - /// Unhide an items Children - Part of expanding - /// - /// - protected void UnhideChildren(bool expand) + public override void MatchExpanded() { - UnhideChildren(_MyBeforeRTBItems, expand); - UnhideChildren(_MyRNORTBItems, expand); - UnhideChildren(_MyAfterRTBItems, expand); if (!_MyvlnExpander.Expanded) - _MyvlnExpander.ShowExpanded(); + _MyvlnExpander.ShowExpanded(); } /// - /// Unhide a list of children - part of expanding - /// - /// - /// - private void UnhideChildren(List childRTBItems, bool expand) - { - if (childRTBItems != null) - { - foreach (RTBItem child in childRTBItems) - { - if (child.Expanded) - child.UnhideChildren(expand); - else if (expand) - child.Expand(expand); - child.Hidden = false; - } - } - } - /// - /// Move children as necessary - /// - protected void AdjustChildren() - { - AdjustChildren(_MyBeforeRTBItems); - AdjustChildren(_MyRNORTBItems); - AdjustChildren(_MyAfterRTBItems); - } - /// - /// Move a list of children - /// - /// - private void AdjustChildren(List childRTBItems) - { - if (childRTBItems != null) - { - foreach (RTBItem child in childRTBItems) - { - child.AdjustLocation(); - if (child.Expanded) child.AdjustChildren(); - } - } - } - /// - /// Expand a list of children - /// - /// - private void ExpandChildren(List childRTBItems) - { - if (childRTBItems != null) - { - foreach (RTBItem child in childRTBItems) - { - if (child.CanExpand) - { - child.Expand(true); - } - child.Hidden = false; - } - } - } - /// - /// Expand children - /// - private void ExpandChildren() - { - // Walk though Children performing Expand - ExpandChildren(_MyBeforeRTBItems); - ExpandChildren(_MyRNORTBItems); - ExpandChildren(_MyAfterRTBItems); - } - private string MyPath - { - get - { - if (MyItemInfo.MyContent.Type >= 20000) - return MyItemInfo.Path.Substring(MyItemInfo.ActiveSection.Path.Length); - return MyItemInfo.MyContent.ToString(); - } - } - private RTBItem AERRTBItem - { - get - { - if(RNOLevel == 0)return null; - if (MyParentRTBItem != null) - { - if (MyParentRTBItem.RNOLevel < RNOLevel) - return MyParentRTBItem; - else - return MyParentRTBItem.AERRTBItem; - } - else if (MyPreviousRTBItem != null) - { - return MyPreviousRTBItem.AERRTBItem; - } - //Volian.Base.Library.vlnStackTrace.ShowStackLocal("'AERRTBItem',{0},{1}", MyID, MyItemInfo.DBSequence); - return null; - } - } - /// - /// Adjust the Location of all items below the current item. - /// - internal void AdjustLocation() - { - //Console.WriteLine("'AdjustLocation',{0},{1},'{2}'", MyID, MyItemInfo.DBSequence, Volian.Base.Library.vlnStackTrace.CalledFrom4); - if (RNORight) MoveRNO(); // This is needed when an AER is Deleted that has an RNO. - if (RNOLevel > 0 && AERRTBItem != null) - AERRTBItem.AdjustLocation(); - RTBItem nextRTBItem = NextDownRTBItem; - //if (MyID == 2138) - // Console.WriteLine("2138"); - //if (_WatchThis > 0 && MyID > _StartingID) - //if((nextRTBItem == null ? 0 : nextRTBItem.MyID) == MyID) - //if(_LookForID.Contains(MyID)) - // Console.WriteLine("{0}AdjustLocation {1},{2},{3} -> {4},{5} ({6}) {7}", WatchThisIndent, MyID, MyItemInfo.Ordinal, MyPath, - // nextRTBItem == null ? 0 : nextRTBItem.MyID, nextRTBItem == null ? 0 : nextRTBItem.MyItemInfo.Ordinal, nextRTBItem == null ? "Null" : nextRTBItem.MyPath, - // _NextDownRTBItemPath); - //if (_WatchThis && MyID == 2119) - // Console.WriteLine("I'm here"); - //if (MyID > 2120) - // Console.WriteLine("{0}\t{1}", MyID, nextRTBItem == null ? 0 : nextRTBItem.MyID); - if (nextRTBItem != null) - { - //int bottom = BottomMostRTBItem.Bottom; - if (nextRTBItem != null) - { - //if (MyID == 2123) - // _LookForID = 2123; - int bottom = nextRTBItem.FindTop(Bottom); - if (nextRTBItem.Top != bottom) - // if (nextRTBItem != null && !nextRTBItem.Moving && nextRTBItem.Top != bottom) - { - _MyStepPanel.ItemMoving++; - nextRTBItem.LastMethodsPush(string.Format("AdjustLocation {0}",MyID)); - nextRTBItem._NextDownRTBItemPath = _NextDownRTBItemPath; - nextRTBItem.Top = bottom; - nextRTBItem.LastMethodsPop(); - _MyStepPanel.ItemMoving--; - } - } - else - { - Console.WriteLine("{0}** No Adjustment next = {1}, moving = {2}", WatchThisIndent, nextRTBItem, nextRTBItem == null ? false : nextRTBItem.Moving); - } - } - } - /// - /// Automatically expands Steps if not currently expanded - /// - internal void AutoExpand() - { - if (CanExpand && Expanded == false)// TODO: May need to do some additional checking for subsections - { - //vlnStackTrace.ShowStack(">AutoExpand ID {0} - Can {1} Expanded {2}", _MyItem.ItemID, CanExpand, Expanded); - Expand(_Type >= 20000); - //Console.WriteLine(" /// Sets the focus to this RTBItem and positions the cursor to the begining of the string /// - public void ItemSelect() + public override void ItemSelect() { // Was getting an Error that _MyStepRTB was Disposed RHM 20101217 if (!_MyStepRTB.Disposing) @@ -2195,229 +657,130 @@ namespace Volian.Controls.Library /// /// Sets the focus to this RTBItem /// - public void ItemShow() + public override void ItemShow() { _MyStepRTB.Focus(); ScrollToCenter(); } - /// - /// Expand an item and it's children - /// If the children have been loaded then just expand them - /// If not, load the children and expand their children etc. - /// - /// normally equal to _Type > = 20000 (Step) - public void Expand(bool expand) + public override DialogResult ReplaceText(string rpltxt, string fndstr, bool caseSensitive, bool matchWholeWord, bool reverse, bool prompt, IWin32Window fndrpldlg) { - //// TIMING: DisplayItem.TimeIt("Expand Start"); - if (_ChildrenLoaded) + return MyStepRTB.ReplaceText(rpltxt, fndstr, caseSensitive, matchWholeWord, reverse, prompt, fndrpldlg); + } + public override bool FindText(string str, bool caseSensitive, bool matchWholeWord, bool reverse) + { + return MyStepRTB.FindText(str, caseSensitive, matchWholeWord, reverse); + } + public override void PositionToEnd() + { + MyStepRTB.SelectionStart = MyStepRTB.Text.Length; + } + public override string SelectedTextForFind + { + get { - // Unhide Children - MyExpandingStatus = ExpandingStatus.Showing; - UnhideChildren(expand); - if (_ExpandPrefix != 0) + StepRTB srtb = MyStepRTB; + if (srtb.SelectionLength > 0) { - _MyStepPanel.ItemMoving++; - TopMostRTBItem.Top = Top; - _MyStepPanel.ItemMoving--; + if (srtb.IsSelectionLinked(srtb.SelectionStart, srtb.SelectionLength)) + return srtb.SelectedText.Substring(0, srtb.SelectedText.IndexOf("#Link")); + else + return srtb.SelectedText; } - else - TopMostRTBItem.AdjustLocation(); - AdjustChildren(); - //if(_Before != null ) - // Top = _Before[_Before.Count - 1].BottomMost.Bottom; + return null; } + } + public override bool SpellCheckNext() + { + return MyStepRTB.SpellCheckNext(); + } + public override void SetActive() + { + MyStepRTB.BackColor = MyStepPanel.ActiveColor; + } + public override bool Empty + { + get { return MyStepRTB.Text == ""; } + set { MyStepRTB.Text = value ? "" : " "; } + } + //public override bool IsEmpty() // this becomes 'Empty' property, i.e. get/set. + //{ // for the set, emtpy is following line (= not ==). + // // for not empty - it's code that is in 'MakeNotEmpty' + // return MyStepRTB.Text == ""; + //} + //public override void MakeNotEmpty() + //{ + // MyStepRTB.Text = " "; + //} + public override void RefreshDisplay(bool activeMode) + { + MyStepRTB.VwMode = MyStepPanel.VwMode; + MyStepRTB.RefreshDisplay(activeMode); + //MyStepRTB.ViewRTB = !activeMode; + } + public override void ToggleEditView(E_ViewMode vwMode) + { + SaveContents(); + MyStepRTB.VwMode = vwMode; + MyStepRTB.RefreshDisplay(); + MyStepRTB.SelectionStart = 0; + MyStepRTB.SelectionLength = 0; + } + public override int TabLeft { get { return lblTab.Left; } set { lblTab.Left = value; } } + public override Font TabFont { get { return lblTab.Font; } set { lblTab.Font = value; } } + public override string TabText { get { return lblTab.Text; } } + public override Point TabLocation { get { return lblTab.Location; } } + public override Font ContentFont { get { return MyStepRTB.Font; } set { MyStepRTB.Font = value; } } + public override float ContentTop { get { return MyStepRTB.Top; } } + public override void SetupHeader(ItemInfo itemInfo) + { + lblTab.Top = 3 + ((itemInfo.HasHeader) ? 23 : 0); + _MyStepRTB.Top = lblTab.Top; // 3 + ((itemInfo.HasHeader) ? 23 : 0); + //lblTab.Move += new EventHandler(lblTab_Move); + if (itemInfo.HasHeader) + SetupHeaderFooter(ref lblHeader, "Header", itemInfo.MyHeader); else { - MyExpandingStatus = ExpandingStatus.Expanding; - _ChildrenLoaded = true; - //_Panel.SuspendLayout(); - AddChildBefore(MyItemInfo.Cautions, expand); - AddChildBefore(MyItemInfo.Notes, expand); - AddChildAfter(MyItemInfo.Procedures, expand); - AddChildAfter(MyItemInfo.Sections, expand); - if (MyItemInfo.RNOs != null && MyItemInfo.RNOLevel < MyItemInfo.ColumnMode) - AddChildRNO(MyItemInfo.RNOs, expand); - AddChildAfter(MyItemInfo.Tables, expand); - AddChildAfter(MyItemInfo.Steps, expand); - if (MyItemInfo.RNOs != null && MyItemInfo.RNOLevel >= MyItemInfo.ColumnMode) - AddChildRNO(MyItemInfo.RNOs, expand); - if (!_MyvlnExpander.Expanded) - _MyvlnExpander.ShowExpanded(); - } - MyExpandingStatus = ExpandingStatus.Done; - BottomMostRTBItem.AdjustLocation(); - MyExpandingStatus = ExpandingStatus.No; - //// TIMING: DisplayItem.TimeIt("Expand End"); - } - public RTBItem BeforeItem - { - get - { - if (_MyAfterRTBItems != null) - { - foreach (RTBItem RTBItem in _MyAfterRTBItems) - { - if (RTBItem._MyBeforeRTBItems != null) - return RTBItem.TopMostRTBItem; - RTBItem beforeItem = RTBItem.BeforeItem; - if (beforeItem != null) return beforeItem; - } - } - return null; + // remove header from screen if it exists: + this.Controls.Remove(lblHeader); + lblHeader = null; } } - public RTBItem ItemAbove + public override void ShowExpanded() { - get - { - if (_MyChildRelation == ChildRelation.Before) return _MyParentRTBItem.ItemAbove; - if (_MyPreviousRTBItem != null) return _MyPreviousRTBItem.BottomMostRTBItem; - if (_MyChildRelation == ChildRelation.After) return _MyParentRTBItem; - if (_MyChildRelation == ChildRelation.RNO) return _MyParentRTBItem; - return null; - } + _MyvlnExpander.ShowExpanded(); } - private static int? max(int? value1, int value2) - { - if (value1 == null || value2 > value1) return value2; - return value1; - } - private static int min(int value1, int value2) - { - if (value2 < value1) return value2; - return value1; - } - public int FindRight() - { - if (!RNORight) return Right; - return _MyRNORTBItems[0].FindRight(); - } - public int? BottomOfParentRNO() - { - int? bottom = null; - RTBItem RTBItem = this; - if (!MyItemInfo.IsTablePart) - { - if (RTBItem._MyChildRelation == ChildRelation.None) - return null; - if (RTBItem._MyChildRelation == ChildRelation.After && !RNORight) - return null; - } - while (RTBItem != null && RTBItem._MyChildRelation != ChildRelation.None && RTBItem._MyChildRelation != ChildRelation.After) - RTBItem = RTBItem.UpOneRTBItem; - if (RTBItem == null || RTBItem._MyChildRelation == ChildRelation.None) - return null; - RTBItem parent = RTBItem.UpOneRTBItem; - int right = FindRight(); - bool centeredTable = (MyItemInfo.IsTablePart && MyItemInfo.FormatStepData.Type.Contains("AER") == false && MyItemInfo.RNOLevel == 0); - while (parent != null && parent.MyItemInfo.IsSection == false) - { - if (parent._MyRNORTBItems != null) - { - if (centeredTable || right > parent._MyRNORTBItems[0].Left) - { - if(parent._MyRNORTBItems[0].BottomMostRTBItem.RNOLevel > RNOLevel && RNOLevel < _MyItemInfo.ColumnMode) - bottom = max(bottom, parent._MyRNORTBItems[0].BottomMostRTBItem.Bottom); - } - } - parent = parent.UpOneRTBItem; - } - return bottom; - } - private string _NextDownRTBItemPath = "None"; /// - /// This finds the next RTBItem down. + /// Sets the Item and as a result the text for the RichTextBox /// - public RTBItem NextDownRTBItem + public override void SetText() { - get + LastMethodsPush("SetText"); + if (MyItemInfo != null) { - RTBItem RTBItem = this; - _NextDownRTBItemPath = "Path 1"; - // If this item appears before it's parent, and it doesn't have anything below it, return the parent - if (MyNextRTBItem == null && MyAfterRTBItems == null && FirstSiblingRTBItem._MyChildRelation == ChildRelation.Before) - return UpOneRTBItem; - _NextDownRTBItemPath = "Path 2"; - if (Expanded && _MyAfterRTBItems != null)// check to see if there is a _After - return MyAfterRTBItems[0].TopMostRTBItem;// if there is, go that way - _NextDownRTBItemPath = "Path 3"; - if (Expanded && MyRNORTBItems != null && MyItemInfo.RNOLevel >= MyItemInfo.ColumnMode)// check to see if there is a _After - return MyRNORTBItems[0].TopMostRTBItem;// if there is, go that way - while (RTBItem != null && RTBItem.MyNextRTBItem == null) // if no Next walk up the parent path - { - bool lastWasRNO = (RTBItem._MyChildRelation == ChildRelation.RNO); - RTBItem = RTBItem.UpOneRTBItem; - _NextDownRTBItemPath = "Path 4"; - if (RTBItem == null) // No Parent - return null; - _NextDownRTBItemPath = string.Format("Path 5 {0}, {1}",RTBItem.MyExpandingStatus,RTBItem.Moving); - if (RTBItem.MyExpandingStatus == ExpandingStatus.Expanding || RTBItem.Moving) // Parent Expanding or Moving - Wait - return null; - _NextDownRTBItemPath = "Path 5 RNO"; - if (RTBItem.RNOBelow && !Ancestor(RTBItem.MyRNORTBItems[0])) - return RTBItem.MyRNORTBItems[0]; - _NextDownRTBItemPath = "Path 6"; - if (RTBItem.MyNextRTBItem == null && RTBItem.FirstSiblingRTBItem._MyChildRelation == ChildRelation.Before) - return RTBItem.UpOneRTBItem; - RTBItem btm = RTBItem.BottomMostRTBItem; // Find the Bottom RTBItem of this ancestor - RTBItem beforeItem = RTBItem.BeforeItem; - if (lastWasRNO && beforeItem != null) - { - _NextDownRTBItemPath = "Path 7"; - if (beforeItem.ItemAbove.Bottom > this.Bottom) return null; - _NextDownRTBItemPath = "Path 8"; - return beforeItem; - } - if (this != btm) // If this is not the bottom, then just adjust things with respect to the bottom - { - RTBItem btmNext = btm.NextDownRTBItem; - //if (RTBItem.MyNextRTBItem != null && RTBItem.MyNextRTBItem.TopMostRTBItem.Top != btm.Bottom) - if (btmNext != null) - { - int bottom = btmNext.FindTop(btm.Bottom); - if(btmNext.Top != bottom) - { - _MyStepPanel.ItemMoving++; - //RTBItem.MyNextRTBItem.TopMostRTBItem.Top = btm.Bottom; - //Console.WriteLine("{0}***Move in NextDownRTBItem {1},{2} From {3} To {4}",WatchThisIndent, btmNext.MyID, btmNext, btmNext.Top, btm.Bottom); - btmNext.LastMethodsPush(string.Format("NextDownRTBItem {0} {1}", MyID, RTBItem.MyID)); - //ShowMe(string.Format("FindTop = {0}", btmNext.FindTop(btm.Bottom))); - btmNext.Top = bottom; - btmNext.LastMethodsPop(); - _MyStepPanel.ItemMoving--; - } - } - _NextDownRTBItemPath = string.Format("Path 9 {0}",btm); - return null; // Not the bottom - don't adjust anything else - } - //else - //{ - //} - } - if (RTBItem != null) - { - // Need to verify that the bottom of the parents RNO does not excede the bottom of this item. - RTBItem next = RTBItem.MyNextRTBItem.TopMostRTBItem; - _NextDownRTBItemPath = "Path A"; - //if (Bottom >= (BottomOfParentRNO(next) ?? Bottom)) - return next;// if no _After - check to see if there is a Next - //_NextDownRTBItemPath = "Path B"; - //return null; - } - _NextDownRTBItemPath = "Path C"; - return null; + MyStepRTB.MyItemInfo = MyItemInfo; + MyStepRTB.RefreshDisplay(); + IdentifyMe(false); } + LastMethodsPop(); } - - private bool Ancestor(RTBItem RTBItem) + public override void SetExpandAndExpander(ItemInfo itemInfo) { - if (MyID == RTBItem.MyID) return true; - if (MyItemInfo.IsHigh) return false; - return UpOneRTBItem.Ancestor(RTBItem); - } - public override string ToString() - { - return _MyItemInfo == null ? base.ToString() : string.Format("{0},'{1}'", MyID, MyPath); // + "-" + MyItemInfo.MyContent.Text; + // Don't allow substeps to expand + switch (ContentType / 10000) + { + case 1: // Section can expand + CanExpand = true; + // If a word document set the expander to attachment + _MyvlnExpander.Attachment = !(itemInfo.IsStepSection); + //OLD: _MyvlnExpander.Attachment = (itemInfo.MyContent.ContentPartCount == 0); + break; + case 2: // High level steps with children can expand + CanExpand = itemInfo.IsHigh && itemInfo.HasChildren; // TemporaryFormat.IsHigh(item); ; + break; + default://Procedures cannot expand, because they automatically expand + CanExpand = false; + break; + } } #endregion } diff --git a/PROMS/Volian.Controls.Library/RTBItem.designer.cs b/PROMS/Volian.Controls.Library/RTBItem.designer.cs index 70f62ef6..45115c07 100644 Binary files a/PROMS/Volian.Controls.Library/RTBItem.designer.cs and b/PROMS/Volian.Controls.Library/RTBItem.designer.cs differ diff --git a/PROMS/Volian.Controls.Library/StepPanel.cs b/PROMS/Volian.Controls.Library/StepPanel.cs index b600693c..5cccc444 100644 --- a/PROMS/Volian.Controls.Library/StepPanel.cs +++ b/PROMS/Volian.Controls.Library/StepPanel.cs @@ -19,21 +19,25 @@ namespace Volian.Controls.Library /// Procedure Item Info - Top ItemInfo /// private ItemInfo _MyProcedureItemInfo; + private E_ViewMode _VwMode = E_ViewMode.Edit; + public E_ViewMode VwMode + { + get { return _VwMode; } + set { _VwMode = value; } + } + // TODO: This is not correct. There should be a dictionary of Section Layouts /// - /// Lookup Table to convert ItemInfo.ItemID to RTBItem + /// Lookup Table to convert ItemInfo.ItemID to EditItem /// - internal Dictionary _LookupRTBItems; - public RTBItem FindItem(ItemInfo itemInfo) + internal Dictionary _LookupEditItems; + public EditItem FindItem(ItemInfo itemInfo) { if (itemInfo == null) return null; - if (!_LookupRTBItems.ContainsKey(itemInfo.ItemID)) return null; - return _LookupRTBItems[itemInfo.ItemID]; + if (!_LookupEditItems.ContainsKey(itemInfo.ItemID)) return null; + return _LookupEditItems[itemInfo.ItemID]; } - /// - /// Currently selected RichTextBox - /// - private StepRTB _SelectedStepRTB = null; + /// /// Currently selected ItemInfo /// @@ -53,7 +57,7 @@ namespace Volian.Controls.Library // Whether panel is in view or edit mode. Toggled from steprtb // or set based on approval/multi-user (these two will be done // later. - public E_ViewMode PanelViewEditMode = E_ViewMode.Edit; + //public E_ViewMode PanelViewEditMode = E_ViewMode.Edit; internal string _LastAdjust=""; private bool _ShowLines = true; private Graphics _MyGraphics = null; @@ -61,7 +65,7 @@ namespace Volian.Controls.Library #endregion #region Item Events /// - /// Occurs when the user clicks tab of a RTBItem + /// Occurs when the user clicks tab of a EditItem /// public event StepPanelEvent ItemClick; /// @@ -75,7 +79,7 @@ namespace Volian.Controls.Library } private bool ItemSelectionChangeShown = false; // This keeps OnItemSelectedChanged from being called twice when an item is selected. /// - /// Occurs when the selected RTBItem changes + /// Occurs when the selected EditItem changes /// public event ItemSelectedChangedEvent ItemSelectedChanged; /// @@ -101,16 +105,16 @@ namespace Volian.Controls.Library internal void OnAttachmentClicked(object sender, StepPanelAttachmentEventArgs args) { if (AttachmentClicked != null) AttachmentClicked(sender, args); - else MessageBox.Show(args.MyRTBItem.MyItemInfo.MyContent.MyEntry.MyDocument.DocumentTitle, "Unhandled Attachment Click", MessageBoxButtons.OK, MessageBoxIcon.Information); + else MessageBox.Show(args.MyEditItem.MyItemInfo.MyContent.MyEntry.MyDocument.DocumentTitle, "Unhandled Attachment Click", MessageBoxButtons.OK, MessageBoxIcon.Information); } // Edit/View mode change - public event StepPanelModeChangeEvent ModeChange; - internal void OnModeChange(object sender, StepRTBModeChangeEventArgs args) - { - PanelViewEditMode = args.ViewMode; - ModeChange(sender, args); - } + //public event StepPanelModeChangeEvent ModeChange; + //internal void OnModeChange(object sender, StepRTBModeChangeEventArgs args) + //{ + // PanelViewEditMode = args.ViewMode; + // ModeChange(sender, args); + //} // various selections from steptabribbon that need to filter up to frmveproms // such as 'global search', 'bookmarks' public event StepPanelTabDisplayEvent TabDisplay; @@ -262,10 +266,10 @@ namespace Volian.Controls.Library InactiveColor = PanelColor = BackColor; foreach (Control ctrl in Controls) { - if (ctrl.GetType() == typeof(RTBItem)) + if (ctrl is EditItem) { - RTBItem rtb = (RTBItem)ctrl; - rtb.BackColor = BackColor; + EditItem ei = (EditItem)ctrl; + ei.BackColor = BackColor; } } } @@ -278,11 +282,11 @@ namespace Volian.Controls.Library private void ExpandAsNeeded(ItemInfo myItemInfo) { int id = myItemInfo.ItemID; - if (!_LookupRTBItems.ContainsKey(id)) // If the item is not currently displayed + if (!_LookupEditItems.ContainsKey(id)) // If the item is not currently displayed ExpandAsNeeded((ItemInfo)myItemInfo.ActiveParent); // Expand it's parent - if (_LookupRTBItems.ContainsKey(id)) // Expanding Parent should have added it to _LookupRTBItems + if (_LookupEditItems.ContainsKey(id)) // Expanding Parent should have added it to _LookupEditItems { - RTBItem itm = _LookupRTBItems[id]; + EditItem itm = _LookupEditItems[id]; ItemInfo ii = myItemInfo.ActiveParent as ItemInfo; if (itm.Visible == false && ii != null) ExpandAsNeeded((ItemInfo)myItemInfo.ActiveParent); @@ -309,10 +313,10 @@ namespace Volian.Controls.Library //this.Scroll += new ScrollEventHandler(DisplayPanel_Scroll); //// TIMING: DisplayItem.TimeIt("pMyItem Scroll"); Controls.Clear(); - _LookupRTBItems = new Dictionary(); + _LookupEditItems = new Dictionary(); //// TIMING: DisplayItem.TimeIt("pMyItem Clear"); //SuspendLayout(); - RTBItem tmpRTBItem = new RTBItem(_MyProcedureItemInfo, this, null, ChildRelation.None, false); + new RTBItem(_MyProcedureItemInfo, this, null, ChildRelation.None, false); //ResumeLayout(); //// TIMING: DisplayItem.TimeIt("pMyItem End"); } @@ -328,95 +332,14 @@ namespace Volian.Controls.Library ExpandAsNeeded(SelectedItemInfo); } /// - /// Get or Set currently selected RichTextBox (StepRTB) + /// Currently selected StepRTB /// - public StepRTB SelectedStepRTB - { - get { return _SelectedStepRTB; } - set - { - StepRTB lastRTB = _SelectedStepRTB; - if(value != null) - value.BackColor = ActiveColor; // Set the active color - if (lastRTB == value) return; // Same - No Change - //RHM ToDo: Why doesn't it have focus for copy Step/Paste - if (value != null) value.Focus(); - if (lastRTB != null && lastRTB.BeingDisposed == false) - { - //_SelectedStepRTB.BackColor = InactiveColor; - //lastRTB.SetBackColor(); - bool shouldDelete = !lastRTB.MyRTBItem.BeingRemoved && lastRTB.Text.Length == 0; - if (shouldDelete) - { - if (lastRTB.MyRTBItem.HasChildren) - { - if (value != null && value.MyItemInfo.HasAncestor(lastRTB.MyItemInfo)) - { - shouldDelete = false; - } - else - { - DialogResult result = MessageBox.Show("This step does not have text but has substeps. Do you want to delete it and its substeps?", "Verify Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Question); - if (result == DialogResult.No) shouldDelete = false; - } - } - } - if (shouldDelete) - { - float oldTop = lastRTB.MyRTBItem.Top; - RTBItem newFocus = lastRTB.MyRTBItem.DeleteItem(); - float newTop = newFocus.Top; - lastRTB.MyRTBItem.Dispose(); - newFocus.SetAllTabs(); - // If the step being deleted appears above the step to recieve focus, find another step - // to use so that the steps are positioned properly (vertically) - if (oldTop < newTop) - { - if (newFocus.MyParentRTBItem != null) - { - if (newFocus.Top > newFocus.MyParentRTBItem.Top) - newFocus.MyParentRTBItem.AdjustLocation(); - else if (newFocus.MyParentRTBItem.MyPreviousRTBItem != null && - newFocus.Top > newFocus.MyParentRTBItem.MyPreviousRTBItem.Top) - newFocus.MyParentRTBItem.MyPreviousRTBItem.AdjustLocation(); - else if (newFocus.MyParentRTBItem.MyParentRTBItem != null && - newFocus.Top > newFocus.MyParentRTBItem.MyParentRTBItem.Top) - newFocus.MyParentRTBItem.MyParentRTBItem.AdjustLocation(); - else - newFocus.AdjustLocation(); - } - else if (newFocus.MyPreviousRTBItem != null) - newFocus.MyPreviousRTBItem.AdjustLocation(); - else - newFocus.AdjustLocation(); - } - else - newFocus.AdjustLocation(); - } - else - { - lastRTB.SaveText(); // Save any changes to the text - lastRTB.SaveConfig(); // This may be redundant - //int selst = _SelectedStepRTB.SelectionStart; - lastRTB.RTBFillIn(false); - //_SelectedStepRTB.SetSelection(selst, 0); - //_SelectedStepRTB.SelectionStart=selst; - lastRTB.ViewRTB = true; - } - } - _SelectedStepRTB = value; - if (value != null) - { - _SelectedStepRTB.ViewRTB = PanelViewEditMode == E_ViewMode.View; - _SelectedStepRTB.RTBFillIn(PanelViewEditMode != E_ViewMode.View); - if (_SelectedItemInfo.ItemID != value.MyItemInfo.ItemID) - SelectedItemInfo = value.MyItemInfo; - } - if(lastRTB != null) - lastRTB.SetBackColor(); - //vlnStackTrace.ShowStack("_DisplayRTB = {0}", _DisplayRTB.MyItem.ItemID);// Show StackTrace - } - } + //private StepRTB _SelectedStepRTB = null; + //public StepRTB SelectedStepRTB + //{ + // get { return _SelectedStepRTB; } + // set { _SelectedStepRTB=value;} + //} /// /// Gets or Sets the SelectedItemInfo /// Activates and Expands as necessary @@ -431,8 +354,8 @@ namespace Volian.Controls.Library int id = value.ItemID; ExpandAsNeeded(value); // reset the entire step panel if the item isn't found. - if (!_LookupRTBItems.ContainsKey(id)) Reset(); - RTBItem itm = _LookupRTBItems[id]; + if (!_LookupEditItems.ContainsKey(id)) Reset(); + EditItem itm = _LookupEditItems[id]; ItemSelectionChangeShown = false;//OnItemSelectedChanged has not run yet. itm.ItemSelect(); if (!ItemSelectionChangeShown) OnItemSelectedChanged(this, new ItemSelectedChangedEventArgs(itm)); @@ -446,21 +369,100 @@ namespace Volian.Controls.Library set { _DisplayItemChanging = value; } } /// - /// Returns the SelectedRTBItem + /// Returns the SelectedEditItem /// - public RTBItem SelectedRTBItem + private EditItem _SelectedEditItem; + public EditItem SelectedEditItem { - get { return (_SelectedItemInfo != null) ? _LookupRTBItems[_SelectedItemInfo.ItemID] : null; } + get + { + return _SelectedEditItem; + //return (_SelectedItemInfo != null) ? _LookupEditItems[_SelectedItemInfo.ItemID] : null; + } + set + { + EditItem lastEI = _SelectedEditItem; + if (value != null) value.SetActive(); // Set the active color + if (lastEI == value) return; // Same - No Change + //RHM ToDo: Why doesn't it have focus for copy Step/Paste + if (value != null) value.SetFocus(); + + if (lastEI != null && lastEI.BeingDisposed == false) + { + bool shouldDelete = !lastEI.BeingRemoved && lastEI.Empty; + if (shouldDelete) + { + if (lastEI.HasChildren) + { + if (value != null && value.MyItemInfo.HasAncestor(lastEI.MyItemInfo)) + { + shouldDelete = false; + } + else + { + DialogResult result = MessageBox.Show("This step does not have text but has substeps. Do you want to delete it and its substeps?", "Verify Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Question); + if (result == DialogResult.No) shouldDelete = false; + } + } + } + if (shouldDelete) + { + float oldTop = lastEI.Top; + EditItem newFocus = lastEI.DeleteItem(); + float newTop = newFocus.Top; + lastEI.Dispose(); + newFocus.SetAllTabs(); + // If the step being deleted appears above the step to recieve focus, find another step + // to use so that the steps are positioned properly (vertically) + if (oldTop < newTop) + { + if (newFocus.MyParentEditItem != null) + { + if (newFocus.Top > newFocus.MyParentEditItem.Top) + newFocus.MyParentEditItem.AdjustLocation(); + else if (newFocus.MyParentEditItem.MyPreviousEditItem != null && + newFocus.Top > newFocus.MyParentEditItem.MyPreviousEditItem.Top) + newFocus.MyParentEditItem.MyPreviousEditItem.AdjustLocation(); + else if (newFocus.MyParentEditItem.MyParentEditItem != null && + newFocus.Top > newFocus.MyParentEditItem.MyParentEditItem.Top) + newFocus.MyParentEditItem.MyParentEditItem.AdjustLocation(); + else + newFocus.AdjustLocation(); + } + else if (newFocus.MyPreviousEditItem != null) + newFocus.MyPreviousEditItem.AdjustLocation(); + else + newFocus.AdjustLocation(); + } + else + newFocus.AdjustLocation(); + } + else + { + lastEI.SaveContents(); + lastEI.RefreshDisplay(false); + } + } + _SelectedEditItem = value; + if (value != null) + { + _SelectedEditItem.RefreshDisplay(true); + if (_SelectedItemInfo.ItemID != value.MyItemInfo.ItemID) + SelectedItemInfo = value.MyItemInfo; + } + if (lastEI != null) + lastEI.IdentifyMe(false); + } } /// - /// Displays the selected RTBItem + /// Displays the selected EditItem /// public void ItemShow() { - if (_SelectedItemInfo != null && SelectedRTBItem.MyStepRTB.BeingDisposed == false) + if (_SelectedItemInfo != null && SelectedEditItem.BeingDisposed == false) { - SelectedRTBItem.ItemShow(); - OnItemSelectedChanged(this, new ItemSelectedChangedEventArgs(SelectedRTBItem)); + SelectedEditItem.ItemShow(); + OnItemSelectedChanged(this, new ItemSelectedChangedEventArgs(SelectedEditItem)); } } public new void MouseWheel(MouseEventArgs e) @@ -675,18 +677,18 @@ namespace Volian.Controls.Library } } /// - /// Output all of the RTBItem controls to the log + /// Output all of the EditItem controls to the log /// private void ListControls() { // Walk through the controls and find the next control for each if(_MyLog.IsInfoEnabled)_MyLog.InfoFormat("'Item','Next'"); foreach (Control control in Controls) - if (control.GetType() == typeof(RTBItem)) + if (control is EditItem) { - RTBItem rtb = (RTBItem)control; - RTBItem nxt = rtb.NextDownRTBItem; - if(_MyLog.IsInfoEnabled)_MyLog.InfoFormat("{0},{1}", rtb.MyID, nxt == null ? 0 : nxt.MyID); + EditItem ei = (EditItem)control; + EditItem nxt = ei.NextDownEditItem; + if(_MyLog.IsInfoEnabled)_MyLog.InfoFormat("{0},{1}", ei.MyID, nxt == null ? 0 : nxt.MyID); } } #endregion @@ -724,7 +726,7 @@ namespace Volian.Controls.Library /// StepRTB /// Point /// E_ArrowKeys - public void CursorMovement(StepRTB rtb, Point position, E_ArrowKeys arrow) + public void CursorMovement(EditItem ei, Point position, E_ArrowKeys arrow) { ItemInfo ii = null; // The following lines are debug to check that the results of moving down and moving up are the same @@ -733,40 +735,40 @@ namespace Volian.Controls.Library { case E_ArrowKeys.Up: case E_ArrowKeys.CtrlUp: - ii = ArrowUp(rtb.MyItemInfo); + ii = ArrowUp(ei.MyItemInfo); // The following lines are debug to check that the results of moving down and moving up are the same //ix = ArrowDown(ii); //Console.WriteLine("'Up',{0},{1},{2},{3}", rtb.MyItemInfo.ItemID, rtb.MyItemInfo.DBSequence, ii.DBSequence, ix.DBSequence); - if (ii != null) SelectedStepRTB = _LookupRTBItems[ii.ItemID].MyStepRTB; + if (ii != null) SelectedEditItem = _LookupEditItems[ii.ItemID]; break; case E_ArrowKeys.Down: case E_ArrowKeys.CtrlDown: - ii = MoveDown(rtb, ii); + ii = MoveDown(ei, ii); break; case E_ArrowKeys.Right: case E_ArrowKeys.CtrlRight: - if (rtb.MyItemInfo.RNOs != null) - SelectedStepRTB = _LookupRTBItems[rtb.MyItemInfo.RNOs[0].ItemID].MyStepRTB; + if (ei.MyItemInfo.RNOs != null) + SelectedEditItem = _LookupEditItems[ei.MyItemInfo.RNOs[0].ItemID]; else - ii = MoveDown(rtb, ii); + ii = MoveDown(ei, ii); break; case E_ArrowKeys.Left: case E_ArrowKeys.CtrlLeft: - if (!rtb.MyItemInfo.IsProcedure) - SelectedStepRTB = _LookupRTBItems[rtb.MyItemInfo.MyParent.ItemID].MyStepRTB; + if (!ei.MyItemInfo.IsProcedure) + SelectedEditItem = _LookupEditItems[ei.MyItemInfo.MyParent.ItemID]; break; default: break; } } - private ItemInfo MoveDown(StepRTB rtb, ItemInfo ii) + private ItemInfo MoveDown(EditItem ei, ItemInfo ii) { - ii = ArrowDown(rtb.MyItemInfo); + ii = ArrowDown(ei.MyItemInfo); // The following lines are debug to check that the results of moving down and moving up are the same //ix = ArrowUp(ii); //Console.WriteLine("'Down',{0},{1},{2},{3}", rtb.MyItemInfo.ItemID, rtb.MyItemInfo.DBSequence, ii.DBSequence, ix.DBSequence); - if (ii != null) SelectedStepRTB = _LookupRTBItems[ii.ItemID].MyStepRTB; + if (ii != null) SelectedEditItem = _LookupEditItems[ii.ItemID]; return ii; } private ItemInfo ArrowUp(ItemInfo ii) @@ -831,9 +833,9 @@ namespace Volian.Controls.Library } return null; } - internal void StepCursorKeys(StepRTB rtb, KeyEventArgs keyargs) + internal void StepCursorKeys(EditItem ei, KeyEventArgs keyargs) { - ItemInfo ii = rtb.MyItemInfo; + ItemInfo ii = ei.MyItemInfo; if (ii.IsSection || ii.IsProcedure) return; while (!ii.IsHigh) { @@ -857,7 +859,7 @@ namespace Volian.Controls.Library break; } if (ii == null) return; - SelectedStepRTB = _LookupRTBItems[ii.ItemID].MyStepRTB; + SelectedEditItem = _LookupEditItems[ii.ItemID]; } #endregion } @@ -1019,11 +1021,11 @@ namespace Volian.Controls.Library } public partial class StepPanelEventArgs { - private RTBItem _MyRTBItem; - public RTBItem MyRTBItem + private EditItem _MyEditItem; + public EditItem MyEditItem { - get { return _MyRTBItem; } - set { _MyRTBItem = value; } + get { return _MyEditItem; } + set { _MyEditItem = value; } } private MouseEventArgs _MyMouseEventArgs; public MouseEventArgs MyMouseEventArgs @@ -1032,9 +1034,9 @@ namespace Volian.Controls.Library set { _MyMouseEventArgs = value; } } - public StepPanelEventArgs(RTBItem myRTBItem, MouseEventArgs myMouseEventArgs) + public StepPanelEventArgs(EditItem myEditItem, MouseEventArgs myMouseEventArgs) { - _MyRTBItem = myRTBItem; + _MyEditItem = myEditItem; _MyMouseEventArgs = myMouseEventArgs; } } @@ -1046,45 +1048,44 @@ namespace Volian.Controls.Library get { return _MyItemInfo; } set { _MyItemInfo = value; } } - private RTBItem _MyRTBItem = null; - public RTBItem MyRTBItem + private EditItem _MyEditItem = null; + public EditItem MyEditItem { - get { return _MyRTBItem; } - set { _MyRTBItem = value; } + get { return _MyEditItem; } + set { _MyEditItem = value; } } public ItemSelectedChangedEventArgs(ItemInfo myItemInfo) { _MyItemInfo = myItemInfo; } - public ItemSelectedChangedEventArgs(RTBItem myRTBItem) + public ItemSelectedChangedEventArgs(EditItem myEditItem) { - _MyItemInfo = myRTBItem.MyItemInfo; - _MyRTBItem = myRTBItem; + _MyItemInfo = myEditItem.MyItemInfo; + _MyEditItem = myEditItem; } } public partial class StepPanelAttachmentEventArgs { - private RTBItem _MyRTBItem; - public RTBItem MyRTBItem + private EditItem _MyEditItem; + public EditItem MyEditItem { - get { return _MyRTBItem; } - set { _MyRTBItem = value; } + get { return _MyEditItem; } + set { _MyEditItem = value; } } - public StepPanelAttachmentEventArgs(RTBItem myRTBItem) + public StepPanelAttachmentEventArgs(EditItem myEditItem) { - _MyRTBItem = myRTBItem; + _MyEditItem = myEditItem; } } public partial class StepPanelLinkEventArgs : EventArgs { private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); - private RTBItem _LinkedRTBItem; - public RTBItem LinkedRTBItem - { - get { return _LinkedRTBItem; } - //set { _LinkedRTBItem = value; } - } + //private EditItem _LinkedEditItem; + //public EditItem LinkedEditItem + //{ + // get { return _LinkedEditItem; } + //} private string _LinkInfoText; public string LinkInfoText { @@ -1095,9 +1096,9 @@ namespace Volian.Controls.Library { get { return _MyLinkText;} } - public StepPanelLinkEventArgs(RTBItem linkedRTBItem, string linkInfoText) + public StepPanelLinkEventArgs(string linkInfoText) { - _LinkedRTBItem = linkedRTBItem; + //_LinkedEditItem = linkedEditItem; _LinkInfoText = linkInfoText; _MyLinkText = new LinkText(_LinkInfoText); //if(_MyLog.IsInfoEnabled)_MyLog.InfoFormat("\r\n LinkInfo '{0}'\r\n", linkInfo.LinkText); diff --git a/PROMS/Volian.Controls.Library/StepPanel.designer.cs b/PROMS/Volian.Controls.Library/StepPanel.designer.cs index 2db7896c..50e571c1 100644 --- a/PROMS/Volian.Controls.Library/StepPanel.designer.cs +++ b/PROMS/Volian.Controls.Library/StepPanel.designer.cs @@ -15,11 +15,11 @@ namespace Volian.Controls.Library { if (disposing && (components != null)) { - SelectedStepRTB = null; // Save Changes - foreach (RTBItem RTBItem in _LookupRTBItems.Values) + SelectedEditItem = null; // Save Changes + foreach (EditItem EditItem in _LookupEditItems.Values) { - RTBItem.MyItemInfo.ResetParts(); - RTBItem.MyItemInfo.MyContent.RefreshContentParts(); + EditItem.MyItemInfo.ResetParts(); + EditItem.MyItemInfo.MyContent.RefreshContentParts(); } components.Dispose(); } diff --git a/PROMS/Volian.Controls.Library/StepRTB.cs b/PROMS/Volian.Controls.Library/StepRTB.cs index 8f8d74d5..9b341e8a 100644 --- a/PROMS/Volian.Controls.Library/StepRTB.cs +++ b/PROMS/Volian.Controls.Library/StepRTB.cs @@ -17,10 +17,82 @@ namespace Volian.Controls.Library public delegate void StepRTBCursorKeysEvent(object sender, KeyEventArgs args); public delegate void StepRTBCursorMovementEvent(object sender, StepRTBCursorMovementEventArgs args); public delegate void StepRTBModeChangeEvent(object sender, StepRTBModeChangeEventArgs args); + public delegate void StepRTBMenuEvent(object sender, StepRTBMenuEventArgs args); + public delegate void StepRTBTableWidthEvent(object sender, StepRTBTableWidthEventArgs args); + public delegate bool StepRTBBooleanEvent(object sender, EventArgs args); + public delegate void StepRTBLocationEvent(object sender, StepRTBLocationEventArgs args); + public delegate void StepRTBMouseEvent(object sender, MouseEventArgs args); //public delegate void StepRTBMouseWheelEvent(object sender, MouseEventArgs args); - public partial class StepRTB : RichTextBox , IStepRTB + public partial class StepRTB : RichTextBox // , IStepRTB { #region Events + public event StepRTBEvent ReturnToEditor; + public void OnReturnToEditor(object sender, EventArgs args) + { + if (ReturnToEditor != null) ReturnToEditor(sender, args); + } + public event StepRTBEvent EditModeChanged; + public void OnEditModeChanged(object sender, EventArgs args) + { + if (EditModeChanged != null) EditModeChanged(sender, args); + } + public event StepRTBEvent DoSaveContents; + public void OnDoSaveContents(object sender, EventArgs args) + { + if (DoSaveContents != null) DoSaveContents(sender, args); + } + public event StepRTBMouseEvent DoMouseWheel; + public void OnDoMouseWheel(object sender, MouseEventArgs args) + { + if (DoMouseWheel != null) DoMouseWheel(sender, args); + } + public event StepRTBLocationEvent OpenContextMenu; + public void OnOpenContextMenu(object sender, StepRTBLocationEventArgs args) + { + if (OpenContextMenu != null) OpenContextMenu(sender, args); + } + public event StepRTBEvent CopyStep; + public void OnCopyStep(object sender, EventArgs args) + { + if (CopyStep != null) CopyStep(sender, args); + } + public event StepRTBBooleanEvent CheckClipboard; + public bool OnCheckClipboard(object sender, EventArgs args) + { + if (CheckClipboard != null) return CheckClipboard(sender, args); + return false; + } + public event StepRTBCursorKeysEvent EnterKeyPressed; + public void OnEnterKeyPressed(object sender, KeyEventArgs args) + { + if (EnterKeyPressed != null) EnterKeyPressed(sender, args); + } + public event StepRTBEvent InsertPgBrk; + public void OnInsertPgBrk(object sender, EventArgs args) + { + if (InsertPgBrk != null) InsertPgBrk(sender, args); + } + public event StepRTBEvent OpenAnnotations; + public void OnOpenAnnotations(object sender, EventArgs args) + { + if (OpenAnnotations != null) OpenAnnotations(sender, args); + } + public event StepRTBBooleanEvent IsNotCurrentSelection; + public bool OnIsNotCurrentSelection(object sender, EventArgs args) + { + if (IsNotCurrentSelection != null) return IsNotCurrentSelection(sender, args); + return false; + } + public event StepRTBTableWidthEvent AdjustTableWidth; + public void OnAdjustTableWidth(object sender, StepRTBTableWidthEventArgs args) + { + if (AdjustTableWidth != null) AdjustTableWidth(sender, args); + } + public event StepRTBMenuEvent SetMenu; + private void OnSetMenu(object sender, StepRTBMenuEventArgs args) + { + if (SetMenu != null) SetMenu(sender, args); + } public event StepRTBEvent RTBSelectionChanged; private void OnRTBSelectionChanged(object sender, EventArgs args) { @@ -46,13 +118,13 @@ namespace Volian.Controls.Library { if (CursorMovement != null) CursorMovement(sender, args); } - public event StepRTBModeChangeEvent ModeChange; - private void OnModeChange(object sender, StepRTBModeChangeEventArgs args) - { - //_MyModeChangeEventArgs = args; - if (ModeChange != null) ModeChange(sender, args); - else MessageBox.Show("StepRTB - no mode change defined"); - } + //public event StepRTBModeChangeEvent ModeChange; + //private void OnModeChange(object sender, StepRTBModeChangeEventArgs args) + //{ + // //_MyModeChangeEventArgs = args; + // if (ModeChange != null) ModeChange(sender, args); + // else MessageBox.Show("StepRTB - no mode change defined"); + //} //public event StepRTBMouseWheelEvent MouseWheel; //private void OnMouseWheel(object sender, MouseEventArgs args) //{ @@ -69,6 +141,19 @@ namespace Volian.Controls.Library } #endregion #region Properties and Variables + private bool _EditMode = true; + /// + /// Allows insert of links. If false, don't allow selection of links. + /// + public bool EditMode + { + get { return _EditMode; } + set + { + _EditMode = value; + OnEditModeChanged(this, new EventArgs()); + } + } private static FontFamily _MyFontFamily = null; public static FontFamily MyFontFamily { @@ -103,15 +188,15 @@ namespace Volian.Controls.Library { get { - return _RtfPrefix + @"\f1\fs" + this.Font.SizeInPoints * 2 + " "; + if (_RtfPrefix == null) + { + StringBuilder selectedRtfSB = new StringBuilder(); + AddFontTable(selectedRtfSB, FormatFont, FontIsFixed(FormatFont)); + _RtfPrefix = selectedRtfSB.ToString(); + } + return _RtfPrefix + @"\f1\fs" + FormatFont.SizeInPoints * 2 + " "; } } - private RTBItem _MyRTBItem; - public RTBItem MyRTBItem - { - get { return _MyRTBItem; } - set { _MyRTBItem = value; } - } // August 5, 2009 - KBR & RHM: // Insert/Overwrite will be developed later if needed. various issues // were found during initial development that made its scope larger than @@ -124,9 +209,9 @@ namespace Volian.Controls.Library // private bool _OverWrite; // _IsDirty compares the original rtf to the current rtf from the // richtextbox to see if a change was made. - private bool _IsDirty + public bool IsDirty { - get { return _origRTF != Rtf; } + get { return OrigRTF != Rtf; } } private bool _InitializingRTB; private IContainer _Container = null; @@ -136,12 +221,14 @@ namespace Volian.Controls.Library get { if (_MyClassName == string.Empty)_MyClassName = CreateParams.ClassName; return _MyClassName; } set { _MyClassName = value; } } - private E_EditPrintMode _epMode = E_EditPrintMode.Edit; - public E_EditPrintMode EpMode - { - get { return _epMode; } - set { _epMode = value; } - } + //private E_EditPrintMode _epMode = E_EditPrintMode.Edit; + //public E_EditPrintMode EpMode + //{ + // get { return _epMode; } + // set { + // if (value == E_EditPrintMode.Print) Console.WriteLine(""); + // _epMode = value; } + //} private E_ViewMode _vwMode = E_ViewMode.Edit; public E_ViewMode VwMode { @@ -151,76 +238,73 @@ namespace Volian.Controls.Library private VE_Font _MyStyleFont; public VE_Font MyStyleFont { - get { return _origDisplayText.TextFont; } + get + { + if (_MyStyleFont == null) _MyStyleFont = MyItemInfo.GetItemFont(); + return _MyStyleFont; + } + } + private bool _ActiveMode = false; + public bool ActiveMode + { + get { return _ActiveMode; } + set { _ActiveMode = value; } } - public bool ViewRTB = true; private ItemInfo _MyItemInfo; public ItemInfo MyItemInfo { get { return _MyItemInfo; } - set + set { _MyItemInfo = value; } + } + private string _OrigRTF; + public string OrigRTF + { + get { return _OrigRTF; } + set { _OrigRTF = value; } + } + private Font _FormatFont; + public Font FormatFont + { + get { - _MyItemInfo = value; - if (value != null) + if (_FormatFont == null) { - RTBFillIn(!ViewRTB); - SetBackColor(); - //ViewRTB = MyRTBItem.MyStepPanel.PanelViewEditMode == E_ViewMode.View; + Font formatFont = MyItemInfo.GetItemFont().WindowsFont; // OrigDisplayText.TextFont.WindowsFont; + if (MyItemInfo.IsTable || MyItemInfo.IsFigure) + _FormatFont = formatFont; + else + { + if (VlnSettings.DebugMode || VlnSettings.ProductionMode) + _FormatFont = new Font(_MyFontFamily == null ? formatFont.FontFamily : _MyFontFamily, formatFont.Size, formatFont.Style); + else + _FormatFont = new Font("Bookman Old Style", formatFont.Size, formatFont.Style); + // TODO: Release Mode + //Font = _origDisplayText.TextFont.WindowsFont; // font defined in plant's format + } } + return _FormatFont; } } - public void SetBackColor() + public void RefreshDisplay() { - if (MyRTBItem == null || MyRTBItem.MyStepPanel == null) return; - if (Focused) // If active Set BackColor to the active color - BackColor = MyRTBItem.MyStepPanel.ActiveColor; - else // Otherwise Set the BackColor to either the InactiveColor or the AnnotationColor - BackColor = _MyItemInfo.ItemAnnotationCount == 0 ? MyRTBItem.MyStepPanel.InactiveColor : MyRTBItem.MyStepPanel.AnnotationColor; + RefreshDisplay(ActiveMode); } - public void HighlightBackColor() + // RefreshDisplay is used to update the rtb for an entire Item as defined by MyItemInfo. + public void RefreshDisplay(bool activeMode) { - // Don't try to highlight if this rtb is used on property pages. - if (MyRTBItem == null || MyRTBItem.MyStepPanel == null) return; - BackColor = Color.Gray; - } - private string _origRTF; - public void RTBFillIn(bool edit) - { - if (edit && _MyRTBItem != null && (_MyItemInfo.IsTable || _MyItemInfo.IsFigure)) - { - // First get ColR - int colR = MyRTBItem.MyStepPanel.ToDisplay(MyRTBItem.MyStepSectionLayoutData.ColRTable, MyItemInfo.ColumnMode); - // Second get WidS - int widS = /* _WidthAdjust + borderWidth + */ MyRTBItem.MyStepPanel.ToDisplay(MyRTBItem.MyStepSectionLayoutData.WidSTableEdit, MyItemInfo.ColumnMode); - //int wNew = _MyRTBItem.MyStepPanel.ToDisplay(_MyRTBItem.MyStepSectionLayoutData.WidT); - int wNew = 70 + widS + colR * MyItemInfo.ColumnMode; - if (wNew > _MyRTBItem.ItemWidth) - { - _MyRTBItem.ItemWidth = wNew; - _MyRTBItem.ItemLocation = _MyRTBItem.TableLocation(_MyRTBItem.MyParentRTBItem, _MyRTBItem.MyStepSectionLayoutData, wNew); - } - } + ActiveMode = activeMode; + OnAdjustTableWidth(this, new StepRTBTableWidthEventArgs(true)); _InitializingRTB = true; - DisplayText vlntxt = new DisplayText(_MyItemInfo, EpMode, VwMode, !edit, FieldToEdit, true); + DisplayText vlntxt = new DisplayText(MyItemInfo, E_EditPrintMode.Edit, VwMode, !ActiveMode, FieldToEdit, true); //if (_origDisplayText != null && vlntxt.StartText == _origDisplayText.StartText) //{ // ReadOnly = !(EpMode == E_EditPrintMode.Edit && VwMode == E_ViewMode.Edit); // if (!ReadOnly && !edit) ReadOnly = true; // return; //} - _origDisplayText = vlntxt; - Font formatFont = _origDisplayText.TextFont.WindowsFont; - if (_MyItemInfo.IsTable || _MyItemInfo.IsFigure) - Font = formatFont; - else - { - if (VlnSettings.DebugMode || VlnSettings.ProductionMode) - Font = new Font(_MyFontFamily == null ? formatFont.FontFamily : _MyFontFamily, formatFont.Size, formatFont.Style); - else - Font = new Font("Bookman Old Style", formatFont.Size, formatFont.Style); - // TODO: Release Mode - //Font = _origDisplayText.TextFont.WindowsFont; // font defined in plant's format - } + OrigDisplayText = vlntxt; + + // RHM 20101201 - Don't reset the text. Calculate the text and compare it with the existing text in AddRTFText //Text = ""; // Initialize text before add text // IMPORTANT: SetLineSpacing must be set before Links, otherwise it @@ -228,7 +312,7 @@ namespace Volian.Controls.Library //Console.WriteLine("'font',{0}", Font); //if(Text == "")SelectionFont = Font; // Initialize SelectionFont RTBAPI.SetLineSpacing(this, RTBAPI.ParaSpacing.PFS_EXACT); - ReadOnly = EpMode == E_EditPrintMode.Print || VwMode == E_ViewMode.View || edit == false; + ReadOnly = VwMode == E_ViewMode.View || ActiveMode == false; AddRtfText(vlntxt.StartText); //AddRtfStyles(); // set readonly based on initial modes, however, these may change if @@ -252,23 +336,14 @@ namespace Volian.Controls.Library // the text within the RichTextBox. RightMargin = Width > 0 ? Width - 1 : 0; // figure out if needs outlined, depends on table/figure type - if (!edit) + if (!ActiveMode) { RemoveEventHandlers(); - if ((!_MyItemInfo.IsSection && !_MyItemInfo.IsProcedure) && (_MyItemInfo.IsTable || _MyItemInfo.IsFigure)) - { - int newwidth = (int)_MyRTBItem.TableWidth(Font, Text, false); - if (_MyRTBItem.ItemWidth != newwidth) - { - _MyRTBItem.ItemWidth = newwidth; - _MyRTBItem.ItemLocation = _MyRTBItem.TableLocation(_MyRTBItem.MyParentRTBItem, _MyRTBItem.MyStepSectionLayoutData, newwidth); - - } - } + OnAdjustTableWidth(this, new StepRTBTableWidthEventArgs(false));// View Mode SelectAll(); if (SelectionHangingIndent !=0) SelectionHangingIndent = 0; int indchar = 0; - string indentToken = _MyItemInfo.ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.IndentToken; + string indentToken = MyItemInfo.ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.IndentToken; if (indentToken == null) indentToken = "\x5"; while ((indchar = Find(indentToken, indchar, RichTextBoxFinds.None)) >= 0) { @@ -280,17 +355,16 @@ namespace Volian.Controls.Library } //else //{ - // if (_MyRTBItem != null && (_MyItemInfo.IsTable || _MyItemInfo.IsFigure)) + // if (MyRTBItem != null && (_MyItemInfo.IsTable || _MyItemInfo.IsFigure)) // { - // //_MyRTBItem.ItemWidth = (int)_MyRTBItem.TableWidth(Font, Text,false); - // _MyRTBItem.ItemWidth = _MyRTBItem.MyStepPanel.ToDisplay(_MyRTBItem.MyStepSectionLayoutData.WidT); + // //MyRTBItem.ItemWidth = (int)MyRTBItem.TableWidth(Font, Text,false); + // MyRTBItem.ItemWidth = MyRTBItem.MyStepPanel.ToDisplay(MyRTBItem.MyStepSectionLayoutData.WidT); // } //} - _origRTF = Rtf; + OrigRTF = Rtf; _InitializingRTB = false; - _MyItemInfo.MyConfig.PropertyChanged += new PropertyChangedEventHandler(MyConfig_PropertyChanged); - AdjustSizeForContents(!edit); // TODO: this is not quite right yet. - if (MyRTBItem != null) MyRTBItem.ChangeBar = MyRTBItem.MyItemInfo.HasChangeBar; + + AdjustSizeForContents(!ActiveMode); // TODO: this is not quite right yet. } private bool _ProcessKeystrokes = true; public bool ProcessKeystrokes @@ -352,7 +426,13 @@ namespace Volian.Controls.Library } } public System.Windows.Forms.AutoScaleMode AutoScaleMode; - private DisplayText _origDisplayText; + private DisplayText _OrigDisplayText; + + public DisplayText OrigDisplayText + { + get { return _OrigDisplayText; } + set { _OrigDisplayText = value; } + } private RichTextBox _rtbTemp = new RichTextBox(); private string _MyLinkText; public string MyLinkText @@ -365,7 +445,7 @@ namespace Volian.Controls.Library // updates to the info panel were not always occurring when the previous two // lines were active _MyLinkText = value; - OnLinkChanged(this, new StepPanelLinkEventArgs(_MyRTBItem, _MyLinkText)); + OnLinkChanged(this, new StepPanelLinkEventArgs(_MyLinkText)); //} } } @@ -387,7 +467,8 @@ namespace Volian.Controls.Library } protected override void OnMouseWheel(MouseEventArgs e) { - _MyRTBItem.MyStepPanel.MouseWheel(e); + OnDoMouseWheel(this, e); + //MyRTBItem.MyStepPanel.MouseWheel(e); //base.OnMouseWheel(e); } private void RemoveEventHandlers() @@ -435,7 +516,7 @@ namespace Volian.Controls.Library try { //Console.WriteLine("{0}", ContextMenuStrip.GetType().FullName); - this.MyRTBItem.MyStepPanel.MyStepTabPanel.MyStepTabRibbon.ClearContextMenu(); + OnSetMenu(this, new StepRTBMenuEventArgs(null)); sublocation = 1; _ContextMenuStripChanged = true; sublocation = 2; @@ -465,10 +546,10 @@ namespace Volian.Controls.Library { _MouseDown = false; } - void MyConfig_PropertyChanged(object sender, PropertyChangedEventArgs e) - { - SaveConfig(); - } + //void MyConfig_PropertyChanged(object sender, PropertyChangedEventArgs e) + //{ + // SaveConfig(); + //} private void StepRTB_Click(object sender, EventArgs e) { if (ReadOnly) return; @@ -486,8 +567,8 @@ namespace Volian.Controls.Library { _MouseDown = true; //Console.WriteLine("vvvvvvvvvv StepRTB Mouse Down id= {0}",MyItemInfo.ItemID); - if (!_ContextMenuStripChanged && this.MyRTBItem != null) - this.MyRTBItem.MyStepPanel.MyStepTabPanel.MyStepTabRibbon.SetContextMenu(); + if (!_ContextMenuStripChanged) + OnSetMenu(this, new StepRTBMenuEventArgs("OpenContextMenu")); _ContextMenuStripChanged = false; CorrectSelectionAtEndOfLine(); } @@ -505,22 +586,24 @@ namespace Volian.Controls.Library } #endregion #region ApplicationSupport - public void ToggleEditView() - { - SaveText(); - //ItemInfo tmp = MyItemInfo; - //MyItemInfo = null; - ReadOnly = !ReadOnly; - EpMode = ReadOnly ? E_EditPrintMode.Print : E_EditPrintMode.Edit; - VwMode = ReadOnly ? E_ViewMode.View : E_ViewMode.Edit; - ViewRTB = ReadOnly; - Clear(); - RTBFillIn(!ViewRTB); - //MyItemInfo = tmp; - SelectionStart = 0; - SelectionLength = 0; - OnModeChange(this, new StepRTBModeChangeEventArgs(ViewRTB?E_ViewMode.View:E_ViewMode.Edit)); - } + // Used in StepTabRibbon: + //public void ToggleEditView(E_ViewMode vwMode) + //{ + // OnDoSaveContents(this, new EventArgs()); // SaveText(); + // //ItemInfo tmp = MyItemInfo; + // //MyItemInfo = null; + // //ReadOnly = !ReadOnly; + // //EpMode = ReadOnly ? E_EditPrintMode.Print : E_EditPrintMode.Edit; + // VwMode = vwMode; + // ReadOnly = VwMode == E_ViewMode.View; + // ViewRTB = ReadOnly; + // Clear(); + // RefreshDisplay(!ViewRTB); + // //MyItemInfo = tmp; + // SelectionStart = 0; + // SelectionLength = 0; + // //OnModeChange(this, new StepRTBModeChangeEventArgs(ViewRTB?E_ViewMode.View:E_ViewMode.Edit)); + //} public void InsertRO(string value, string link) { AddRtfLink(value, link); @@ -541,9 +624,8 @@ namespace Volian.Controls.Library { AddSymbol(symbol); } - public void InsertIndent() + public void InsertIndent(string indentToken) { - string indentToken = _MyItemInfo.ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.IndentToken; if (indentToken == null) indentToken = "\x5"; AddText(indentToken); } @@ -675,44 +757,6 @@ namespace Volian.Controls.Library SelectionLength = olen; } #endregion - #region SaveData - public void SaveText(bool force) - { - if (ReadOnly) return; - if (ViewRTB) return; - if (!force && !_IsDirty && Text.Contains("(Resolved Transition Text)") == false) return; - bool success = _origDisplayText.Save((RichTextBox)this); - if (success) - { - FindAllLinks(); - _origRTF = Rtf; - ClearUndo(); - } - } - public void SaveText() - { - if (ReadOnly) return; - if (ViewRTB) return; - if (!_IsDirty && Text.Contains("(Resolved Transition Text)") == false) return; - bool success = _origDisplayText.Save((RichTextBox)this); - if (success) - { - FindAllLinks(); - _origRTF = Rtf; - ClearUndo(); - } - } - public void SaveConfig() - { - if (!_MyItemInfo.MyConfig.IsDirty) return; - using (Item itm = _MyItemInfo.Get()) - { - itm.MyContent.Config = _MyItemInfo.MyConfig.ToString(); - itm.Save(); - } - _MyItemInfo.MyConfig.IsDirty = false; - } - #endregion #region AddRtfTextAndStyles private string _LastRtf = ""; private bool _lastReadOnly = false; @@ -722,7 +766,7 @@ namespace Volian.Controls.Library //if(MyItemInfo.ItemID==10256) // Volian.Base.Library.vlnStackTrace.ShowStackLocal("ItemID:{0}", MyItemInfo.ItemID.ToString()); StringBuilder selectedRtfSB = new StringBuilder(); - AddFontTable(selectedRtfSB); + AddFontTable(selectedRtfSB, FormatFont, FontIsFixed(FormatFont)); _RtfPrefix = selectedRtfSB.ToString(); selectedRtfSB.Append(txt); string newRtf = selectedRtfSB.ToString() + "}"; @@ -737,40 +781,40 @@ namespace Volian.Controls.Library } FindAllLinks(); } - private void AddFontTable(StringBuilder selectedRtfSB) + private static void AddFontTable(StringBuilder selectedRtfSB, Font myFont, bool isFixed) { StringBuilder sbbeg = new StringBuilder(); StringBuilder sbend = new StringBuilder(); - if (Font.Bold) + if (myFont.Bold) { sbbeg.Append(@"\b"); sbend.Append(@"\b0"); } - if (Font.Underline) + if (myFont.Underline) { sbbeg.Append(@"\ul"); sbend.Insert(0, @"\ulnone"); } - if (Font.Italic) + if (myFont.Italic) { sbbeg.Append(@"\i"); sbend.Insert(0, @"\i0"); } - selectedRtfSB.Append(@"{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fnil\fcharset2 " + this.Font.FontFamily.Name + @";}"); //}\f0\fs" + this.Font.SizeInPoints * 2 + @" " + myDisplayTextElement.Text + @"}}"; - if (!FontIsFixed()) + selectedRtfSB.Append(@"{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fnil\fcharset2 " + myFont.FontFamily.Name + @";}"); //}\f0\fs" + this.Font.SizeInPoints * 2 + @" " + myDisplayTextElement.Text + @"}}"; + if (!isFixed) selectedRtfSB.Append(@"{\f1\fnil\fcharset0 Arial Unicode MS;}}{\colortbl ;\red255\green0\blue0;}"); else selectedRtfSB.Append(@"{\f1\fnil\fcharset0 VESymbFix;}}{\colortbl ;\red255\green0\blue0;}"); selectedRtfSB.Append("\r\n"); // use styles to construct rtf commands to insert into next line (where \b, etc is) - selectedRtfSB.Append(@"\viewkind4\uc1\pard\sl-240\slmult0" + sbbeg.ToString() + @"\fs" + Convert.ToInt32(this.Font.SizeInPoints * 2).ToString() + @" "); // \f0\fs" + this.Font.SizeInPoints * 2 + @" " + myDisplayTextElement.Text + @"}"; + selectedRtfSB.Append(@"\viewkind4\uc1\pard\sl-240\slmult0" + sbbeg.ToString() + @"\fs" + Convert.ToInt32(myFont.SizeInPoints * 2).ToString() + @" "); // \f0\fs" + this.Font.SizeInPoints * 2 + @" " + myDisplayTextElement.Text + @"}"; } - private bool FontIsFixed() + private bool FontIsFixed(Font myFont) { Graphics grph = Graphics.FromHwnd(this.Handle); - SizeF sfW = grph.MeasureString("W", this.Font); - SizeF sfE = grph.MeasureString("!", this.Font); + SizeF sfW = grph.MeasureString("W", myFont); + SizeF sfE = grph.MeasureString("!", myFont); if (sfW.Width == sfE.Width) return true; return false; } @@ -805,11 +849,11 @@ namespace Volian.Controls.Library // See comments in AddRtf(string str) to explain the font style setting RTBAPI.E_FontStyle fs = RTBAPI.GetFontStyle(this); int position = SelectionStart; - SelectedRtf = _RtfPrefix + @"\f1\fs" + this.Font.SizeInPoints * 2 + @" " + str + @"}"; + SelectedRtf = RtfPrefix + str + @"}"; Select(position, 1); RTBAPI.SetFontStyle(this, fs); Select(position + 1, 0); - SelectionFont = _origDisplayText.TextFont.WindowsFont; + SelectionFont = MyItemInfo.GetItemFont().WindowsFont; } private string GetAddSymbolText(string symtxt) { @@ -828,8 +872,8 @@ namespace Volian.Controls.Library get { StringBuilder sb = new StringBuilder(); - sb.Append(@"{\fonttbl{\f0\fnil\fcharset2 " + this.Font.FontFamily.Name + @";}"); - if (!FontIsFixed()) + sb.Append(@"{\fonttbl{\f0\fnil\fcharset2 " + this.Font.FontFamily.Name + @";}"); + if (!FontIsFixed(this.Font)) sb.Append(@"{\f1\fnil\fcharset0 Arial Unicode MS;}}"); else sb.Append(@"{\f1\fnil\fcharset0 VESymbFix;}}"); @@ -850,14 +894,11 @@ namespace Volian.Controls.Library string fonttab = FontTable; string fontsize = FontSize; this.DetectUrls = false; - //if (SelectionLength > 0) DeleteCurrentSelection(null); if (SelectionLength > 0)HandleDeleteKeyWithSelectedText(new KeyEventArgs(Keys.None), null); int position = SelectionStart; SelectionLength = 0; - //Console.WriteLine(this.Rtf); linkValue = linkValue.Replace("\\u8209?", "\\f1\\u8209?\\f0 "); SelectedRtf = @"{\rtf1\ansi"+FontTable+@"{\colortbl ;\red255\green0\blue0;}\v"+FontSize+@" \v0 }"; - //Console.WriteLine(this.Rtf); this.SelectionLength = 0; this.SelectionStart = position; FindAllLinks(); @@ -873,7 +914,7 @@ namespace Volian.Controls.Library } private void AddRtfStyles() { - if ((_origDisplayText.TextFont.Style & E_Style.Bold) > 0) + if ((OrigDisplayText.TextFont.Style & E_Style.Bold) > 0) { this.SelectAll(); RTBAPI.ToggleBold(true, this, RTBAPI.RTBSelection.SCF_SELECTION); @@ -884,7 +925,7 @@ namespace Volian.Controls.Library // apply the underlining to the selected text, because if the // the underlining was applied to RTBAPI.RTBSelection.SCF_ALL // the Links were changed so that they were no longer hidden. - if ((_origDisplayText.TextFont.Style & E_Style.Underline) > 0) + if ((OrigDisplayText.TextFont.Style & E_Style.Underline) > 0) // RTBAPI.ToggleUnderline(true, this, RTBAPI.RTBSelection.SCF_ALL); { this.SelectAll(); @@ -896,7 +937,7 @@ namespace Volian.Controls.Library // apply the italics to the selected text, because if the // the italics was applied to RTBAPI.RTBSelection.SCF_ALL // the Links were changed so that they were no longer hidden. - if ((_origDisplayText.TextFont.Style & E_Style.Italics) > 0) + if ((OrigDisplayText.TextFont.Style & E_Style.Italics) > 0) // RTBAPI.ToggleItalic(true, this, RTBAPI.RTBSelection.SCF_ALL); { this.SelectAll(); @@ -1027,22 +1068,22 @@ namespace Volian.Controls.Library } #endregion #region ColorSupport - Not currently used. - private void SetBackGroundColor(ItemInfo itemInfo) - { - string backcolor = null; - int type = (int)itemInfo.MyContent.Type; - FormatInfo formatinfo = itemInfo.ActiveFormat; - if (type == (int)E_FromType.Procedure) - backcolor = formatinfo.PlantFormat.FormatData.ProcData.BackColor; - else if (type == (int)E_FromType.Section) - backcolor = formatinfo.PlantFormat.FormatData.SectData.BackColor; - else - { - int typindx = (int)itemInfo.MyContent.Type - 20000; // what to do for other types rather than steps - backcolor = formatinfo.PlantFormat.FormatData.StepDataList[typindx].StepLayoutData.BackColor; - } - BackColor = Color.FromName(backcolor); - } + //private void SetBackGroundColor(ItemInfo itemInfo) + //{ + // string backcolor = null; + // int type = (int)itemInfo.MyContent.Type; + // FormatInfo formatinfo = itemInfo.ActiveFormat; + // if (type == (int)E_FromType.Procedure) + // backcolor = formatinfo.PlantFormat.FormatData.ProcData.BackColor; + // else if (type == (int)E_FromType.Section) + // backcolor = formatinfo.PlantFormat.FormatData.SectData.BackColor; + // else + // { + // int typindx = (int)itemInfo.MyContent.Type - 20000; // what to do for other types rather than steps + // backcolor = formatinfo.PlantFormat.FormatData.StepDataList[typindx].StepLayoutData.BackColor; + // } + // BackColor = Color.FromName(backcolor); + //} #endregion #region EventSupport #region LinkEvents @@ -1093,7 +1134,8 @@ namespace Volian.Controls.Library private bool _HandlingCtrlA = false; private void HandleLocalSelectionChange() { - if (MyRTBItem != null && MyRTBItem.MyStepPanel.SelectedStepRTB != this) + //if (MyRTBItem != null && MyRTBItem.MyStepPanel.SelectedStepRTB != this) + if (OnIsNotCurrentSelection(this, new EventArgs())) return; HandleSelectionChange(); @@ -1339,9 +1381,10 @@ namespace Volian.Controls.Library public bool WasXDelete = false; private void DeleteCurrentSelection(string keys) { + DebugPrint("vvvvvvvvvvvvxxxxxxxxxxxx>"); DebugSelection("Before X"); - + DebugPrint(keys == null ? "NULL" : "NOT NULL"); SelectedText = keys==null?"X":keys; // replace text with X WasXDelete = (keys == null); DebugSelection("After X"); @@ -1418,53 +1461,50 @@ namespace Volian.Controls.Library { if (e.Control) { - if (this.MyRTBItem != null) + if (e.Alt) { - if (e.Alt) + switch (e.KeyCode) { - switch (e.KeyCode) - { - case Keys.M: - this.MyRTBItem.MyStepPanel.MyStepTabPanel.MyStepTabRibbon.btnAnnots_Click(sender, e); - e.Handled = true; - break; - default: - break; - } + case Keys.M: + OnOpenAnnotations(this, new EventArgs()); + e.Handled = true; + break; + default: + break; } - if (e.Shift) + } + if (e.Shift) + { + switch (e.KeyCode) { - switch (e.KeyCode) - { - case Keys.F: - this.MyRTBItem.MyStepPanel.MyStepTabPanel.MyStepTabRibbon.ShortCutContextMenu("InsFigure"); - e.Handled = true; - break; - case Keys.T: - this.MyRTBItem.MyStepPanel.MyStepTabPanel.MyStepTabRibbon.ShortCutContextMenu("InsTable"); - e.Handled = true; - break; - case Keys.N: - this.MyRTBItem.MyStepPanel.MyStepTabPanel.MyStepTabRibbon.ShortCutContextMenu("InsNote"); - e.Handled = true; - break; - case Keys.C: - this.MyRTBItem.MyStepPanel.MyStepTabPanel.MyStepTabRibbon.ShortCutContextMenu("InsCaution"); - e.Handled = true; - break; - case Keys.S: - this.MyRTBItem.MyStepPanel.MyStepTabPanel.MyStepTabRibbon.ShortCutContextMenu("InsSubStps"); - e.Handled = true; - break; - case Keys.H: - this.MyRTBItem.MyStepPanel.MyStepTabPanel.MyStepTabRibbon.ShortCutContextMenu("InsHLS"); - e.Handled = true; - break; - case Keys.R: - this.MyRTBItem.MyStepPanel.MyStepTabPanel.MyStepTabRibbon.ShortCutContextMenu("InsRNO"); - e.Handled = true; - break; - } + case Keys.F: + OnSetMenu(this, new StepRTBMenuEventArgs("InsFigure")); + e.Handled = true; + break; + case Keys.T: + OnSetMenu(this, new StepRTBMenuEventArgs("InsTable")); + e.Handled = true; + break; + case Keys.N: + OnSetMenu(this, new StepRTBMenuEventArgs("InsNote")); + e.Handled = true; + break; + case Keys.C: + OnSetMenu(this, new StepRTBMenuEventArgs("InsCaution")); + e.Handled = true; + break; + case Keys.S: + OnSetMenu(this, new StepRTBMenuEventArgs("InsSubStps")); + e.Handled = true; + break; + case Keys.H: + OnSetMenu(this, new StepRTBMenuEventArgs("InsHLS")); + e.Handled = true; + break; + case Keys.R: + OnSetMenu(this, new StepRTBMenuEventArgs("InsRNO")); + e.Handled = true; + break; } } } @@ -1567,11 +1607,8 @@ namespace Volian.Controls.Library e.Handled = true; break; case Keys.Enter: - if (this.MyRTBItem != null) - { - this.MyRTBItem.MyStepPanel.MyStepTabPanel.MyStepTabRibbon.btnInsPgBrk_Click(sender, e); - e.Handled = true; - } + OnInsertPgBrk(this, new EventArgs()); + e.Handled = true; break; } } @@ -1626,7 +1663,7 @@ namespace Volian.Controls.Library // because selection is first character or link without any other selection. Don't // need to write code to handle link at beginning of box in Shift Right code because // it's handled in HandleSelectionChange. - if (e.Shift && ((SelectionStart > 0) || (SelectionStart==0 && _LinkLocations.Count>0 && _LinkLocations[0].Start!=7))) + if (e.Shift && ((SelectionStart > 0) || (SelectionStart == 0 && _LinkLocations.Count > 0 && _LinkLocations[0].Start != 7))) { int newlen = FindEnd(); int len = SelectionLength + newlen; @@ -1658,13 +1695,13 @@ namespace Volian.Controls.Library if (!e.Shift) HandleLocalSelectionChange(); // if shift-down & on link at beginning of box - do special processing (regular processing // didn't handle it correctly. - if (e.Shift && lastLine > 0 && SelectionStart==0 && _LinkLocations.Count>0 && _LinkLocations[0].Start==7) + if (e.Shift && lastLine > 0 && SelectionStart == 0 && _LinkLocations.Count > 0 && _LinkLocations[0].Start == 7) { Point cpos = GetPositionFromCharIndex(SelectionStart); int addon = ClientRectangle.Height / (lastLine + 1); cpos.Y = cpos.Y + addon; int selend = GetCharIndexFromPosition(cpos); - Select(7, selend-7); + Select(7, selend - 7); e.Handled = true; } break; @@ -1735,19 +1772,16 @@ namespace Volian.Controls.Library e.Handled = true; break; case Keys.F5: - if (this.MyRTBItem != null) + if (e.Shift) { - if (e.Shift) - { - e.Handled = true; - if (MyRTBItem.MyStepPanel.MyStepTabPanel.MyDisplayTabControl.MyCopyStep == null) return; - MyRTBItem.MyStepPanel.MyStepTabPanel.MyStepTabRibbon.ShortCutContextMenu("StepPaste"); - } - else if (!e.Control && !e.Alt) - { - e.Handled = true; - this.MyRTBItem.MyStepPanel.MyStepTabPanel.MyStepTabRibbon.DoCopyStep(); - } + e.Handled = true; + if (!OnCheckClipboard(this, new EventArgs())) return; // check if 'clipboard' contains a step. + OnSetMenu(this, new StepRTBMenuEventArgs("StepPaste")); + } + else if (!e.Control && !e.Alt) + { + e.Handled = true; + OnCopyStep(this, new EventArgs()); } break; case Keys.F6: @@ -1755,52 +1789,44 @@ namespace Volian.Controls.Library SendKeys.Send("%H{ESC}"); break; case Keys.Tab: - e.SuppressKeyPress = true; - e.Handled = true; - if (MyRTBItem == null) - { - Form frm = ParentForm(this); - if (frm != null) - frm.SelectNextControl(this, true, true, true, true); - } - + e.SuppressKeyPress = true; + e.Handled = true; + Form frm = ParentForm(this); + if (frm != null) + frm.SelectNextControl(this, true, true, true, true); break; case Keys.Enter: if (!e.Control && !e.Shift && !e.Alt) { - if (MyRTBItem != null && !MyRTBItem.MyItemInfo.IsTablePart) - { - e.Handled = true; - MyRTBItem.MyStepPanel.MyStepTabPanel.MyStepTabRibbon.ProcessEnterKey(); - } + OnEnterKeyPressed(sender, e); } break; } } private static Form ParentForm(Control ctrl) { - while (!(ctrl.Parent is Form)) ctrl = ctrl.Parent; + while (!(ctrl.Parent is Form || ctrl.Parent is EditItem)) + ctrl = ctrl.Parent; return ctrl.Parent as Form; } - 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)_MyRTBItem.MyStepPanel.StepCursorKeys(this, keyargs); // Replaced with an event + //if (keyargs.Control)MyRTBItem.MyStepPanel.StepCursorKeys(this, keyargs); // Replaced with an event if (keyargs.Control) OnCursorKeyPress(this, keyargs); } private void StepRTB_PageKeyPressed(KeyEventArgs keyargs) { if (MyItemInfo.IsProcedure || MyItemInfo.IsSection) return; - //_MyRTBItem.MyStepPanel.StepCursorKeys(this, keyargs); Replaced with an event + //MyRTBItem.MyStepPanel.StepCursorKeys(this, keyargs); Replaced with an event OnCursorKeyPress(this, keyargs); } public void StepRTB_ArrowPressed(E_ArrowKeys key) { Point cp = PointToClient(Cursor.Position); - //_MyRTBItem.MyStepPanel.CursorMovement(this, cp, key); Replaced with an event + //MyRTBItem.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) @@ -2607,7 +2633,8 @@ namespace Volian.Controls.Library static void tsi_Click(object sender, EventArgs e) { ToolStripMenuItem tsmi = sender as ToolStripMenuItem; - _ContextMenuStepRTB.MyRTBItem.MyStepPanel.MyStepTabPanel.MyStepTabRibbon.OpenContextMenu(tsmi.Owner.Location); + //_ContextMenuStepRTB.MyRTBItem.MyStepPanel.MyStepTabPanel.MyStepTabRibbon.OpenContextMenu(tsmi.Owner.Location); + _ContextMenuStepRTB.OnOpenContextMenu(sender, new StepRTBLocationEventArgs(tsmi.Owner.Location)); } // This is our customized Spell Check dialog @@ -2681,6 +2708,32 @@ namespace Volian.Controls.Library _ViewMode = vmode; } } + public partial class StepRTBMenuEventArgs + { + private string _MenuGroup; + public string MenuGroup + { + get { return _MenuGroup; } + set { _MenuGroup = value; } + } + public StepRTBMenuEventArgs(string menuGroup) + { + _MenuGroup = menuGroup; + } + } + public partial class StepRTBTableWidthEventArgs + { + bool _EditMode; + public bool EditMode + { + get { return _EditMode; } + set { _EditMode = value; } + } + public StepRTBTableWidthEventArgs(bool editMode) + { + _EditMode = editMode; + } + } public class StepRTBCursorMovementEventArgs { private Point _CursorLocation; @@ -2701,6 +2754,19 @@ namespace Volian.Controls.Library _Key = key; } } + public class StepRTBLocationEventArgs:EventArgs + { + private Point _Location; + public Point Location + { + get { return _Location; } + set { _Location = value; } + } + public StepRTBLocationEventArgs(Point location) + { + _Location = location; + } + } #region LinkLocation Class public class LinkLocation { diff --git a/PROMS/Volian.Controls.Library/StepRTB.designer.cs b/PROMS/Volian.Controls.Library/StepRTB.designer.cs index 8cf8c43b..54c702ee 100644 --- a/PROMS/Volian.Controls.Library/StepRTB.designer.cs +++ b/PROMS/Volian.Controls.Library/StepRTB.designer.cs @@ -6,20 +6,13 @@ namespace Volian.Controls.Library /// Required designer variable. /// private System.ComponentModel.IContainer components = null; - private bool _BeingDisposed = false; - - public bool BeingDisposed - { - get { return _BeingDisposed; } - set { _BeingDisposed = value; } - } + /// /// Clean up any resources being used. /// /// true if managed resources should be disposed; otherwise, false. protected override void Dispose(bool disposing) { - _BeingDisposed = true; if (disposing && (components != null)) { components.Dispose();