diff --git a/PROMS/VEPROMS User Interface/frmVEPROMS.cs b/PROMS/VEPROMS User Interface/frmVEPROMS.cs index 9e28e9f7..8fcf2c69 100644 --- a/PROMS/VEPROMS User Interface/frmVEPROMS.cs +++ b/PROMS/VEPROMS User Interface/frmVEPROMS.cs @@ -918,12 +918,24 @@ namespace VEPROMS WindowsFormsSynchronizationContext mUIContext = new WindowsFormsSynchronizationContext(); public void MyFindNodeAndExpand(object obj) { + IVEDrillDownReadOnly veObj1 = ((tv.SelectedNode as VETreeNode).VEObject as IVEDrillDownReadOnly); int id = (int)obj; ItemInfo ii = ItemInfo.Get(id); ii.ResetParts(); using (Item i = Item.Get(id)) ItemInfo.Refresh(i); tv.RefreshRelatedNode(ii); + IVEDrillDownReadOnly veObj2 = ((tv.SelectedNode as VETreeNode).VEObject as IVEDrillDownReadOnly); + if (veObj1.ToString() != veObj2.ToString()) + { + VETreeNode tnNew = null; + foreach (VETreeNode tn in tv.SelectedNode.Nodes) + { + if (tn.VEObject.ToString() == veObj1.ToString()) + tnNew = tn; + } + if (tnNew != null) tv.SelectedNode = tnNew; + } } private void RefreshChanged(Object obj) { @@ -969,6 +981,13 @@ namespace VEPROMS } MySemaphore.Release(); } + private int TotalCount(TreeNodeCollection tns) + { + int total = tns.Count; + foreach (TreeNode tn in tns) + total += TotalCount(tn.Nodes); + return total; + } private bool ByteArrayIsEmpty(byte[] myArray) { for (int i = 0; i < myArray.Length; i++) diff --git a/PROMS/Volian.Controls.Library/vlnTreeView.cs b/PROMS/Volian.Controls.Library/vlnTreeView.cs index 2282fe6a..851cba43 100644 --- a/PROMS/Volian.Controls.Library/vlnTreeView.cs +++ b/PROMS/Volian.Controls.Library/vlnTreeView.cs @@ -143,6 +143,19 @@ namespace Volian.Controls.Library } //end jcb multiunit #endregion + public override string ToString() + { + return string.Format("Node={0},Destination={1},Index={2},Unit={3},UnitIndex={4}",NodePath(this.Node),this.Destination, this.Index,this.Unit, this.UnitIndex); + } + + private string NodePath(TreeNode node) + { + string retval = ""; + if (node.Parent != null) + retval = NodePath(node.Parent) + ":"; + retval += node.Text; + return retval; + } } public partial class vlnTreeItemInfoEventArgs { @@ -1956,7 +1969,7 @@ namespace Volian.Controls.Library if (!hasMetaSubs) doPseudo = true; } } - using(Section section = CreateNewSection()) + using (Section section = CreateNewSection()) { ShowBrokenRules(section.BrokenRulesCollection); SetLastValues(SectionInfo.Get(section.ItemID)); @@ -2033,11 +2046,15 @@ namespace Volian.Controls.Library { ShowBrokenRules(section.BrokenRulesCollection); SetLastValues(SectionInfo.Get(section.ItemID)); + TreeNode par = SelectedNode.Parent; if (OnNodeOpenProperty(this, new vlnTreePropertyEventArgs("New Section", section.SectionConfig)) == DialogResult.OK) { - tn = new VETreeNode(_LastSectionInfo); - TreeNode par = SelectedNode.Parent; - par.Nodes.Insert(tvindex + ((newtype == MenuSelections.SectionBefore) ? 0 : 1), tn); + int indx = tvindex + ((newtype == MenuSelections.SectionBefore) ? 0 : 1); + if ((par.Nodes[indx] as VETreeNode).VEObject.ToString() != _LastSectionInfo.ToString()) + { + tn = new VETreeNode(_LastSectionInfo); + par.Nodes.Insert(indx, tn); + } } else s2 = section.ItemID;