This commit is contained in:
parent
10898f5d90
commit
c17133d47e
@ -16,7 +16,9 @@ namespace Volian.Controls.Library
|
|||||||
{
|
{
|
||||||
#region DelegatesAndEventArgs
|
#region DelegatesAndEventArgs
|
||||||
public delegate void vlnTreeViewEvent(object sender, vlnTreeEventArgs args);
|
public delegate void vlnTreeViewEvent(object sender, vlnTreeEventArgs args);
|
||||||
|
public delegate void vlnTreeViewItemInfoEvent(object sender, vlnTreeItemInfoEventArgs args);
|
||||||
public delegate bool vlnTreeViewBoolEvent(object sender, vlnTreeEventArgs args);
|
public delegate bool vlnTreeViewBoolEvent(object sender, vlnTreeEventArgs args);
|
||||||
|
public delegate bool vlnTreeViewItemInfoDeleteEvent(object sender, vlnTreeItemInfoEventArgs args);
|
||||||
public delegate TreeNode vlnTreeViewTreeNodeEvent(object sender, vlnTreeEventArgs args);
|
public delegate TreeNode vlnTreeViewTreeNodeEvent(object sender, vlnTreeEventArgs args);
|
||||||
public delegate DialogResult vlnTreeViewPropertyEvent(object sender, vlnTreePropertyEventArgs args);
|
public delegate DialogResult vlnTreeViewPropertyEvent(object sender, vlnTreePropertyEventArgs args);
|
||||||
public delegate void vlnTreeViewSectionInfoEvent(object sender, vlnTreeSectionInfoEventArgs args);
|
public delegate void vlnTreeViewSectionInfoEvent(object sender, vlnTreeSectionInfoEventArgs args);
|
||||||
@ -69,6 +71,24 @@ namespace Volian.Controls.Library
|
|||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
|
public partial class vlnTreeItemInfoEventArgs
|
||||||
|
{
|
||||||
|
#region Business Methods
|
||||||
|
private ItemInfo _MyItemInfo;
|
||||||
|
public ItemInfo MyItemInfo
|
||||||
|
{
|
||||||
|
get { return _MyItemInfo; }
|
||||||
|
set { _MyItemInfo = value; }
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
#region Factory Methods
|
||||||
|
private vlnTreeItemInfoEventArgs() { ;}
|
||||||
|
public vlnTreeItemInfoEventArgs(ItemInfo myItemInfo)
|
||||||
|
{
|
||||||
|
_MyItemInfo = myItemInfo;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
public partial class vlnTreePropertyEventArgs : EventArgs
|
public partial class vlnTreePropertyEventArgs : EventArgs
|
||||||
{
|
{
|
||||||
private string _Title;
|
private string _Title;
|
||||||
@ -145,6 +165,12 @@ namespace Volian.Controls.Library
|
|||||||
ItemInfo _LastItemInfo = null;
|
ItemInfo _LastItemInfo = null;
|
||||||
#endregion
|
#endregion
|
||||||
#region Events
|
#region Events
|
||||||
|
public event vlnTreeViewItemInfoDeleteEvent DeleteItemInfo;
|
||||||
|
private bool OnDeleteItemInfo(object sender, vlnTreeItemInfoEventArgs args)
|
||||||
|
{
|
||||||
|
if (DeleteItemInfo != null) return DeleteItemInfo(sender, args);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
public event vlnTreeViewEvent NodeMove;
|
public event vlnTreeViewEvent NodeMove;
|
||||||
private void OnNodeMove(object sender, vlnTreeEventArgs args)
|
private void OnNodeMove(object sender, vlnTreeEventArgs args)
|
||||||
{
|
{
|
||||||
@ -176,6 +202,11 @@ namespace Volian.Controls.Library
|
|||||||
{
|
{
|
||||||
if (SectionShouldClose != null) SectionShouldClose(sender, args);
|
if (SectionShouldClose != null) SectionShouldClose(sender, args);
|
||||||
}
|
}
|
||||||
|
public event vlnTreeViewItemInfoEvent OpenItem;
|
||||||
|
private void OnOpenItem(object sender, vlnTreeItemInfoEventArgs args)
|
||||||
|
{
|
||||||
|
if (OpenItem != null) OpenItem(sender, args);
|
||||||
|
}
|
||||||
#endregion
|
#endregion
|
||||||
#region Constructors
|
#region Constructors
|
||||||
public vlnTreeView()
|
public vlnTreeView()
|
||||||
@ -327,11 +358,16 @@ namespace Volian.Controls.Library
|
|||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
#region Menu_Delete
|
#region Menu_Delete
|
||||||
// Add delete to the menu unless at the very 'top' node.
|
// Add delete to the menu unless at the very 'top' node or on a grouping (partinfo)
|
||||||
if (tn.Parent!=null) cm.MenuItems.Add("Delete", new EventHandler(mi_Click));
|
// node (RNOs, Steps, Cautions, Notes)
|
||||||
|
PartInfo pi = tn.VEObject as PartInfo;
|
||||||
|
if (pi == null && tn.Parent!=null) cm.MenuItems.Add("Delete", new EventHandler(mi_Click));
|
||||||
#endregion
|
#endregion
|
||||||
#region Menu_Properties
|
#region Menu_Properties
|
||||||
cm.MenuItems.Add("Properties...", new EventHandler(mi_Click));
|
// Add delete to the menu unless at the very 'top' node or on a grouping (partinfo)
|
||||||
|
// node (RNOs, Steps, Cautions, Notes)
|
||||||
|
PartInfo pia = tn.VEObject as PartInfo;
|
||||||
|
if (pia == null) cm.MenuItems.Add("Properties...", new EventHandler(mi_Click));
|
||||||
#endregion
|
#endregion
|
||||||
cm.Show(this, new Point(e.X, e.Y));
|
cm.Show(this, new Point(e.X, e.Y));
|
||||||
}
|
}
|
||||||
@ -341,7 +377,6 @@ namespace Volian.Controls.Library
|
|||||||
void mi_Click(object sender, EventArgs e)
|
void mi_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
MenuItem mi = (MenuItem)sender;
|
MenuItem mi = (MenuItem)sender;
|
||||||
SelectedNode.Expand();
|
|
||||||
switch (mi.Text)
|
switch (mi.Text)
|
||||||
{
|
{
|
||||||
case "Open":
|
case "Open":
|
||||||
@ -354,12 +389,15 @@ namespace Volian.Controls.Library
|
|||||||
tv_NodeNew(MenuSelections.FolderAfter);
|
tv_NodeNew(MenuSelections.FolderAfter);
|
||||||
break;
|
break;
|
||||||
case "New Folder":
|
case "New Folder":
|
||||||
|
SelectedNode.Expand();
|
||||||
tv_NodeNew(MenuSelections.Folder);
|
tv_NodeNew(MenuSelections.Folder);
|
||||||
break;
|
break;
|
||||||
case "Create Working Draft":
|
case "Create Working Draft":
|
||||||
|
SelectedNode.Expand();
|
||||||
tv_NodeNew(MenuSelections.DocVersion);
|
tv_NodeNew(MenuSelections.DocVersion);
|
||||||
break;
|
break;
|
||||||
case "New Procedure":
|
case "New Procedure":
|
||||||
|
SelectedNode.Expand();
|
||||||
tv_NodeNew(MenuSelections.Procedure);
|
tv_NodeNew(MenuSelections.Procedure);
|
||||||
break;
|
break;
|
||||||
case "Insert Procedure Before":
|
case "Insert Procedure Before":
|
||||||
@ -370,6 +408,7 @@ namespace Volian.Controls.Library
|
|||||||
break;
|
break;
|
||||||
case "New Section":
|
case "New Section":
|
||||||
case "New Subsection":
|
case "New Subsection":
|
||||||
|
SelectedNode.Expand();
|
||||||
tv_NodeNew(MenuSelections.Section);
|
tv_NodeNew(MenuSelections.Section);
|
||||||
break;
|
break;
|
||||||
case "Insert Section Before":
|
case "Insert Section Before":
|
||||||
@ -385,6 +424,7 @@ namespace Volian.Controls.Library
|
|||||||
tv_NodeNew(MenuSelections.StepAfter);
|
tv_NodeNew(MenuSelections.StepAfter);
|
||||||
break;
|
break;
|
||||||
case "New Step":
|
case "New Step":
|
||||||
|
SelectedNode.Expand();
|
||||||
tv_NodeNew(MenuSelections.Step);
|
tv_NodeNew(MenuSelections.Step);
|
||||||
break;
|
break;
|
||||||
case "Copy"://Copy the selected node
|
case "Copy"://Copy the selected node
|
||||||
@ -405,7 +445,7 @@ namespace Volian.Controls.Library
|
|||||||
case "Paste Step After":
|
case "Paste Step After":
|
||||||
tv_NodePaste(mi.Text);
|
tv_NodePaste(mi.Text);
|
||||||
break;
|
break;
|
||||||
case "Delete"://Delete the selected node
|
case "Delete":
|
||||||
if (tv_NodeDelete())
|
if (tv_NodeDelete())
|
||||||
{
|
{
|
||||||
TreeNode myParent = SelectedNode.Parent;
|
TreeNode myParent = SelectedNode.Parent;
|
||||||
@ -577,7 +617,7 @@ namespace Volian.Controls.Library
|
|||||||
VETreeNode tn = SelectedNode as VETreeNode;
|
VETreeNode tn = SelectedNode as VETreeNode;
|
||||||
if (tn != null)
|
if (tn != null)
|
||||||
{
|
{
|
||||||
if (tn.VEObject.GetType() == typeof(FolderInfo) || tn.VEObject.GetType() == typeof(DocVersionInfo))
|
if (tn.VEObject.GetType() == typeof(FolderInfo) || tn.VEObject.GetType() == typeof(DocVersionInfo) || tn.VEObject.GetType() == typeof(PartInfo))
|
||||||
{
|
{
|
||||||
if (tn.Nodes.Count > 0)
|
if (tn.Nodes.Count > 0)
|
||||||
{
|
{
|
||||||
@ -819,7 +859,6 @@ namespace Volian.Controls.Library
|
|||||||
#region DeleteAllLevels
|
#region DeleteAllLevels
|
||||||
private bool tv_NodeDelete()
|
private bool tv_NodeDelete()
|
||||||
{
|
{
|
||||||
OnNodeSelect(this, new vlnTreeEventArgs(SelectedNode));
|
|
||||||
SetLastValues((VETreeNode)SelectedNode);
|
SetLastValues((VETreeNode)SelectedNode);
|
||||||
|
|
||||||
DialogResult result = MessageBox.Show("Are you sure you want to delete " + SelectedNode.Text, "Verify Delete",
|
DialogResult result = MessageBox.Show("Are you sure you want to delete " + SelectedNode.Text, "Verify Delete",
|
||||||
@ -840,25 +879,80 @@ namespace Volian.Controls.Library
|
|||||||
}
|
}
|
||||||
else if (_LastProcedureInfo != null)
|
else if (_LastProcedureInfo != null)
|
||||||
{
|
{
|
||||||
Procedure.Delete(_LastProcedureInfo.ItemID);
|
// always return false because an event gets fired to delete tree nodes.
|
||||||
|
if (!DeleteItemInfoAndChildren(_LastProcedureInfo)) return false;
|
||||||
_LastProcedureInfo = null;
|
_LastProcedureInfo = null;
|
||||||
return true;
|
return false;
|
||||||
}
|
}
|
||||||
else if (_LastSectionInfo != null)
|
else if (_LastSectionInfo != null)
|
||||||
{
|
{
|
||||||
Section.Delete(_LastSectionInfo.ItemID);
|
OnSectionShouldClose(this, new vlnTreeSectionInfoEventArgs(_LastSectionInfo));
|
||||||
|
// always return false because an event gets fired to delete tree nodes.
|
||||||
|
if (!DeleteItemInfoAndChildren(_LastSectionInfo)) return false;
|
||||||
_LastSectionInfo = null;
|
_LastSectionInfo = null;
|
||||||
return true;
|
return false;
|
||||||
}
|
}
|
||||||
else if (_LastStepInfo != null)
|
else if (_LastStepInfo != null)
|
||||||
{
|
{
|
||||||
Step.Delete(_LastStepInfo.ItemID);
|
// always return false because an event gets fired to delete tree nodes.
|
||||||
|
if (!DeleteItemInfoAndChildren(_LastStepInfo)) return false;
|
||||||
_LastStepInfo = null;
|
_LastStepInfo = null;
|
||||||
return true;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
private bool DeleteItemInfoAndChildren(ItemInfo ii)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// if the procedure is open & you're deleting procedure, you want to close open
|
||||||
|
// window.
|
||||||
|
if (!OnDeleteItemInfo(this, new vlnTreeItemInfoEventArgs(ii)))
|
||||||
|
Item.DeleteItemAndChildren(ii);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
catch (System.Data.SqlClient.SqlException ex)
|
||||||
|
{
|
||||||
|
HandleSqlExceptionOnDelete(ex, ii);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void HandleSqlExceptionOnDelete(System.Data.SqlClient.SqlException ex, ItemInfo ii)
|
||||||
|
{
|
||||||
|
if (ex.Message.Contains("has External Transitions and has no next step"))
|
||||||
|
{
|
||||||
|
using (TransitionInfoList exTrans = TransitionInfoList.GetExternalTransitions(ii.ItemID))
|
||||||
|
{
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
OnOpenItem(this, new vlnTreeItemInfoEventArgs(exTrans[0].MyContent.ContentItems[0]));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (ex.Message.Contains("has External Transitions to it's children"))
|
||||||
|
{
|
||||||
|
using (TransitionInfoList exTrans = TransitionInfoList.GetExternalTransitionsToChildren(ii.ItemID))
|
||||||
|
{
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
OnOpenItem(this, new vlnTreeItemInfoEventArgs(exTrans[0].MyContent.ContentItems[0]));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
MessageBox.Show(ex.Message, "SQL Exception", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
|
||||||
|
}
|
||||||
#endregion
|
#endregion
|
||||||
#region SetLastValuesAndSaveIfChangedStuff
|
#region SetLastValuesAndSaveIfChangedStuff
|
||||||
private void SetLastValues(VETreeNode node)
|
private void SetLastValues(VETreeNode node)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user