This commit is contained in:
Kathy Ruffing 2010-11-08 14:57:27 +00:00
parent c332a71be2
commit b135576283

View File

@ -717,7 +717,6 @@ namespace Volian.Controls.Library
private void OpenProperties(SectionInfo sectInfo) private void OpenProperties(SectionInfo sectInfo)
{ {
OnSectionShouldClose(this, new vlnTreeSectionInfoEventArgs(sectInfo)); OnSectionShouldClose(this, new vlnTreeSectionInfoEventArgs(sectInfo));
using (Section sect = sectInfo.Get()) using (Section sect = sectInfo.Get())
{ {
string title = null; string title = null;
@ -725,9 +724,7 @@ namespace Volian.Controls.Library
title = string.Format("{0} {1} Properties", sectInfo.SectionConfig.Number, sectInfo.SectionConfig.Title); title = string.Format("{0} {1} Properties", sectInfo.SectionConfig.Number, sectInfo.SectionConfig.Title);
else else
title = string.Format("{0} Properties", sectInfo.SectionConfig.Title); title = string.Format("{0} Properties", sectInfo.SectionConfig.Title);
OnNodeOpenProperty(this, new vlnTreePropertyEventArgs(title, sect.SectionConfig)); OnNodeOpenProperty(this, new vlnTreePropertyEventArgs(title, sect.SectionConfig));
FinishSectionSave(sect);
} }
} }
private void OpenProperties(StepInfo stpinfo) private void OpenProperties(StepInfo stpinfo)
@ -780,32 +777,44 @@ namespace Volian.Controls.Library
{ {
if (newtype == MenuSelections.DocVersion) 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)) using (DocVersion docversion = DocVersion.MakeDocVersion(parentfolder, "Working Draft", "Title", null, null, null))
{ {
ShowBrokenRules(docversion.BrokenRulesCollection); ShowBrokenRules(docversion.BrokenRulesCollection);
SetLastValues(DocVersionInfo.Get(docversion.VersionID)); SetLastValues(DocVersionInfo.Get(docversion.VersionID));
if (OnNodeOpenProperty(this, new vlnTreePropertyEventArgs("Working Draft", docversion.DocVersionConfig)) == DialogResult.OK) if (OnNodeOpenProperty(this, new vlnTreePropertyEventArgs("Working Draft", docversion.DocVersionConfig)) == DialogResult.OK)
{
docversion.Save().Dispose(); docversion.Save().Dispose();
tn = new VETreeNode(_LastDocVersionInfo); tn = new VETreeNode(_LastDocVersionInfo);
SelectedNode.Nodes.Add(tn); // add tree node to end of list. 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) 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"); 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")) using (Folder folder = Folder.MakeFolder(parentfolder, parentfolder.MyConnection, uniquename, string.Empty, "Short Name", null, string.Empty, DateTime.Now, "Test"))
{ {
ShowBrokenRules(folder.BrokenRulesCollection); ShowBrokenRules(folder.BrokenRulesCollection);
SetLastValues(FolderInfo.Get(folder.FolderID)); SetLastValues(FolderInfo.Get(folder.FolderID));
if (OnNodeOpenProperty(this, new vlnTreePropertyEventArgs(uniquename, folder.FolderConfig)) == DialogResult.OK) if (OnNodeOpenProperty(this, new vlnTreePropertyEventArgs(uniquename, folder.FolderConfig)) == DialogResult.OK)
{
folder.Save().Dispose(); folder.Save().Dispose();
tn = new VETreeNode((IVEDrillDownReadOnly)_LastFolderInfo); tn = new VETreeNode((IVEDrillDownReadOnly)_LastFolderInfo);
SelectedNode.Nodes.Add(tn); // add new tree node to end of childlist. 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) else if (newtype == MenuSelections.FolderAfter||newtype == MenuSelections.FolderBefore)
{ {
int f2 = -1;
string uniquename = _LastFolderInfo.MyParent.UniqueChildName("New Folder"); string uniquename = _LastFolderInfo.MyParent.UniqueChildName("New Folder");
int myindex = SelectedNode.Index + ((newtype == MenuSelections.FolderAfter) ? 1 : 0); int myindex = SelectedNode.Index + ((newtype == MenuSelections.FolderAfter) ? 1 : 0);
FolderInfo parfolderinfo = FolderInfo.Get(parentfolder.FolderID); FolderInfo parfolderinfo = FolderInfo.Get(parentfolder.FolderID);
@ -815,11 +824,16 @@ namespace Volian.Controls.Library
ShowBrokenRules(folder.BrokenRulesCollection); ShowBrokenRules(folder.BrokenRulesCollection);
SetLastValues(FolderInfo.Get(folder.FolderID)); SetLastValues(FolderInfo.Get(folder.FolderID));
if (OnNodeOpenProperty(this, new vlnTreePropertyEventArgs(uniquename, folder.FolderConfig)) == DialogResult.OK) if (OnNodeOpenProperty(this, new vlnTreePropertyEventArgs(uniquename, folder.FolderConfig)) == DialogResult.OK)
{
folder.Save().Dispose(); folder.Save().Dispose();
tn = new VETreeNode((IVEDrillDownReadOnly)_LastFolderInfo); tn = new VETreeNode((IVEDrillDownReadOnly)_LastFolderInfo);
if (newtype == MenuSelections.FolderBefore) SelectedNode.Parent.Nodes.Insert(SelectedNode.Index, tn); if (newtype == MenuSelections.FolderBefore) SelectedNode.Parent.Nodes.Insert(SelectedNode.Index, tn);
if (newtype == MenuSelections.FolderAfter) SelectedNode.Parent.Nodes.Insert(SelectedNode.Index + 1, 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 #region InsertProcedure
else if (newtype == MenuSelections.Procedure) 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)) using (Procedure procedure = Procedure.MakeProcedure(_LastDocVersionInfo, _LastDocVersionInfo.Procedures.Count!=0?_LastDocVersionInfo.Procedures[_LastDocVersionInfo.Procedures.Count-1]:null, null, "New Procedure", 0))
{ {
ShowBrokenRules(procedure.BrokenRulesCollection); ShowBrokenRules(procedure.BrokenRulesCollection);
SetLastValues(ProcedureInfo.Get(procedure.ItemID)); SetLastValues(ProcedureInfo.Get(procedure.ItemID));
if (OnNodeOpenProperty(this, new vlnTreePropertyEventArgs("New Procedure", procedure.ProcedureConfig)) == DialogResult.OK) if (OnNodeOpenProperty(this, new vlnTreePropertyEventArgs("New Procedure", procedure.ProcedureConfig)) == DialogResult.OK)
{
procedure.Save().Dispose(); procedure.Save().Dispose();
tn = new VETreeNode(_LastProcedureInfo); tn = new VETreeNode(_LastProcedureInfo);
SelectedNode.Nodes.Add(tn); // add tree node to end of list. 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) else if (newtype == MenuSelections.ProcedureAfter || newtype == MenuSelections.ProcedureBefore)
{ {
int p2 = -1;
int tvindex = SelectedNode.Index; int tvindex = SelectedNode.Index;
// if inserting before, the parent is set in case previous is null, i.e. beginning of the list. // 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)) 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); ShowBrokenRules(procedure.BrokenRulesCollection);
SetLastValues(ProcedureInfo.Get(procedure.ItemID)); SetLastValues(ProcedureInfo.Get(procedure.ItemID));
if (OnNodeOpenProperty(this, new vlnTreePropertyEventArgs("New Procedure", procedure.ProcedureConfig)) == DialogResult.OK) if (OnNodeOpenProperty(this, new vlnTreePropertyEventArgs("New Procedure", procedure.ProcedureConfig)) == DialogResult.OK)
{
procedure.Save().Dispose(); procedure.Save().Dispose();
tn = new VETreeNode(_LastProcedureInfo); tn = new VETreeNode(_LastProcedureInfo);
TreeNode par = SelectedNode.Parent; TreeNode par = SelectedNode.Parent;
par.Nodes.Insert(tvindex + ((newtype == MenuSelections.ProcedureBefore) ? 0 : 1), tn); par.Nodes.Insert(tvindex + ((newtype == MenuSelections.ProcedureBefore) ? 0 : 1), tn);
}
else
p2 = procedure.ItemID;
} }
if (p2 != -1) Item.Delete(p2);
} }
#endregion #endregion
#region InsertSection #region InsertSection
else if (newtype == MenuSelections.Section) // Insert subsection at end of parents section list else if (newtype == MenuSelections.Section) // Insert subsection at end of parents section list
{ {
int s1 = -1;
if (!(_LastProcedureInfo == null) || !(_LastSectionInfo == null)) 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); ShowBrokenRules(section.BrokenRulesCollection);
SetLastValues(SectionInfo.Get(section.ItemID)); SetLastValues(SectionInfo.Get(section.ItemID));
if (OnNodeOpenProperty(this, new vlnTreePropertyEventArgs("New Section", section.SectionConfig)) == DialogResult.OK) if (OnNodeOpenProperty(this, new vlnTreePropertyEventArgs("New Section", section.SectionConfig)) == DialogResult.OK)
{ {
section.Save().Dispose(); tn = new VETreeNode(_LastSectionInfo);
FinishSectionSave(section); // make a word document if type was set to word document. SelectedNode.Nodes.Add(tn); // add tree node to end of list.
} }
else
tn = new VETreeNode(_LastSectionInfo); s1 = section.ItemID;
SelectedNode.Nodes.Add(tn); // add tree node to end of list.
} }
if (s1 != -1) Item.Delete(s1);
} }
} }
else if (newtype == MenuSelections.SectionAfter || newtype == MenuSelections.SectionBefore) else if (newtype == MenuSelections.SectionAfter || newtype == MenuSelections.SectionBefore)
{ {
int tvindex = SelectedNode.Index; int tvindex = SelectedNode.Index;
// if inserting before, the parent is set in case previous is null, i.e. beginning of the list. // 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)) using (Section section = Section.MakeSection((newtype == MenuSelections.SectionAfter) ? null : _LastSectionInfo.MyParent, (newtype == MenuSelections.SectionAfter) ? _LastSectionInfo : _LastSectionInfo.MyPrevious, null, "New Section", 10000))
{ {
ShowBrokenRules(section.BrokenRulesCollection); ShowBrokenRules(section.BrokenRulesCollection);
SetLastValues(SectionInfo.Get(section.ItemID)); SetLastValues(SectionInfo.Get(section.ItemID));
if (OnNodeOpenProperty(this, new vlnTreePropertyEventArgs("New Section", section.SectionConfig)) == DialogResult.OK) if (OnNodeOpenProperty(this, new vlnTreePropertyEventArgs("New Section", section.SectionConfig)) == DialogResult.OK)
{ {
section.Save().Dispose(); tn = new VETreeNode(_LastSectionInfo);
FinishSectionSave(section); // make a word document if type was set to word document. TreeNode par = SelectedNode.Parent;
par.Nodes.Insert(tvindex + ((newtype == MenuSelections.SectionBefore) ? 0 : 1), tn);
} }
tn = new VETreeNode(_LastSectionInfo); else
TreeNode par = SelectedNode.Parent; s2 = section.ItemID;
par.Nodes.Insert(tvindex + ((newtype == MenuSelections.SectionBefore) ? 0 : 1), tn);
} }
if (s2 != -1) Item.Delete(s2);
} }
#endregion #endregion
#region InsertStep #region InsertStep
@ -908,6 +936,7 @@ namespace Volian.Controls.Library
{ {
SelectedNode = tn; SelectedNode = tn;
OnNodeSelect(this, new vlnTreeEventArgs(SelectedNode)); OnNodeSelect(this, new vlnTreeEventArgs(SelectedNode));
Refresh(); Refresh();
} }
} }
@ -953,62 +982,6 @@ namespace Volian.Controls.Library
} }
return tn; return tn;
} }
/// <summary>
/// NewName will check the existing children to assure that the name is not a duplicate name.
/// </summary>
/// <param name="parentFolderInfo"></param>
/// <param name="folderName"></param>
/// <returns></returns>
//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) private void ShowBrokenRules(BrokenRulesCollection brs)
{ {
if (brs != null) if (brs != null)
@ -1190,6 +1163,14 @@ namespace Volian.Controls.Library
if(t2 != null) if(t2 != null)
if(_MyLog.IsInfoEnabled)_MyLog.InfoFormat("Item Drag {0} - {1}", t2.FullName, t2.BaseType.FullName); if(_MyLog.IsInfoEnabled)_MyLog.InfoFormat("Item Drag {0} - {1}", t2.FullName, t2.BaseType.FullName);
this.SelectedNode = dragNode; 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)) if (SetupDragCursor(_dragImageList, dragNode))
{ {
this.DoDragDrop(dragNode, DragDropEffects.Move | DragDropEffects.Copy);// Begin dragging this.DoDragDrop(dragNode, DragDropEffects.Move | DragDropEffects.Copy);// Begin dragging