diff --git a/PROMS/VEPROMS.CSLA.Library/Extension/AuditExt.cs b/PROMS/VEPROMS.CSLA.Library/Extension/AuditExt.cs index f2df83af..0f542d80 100644 --- a/PROMS/VEPROMS.CSLA.Library/Extension/AuditExt.cs +++ b/PROMS/VEPROMS.CSLA.Library/Extension/AuditExt.cs @@ -29,9 +29,20 @@ namespace VEPROMS.CSLA.Library get { return _IContentID; } set { _IContentID = value; } } + public ItemInfo MyItemInfo + { + get {return ItemInfo.Get(this.ItemID);} + } public override string ToString() { - return string.Format("{0} by {1} on {2}", this.DeleteStatus == 0 ? "Changed" : "Deleted", this.UserID, this.DTS.ToString("MM/dd/yyyy @ HH:mm:ss")); + string who = string.Empty; + string when = string.Empty; + if (this.UserID != "Migration" || this.TypeID != 1) + who = string.Format(" by {0}", this.UserID); + if (this.DTS != DateTime.Parse("1/1/1980")) + when = string.Format(" on {0}", this.DTS.ToString("MM/dd/yyyy @ HH:mm:ss")); + //return string.Format("{0}{1}{2}", this.ActionWhat, who, when); + return string.Format("{0}{1}{2}", this.DeleteStatus == 0 ? "Changed" : "Deleted", who, when); } } @@ -63,7 +74,13 @@ namespace VEPROMS.CSLA.Library } public override string ToString() { - return string.Format("{0} by {1} on {2}", this.ActionWhat, this.UserID, this.DTS.ToString("MM/dd/yyyy @ HH:mm:ss")); + string who = string.Empty; + string when = string.Empty; + if (this.UserID != "Migration") + who = string.Format(" by {0}", this.UserID); + if (this.DTS != DateTime.Parse("1/1/1980")) + when = string.Format(" on {0}", this.DTS.ToString("MM/dd/yyyy @ HH:mm:ss")); + return string.Format("{0}{1}{2}", this.ActionWhat, who, when); //return string.Format("{0} by {1} on {2}", this.DeleteStatus == 0 ? "Changed" : "Deleted", this.UserID, this.DTS.ToString("MM/dd/yyyy @ HH:mm:ss")); //return string.Format("{0} - {1} {2}", this.UserID, this.DTS, this.DeleteStatus == 0 ? "" : "Deleted"); } @@ -1161,15 +1178,22 @@ namespace VEPROMS.CSLA.Library } public ItemInfo RestoreItem(ItemAuditInfo iai) { + ItemInfo tmp2 = null; try { ItemInfo tmp = DataPortal.Fetch(new RestoreCriteria(iai, this)); + tmp2 = tmp; AddToCache(tmp); if (tmp.ErrorMessage == "No Record Found") tmp = null; if(iai.Level == 2) OnNewChild(new ItemInfoInsertEventArgs(tmp, EAddpingPart.Child)); - ItemInfo.RefreshPrevious(tmp.NextItem.ItemID, tmp.ItemID); - tmp.NextItem.ResetOrdinal(); + int? nextID = null; + if (tmp.NextItem != null) + { + nextID = tmp.NextItem.ItemID; + ItemInfo.RefreshPrevious(nextID, tmp.ItemID); + tmp.NextItem.ResetOrdinal(); + } //tmp.UpdateTransitionText(); if (tmp.MyContent.ContentTransitions != null) { diff --git a/PROMS/VEPROMS.CSLA.Library/Extension/ItemExt.cs b/PROMS/VEPROMS.CSLA.Library/Extension/ItemExt.cs index 4ffe9552..cb6fcdfa 100644 --- a/PROMS/VEPROMS.CSLA.Library/Extension/ItemExt.cs +++ b/PROMS/VEPROMS.CSLA.Library/Extension/ItemExt.cs @@ -1762,14 +1762,19 @@ namespace VEPROMS.CSLA.Library //using (ContentInfo parentContent = ParentContent) //{ ContentInfo parentContent = ParentContent; - if (parentContent == null || parentContent.ContentItemCount == 0) + if (parentContent == null)// || parentContent.ContentItemCount == 0) _ActiveParent = this; else { int itemID = 0; + if (parentContent.ContentItems.Count == 0) + parentContent.RefreshContentItems(); using(ItemInfoList list = parentContent.ContentItems) itemID = list[0].ItemID; - _ActiveParent = ItemInfo.Get(itemID); + if (itemID == 0) + _ActiveParent = this; + else + _ActiveParent = ItemInfo.Get(itemID); } //} } diff --git a/PROMS/VEPROMS.CSLA.Library/Extension/ItemInsertExt.cs b/PROMS/VEPROMS.CSLA.Library/Extension/ItemInsertExt.cs index 4f9b2848..e4880d74 100644 --- a/PROMS/VEPROMS.CSLA.Library/Extension/ItemInsertExt.cs +++ b/PROMS/VEPROMS.CSLA.Library/Extension/ItemInsertExt.cs @@ -192,6 +192,20 @@ namespace VEPROMS.CSLA.Library MyParent.MyContent.RefreshContentParts(); } } + //internal void OnDeleted(object sender, Volian.Base.Library.VlnTimer tmr) + //{ + //tmr.ActiveProcess = "Deleted"; + //if (Deleted != null) Deleted(sender); + //tmr.ActiveProcess = "ItemDeleted"; + //if (ItemDeleted != null) ItemDeleted(sender); + //if (MyParent != null) + //{ + //tmr.ActiveProcess = "OnChildrenDeleted"; + //MyParent.OnChildrenDeleted(sender); + //tmr.ActiveProcess = "RefreshContentParts"; + //MyParent.MyContent.RefreshContentParts(); + //} + //} public event ItemInfoEvent ChildrenDeleted; internal void OnChildrenDeleted(object sender) { @@ -770,6 +784,8 @@ namespace VEPROMS.CSLA.Library } public static void DeleteItemInfoAndChildren(int itemID) { + //Volian.Base.Library.VlnTimer _MyTimer = new Volian.Base.Library.VlnTimer(); + //_MyTimer.ActiveProcess = "ConvertListToDictionary"; ConvertListToDictionary(); string key = itemID.ToString(); if(_CacheByPrimaryKey.ContainsKey(key)) @@ -777,18 +793,24 @@ namespace VEPROMS.CSLA.Library ItemInfo [] items = _CacheByPrimaryKey[key].ToArray(); ItemInfo parent = items[0].ActiveParent as ItemInfo; + //_MyTimer.ActiveProcess = "ResetParts"; if (parent != null) ItemInfo.ResetParts(parent.ItemID); //Console.WriteLine("\r\n\r\n'Deleting Item {0}'\r\n{0}'Type ','ParentID','ParentUnique','ItemID','Unique'",itemID); foreach (ItemInfo item in items) { + //_MyTimer.ActiveProcess = "IsDeleted"; item.IsDeleted = true; + //_MyTimer.ActiveProcess = string.Format("OnDeleted {0}", items.Length); item.OnDeleted(item); + //item.OnDeleted(item, _MyTimer); + //_MyTimer.ActiveProcess = "DeleteItemInfoAndChildren"; item.DeleteItemInfoAndChildren(" "); } //Console.WriteLine("\r\n'Item Deleted'"); } + //_MyTimer.ShowElapsedTimes("DeleteItemInfoAndChildren"); } private void DeleteItemInfoAndChildren(string depth) @@ -868,6 +890,7 @@ namespace VEPROMS.CSLA.Library #region DeleteItemAndChildren public static void DeleteItemAndChildren(ItemInfo item) { + //Volian.Base.Library.VlnTimer _MyTimer = new Volian.Base.Library.VlnTimer(); if (!CanDeleteObject()) throw new System.Security.SecurityException("User not authorized to remove a Item"); try @@ -875,23 +898,31 @@ namespace VEPROMS.CSLA.Library ItemInfo nextItem = item.NextItem; ItemInfo prevItem = item.MyPrevious; item.OnBeforeDelete(); + //_MyTimer.ActiveProcess = "DataPortal.Delete"; DataPortal.Delete(new DeleteCriteria(item.ItemID, Volian.Base.Library.VlnSettings.UserID)); if (nextItem != null) // Adjust PreviousID for NextItem { + //_MyTimer.ActiveProcess = "RefreshPrevious"; ItemInfo.RefreshPrevious(nextItem.ItemID, item.PreviousID); // The order of the next two methods was required to fix a null reference // when getting myparent. This bug was found when deleting a node from the // tree when the RTBItem was not open (i.e. in the step editor window). + //_MyTimer.ActiveProcess = "RefreshItemParts"; nextItem.RefreshItemParts(); //nextItem.ResetOrdinal(); - UpdateTransitionText calls ResetOrdinal + //_MyTimer.ActiveProcess = "UpdateTransitionText"; nextItem.UpdateTransitionText(); } else if (prevItem != null) { + //_MyTimer.ActiveProcess = "RefreshNextItems"; prevItem.RefreshNextItems(); + //_MyTimer.ActiveProcess = "ResetOrdinal"; if (prevItem.IsCaution || prevItem.IsNote) prevItem.ResetOrdinal(); + //_MyTimer.ActiveProcess = "UpdateTransitionText"; prevItem.UpdateTransitionText(); } + //_MyTimer.ActiveProcess = "DeleteItemInfoAndChildren"; ItemInfo.DeleteItemInfoAndChildren(item.ItemID); // Dispose ItemInfo and Children } catch (Exception ex) @@ -904,6 +935,7 @@ namespace VEPROMS.CSLA.Library else throw new DbCslaException("Error on Item.DeleteItemAndChildren", ex); } + //_MyTimer.ShowElapsedTimes("DeleteItemAndChildren"); } private static System.Data.SqlClient.SqlException SqlException(Exception ex) { diff --git a/PROMS/VEPROMS.CSLA.Library/VEObjects/VETreeNode.cs b/PROMS/VEPROMS.CSLA.Library/VEObjects/VETreeNode.cs index 359f1f0a..f1f96999 100644 --- a/PROMS/VEPROMS.CSLA.Library/VEObjects/VETreeNode.cs +++ b/PROMS/VEPROMS.CSLA.Library/VEObjects/VETreeNode.cs @@ -388,7 +388,8 @@ namespace VEPROMS.CSLA.Library { int nextItemID = args.ItemInserted.NextItem.ItemID; VETreeNode nextNode = FindChildOrGrandChild(nextItemID); - nextNode.myItemInfo_NewSiblingBefore(sender, args); + if(nextNode != null) + nextNode.myItemInfo_NewSiblingBefore(sender, args); return; } if (args.ItemInserted.MyPrevious != null) // insert after diff --git a/PROMS/Volian.Base.Library/VlnTimer.cs b/PROMS/Volian.Base.Library/VlnTimer.cs new file mode 100644 index 00000000..e5bffd19 --- /dev/null +++ b/PROMS/Volian.Base.Library/VlnTimer.cs @@ -0,0 +1,55 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Volian.Base.Library +{ + public class VlnTimer + { + private DateTime _LastTime = DateTime.Now; + public DateTime LastTime + { + get { return _LastTime; } + set { _LastTime = value; } + } + private string _LastProcess = "Initialize"; + public string LastProcess + { + get { return _LastProcess; } + set { _LastProcess = value; } + } + public string ActiveProcess + { + get { return _LastProcess; } + set + { + DateTime tNow = DateTime.Now; + TimeSpan ts = tNow - LastTime; + LastTime = tNow; + if (!ElapsedTimes.ContainsKey(LastProcess)) + ElapsedTimes.Add(LastProcess, ts); + else + ElapsedTimes[LastProcess] += ts; + LastProcess = value; + } + } + Dictionary _ElapsedTimes = new Dictionary(); + public Dictionary ElapsedTimes + { + get { return _ElapsedTimes; } + set { _ElapsedTimes = value; } + } + public void ShowElapsedTimes() + { + ActiveProcess = "fini"; + Console.WriteLine("'Process'\t'Elapsed'"); + foreach (string proc in ElapsedTimes.Keys) + Console.WriteLine("'{0}'\t{1}", proc, ElapsedTimes[proc].TotalSeconds); + } + public void ShowElapsedTimes(string title) + { + Console.WriteLine(title); + ShowElapsedTimes(); + } + } +} diff --git a/PROMS/Volian.Controls.Library/AnnotationDetails.cs b/PROMS/Volian.Controls.Library/AnnotationDetails.cs index 6436666b..74516061 100644 --- a/PROMS/Volian.Controls.Library/AnnotationDetails.cs +++ b/PROMS/Volian.Controls.Library/AnnotationDetails.cs @@ -300,6 +300,7 @@ namespace Volian.Controls.Library annotation.SearchText = rtxbComment.Text; annotation.MyAnnotationType = annotationType; annotation.DTS = DateTime.Now; + annotation.UserID = Volian.Base.Library.VlnSettings.UserID; annotation.Save(); } } diff --git a/PROMS/Volian.Controls.Library/DisplayHistory.cs b/PROMS/Volian.Controls.Library/DisplayHistory.cs index 9bae76fc..99f649e5 100644 --- a/PROMS/Volian.Controls.Library/DisplayHistory.cs +++ b/PROMS/Volian.Controls.Library/DisplayHistory.cs @@ -120,8 +120,8 @@ namespace Volian.Controls.Library private void UpdateHistory() { this.Cursor = Cursors.WaitCursor; - DateTime start = DateTime.Now; - Console.WriteLine(start); + //DateTime start = DateTime.Now; + //Console.WriteLine(start); #region setup btnRestore.Enabled = false; myRTB.Clear(); @@ -380,15 +380,15 @@ namespace Volian.Controls.Library tnn.Tag = iai; #endregion } - Console.WriteLine("UpdateHistory: {0} seconds",TimeSpan.FromTicks(DateTime.Now.Ticks - start.Ticks).TotalSeconds); + //Console.WriteLine("UpdateHistory: {0} seconds",TimeSpan.FromTicks(DateTime.Now.Ticks - start.Ticks).TotalSeconds); this.Cursor = Cursors.Default; } private void WalkProcedure() { //return; this.Cursor = Cursors.WaitCursor; - DateTime start = DateTime.Now; - Console.WriteLine(start); + //DateTime start = DateTime.Now; + //Console.WriteLine(start); lbChanges.Items.Clear(); if (MyProcedureInfo == null) { @@ -397,17 +397,16 @@ namespace Volian.Controls.Library return; } ContentAuditInfoList cail2 = ContentAuditInfoList.GetChronology(MyProcedureInfo.ItemID, MyProcedureInfo.ItemID, false); - Console.WriteLine("WalkProcedure cail2: {0} seconds", TimeSpan.FromTicks(DateTime.Now.Ticks - start.Ticks).TotalSeconds); + //Console.WriteLine("WalkProcedure cail2: {0} seconds", TimeSpan.FromTicks(DateTime.Now.Ticks - start.Ticks).TotalSeconds); _ChronologyAuditList = cail2; ContentAuditInfoList cail3 = ContentAuditInfoList.GetSummary(MyProcedureInfo.ItemID, MyProcedureInfo.ItemID, false); _SummaryAuditList = cail3; AnnotationAuditInfoList aail2 = AnnotationAuditInfoList.GetChronology(MyProcedureInfo.ItemID, MyProcedureInfo.ItemID); - Console.WriteLine("WalkProcedure aail2: {0} seconds", TimeSpan.FromTicks(DateTime.Now.Ticks - start.Ticks).TotalSeconds); + //Console.WriteLine("WalkProcedure aail2: {0} seconds", TimeSpan.FromTicks(DateTime.Now.Ticks - start.Ticks).TotalSeconds); _AnnotationList = aail2; foreach (ContentAuditInfo cai in cail2) { - string itemTitle = Regex.Replace(cai.Path, "^..+?\\u0007", ""); - itemTitle = itemTitle.Replace("\x11", itemTitle[0]=='\x11' ? "" : " - "); + string itemTitle = FixPath(cai.Path); lbChanges.Items.Add(string.Format("{4} item {0} by {1} on {2} @ {3}", cai.ActionWhat, cai.UserID, cai.ActionWhen == DateTime.MinValue ? cai.DTS.ToShortDateString() : cai.ActionWhen.ToShortDateString(), cai.ActionWhen == DateTime.MinValue ? cai.DTS.ToShortTimeString() : cai.ActionWhen.ToShortTimeString(), itemTitle)); } foreach (AnnotationAuditInfo aai in aail2) @@ -417,13 +416,19 @@ namespace Volian.Controls.Library { if (cai.ContentID == aai.IContentID) { - stepnum = Regex.Replace(cai.Path, "^..+?\\u0007.", ""); + stepnum = FixPath(cai.Path); break; } } - lbChanges.Items.Add(string.Format("{4} Annotation {0} by {1} on {2} @ {3}", aai.ActionWhat, aai.UserID, aai.ActionWhen.ToShortDateString(), aai.ActionWhen.ToShortTimeString(), stepnum)); + if (stepnum == string.Empty) + { + ItemInfo iii = aai.MyItemInfo; + if(iii != null) + stepnum = FixPath(iii.SearchPath); + } + lbChanges.Items.Add(string.Format("{0} Annotation {1}", stepnum, aai.ToString())); } - Console.WriteLine("WalkProcedure fini: {0} seconds", TimeSpan.FromTicks(DateTime.Now.Ticks - start.Ticks).TotalSeconds); + //Console.WriteLine("WalkProcedure fini: {0} seconds", TimeSpan.FromTicks(DateTime.Now.Ticks - start.Ticks).TotalSeconds); this.Cursor = Cursors.Default; btnViewSummaryReport.Enabled = btnViewChronologyReport.Enabled = lbChanges.Items.Count > 0; return; @@ -559,6 +564,12 @@ namespace Volian.Controls.Library } btnViewSummaryReport.Enabled = btnViewChronologyReport.Enabled = lbChanges.Items.Count > 0; } + private static string FixPath(string path) + { + string itemTitle = Regex.Replace(path, "^..+?\\u0007", ""); + itemTitle = itemTitle.Replace("\x11", itemTitle[0] == '\x11' ? "" : " - ").Replace("\\u8209?", "-"); + return itemTitle; + } private void btnViewChronologyReport_Click(object sender, EventArgs e) { //if (lbChanges.Items.Count > 0) @@ -596,7 +607,7 @@ namespace Volian.Controls.Library ItemAuditInfo iai = tn.Tag as ItemAuditInfo; if (MessageBox.Show(this, string.Format("Do you want to restore this {0}?",iai.ItemType), string.Format("Confirm {0} Restore",iai.ItemType), MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question) == DialogResult.Yes) { - Console.WriteLine("DisplayHistory.btnRestore_Click @ {0}", DateTime.Now); + //Console.WriteLine("DisplayHistory.btnRestore_Click @ {0}", DateTime.Now); ItemInfo ii = null; if (iai.Level == 2) { @@ -829,6 +840,17 @@ namespace Volian.Controls.Library { if(this.Visible)this.RefreshList(); } + public void RefreshChangeList() + { + myTimer.Enabled = false; + myTimer.Enabled = true; + } + private void myTimer_Tick(object sender, System.EventArgs e) + { + myTimer.Enabled = false; + RefreshList(); + } + } public delegate void ItemRestoredHandler(ItemInfo restoredItemInfo); diff --git a/PROMS/Volian.Controls.Library/DisplayHistory.designer.cs b/PROMS/Volian.Controls.Library/DisplayHistory.designer.cs index 7ffbb180..ecf60933 100644 Binary files a/PROMS/Volian.Controls.Library/DisplayHistory.designer.cs and b/PROMS/Volian.Controls.Library/DisplayHistory.designer.cs differ diff --git a/PROMS/Volian.Controls.Library/EditItem.cs b/PROMS/Volian.Controls.Library/EditItem.cs index cfad90c8..76632ecf 100644 --- a/PROMS/Volian.Controls.Library/EditItem.cs +++ b/PROMS/Volian.Controls.Library/EditItem.cs @@ -195,6 +195,7 @@ namespace Volian.Controls.Library { // Update the text to reflect the content change MyItemInfo.RefreshItemAnnotations(); + ChangeBar = MyItemInfo.HasChangeBar; RefreshContent(); } void value_OrdinalChanged(object sender) @@ -544,29 +545,40 @@ namespace Volian.Controls.Library } public void RemoveItem() { + //Volian.Base.Library.VlnTimer _MyTimer = new VlnTimer(); BeingRemoved = true; MyStepPanel.SelectedEditItem = null; // Unselect the item to be deleted //ShowTops("\r\n"); int TopMostYBefore = TopMostEditItem.Top; + //_MyTimer.ActiveProcess = "DeleteItem"; EditItem newFocus = DeleteItem(); if (newFocus == null) return; + //_MyTimer.ActiveProcess = "SetFocus"; newFocus.SetFocus(); + //_MyTimer.ActiveProcess = "Dispose"; Dispose(); + //_MyTimer.ActiveProcess = "SetAllTabs"; newFocus.SetAllTabs(); + //_MyTimer.ActiveProcess = "TopMostYAfter"; int TopMostYAfter = newFocus.TopMostEditItem.Top; if (TopMostYAfter > TopMostYBefore) newFocus.TopMostEditItem.Top = TopMostYBefore; + //_MyTimer.ActiveProcess = "AdjustLocation"; newFocus.AdjustLocation(); //newFocus.ShowTops(""); + //_MyTimer.ShowElapsedTimes("RemoveItem"); } public EditItem DeleteItem() { + //Volian.Base.Library.VlnTimer _MyTimer = new VlnTimer(); + //_MyTimer.ActiveProcess = "_LookupEditItems.Remove"; MyStepPanel._LookupEditItems.Remove(MyID); EditItem newFocus = null; int? TopMostParentY = (MyParentEditItem == null ? null : (int?)(MyParentEditItem.TopMostEditItem.Top)); int? ParentY = (MyParentEditItem == null ? null : (int?)(MyParentEditItem.Top)); try { + //_MyTimer.ActiveProcess = "DeleteItemAndChildren"; Item.DeleteItemAndChildren(MyItemInfo); } catch (System.Data.SqlClient.SqlException ex) @@ -575,7 +587,9 @@ namespace Volian.Controls.Library return null; } // Remove EditItems + //_MyTimer.ActiveProcess = "RemoveFromParentsChildList"; RemoveFromParentsChildList(); + //_MyTimer.ActiveProcess = "MyNextEditItem"; if (MyNextEditItem != null) { if (MyPreviousEditItem != null) @@ -608,6 +622,7 @@ namespace Volian.Controls.Library MyParentEditItem = null; //Console.Write(",\"Parent\","); } + //_MyTimer.ShowElapsedTimes("DeleteItem"); return newFocus; } diff --git a/PROMS/Volian.Controls.Library/GridItem.cs b/PROMS/Volian.Controls.Library/GridItem.cs index 5d30741c..03dc505c 100644 --- a/PROMS/Volian.Controls.Library/GridItem.cs +++ b/PROMS/Volian.Controls.Library/GridItem.cs @@ -509,20 +509,20 @@ namespace Volian.Controls.Library MyStepRTB.ClearUndo(); } } - private string DoLinkForRoTable() + private string DoLinkForRoTable(Item itm) { // if no ro has been defined yet, just return null if (MyFlexGrid.ROID == null) return null; ContentRoUsage rousg = null; - using (Item itm = MyItemInfo.Get()) - { +// using (Item itm = MyItemInfo.Get()) +// { using (RODb rodb = RODb.GetJustRoDb(MyFlexGrid.RODbId)) { string padroid = (MyFlexGrid.ROID.Length <= 12) ? MyFlexGrid.ROID + "0000" : MyFlexGrid.ROID; rousg = itm.MyContent.ContentRoUsages.Add(MyFlexGrid.ROID, rodb); } - itm.Save(); - } + //itm.Save(); +// } MyItemInfo.MyContent.RefreshContentRoUsages(); return string.Format(@"#Link:ReferencedObject:{0} {1} {2}", rousg.ROUsageID, MyFlexGrid.ROID, MyFlexGrid.RODbId); } @@ -566,7 +566,7 @@ namespace Volian.Controls.Library // been saved. if (MyFlexGrid.IsRoTable && MyFlexGrid.ROID != null && itm.MyContent.ContentRoUsageCount < 1) { - searchableText = string.Format(@"\v\v0 ", searchableText, DoLinkForRoTable()); + searchableText = string.Format(@"\v\v0 ", searchableText, DoLinkForRoTable(itm)); //if (itm.MyContent.Text != searchableText) //{ itm.MyContent.Text = searchableText; diff --git a/PROMS/Volian.Controls.Library/StepRTB.cs b/PROMS/Volian.Controls.Library/StepRTB.cs index 3b7e5756..4347f3cb 100644 --- a/PROMS/Volian.Controls.Library/StepRTB.cs +++ b/PROMS/Volian.Controls.Library/StepRTB.cs @@ -372,8 +372,15 @@ namespace Volian.Controls.Library } public void RefreshDisplay() { - if (Disposing) return; - RefreshDisplay(ActiveMode); + if (Closed) return; + try + { + RefreshDisplay(ActiveMode); + } + catch (Exception ex) + { + _MyLog.Error(string.Format("MyItemInfo: {0} - {1} Problem doing RefreshDisplay",MyItemInfo.ItemID,MyItemInfo.ShortPath), ex); + } } // RefreshDisplay is used to update the rtb for an entire Item as defined by MyItemInfo. public void RefreshDisplay(bool activeMode) @@ -576,6 +583,7 @@ namespace Volian.Controls.Library this.SelectionChanged -= new EventHandler(StepRTB_SelectionChanged); this.ContextMenuStripChanged -= new EventHandler(StepRTB_ContextMenuStripChanged); this.RTBSelectionChanged -= new StepRTBEvent(StepRTB_RTBSelectionChanged); + this.HandleDestroyed -= new EventHandler(StepRTB_HandleDestroyed); } private void AddEventHandlers() { @@ -594,6 +602,18 @@ namespace Volian.Controls.Library this.SelectionChanged +=new EventHandler(StepRTB_SelectionChanged); this.ContextMenuStripChanged += new EventHandler(StepRTB_ContextMenuStripChanged); this.RTBSelectionChanged += new StepRTBEvent(StepRTB_RTBSelectionChanged); + this.HandleDestroyed += new EventHandler(StepRTB_HandleDestroyed); + } + private bool _Closed = false; + public bool Closed + { + get { return _Closed; } + set { _Closed = value; } + } + void StepRTB_HandleDestroyed(object sender, EventArgs e) + { + Closed = true; + RemoveEventHandlers(); } void StepRTB_RTBSelectionChanged(object sender, EventArgs args) {