diff --git a/PROMS/Volian.Controls.Library/vlnTreeView.cs b/PROMS/Volian.Controls.Library/vlnTreeView.cs
index 37983fbd..0f01777b 100644
--- a/PROMS/Volian.Controls.Library/vlnTreeView.cs
+++ b/PROMS/Volian.Controls.Library/vlnTreeView.cs
@@ -717,7 +717,6 @@ namespace Volian.Controls.Library
private void OpenProperties(SectionInfo sectInfo)
{
OnSectionShouldClose(this, new vlnTreeSectionInfoEventArgs(sectInfo));
-
using (Section sect = sectInfo.Get())
{
string title = null;
@@ -725,9 +724,7 @@ namespace Volian.Controls.Library
title = string.Format("{0} {1} Properties", sectInfo.SectionConfig.Number, sectInfo.SectionConfig.Title);
else
title = string.Format("{0} Properties", sectInfo.SectionConfig.Title);
-
OnNodeOpenProperty(this, new vlnTreePropertyEventArgs(title, sect.SectionConfig));
- FinishSectionSave(sect);
}
}
private void OpenProperties(StepInfo stpinfo)
@@ -780,32 +777,44 @@ namespace Volian.Controls.Library
{
if (newtype == MenuSelections.DocVersion)
{
+ int dvid = -1; // flag to allow user to cancel from dialog & then we remove it.
using (DocVersion docversion = DocVersion.MakeDocVersion(parentfolder, "Working Draft", "Title", null, null, null))
{
ShowBrokenRules(docversion.BrokenRulesCollection);
SetLastValues(DocVersionInfo.Get(docversion.VersionID));
if (OnNodeOpenProperty(this, new vlnTreePropertyEventArgs("Working Draft", docversion.DocVersionConfig)) == DialogResult.OK)
+ {
docversion.Save().Dispose();
- tn = new VETreeNode(_LastDocVersionInfo);
- SelectedNode.Nodes.Add(tn); // add tree node to end of list.
+ tn = new VETreeNode(_LastDocVersionInfo);
+ SelectedNode.Nodes.Add(tn); // add tree node to end of list.
+ }
+ else
+ dvid = docversion.VersionID;
}
+ if (dvid != -1) DocVersion.Delete(dvid);
}
else if (newtype == MenuSelections.Folder)
{
+ int f1 = -1; // flag to allow user to cancel from dialog & then we remove it.
string uniquename = _LastFolderInfo.UniqueChildName("New Folder");
using (Folder folder = Folder.MakeFolder(parentfolder, parentfolder.MyConnection, uniquename, string.Empty, "Short Name", null, string.Empty, DateTime.Now, "Test"))
{
ShowBrokenRules(folder.BrokenRulesCollection);
SetLastValues(FolderInfo.Get(folder.FolderID));
if (OnNodeOpenProperty(this, new vlnTreePropertyEventArgs(uniquename, folder.FolderConfig)) == DialogResult.OK)
+ {
folder.Save().Dispose();
- tn = new VETreeNode((IVEDrillDownReadOnly)_LastFolderInfo);
- SelectedNode.Nodes.Add(tn); // add new tree node to end of childlist.
-
+ tn = new VETreeNode((IVEDrillDownReadOnly)_LastFolderInfo);
+ SelectedNode.Nodes.Add(tn); // add new tree node to end of childlist.
+ }
+ else
+ f1 = folder.FolderID;
}
+ if (f1 != -1) Folder.Delete(f1);
}
else if (newtype == MenuSelections.FolderAfter||newtype == MenuSelections.FolderBefore)
{
+ int f2 = -1;
string uniquename = _LastFolderInfo.MyParent.UniqueChildName("New Folder");
int myindex = SelectedNode.Index + ((newtype == MenuSelections.FolderAfter) ? 1 : 0);
FolderInfo parfolderinfo = FolderInfo.Get(parentfolder.FolderID);
@@ -815,11 +824,16 @@ namespace Volian.Controls.Library
ShowBrokenRules(folder.BrokenRulesCollection);
SetLastValues(FolderInfo.Get(folder.FolderID));
if (OnNodeOpenProperty(this, new vlnTreePropertyEventArgs(uniquename, folder.FolderConfig)) == DialogResult.OK)
+ {
folder.Save().Dispose();
- tn = new VETreeNode((IVEDrillDownReadOnly)_LastFolderInfo);
- if (newtype == MenuSelections.FolderBefore) SelectedNode.Parent.Nodes.Insert(SelectedNode.Index, tn);
- if (newtype == MenuSelections.FolderAfter) SelectedNode.Parent.Nodes.Insert(SelectedNode.Index + 1, tn);
+ tn = new VETreeNode((IVEDrillDownReadOnly)_LastFolderInfo);
+ if (newtype == MenuSelections.FolderBefore) SelectedNode.Parent.Nodes.Insert(SelectedNode.Index, tn);
+ if (newtype == MenuSelections.FolderAfter) SelectedNode.Parent.Nodes.Insert(SelectedNode.Index + 1, tn);
+ }
+ else
+ f2 = folder.FolderID;
}
+ if (f2 != -1) Folder.Delete(f2);
}
}
}
@@ -827,18 +841,25 @@ namespace Volian.Controls.Library
#region InsertProcedure
else if (newtype == MenuSelections.Procedure)
{
+ int p1 = -1;
using (Procedure procedure = Procedure.MakeProcedure(_LastDocVersionInfo, _LastDocVersionInfo.Procedures.Count!=0?_LastDocVersionInfo.Procedures[_LastDocVersionInfo.Procedures.Count-1]:null, null, "New Procedure", 0))
{
ShowBrokenRules(procedure.BrokenRulesCollection);
SetLastValues(ProcedureInfo.Get(procedure.ItemID));
if (OnNodeOpenProperty(this, new vlnTreePropertyEventArgs("New Procedure", procedure.ProcedureConfig)) == DialogResult.OK)
+ {
procedure.Save().Dispose();
- tn = new VETreeNode(_LastProcedureInfo);
- SelectedNode.Nodes.Add(tn); // add tree node to end of list.
+ tn = new VETreeNode(_LastProcedureInfo);
+ SelectedNode.Nodes.Add(tn); // add tree node to end of list.
+ }
+ else
+ p1 = procedure.ItemID;
}
+ if (p1 != -1) Item.Delete(p1);
}
else if (newtype == MenuSelections.ProcedureAfter || newtype == MenuSelections.ProcedureBefore)
{
+ int p2 = -1;
int tvindex = SelectedNode.Index;
// if inserting before, the parent is set in case previous is null, i.e. beginning of the list.
using (Procedure procedure = Procedure.MakeProcedure((newtype == MenuSelections.ProcedureAfter) ? null : _LastProcedureInfo.ActiveParent, (newtype == MenuSelections.ProcedureAfter) ? _LastProcedureInfo : _LastProcedureInfo.MyPrevious, null, "New Procedure", 0))
@@ -846,51 +867,58 @@ namespace Volian.Controls.Library
ShowBrokenRules(procedure.BrokenRulesCollection);
SetLastValues(ProcedureInfo.Get(procedure.ItemID));
if (OnNodeOpenProperty(this, new vlnTreePropertyEventArgs("New Procedure", procedure.ProcedureConfig)) == DialogResult.OK)
+ {
procedure.Save().Dispose();
- tn = new VETreeNode(_LastProcedureInfo);
- TreeNode par = SelectedNode.Parent;
- par.Nodes.Insert(tvindex + ((newtype == MenuSelections.ProcedureBefore) ? 0 : 1), tn);
+ tn = new VETreeNode(_LastProcedureInfo);
+ TreeNode par = SelectedNode.Parent;
+ par.Nodes.Insert(tvindex + ((newtype == MenuSelections.ProcedureBefore) ? 0 : 1), tn);
+ }
+ else
+ p2 = procedure.ItemID;
}
+ if (p2 != -1) Item.Delete(p2);
}
#endregion
#region InsertSection
else if (newtype == MenuSelections.Section) // Insert subsection at end of parents section list
{
+ int s1 = -1;
if (!(_LastProcedureInfo == null) || !(_LastSectionInfo == null))
{
- using (Section section = Section.MakeSection(_LastItemInfo, _LastItemInfo.LastChild(E_FromType.Section), null, "New Section", 10000))// not sure of type - dataloader has: 10000+docstyleindx
+ using (Section section = Section.MakeSection(_LastItemInfo, _LastItemInfo.LastChild(E_FromType.Section), null, "New Section", 10000))
{
ShowBrokenRules(section.BrokenRulesCollection);
SetLastValues(SectionInfo.Get(section.ItemID));
if (OnNodeOpenProperty(this, new vlnTreePropertyEventArgs("New Section", section.SectionConfig)) == DialogResult.OK)
{
- section.Save().Dispose();
- FinishSectionSave(section); // make a word document if type was set to word document.
+ tn = new VETreeNode(_LastSectionInfo);
+ SelectedNode.Nodes.Add(tn); // add tree node to end of list.
}
-
- tn = new VETreeNode(_LastSectionInfo);
- SelectedNode.Nodes.Add(tn); // add tree node to end of list.
+ else
+ s1 = section.ItemID;
}
+ if (s1 != -1) Item.Delete(s1);
}
}
else if (newtype == MenuSelections.SectionAfter || newtype == MenuSelections.SectionBefore)
{
int tvindex = SelectedNode.Index;
// if inserting before, the parent is set in case previous is null, i.e. beginning of the list.
- //ItemInfo parent = (newtype == MenuSelections.SectionAfter) ? null : _LastSectionInfo.MyParent;
+ int s2 = -1;
using (Section section = Section.MakeSection((newtype == MenuSelections.SectionAfter) ? null : _LastSectionInfo.MyParent, (newtype == MenuSelections.SectionAfter) ? _LastSectionInfo : _LastSectionInfo.MyPrevious, null, "New Section", 10000))
{
ShowBrokenRules(section.BrokenRulesCollection);
SetLastValues(SectionInfo.Get(section.ItemID));
if (OnNodeOpenProperty(this, new vlnTreePropertyEventArgs("New Section", section.SectionConfig)) == DialogResult.OK)
{
- section.Save().Dispose();
- FinishSectionSave(section); // make a word document if type was set to word document.
+ tn = new VETreeNode(_LastSectionInfo);
+ TreeNode par = SelectedNode.Parent;
+ par.Nodes.Insert(tvindex + ((newtype == MenuSelections.SectionBefore) ? 0 : 1), tn);
}
- tn = new VETreeNode(_LastSectionInfo);
- TreeNode par = SelectedNode.Parent;
- par.Nodes.Insert(tvindex + ((newtype == MenuSelections.SectionBefore) ? 0 : 1), tn);
+ else
+ s2 = section.ItemID;
}
+ if (s2 != -1) Item.Delete(s2);
}
#endregion
#region InsertStep
@@ -908,6 +936,7 @@ namespace Volian.Controls.Library
{
SelectedNode = tn;
OnNodeSelect(this, new vlnTreeEventArgs(SelectedNode));
+
Refresh();
}
}
@@ -953,62 +982,6 @@ namespace Volian.Controls.Library
}
return tn;
}
- ///
- /// NewName will check the existing children to assure that the name is not a duplicate name.
- ///
- ///
- ///
- ///
- //private string NewName(FolderInfo parentFolderInfo, string folderName)
- //{
- // string retval = folderName;
- // int iSuffix = -1;
- // parentFolderInfo.RefreshChildFolders();
- // foreach (FolderInfo fi in parentFolderInfo.ChildFolders)
- // {
- // if (fi.Name.StartsWith(folderName))
- // {
- // if (fi.Name == folderName)
- // iSuffix = 0;
- // else if (Regex.IsMatch(fi.Name, folderName + "[_][0-9]+"))
- // {
- // int ii = int.Parse(fi.Name.Substring(1 + folderName.Length));
- // if (ii > iSuffix) iSuffix = ii;
- // }
- // }
- // }
- // if (iSuffix >= 0)
- // retval = string.Format("{0}_{1}", folderName, iSuffix + 1);
- // // Console.WriteLine("FolderName = '{0}'", retval);
- // return retval;
- //}
- private void FinishSectionSave(Section section)
- {
- ItemInfo sectinfo = ItemInfo.Get(section.ItemID);
-
- // need to find out if this is a word document type section & if it is, create a new word doc.
- bool isWordSect = true;
- int sectype = (int) sectinfo.MyContent.Type - 10000;
- PlantFormat pf = sectinfo.ActiveFormat.PlantFormat;
- for (int i = 0; i < pf.DocStyles.DocStyleList.Count; i++)
- {
- if (pf.DocStyles.DocStyleList[i].Index == sectype)
- {
- isWordSect = !pf.DocStyles.DocStyleList[i].IsStepSection;
- break;
- }
- }
- if (isWordSect && !sectinfo.HasWordContent)
- {
- Content cont = Content.Get(sectinfo.MyContent.ContentID);
-
- Byte[] tstbyte = System.Text.Encoding.Default.GetBytes("{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033\\uc1 }\r\n");
- Document doc = Document.MakeDocument(null, tstbyte, null, null, null);
- Entry entry = cont.MyEntry;
- entry.MyDocument = Document.Get(doc.DocID);
- cont.Save().Dispose();
- }
- }
private void ShowBrokenRules(BrokenRulesCollection brs)
{
if (brs != null)
@@ -1190,6 +1163,14 @@ namespace Volian.Controls.Library
if(t2 != null)
if(_MyLog.IsInfoEnabled)_MyLog.InfoFormat("Item Drag {0} - {1}", t2.FullName, t2.BaseType.FullName);
this.SelectedNode = dragNode;
+ ItemInfo iidrag = ((VETreeNode)dragNode).VEObject as ItemInfo;
+ FolderInfo fdrag = ((VETreeNode)dragNode).VEObject as FolderInfo;
+ DocVersionInfo ddrag = ((VETreeNode)dragNode).VEObject as DocVersionInfo;
+ if ((iidrag == null && fdrag == null && ddrag == null) || (iidrag != null && iidrag.IsStep))
+ {
+ MessageBox.Show(iidrag==null?"Cannot drag/drop a grouping node.":"Cannot drag/drop a Step");
+ return;
+ }
if (SetupDragCursor(_dragImageList, dragNode))
{
this.DoDragDrop(dragNode, DragDropEffects.Move | DragDropEffects.Copy);// Begin dragging