diff --git a/PROMS/Volian.Controls.Library/RTBItem.cs b/PROMS/Volian.Controls.Library/RTBItem.cs
index 4cc7a09f..ea2f1dea 100644
--- a/PROMS/Volian.Controls.Library/RTBItem.cs
+++ b/PROMS/Volian.Controls.Library/RTBItem.cs
@@ -25,7 +25,8 @@ namespace Volian.Controls.Library
No = 0,
Before = 1,
After = 2,
- Child = 3
+ Child = 3,
+ Replace = 4
}
#endregion
public partial class RTBItem : EditItem
@@ -238,6 +239,7 @@ namespace Volian.Controls.Library
get { return _EnhAddFromItemInfo; }
set { _EnhAddFromItemInfo = value; }
}
+ private ItemInfo _EnhCopiedItemInfo = null;
#endregion
#region Constructors
public RTBItem(ItemInfo itemInfo, StepPanel myStepPanel, EditItem myParentEditItem, ChildRelation myChildRelation, bool expand)
@@ -442,14 +444,20 @@ namespace Volian.Controls.Library
_ProcessingEnter = true;
DisplayTabItem dti = null;
// Syncronize any open Enhanced Documents
- StepConfig sc = new StepConfig(MyItemInfo.MyContent.Config);
- foreach (EnhancedDocument ed in sc.MyEnhancedDocuments)
+ if (MyStepPanel.MyStepTabPanel.MyDisplayTabControl.SyncEnhancedDocuments)
{
- ItemInfo ii = ItemInfo.Get(ed.ItemID);
- if (MyStepPanel.MyStepTabPanel.MyDisplayTabControl.IsItemInfoProcedureOpen(ii))
- MyStepPanel.MyStepTabPanel.MyDisplayTabControl.OnOpenEnhancedDocument(new ItemSelectedChangedEventArgs(ii));
- if (dti != null)
- dti.MyStepTabPanel.MyDisplayTabControl.OpenItem(this.MyItemInfo);
+ StepConfig sc = new StepConfig(MyItemInfo.MyContent.Config);
+ foreach (EnhancedDocument ed in sc.MyEnhancedDocuments)
+ {
+ if (ed.Type != 0)
+ {
+ ItemInfo ii = ItemInfo.Get(ed.ItemID);
+ //if (MyStepPanel.MyStepTabPanel.MyDisplayTabControl.IsItemInfoProcedureOpen(ii))
+ MyStepPanel.MyStepTabPanel.MyDisplayTabControl.OnRefreshEnhancedDocument(new ItemSelectedChangedEventArgs(ii));
+ if (dti != null)
+ dti.MyStepTabPanel.MyDisplayTabControl.OpenItem(this.MyItemInfo);
+ }
+ }
}
_ProcessingEnter = false;
}
@@ -773,44 +781,42 @@ namespace Volian.Controls.Library
MyStepRTB.OrigRTF = MyStepRTB.Rtf;
MyStepRTB.ClearUndo();
- // see if enhanced document related steps need to be created: KBR 10/2/15 - NEED to do this when saving RO
+ // see if enhanced document related steps need to be created.
if (EnhAddType != EnhancedAddTypes.No)
{
- StepConfig sib = EnhAddFromItemInfo.MyConfig as StepConfig;
- foreach (EnhancedDocument ed in sib.MyEnhancedDocuments)
+ // get the list of enhanced, may be coming from a section or a step:
+ EnhancedDocuments eds = EnhAddFromItemInfo.GetMyEnhancedDocuments();
+ foreach (EnhancedDocument ed in eds)
{
// create a new enhanced step and link it to this new source step.
- // the new source step's item is passed in to know what type & what to link to.
- // The ed.Type & itemid show what type of enhanced document (use to create new
- // config Type) and itemid is the one to insert after.
- DoAddEnhancedSteps(ed.Type, ed.ItemID);
+ // the new source step's item is used to know what type & what to link to.
+ // The ed.Type & ed.itemid show what type of enhanced document (use to create new
+ // config Type).
+ ItemInfo.EAddpingPart addpart = ItemInfo.EAddpingPart.After;
+ if (EnhAddType == EnhancedAddTypes.Before) addpart = ItemInfo.EAddpingPart.Before;
+ else if (EnhAddType == EnhancedAddTypes.Child) addpart = ItemInfo.EAddpingPart.Child;
+ ItemInfo newEnh = MyItemInfo.DoAddEnhancedSteps(ed.Type, ed.ItemID, addpart);
+ if (newEnh != null)
+ {
+ // if tabcontrol was open for enhanced, display the steps:
+ ItemInfo proc = newEnh.MyProcedure; // Find procedure Item
+ string key = "Item - " + proc.ItemID.ToString();
+ if (MyStepPanel.MyStepTabPanel.MyDisplayTabControl._MyDisplayTabItems.ContainsKey(key))
+ {
+ DisplayTabItem pg = MyStepPanel.MyStepTabPanel.MyDisplayTabControl._MyDisplayTabItems[key];
+ // _MyDisplayTabItems (in line above) had tabs that were closed, so use the next line
+ // to validate that the tab is still open.
+ foreach (DisplayTabItem ti in MyStepPanel.MyStepTabPanel.MyDisplayTabControl.MyBar.Items)
+ {
+ if (ti == pg) pg.MyStepTabPanel.MyStepPanel.GetEditItem(newEnh);
+ }
+ }
+ }
}
EnhAddType = EnhancedAddTypes.No;
}
}
}
- private void DoAddEnhancedSteps(int enhType, int enhItemID)
- {
- // get the item object in the enhanced document so that inserting of the new enhanced item and
- // its children can be done:
- ItemInfo existingEnhancedItemInfo = ItemInfo.Get(enhItemID);
- ItemInfo.EAddpingPart addpart = ItemInfo.EAddpingPart.After;
- if (EnhAddType == EnhancedAddTypes.Before) addpart = ItemInfo.EAddpingPart.Before;
- else if (EnhAddType == EnhancedAddTypes.Child) addpart = ItemInfo.EAddpingPart.Child;
- ItemInfo newEnhancedItemInfo = existingEnhancedItemInfo.InsertEnhancedSteps(MyItemInfo.MyContent.Text, null, addpart, MyItemInfo.MyContent.Type, enhType, MyItemInfo.ItemID);
- StepConfig sc = new StepConfig(MyItemInfo.MyContent.Config);
- sc.AddEnhancedDocument(enhType, newEnhancedItemInfo.ItemID);
- using (Content c = Content.Get(MyItemInfo.ContentID))
- {
- c.Config = sc.ToString();
- c.Save();
- }
- MyItemInfo.RefreshConfig();
- }
- //public override void SetBackgroundColor()
- //{
- // MyStepRTB.SetBackColor();
- //}
public override void IdentifyMe(bool highlight)
{
if (highlight)
diff --git a/PROMS/Volian.Controls.Library/RTBItem.designer.cs b/PROMS/Volian.Controls.Library/RTBItem.designer.cs
index 3ce1c1d2..eea29b93 100644
Binary files a/PROMS/Volian.Controls.Library/RTBItem.designer.cs and b/PROMS/Volian.Controls.Library/RTBItem.designer.cs differ
diff --git a/PROMS/Volian.Controls.Library/StepPanel.cs b/PROMS/Volian.Controls.Library/StepPanel.cs
index 45bf683d..bdf54274 100644
--- a/PROMS/Volian.Controls.Library/StepPanel.cs
+++ b/PROMS/Volian.Controls.Library/StepPanel.cs
@@ -314,6 +314,7 @@ namespace Volian.Controls.Library
/// Item to Expand
private void ExpandAsNeeded(ItemInfo myItemInfo)
{
+
int id = myItemInfo.ItemID;
if (!_LookupEditItems.ContainsKey(id)) // If the item is not currently displayed
ExpandAsNeeded((ItemInfo)myItemInfo.ActiveParent); // Expand it's parent
@@ -465,6 +466,33 @@ namespace Volian.Controls.Library
}
if (shouldDelete)
{
+ // if this item has enhanced edititems, remove them. Note that this code supports
+ // deleting text in an rtbitem that may be a step or section level.
+ EnhancedDocuments eds = null;
+ StepConfig sc = lastEI.MyItemInfo.MyConfig as StepConfig;
+ if (sc != null) eds = sc.MyEnhancedDocuments;
+ else
+ {
+ // if a section, just the title or all contents may be linked. If just title,
+ // don't delete enhanced, but clear links back from enhanced.
+ if (lastEI.MyItemInfo.IsSection)
+ {
+ SectionConfig sec = lastEI.MyItemInfo.MyConfig as SectionConfig;
+ if (sec != null)
+ {
+ if (sec.Section_LnkEnh == "Y") eds = sec.MyEnhancedDocuments;
+ else lastEI.MyItemInfo.ClearEnhancedSectionLink();
+ }
+ }
+ }
+ List enhIds = new List();
+ if (eds != null)
+ {
+ foreach (EnhancedDocument ed in eds)
+ {
+ if (ed.Type != 0) enhIds.Add(ed.ItemID);
+ }
+ }
float oldTop = lastEI.Top;
EditItem newFocus = lastEI.DeleteItem();
float newTop = newFocus.Top;
@@ -494,6 +522,13 @@ namespace Volian.Controls.Library
}
else
newFocus.AdjustLocation();
+ foreach (int enhId in enhIds)
+ {
+ ItemInfo ii = ItemInfo.Get(enhId);
+ bool success = MyStepTabPanel.MyDisplayTabControl.DeleteRTBItem(ii);
+ if (!success) // item was not displayed in editor, just delete from database (add tree if necessarY)
+ Item.DeleteItemAndChildren(ii);
+ }
}
else
{
diff --git a/PROMS/Volian.Controls.Library/StepPanel.designer.cs b/PROMS/Volian.Controls.Library/StepPanel.designer.cs
index 50e571c1..08510a93 100644
--- a/PROMS/Volian.Controls.Library/StepPanel.designer.cs
+++ b/PROMS/Volian.Controls.Library/StepPanel.designer.cs
@@ -21,6 +21,7 @@ namespace Volian.Controls.Library
EditItem.MyItemInfo.ResetParts();
EditItem.MyItemInfo.MyContent.RefreshContentParts();
}
+ _LookupEditItems.Clear();
components.Dispose();
}
base.Dispose(disposing);
diff --git a/PROMS/Volian.Controls.Library/StepTabRibbon.cs b/PROMS/Volian.Controls.Library/StepTabRibbon.cs
index fb2c85c9..44981e52 100644
--- a/PROMS/Volian.Controls.Library/StepTabRibbon.cs
+++ b/PROMS/Volian.Controls.Library/StepTabRibbon.cs
@@ -128,7 +128,6 @@ namespace Volian.Controls.Library
private void AddEnhancedDocumentMenu(DevComponents.DotNetBar.ButtonItem myButtonItem)
{
- #region enhanced
// get a list of all of the current enhanced buttons that been defined for context menu
List unusedEnhancedButtons = new List();
foreach (DevComponents.DotNetBar.ButtonItem bi in myButtonItem.SubItems)
@@ -141,12 +140,14 @@ namespace Volian.Controls.Library
DVEnhancedDocuments dveds = MyItemInfo.MyDocVersion.DocVersionConfig.MyEnhancedDocuments;
foreach(EnhancedDocument ed in sc.MyEnhancedDocuments)
{
- string buttonName = string.Format("btnEnhancedTo{0}", dveds[ed.Type]);
+ string buttonName = string.Format("btnEnhancedTo{0}", dveds.GetByType(ed.Type));
+ //string buttonName = string.Format("btnEnhancedTo{0}", dveds[ed.Type]);
if (unusedEnhancedButtons.Contains(buttonName)) unusedEnhancedButtons.Remove(buttonName);
DevComponents.DotNetBar.ButtonItem biEnhanced;
if (!myButtonItem.SubItems.Contains(buttonName))
{
- biEnhanced = new DevComponents.DotNetBar.ButtonItem(buttonName, "Go To " + dveds[ed.Type].Name + " Document");
+ //biEnhanced = new DevComponents.DotNetBar.ButtonItem(buttonName, "Go To " + dveds[ed.Type].Name + " Document");
+ biEnhanced = new DevComponents.DotNetBar.ButtonItem(buttonName, "Go To " + dveds.GetByType(ed.Type).Name + " Document");
biEnhanced.Click += btnSourceToBackground_Click;
myButtonItem.SubItems.Add(biEnhanced);
}
@@ -161,87 +162,6 @@ namespace Volian.Controls.Library
biUnused.Visible = false;
}
#endregion
- #region background
- //if (!myButtonItem.SubItems.Contains("btnSourceToBackground"))
- //{
- // btnSourceToBackground = new DevComponents.DotNetBar.ButtonItem("btnSourceToBackground", "Go To Background Document");
- // btnSourceToBackground.Visible = false;
- // btnSourceToBackground.Click += btnSourceToBackground_Click;
- // myButtonItem.SubItems.Add(btnSourceToBackground);
- //}
- //else
- // btnSourceToBackground = myButtonItem.SubItems["btnSourceToBackground"];
- //if (!myButtonItem.SubItems.Contains("btnBackgroundToSource"))
- //{
- // btnBackgroundToSource = new DevComponents.DotNetBar.ButtonItem("btnBackgroundToSource", "Go To Source Document");
- // btnBackgroundToSource.Visible = false;
- // btnBackgroundToSource.Click += btnBackgroundToSource_Click;
- // myButtonItem.SubItems.Add(btnBackgroundToSource);
- //}
- //else
- // btnBackgroundToSource = myButtonItem.SubItems["btnBackgroundToSource"];
- //StepConfig sc = new StepConfig(_MyStepRTB.MyItemInfo.MyContent.Config);
- //if (sc.Step_SourceToBackground != null)
- //{
- // btnSourceToBackground.Tag = sc.Step_SourceToBackground;
- // btnSourceToBackground.Visible = true;
- //}
- //else
- //{
- // btnSourceToBackground.Tag = string.Empty;
- // btnSourceToBackground.Visible = false;
- //}
- //if (sc.Step_BackgroundToSource != null)
- //{
- // btnBackgroundToSource.Tag = sc.Step_BackgroundToSource;
- // btnBackgroundToSource.Visible = true;
- //}
- //else
- //{
- // btnBackgroundToSource.Tag = string.Empty;
- // btnBackgroundToSource.Visible = false;
- //}
- #endregion
- #region deviation
- //if (!myButtonItem.SubItems.Contains("btnSourceToDeviation"))
- //{
- // btnSourceToDeviation = new DevComponents.DotNetBar.ButtonItem("btnSourceToDeviation", "Go To Deviation Document");
- // btnSourceToDeviation.Visible = false;
- // btnSourceToDeviation.Click += btnSourceToBackground_Click;
- // myButtonItem.SubItems.Add(btnSourceToDeviation);
- //}
- //else
- // btnSourceToDeviation = myButtonItem.SubItems["btnSourceToDeviation"];
- //if (!myButtonItem.SubItems.Contains("btnDeviationToSource"))
- //{
- // btnDeviationToSource = new DevComponents.DotNetBar.ButtonItem("btnDeviationToSource", "Go To Source Document");
- // btnDeviationToSource.Visible = false;
- // btnDeviationToSource.Click += btnBackgroundToSource_Click;
- // myButtonItem.SubItems.Add(btnDeviationToSource);
- //}
- //else
- // btnDeviationToSource = myButtonItem.SubItems["btnDeviationToSource"];
- //if (sc.Step_SourceToDeviation != null)
- //{
- // btnSourceToDeviation.Tag = sc.Step_SourceToDeviation;
- // btnSourceToDeviation.Visible = true;
- //}
- //else
- //{
- // btnSourceToDeviation.Tag = string.Empty;
- // btnSourceToDeviation.Visible = false;
- //}
- //if (sc.Step_DeviationToSource != null)
- //{
- // btnDeviationToSource.Tag = sc.Step_DeviationToSource;
- // btnDeviationToSource.Visible = true;
- //}
- //else
- //{
- // btnDeviationToSource.Tag = string.Empty;
- // btnDeviationToSource.Visible = false;
- //}
- #endregion
}
void btnBackgroundToSource_Click(object sender, EventArgs e)
@@ -494,6 +414,7 @@ namespace Volian.Controls.Library
}
public void OpenContextMenu(Point loc)
{
+ AddEnhancedDocumentMenu(btnCMRtfEdit);
btnCMRtfEdit.Popup(loc);
}
private int _MyLastFormatID = -1;
@@ -761,7 +682,6 @@ namespace Volian.Controls.Library
//{
// SetButtonAndMenuEnabling(true);
//}
- #endregion
#region Constructor
public StepTabRibbon()
{
@@ -1066,10 +986,20 @@ namespace Volian.Controls.Library
return; // No need to change menu that does not get used
DocVersionInfo dvi = MyEditItem.MyItemInfo.MyProcedure.ActiveParent as DocVersionInfo;
if (dvi == null) return;
+ // enable the following in case they were disabled for enhanced steps - only do for formats that have enhanced:
+ if (!MyItemInfo.IsEnhancedStep && !MyItemInfo.IsEnhancedSection &&
+ (((MyItemInfo.ActiveFormat.PlantFormat.FormatData.PurchaseOptions.Value & E_PurchaseOptions.EnhancedBackgrounds) == E_PurchaseOptions.EnhancedBackgrounds) ||
+ ((MyItemInfo.ActiveFormat.PlantFormat.FormatData.PurchaseOptions.Value & E_PurchaseOptions.EnhancedDeviations) == E_PurchaseOptions.EnhancedDeviations)))
+ SetButtonEnablingForEnhanced(true);
+
if (dvi.VersionType > 127 || MyEditItem.MyStepPanel.VwMode == E_ViewMode.View)
{
SetButtonMenuEnabledDisabledOnSelection(false);
}
+ else if (MyItemInfo != null && MyItemInfo.IsEnhancedStep || MyItemInfo.IsEnhancedSection)
+ {
+ SetButtonEnablingForEnhanced(false);
+ }
else
{
SetButtonMenuEnabledDisabledOnSelection(true);
@@ -1128,6 +1058,26 @@ namespace Volian.Controls.Library
// OLD: SetStepButtonAndMenuEnabling(docontextmenus);
}
+ private void SetButtonEnablingForEnhanced(bool setting)
+ {
+ btnPaste.Enabled = btnCut.Enabled = setting;
+ btnUndo.Enabled = btnRedo.Enabled = setting;
+ rbFont.Enabled = rbStepType.Enabled = setting;
+ rbSteps.Enabled = setting;
+ rbnCharacters.Enabled = rbnParagraph.Enabled = rbnSiblings.Enabled = rbnLinks.Enabled = setting;
+ btnCMEdit.Enabled = setting;
+ btnDelStep.Enabled = setting; // context menu item
+ btnPageBreak.Enabled = setting; // context menu item
+ btnCMHardSpace.Enabled = btnCMTransition.Enabled = btnCMRO.Enabled = btnCMSymbol.Enabled = setting;
+ btnFindRplDlg.Enabled = setting; // no find replace button is available when in an enhanced document
+ btnEditMode.Enabled = btnCMEditMode1.Enabled = setting;
+ if (((MyItemInfo.ActiveFormat.PlantFormat.FormatData.PurchaseOptions.Value & E_PurchaseOptions.EnhancedBackgrounds) == E_PurchaseOptions.EnhancedBackgrounds) ||
+ ((MyItemInfo.ActiveFormat.PlantFormat.FormatData.PurchaseOptions.Value & E_PurchaseOptions.EnhancedDeviations) == E_PurchaseOptions.EnhancedDeviations))
+ btnCASCreate.Enabled = false;
+ else
+ btnCASCreate.Enabled = (MyEditItem != null) ? (MyEditItem.MyStepPanel.ApplDisplayMode > 0) : false;
+ }
+
private void SetPasteButtonEnabled()
{
#region new code
@@ -1165,6 +1115,17 @@ namespace Volian.Controls.Library
btnPasteReplace.Enabled = btnCMPasteReplace.Enabled = false; // don't replace itself
return;
}
+ // THE FOLLOWING NEEDS TO BE ADDED IN - CODE HAD TO BE CHECKED IN BEFORE THIS COULD BE TESTED BY SOFTWARE ENGINEER (KBR) but is needed.
+ // for now (Jan 2016 - initial implementation of enhanced document support) do NOT paste any step (MyCopyStep) that has enhanced data associated
+ // with it unless pasting within a enhanced source document. The reason is that code would need to handle clearing the pasted enhanced config
+ // data if it is pasted into a non-enhanced location.
+ //if ((!MyItemInfo.IsEnhancedSection && !!!MyItemInfo.IsEnhancedStep) && tmp.MyDisplayTabControl.MyCopyStep.IsEnhancedStep)
+ //{
+ // btnPasteBefore.Enabled = btnCMPasteBefore.Enabled = false;
+ // btnPasteAfter.Enabled = btnCMPasteAfter.Enabled = false;
+ // btnPasteReplace.Enabled = btnCMPasteReplace.Enabled = false;
+ // return;
+ //}
//copy item is high level step
// Allow a High Level step to be pasted to a sub-step, but not to a table, figure, section or procedure type
if (tmp.MyDisplayTabControl.MyCopyStep.IsHigh && (MyItemInfo.IsTable || MyItemInfo.IsFigure || MyItemInfo.IsSection || MyItemInfo.IsProcedure))
@@ -1322,7 +1283,7 @@ namespace Volian.Controls.Library
// disable buttons. Info panels for ROs and Transitions are made invisible in frmVEPROMS.cs
btnInsTrans.Enabled = btnCMTransition.Enabled = btnInsRO.Enabled = btnCMRO.Enabled = false;
btnInsAftH.Enabled = btnInsBefH.Enabled = false;
- btnInsHLS.Enabled = (!MyItemInfo.IsStepSection) ? false : true; // allow hls from step section
+ btnInsHLS.Enabled = (!MyItemInfo.IsStepSection || (MyItemInfo.IsStepSection && MyItemInfo.IsEnhancedSection)) ? false : true; // allow hls from step section
// if active item is a section and format has metasections, check that a hls can be added.
if (MyItemInfo.IsStepSection)
{
@@ -1350,9 +1311,10 @@ namespace Volian.Controls.Library
StepData sd = MyItemInfo.FormatStepData;
actable = sd.StepEditData.AcTable;
if (actable == null) actable = 0;
- btnInsHLS.Enabled = true;
- btnInsCaut.Enabled = (actable & E_AccStep.AddingCaution) > 0;
- btnInsNote.Enabled = (actable & E_AccStep.AddingNote) > 0;
+
+ btnInsHLS.Enabled = !MyItemInfo.IsEnhancedStep; // (actable & E_AccStep.EnhancedLinkedStep) == 0;
+ btnInsCaut.Enabled = ((actable & E_AccStep.AddingCaution) > 0) && !MyItemInfo.IsEnhancedStep; // ((actable & E_AccStep.AddingCaution) > 0) && ((actable & E_AccStep.EnhancedLinkedStep) == 0);
+ btnInsNote.Enabled = ((actable & E_AccStep.AddingNote) > 0) && !MyItemInfo.IsEnhancedStep;
btnInsRNO.Enabled = (actable & E_AccStep.AddingRNO) > 0;
btnInsFig.Enabled = (actable & E_AccStep.AddingTable) > 0;
btnInsTable.Enabled = (actable & E_AccStep.AddingTable) > 0;
@@ -1733,13 +1695,7 @@ namespace Volian.Controls.Library
myRtb.SelectedText = _MyStepRTB.GetPasteText(PasteNoReturnsSetting, myDO);
else
{
- tmpForLink = Regex.Replace(tmpForLink, @"#Link:ReferencedObject:[0-9]+ ", @"#Link:ReferencedObject: ");
- tmpForLink = Regex.Replace(tmpForLink, @"#Link:Transition:([0-9]+) [0-9]+ ", @"#Link:Transition:$1 ");
- tmpForLink = Regex.Replace(tmpForLink, @"#Link:TransitionRange:([0-9]+) [0-9]+ ", @"#Link:TransitionRange:$1 ");
- tmpForLink = tmpForLink.Replace(@"\u8212 \'96", @"-"); // Replace EM Dash with hyphen
- tmpForLink = tmpForLink.Replace(@"\u8211 \'96", @"-"); // Replace EN Dash with hyphen
- tmpForLink = tmpForLink.Replace(@"\u8212 ", @"-"); // Replace EM Dash with hyphen
- tmpForLink = tmpForLink.Replace(@"\u8211 ", @"-"); // Replace EN Dash with hyphen
+ tmpForLink = ItemInfo.ReplaceLinkWithNewID(tmpForLink);
myRtb.SelectedRtf = tmpForLink;
// Fix for B2014-071: if link, save after paste so that goto's don't crash (grid & step run through this code)
if (tmpForLink.Contains("")) _MyStepRTB.OnDoSaveContents(this, new EventArgs());
@@ -2337,7 +2293,7 @@ namespace Volian.Controls.Library
bool surpressMessageBox = (e == null);
SectionInfo si = MyEditItem.MyItemInfo as SectionInfo;
- if (si != null)
+ if (si != null) // KBR What if linked to an enhanced section?
{
string msg = si.HasChildren ? "Are you sure you want to delete this section and its steps?" : "Are you sure you want to delete this section?";
DialogResult result = MessageBox.Show(msg, "Verify Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
@@ -3274,7 +3230,6 @@ namespace Volian.Controls.Library
(this.Parent as StepTabPanel).MyDisplayTabControl.ItemsChangeIds.Add(_MyEditItem.MyStepRTB.MyItemInfo.MyProcedure.ItemID, txtBxChgId.Text);
}
}
- public enum E_FieldToEdit { StepText, Text, Number, PSI };
public class StepTabRibbonEventArgs : EventArgs
{
public StepTabRibbonEventArgs() { ; }
diff --git a/PROMS/Volian.Controls.Library/vlnTreeView.cs b/PROMS/Volian.Controls.Library/vlnTreeView.cs
index 4c7c4b3d..bce64b2c 100644
--- a/PROMS/Volian.Controls.Library/vlnTreeView.cs
+++ b/PROMS/Volian.Controls.Library/vlnTreeView.cs
@@ -810,6 +810,7 @@ namespace Volian.Controls.Library
// A word doc section can contain another subsection (either step section or word doc section),
// but cannot contain steps.
SectionInfo si = tn.VEObject as SectionInfo;
+ // if this is an enhanced section, don't do 'New Step'
if (ui.IsAdministrator() || ui.IsSetAdministrator(si.MyProcedure.MyDocVersion) || ui.IsWriter(si.MyProcedure.MyDocVersion))
{
if (si.HasWordContent)
@@ -832,7 +833,7 @@ namespace Volian.Controls.Library
if (si.IsStepSection)
{
SectionConfig sc = si.MyConfig as SectionConfig;
- if (si.Sections == null || si.Sections.Count == 0 || (meta && sc != null && si.Sections != null && si.Sections.Count > 0 && sc.SubSection_Edit == "Y"))
+ if (!si.IsEnhancedSection && (si.Sections == null || si.Sections.Count == 0 || (meta && sc != null && si.Sections != null && si.Sections.Count > 0 && sc.SubSection_Edit == "Y")))
cm.MenuItems.Add("New Step", new EventHandler(mi_Click));
}
}
@@ -897,7 +898,15 @@ namespace Volian.Controls.Library
{
DocVersionInfo di = tn.VEObject as DocVersionInfo;
if (di == null || tn.Nodes.Count == 0) // it's not a docversion or it has no children
- cm.MenuItems.Add("Delete", new EventHandler(mi_Click));
+ {
+ // if it's an enhanced step that was linked from a source, don't allow delete
+ bool canDoDel = true;
+ ItemInfo iienh = tn.VEObject as ItemInfo;
+ if (iienh != null && iienh.IsProcedure && iienh.IsEnhancedProcedure) canDoDel = false;
+ if (iienh != null && iienh.IsSection && iienh.IsEnhancedSection && !iienh.IsEnhancedSectionTitleOnly) canDoDel = false;
+ if (iienh != null && iienh.IsEnhancedStep) canDoDel = false;
+ if (canDoDel) cm.MenuItems.Add("Delete", new EventHandler(mi_Click));
+ }
}
}
}
@@ -1750,6 +1759,12 @@ namespace Volian.Controls.Library
string chgId = OnGetChangeId(this, new vlnTreeItemInfoEventArgs(ii));
ItemInfo newItemInfo = null;
newItemInfo = ii.PasteChild(copyStartID, chgId);
+ if (newItemInfo != null)
+ {
+ // paste enhanced steps if applicable (this code is only run if a step is pasted, not for a section).
+ ItemInfo.EAddpingPart addpart = ItemInfo.EAddpingPart.Child;
+ ItemInfo newEnhStep = newItemInfo.PasteEnhancedItems(copyStartID, ii, addpart, chgId);
+ }
}
if (pasteSectIntoEmptySect)
{
@@ -1766,16 +1781,23 @@ namespace Volian.Controls.Library
ItemInfo.EAddpingPart pasteOpt = newtype == MenuSelections.StepBefore ? ItemInfo.EAddpingPart.Before : ItemInfo.EAddpingPart.After;
// If parent step is open in step editor, the 'OnPasteItemInfo' event will cause
// the item to be pasted in the step editor and the tree.
+ ItemInfo newItemInfo = null;
if (ii.IsProcedure || !OnPasteItemInfo(this, new vlnTreeItemInfoPasteEventArgs(ii, copyStartID, pasteOpt, ii.MyContent.Type)))
{
// The parent step was not open in the step editor, just paste step (in data) and add treenode.
// first, check if a changeid is required.
string chgId = OnGetChangeId(this, new vlnTreeItemInfoEventArgs(ii));
- ItemInfo newItemInfo = null;
if (newtype == MenuSelections.StepBefore)
newItemInfo = ii.PasteSiblingBefore(copyStartID, chgId);
else
newItemInfo = ii.PasteSiblingAfter(copyStartID, chgId);
+ if (newItemInfo != null)
+ {
+ // paste enhanced steps if applicable (this code is only run if a step is pasted, not for a section).
+ ItemInfo.EAddpingPart addpart = ItemInfo.EAddpingPart.After;
+ if (newtype == MenuSelections.StepBefore) addpart = ItemInfo.EAddpingPart.Before;
+ ItemInfo newEnhStep = newItemInfo.PasteEnhancedItems(copyStartID, ii, addpart, chgId);
+ }
}
SelectedNode = (VETreeNode)((newtype == MenuSelections.StepAfter) ? tn.NextNode : tn.PrevNode);
}
@@ -1789,7 +1811,12 @@ namespace Volian.Controls.Library
// first, check if a changeid is required.
string chgId = OnGetChangeId(this, new vlnTreeItemInfoEventArgs(ii));
ItemInfo replItemInfo = Item.PasteReplace(ii, copyStartID, chgId);
- if(replItemInfo != null) OnOpenItem(this,new vlnTreeItemInfoEventArgs(replItemInfo));
+ StepConfig replItemConfig = ii.MyConfig as StepConfig;
+ if (replItemInfo != null)
+ {
+ OnOpenItem(this, new vlnTreeItemInfoEventArgs(replItemInfo));
+ ItemInfo newEnhStep = replItemInfo.EnhancedPasteItem(copyStartID, ii, ItemInfo.EAddpingPart.Replace, chgId);
+ }
}
SelectedNode = (VETreeNode)((prevtn != null) ? prevtn.NextNode : partn.FirstNode);
}
@@ -1978,6 +2005,11 @@ namespace Volian.Controls.Library
procedure.Save();
tn = new VETreeNode(_LastProcedureInfo);
SelectedNode.Nodes.Add(tn); // add tree node to end of list.
+ if (procedure.MyProcedureInfo.CreateEnhanced)
+ {
+ procedure.MyProcedureInfo.CreateEnhanced = false;
+ CreateEnhancedForProcedure(newtype, procedure, null);
+ }
}
else
p1 = procedure.ItemID;
@@ -1990,6 +2022,7 @@ namespace Volian.Controls.Library
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.
+ ProcedureInfo savLastProcedureInfo = _LastProcedureInfo;
using (Procedure procedure = Procedure.MakeProcedure((newtype == MenuSelections.ProcedureAfter) ? null : _LastProcedureInfo.ActiveParent, (newtype == MenuSelections.ProcedureAfter) ? _LastProcedureInfo : _LastProcedureInfo.MyPrevious, null, "New Procedure", 0))
{
ShowBrokenRules(procedure.BrokenRulesCollection);
@@ -2000,6 +2033,11 @@ namespace Volian.Controls.Library
tn = new VETreeNode(_LastProcedureInfo);
TreeNode par = SelectedNode.Parent;
par.Nodes.Insert(tvindex + ((newtype == MenuSelections.ProcedureBefore) ? 0 : 1), tn);
+ if (procedure.MyProcedureInfo.CreateEnhanced)
+ {
+ procedure.MyProcedureInfo.CreateEnhanced = false;
+ CreateEnhancedForProcedure(newtype, procedure, savLastProcedureInfo);
+ }
}
else
p2 = procedure.ItemID;
@@ -2044,6 +2082,7 @@ namespace Volian.Controls.Library
using(Section section = CreateNewSection())
{
ShowBrokenRules(section.BrokenRulesCollection);
+ SectionInfo savLastSectionInfo = _LastSectionInfo;
SetLastValues(SectionInfo.Get(section.ItemID));
if (OnNodeOpenProperty(this, new vlnTreePropertyEventArgs("New Section", section.SectionConfig)) == DialogResult.OK)
{
@@ -2051,6 +2090,12 @@ namespace Volian.Controls.Library
{
tn = new VETreeNode(_LastSectionInfo);
SelectedNode.Nodes.Add(tn); // add tree node to end of list.
+ // if the new section was flagged as either having an enhanced link for Title or Contents, create the
+ // Enhanced section:
+ Section sectiontmp = Section.Get(section.ItemID); // need to do this because of 'caching' problem.
+ if (sectiontmp.SectionConfig.LinkEnhanced == "T" || sectiontmp.SectionConfig.LinkEnhanced == "Y")
+ CreateEnhancedForSection(newtype, sectiontmp, savLastSectionInfo);
+ sectiontmp.Dispose();
OnNodeSelect(this, new vlnTreeEventArgs(tn));
}
else
@@ -2094,6 +2139,12 @@ namespace Volian.Controls.Library
SelectedNode.Nodes.Add(tnPart);
tn = new VETreeNode(_LastSectionInfo);
tnPart.Nodes.Add(tn); // add tree node to end of list.
+ // if the new section was flagged as either having an enhanced link for Title or Contents, create the
+ // Enhanced section:
+ Section sectiontmp = Section.Get(section.ItemID); // need to do this because of 'caching' problem.
+ if (sectiontmp.SectionConfig.LinkEnhanced == "T" || sectiontmp.SectionConfig.LinkEnhanced == "Y")
+ CreateEnhancedForSection(newtype, sectiontmp, savLastSectionInfo);
+ sectiontmp.Dispose();
}
}
else
@@ -2117,15 +2168,23 @@ namespace Volian.Controls.Library
using (Section section = Section.MakeSection((newtype == MenuSelections.SectionAfter) ? null : _LastSectionInfo.MyParent, (newtype == MenuSelections.SectionAfter) ? _LastSectionInfo : _LastSectionInfo.MyPrevious, null, "New Section", 10000))
{
ShowBrokenRules(section.BrokenRulesCollection);
+ SectionInfo savLastSectionInfo = _LastSectionInfo;
SetLastValues(SectionInfo.Get(section.ItemID));
TreeNode par = SelectedNode.Parent;
if (OnNodeOpenProperty(this, new vlnTreePropertyEventArgs("New Section", section.SectionConfig)) == DialogResult.OK)
{
int indx = tvindex + ((newtype == MenuSelections.SectionBefore) ? 0 : 1);
- if (indx >= par.Nodes.Count || (par.Nodes[indx] as VETreeNode).VEObject.ToString() != _LastSectionInfo.ToString())
+ int itemido = (indx >= par.Nodes.Count)?-1:(((par.Nodes[indx] as VETreeNode).VEObject) as ItemInfo).ItemID;
+ if (indx >= par.Nodes.Count || (par.Nodes[indx] as VETreeNode).VEObject.ToString() != _LastSectionInfo.ToString() || itemido !=section.ItemID)
{
tn = new VETreeNode(_LastSectionInfo);
par.Nodes.Insert(indx, tn);
+ // if the new section was flagged as either having an enhanced link for Title or Contents, create the
+ // Enhanced section:
+ Section sectiontmp = Section.Get(section.ItemID); // need to do this because of 'caching' problem.
+ if (sectiontmp.SectionConfig.LinkEnhanced == "T" || sectiontmp.SectionConfig.LinkEnhanced == "Y")
+ CreateEnhancedForSection(newtype, sectiontmp, savLastSectionInfo);
+ sectiontmp.Dispose();
}
}
else
@@ -2166,6 +2225,151 @@ namespace Volian.Controls.Library
OnNodeInsert(this, new vlnTreeEventArgs(SelectedNode));
}
}
+ private void CreateEnhancedForProcedure(MenuSelections typ, Procedure sourceProc, ProcedureInfo lastProcedureInfo)
+ {
+ if (typ == MenuSelections.ProcedureAfter || typ == MenuSelections.ProcedureBefore) // new from procedure (before or after)
+ {
+ // The procedure that this is inserted from may not have associated enhanced procedures. Going up list, look for a procedure
+ // that has enhanced.
+ ItemInfo tmpPI = lastProcedureInfo;
+ EnhancedDocuments eds = null;
+ while (eds == null && tmpPI != null)
+ {
+ ProcedureConfig pc = tmpPI.MyConfig as ProcedureConfig;
+ if (pc.MyEnhancedDocuments != null && pc.MyEnhancedDocuments.Count > 0)
+ {
+ eds = pc.MyEnhancedDocuments;
+ break;
+ }
+ tmpPI = tmpPI.MyPrevious;
+ }
+ if (eds != null)
+ {
+ foreach (EnhancedDocument ped in eds)
+ {
+ ProcedureInfo epi = ProcedureInfo.Get(ped.ItemID);
+ using (Procedure newenhProcedure = Procedure.MakeProcedure((typ == MenuSelections.ProcedureAfter) ? null : epi.ActiveParent, (typ == MenuSelections.ProcedureAfter) ? epi : epi.MyPrevious, null, "New Procedure", 0))
+ {
+ SaveEnhancedForProcedure(sourceProc, newenhProcedure, ped.Type);
+ RefreshRelatedNode(ProcedureInfo.Get(newenhProcedure.ItemID));
+ }
+ }
+ return;
+ }
+ }
+ // do the following code if insert the procedure from docverion, or if no linked procedure was found above while doing an insert section from before/after
+ DocVersionConfig dvc = sourceProc.MyProcedureInfo.MyDocVersion.MyConfig as DocVersionConfig;
+ ProcedureConfig sourcecfg = sourceProc.ProcedureConfig;
+ if (dvc != null)
+ {
+ foreach (DVEnhancedDocument ded in dvc.MyEnhancedDocuments)
+ {
+ // get the enhaced docversioninfo:
+ DocVersionInfo enhDVInfo = DocVersionInfo.Get(ded.VersionID);
+ using (Procedure newenhProcedure = Procedure.MakeProcedure(enhDVInfo, enhDVInfo.Procedures.Count != 0 ? enhDVInfo.Procedures[enhDVInfo.Procedures.Count - 1] : null, null, "New Procedure", 0))
+ {
+ SaveEnhancedForProcedure(sourceProc, newenhProcedure, ded.Type);
+ RefreshRelatedNode(ProcedureInfo.Get(newenhProcedure.ItemID)); // this updates the treeview to include the new enhanced procedure
+ }
+ }
+ }
+ }
+ private void SaveEnhancedForProcedure(Procedure sourceProc, Procedure newenhProcedure, int enhtype)
+ {
+ ProcedureConfig newenhcfg = new ProcedureConfig(newenhProcedure);
+ newenhcfg.AddEnhancedDocument(0, sourceProc.ItemID);
+ newenhcfg.SaveEnhancedDocuments();
+ using (Content c1 = Content.Get(newenhProcedure.ContentID))
+ {
+ c1.Config = newenhcfg.ToString();
+ c1.Save();
+ }
+ sourceProc.ProcedureConfig.AddEnhancedDocument(enhtype, newenhProcedure.ItemID);
+ sourceProc.ProcedureConfig.SaveEnhancedDocuments();
+ using (Content cs = Content.Get(sourceProc.ContentID))
+ {
+ cs.Config = sourceProc.ProcedureConfig.ToString();
+ cs.Save();
+ }
+ }
+ private void CreateEnhancedForSection(MenuSelections typ, Section sourceSect, SectionInfo lastSectionInfo)
+ {
+ if (typ == MenuSelections.SectionAfter || typ == MenuSelections.SectionBefore)
+ {
+ ItemInfo tmpSI = lastSectionInfo;
+ EnhancedDocuments eds = null; // need to find a good list, i.e. there may be non-linked sections before/after:
+ while (eds == null && tmpSI != null)
+ {
+ SectionConfig sc = tmpSI.MyConfig as SectionConfig;
+ if (sc.MyEnhancedDocuments != null && sc.MyEnhancedDocuments.Count > 0)
+ {
+ eds = sc.MyEnhancedDocuments;
+ break;
+ }
+ tmpSI = tmpSI.MyPrevious;
+ }
+ if (eds != null) // found valid enhanced ids to insert from:
+ {
+ foreach (EnhancedDocument sed in eds)
+ {
+ SectionInfo esi = SectionInfo.Get(sed.ItemID);
+ using (Section newenhSection = Section.MakeSection((typ == MenuSelections.SectionAfter) ? null : esi.ActiveParent, (typ == MenuSelections.SectionAfter) ? esi : esi.MyPrevious, null, "New Section", 10000))
+ {
+ SaveEnhancedForSection(sourceSect, newenhSection, sed.Type);
+ RefreshRelatedNode(SectionInfo.Get(newenhSection.ItemID));
+ }
+ }
+ return;
+ }
+ }
+ // do the following code if insert the section from the procedure, or if no linked section was found above while doing an insert section from before/after
+ ProcedureConfig pc = sourceSect.MyItemInfo.MyProcedure.MyConfig as ProcedureConfig;
+ SectionConfig sourcecfg = sourceSect.SectionConfig;
+ if (pc != null)
+ {
+ foreach (EnhancedDocument ed in pc.MyEnhancedDocuments)
+ {
+ // get the enhanced procedureinfo:
+ ProcedureInfo enhInfo = ProcedureInfo.Get(ed.ItemID);
+ if (enhInfo.LastChild(E_FromType.Section) != null)
+ {
+ using (Section newenhSection = Section.MakeSection(enhInfo, (enhInfo.Sections != null && enhInfo.Sections.Count != 0) ? enhInfo.Sections[enhInfo.Sections.Count - 1] : null, null, "New Section", 10000))
+ {
+ SaveEnhancedForSection(sourceSect, newenhSection, ed.Type);
+ RefreshRelatedNode(SectionInfo.Get(newenhSection.ItemID));
+ }
+ }
+ else
+ {
+ ItemInfo newenhSectionII = enhInfo.InsertChild(E_FromType.Section, 10000, "New Section", null);
+ using (Section newenhSect = Section.Get(newenhSectionII.ItemID))
+ {
+ SaveEnhancedForSection(sourceSect, newenhSect, ed.Type);
+ RefreshRelatedNode(SectionInfo.Get(newenhSect.ItemID));
+ }
+ }
+ }
+ }
+ }
+ private void SaveEnhancedForSection(Section sourceSect, Section newenhSection, int enhtype)
+ {
+ SectionConfig newenhcfg = new SectionConfig(newenhSection);
+ newenhcfg.AddEnhancedDocument(0, sourceSect.ItemID);
+ newenhcfg.SaveEnhancedDocuments(); // does this save data?
+ using (Content c1 = Content.Get(newenhSection.ContentID))
+ {
+ c1.Config = newenhcfg.ToString();
+ c1.Save();
+ }
+ sourceSect.SectionConfig.AddEnhancedDocument(enhtype, newenhSection.ItemID);
+ sourceSect.SectionConfig.SaveEnhancedDocuments();
+ using (Content cs = Content.Get(sourceSect.ContentID))
+ {
+ cs.Config = sourceSect.SectionConfig.ToString();
+ cs.Save();
+ }
+ }
+
private Section CreateNewSection()
{
if(_LastItemInfo.LastChild(E_FromType.Section) != null)
@@ -2175,12 +2379,21 @@ namespace Volian.Controls.Library
}
private VETreeNode InsertChildStep(VETreeNode tn)
{
+ // 11/17/15: if inserted with step editor open, step gets inserted as child first child. If step editor is not
+ // open, step gets inserted at end (as last item in list)
+
// If parent step is open in editor, use the OnInsertItemInfo to insert step & add RTBItems to step editor panel
ItemInfo ii = tn.VEObject as ItemInfo;
if (OnInsertItemInfo(this, new vlnTreeItemInfoInsertEventArgs(ii, E_InsertType.Child, "New Step", 20002, E_FromType.Step)))
{
- return null; // should we try to get to the child?
+ if (ii.IsStep) return null;
+ // if this was a section, it may have enhanced, so the enhanced steps will need to be created also.
+ SectionConfig scfg = ii.MyConfig as SectionConfig;
+ if (scfg.Section_LnkEnh != "Y") return null;
+ SetLastValues(StepInfo.Get(ii.Steps[0].ItemID));
}
+ else
+ {
// The parent step was not open in the step editor, just create new step and add treenode.
using (Step step = Step.MakeStep(_LastItemInfo, _LastItemInfo.LastChild(E_FromType.Step), null, "New Step", 20002, E_FromType.Step))
{
@@ -2189,6 +2402,35 @@ namespace Volian.Controls.Library
tn = new VETreeNode(_LastStepInfo);
SelectedNode.Nodes.Add(tn); // add tree node to end of list.
}
+ }
+
+ // see if enhanced related steps need created:
+ SectionConfig scfgE = _LastItemInfo.MyActiveSection.MyConfig as SectionConfig;
+ if (scfgE != null && scfgE.Section_LnkEnh=="Y")
+ {
+ // set up which item to insert from based on whether editor was open (see comment from 11/17 above).
+ EnhancedDocuments enhdocs = null;
+ ItemInfo.EAddpingPart addpart = ItemInfo.EAddpingPart.Child;
+ if (_LastItemInfo.MyPrevious != null) // the code above will do the MakeStep regardless of whether editor is up if this is the only step.
+ {
+ addpart = ItemInfo.EAddpingPart.After;
+ ItemInfo lstSrc = _LastItemInfo.MyPrevious;
+ StepConfig stcfg = lstSrc.MyConfig as StepConfig;
+ if (stcfg == null) enhdocs = scfgE.MyEnhancedDocuments;
+ else enhdocs = stcfg.MyEnhancedDocuments;
+ }
+ else
+ {
+ enhdocs = scfgE.MyEnhancedDocuments;
+ }
+ foreach (EnhancedDocument ed in enhdocs)
+ {
+ // the new source step's item is passed in to know what type & what to link to.
+ // The ed.Type & itemid show what type of enhanced document (used to create new
+ // config Type)
+ _LastItemInfo.DoAddEnhancedSteps(ed.Type, ed.ItemID, addpart);
+ }
+ }
return tn;
}
@@ -2198,8 +2440,10 @@ namespace Volian.Controls.Library
ItemInfo ii = tn.VEObject as ItemInfo;
if (OnInsertItemInfo(this, new vlnTreeItemInfoInsertEventArgs(ii, (newtype == MenuSelections.StepAfter) ? E_InsertType.After : E_InsertType.Before, "New Step")))
{
- return (VETreeNode)((newtype == MenuSelections.StepAfter) ? tn.NextNode : tn.PrevNode);
+ tn = (VETreeNode)((newtype == MenuSelections.StepAfter) ? tn.NextNode : tn.PrevNode);
}
+ else
+ {
// The parent step was not open in the step editor, just create new step and add treenode.
int tvindex = SelectedNode.Index;
// if inserting before, the parent is set in case previous is null, i.e. beginning of the list.
@@ -2214,6 +2458,25 @@ namespace Volian.Controls.Library
TreeNode par = SelectedNode.Parent;
par.Nodes.Insert(tvindex + ((newtype == MenuSelections.StepBefore) ? 0 : 1), tn);
}
+ }
+ if (tn != null)
+ {
+ // add enhanced steps if applicable (this code is only run if a step is inserted, not for a section).
+ // Also, NOTE that this is not needed for InsertChildStep from tree because there is no menu item
+ // to support inserting a type that would have enhanced from tree.
+ StepConfig sib = ii.MyConfig as StepConfig;
+ foreach (EnhancedDocument ed in sib.MyEnhancedDocuments)
+ {
+ // create a new enhanced step and link it to this new source step.
+ // the new source step's item is passed in to know what type & what to link to.
+ // The ed.Type & itemid show what type of enhanced document (use to create new
+ // config Type) and itemid is the one to insert after.
+ ItemInfo.EAddpingPart addpart = ItemInfo.EAddpingPart.After;
+ if (newtype == MenuSelections.StepBefore) addpart = ItemInfo.EAddpingPart.Before;
+ ItemInfo newSourceStep = tn.VEObject as ItemInfo;
+ newSourceStep.DoAddEnhancedSteps(ed.Type, ed.ItemID, addpart);
+ }
+ }
return tn;
}
private void ShowBrokenRules(BrokenRulesCollection brs)
@@ -2299,19 +2562,71 @@ namespace Volian.Controls.Library
}
else if (_LastDocVersionInfo != null)
{
+ // if this has enhanced linked DocVersions, delete them first.
+ DocVersionConfig dvc = _LastDocVersionInfo.MyConfig as DocVersionConfig;
+ if (dvc != null && dvc.MyEnhancedDocuments != null && dvc.MyEnhancedDocuments.Count > 0)
+ {
+ foreach (DVEnhancedDocument dve in dvc.MyEnhancedDocuments)
+ {
+ if (dve.Type != 0) DocVersion.Delete(dve.VersionID);
+ }
+ }
DocVersion.Delete(_LastDocVersionInfo.VersionID);
_LastDocVersionInfo = null;
return true;
}
else if (_LastProcedureInfo != null)
{
+ //If there are enhanced, they will also need deleted, save the ids so that they
+ // can be deleted after this item gets deleted.
+ List enhIds = new List();
+ ProcedureConfig prc = _LastProcedureInfo.MyConfig as ProcedureConfig;
+ foreach (EnhancedDocument ed in prc.MyEnhancedDocuments)
+ if (ed.Type != 0) enhIds.Add(ed.ItemID);
// always return false because an event gets fired to delete tree nodes.
if (!DeleteItemInfoAndChildren(_LastProcedureInfo)) return false;
_LastProcedureInfo = null;
+ foreach (int enhId in enhIds)
+ {
+ ProcedureInfo pi = ProcedureInfo.Get(enhId);
+ // if the item was displayed in the editor, the 'DeleteItemInfoAndChildren' call
+ // above will go through user interface code that deletes the enhanced, so 'Get'
+ // will return a null (i.e. the data no longer exists).
+ if (pi != null)
+ {
+ if (!DeleteItemInfoAndChildren(pi)) Console.WriteLine("do an error log item");
+ }
+ }
return false;
}
else if (_LastSectionInfo != null)
{
+ // For sections, there are a number of things to check for if enhanced is active:
+ // 1) in a source and the enhanced link can be none, title or contents.
+ // 2) if none, just delete
+ // 3) If just title and in source, clear links in enhanced back to this source
+ // before delete.
+ // 4) If in enhanced, by source has link type set to title, can delete this
+ // section, but first clear source's links
+
+ //If there are enhanced, they will also need deleted, save the ids so that they
+ // can be deleted after this item gets deleted.
+ List enhIds = new List();
+ SectionConfig sec = _LastSectionInfo.MyConfig as SectionConfig;
+ if (_LastSectionInfo.IsEnhancedSectionTitleOnly)
+ {
+ _LastSectionInfo.ClearEnhancedSectionFromSource(sec.MyEnhancedDocuments[0].ItemID);
+ }
+ else if (sec.Section_LnkEnh == "Y")
+ {
+ foreach (EnhancedDocument ed in sec.MyEnhancedDocuments)
+ if (ed.Type != 0) enhIds.Add(ed.ItemID);
+ }
+ else if (sec.Section_LnkEnh == "T")
+ {
+ // just clear enhanced links back
+ _LastSectionInfo.ClearEnhancedSectionLink();
+ }
OnSectionShouldClose(this, new vlnTreeSectionInfoEventArgs(_LastSectionInfo,true));
// always return false because an event gets fired to delete tree nodes.
if (!DeleteItemInfoAndChildren(_LastSectionInfo))
@@ -2321,13 +2636,43 @@ namespace Volian.Controls.Library
WordSectionEventArgs args = new WordSectionEventArgs(_LastSectionInfo);
OnWordSectionDeleted(this, args);
_LastSectionInfo = null;
+ foreach (int enhId in enhIds)
+ {
+ SectionInfo si = SectionInfo.Get(enhId);
+ // if the item was displayed in the editor, the 'DeleteItemInfoAndChildren' call
+ // above will go through user interface code that deletes the enhanced, so 'Get'
+ // will return a null (i.e. the data no longer exists).
+ if (si != null)
+ {
+ if (!DeleteItemInfoAndChildren(si)) Console.WriteLine("do an error log item");
+ }
+ }
return false;
}
else if (_LastStepInfo != null)
{
+ //If there are enhanced, they will also need deleted, save the ids so that they
+ // can be deleted after this item gets deleted. Note that if the step(s) were
+ // displayed in step editor, that code deletes the enhanced steps.
+ List enhIds = new List();
+ StepConfig sc = _LastStepInfo.MyConfig as StepConfig;
+ foreach (EnhancedDocument ed in sc.MyEnhancedDocuments)
+ if (ed.Type != 0) enhIds.Add(ed.ItemID);
+
// always return false because an event gets fired to delete tree nodes.
if (!DeleteItemInfoAndChildren(_LastStepInfo)) return false;
_LastStepInfo = null;
+ foreach (int enhId in enhIds)
+ {
+ StepInfo si = StepInfo.Get(enhId);
+ // if the item was displayed in the editor, the 'DeleteItemInfoAndChildren' call
+ // above will go through user interface code that deletes the enhanced, so 'Get'
+ // will return a null (i.e. the data no longer exists).
+ if (si != null)
+ {
+ if (!DeleteItemInfoAndChildren(si)) Console.WriteLine("do an error log item");
+ }
+ }
return false;
}
}
@@ -3022,6 +3367,7 @@ namespace Volian.Controls.Library
}
public bool CompareVEObject(IVEDrillDownReadOnly obj1, IVEDrillDownReadOnly obj2)
{
+ if (obj1.GetType().Name != obj2.GetType().Name) return false;
ItemInfo myItem = obj1 as ItemInfo;
if (myItem != null)
if (myItem.ItemID == ((ItemInfo)obj2).ItemID) return true;
diff --git a/PROMS/Volian.Print.Library/PromsPrinter.cs b/PROMS/Volian.Print.Library/PromsPrinter.cs
index 30090da6..13434103 100644
--- a/PROMS/Volian.Print.Library/PromsPrinter.cs
+++ b/PROMS/Volian.Print.Library/PromsPrinter.cs
@@ -1076,11 +1076,11 @@ namespace Volian.Print.Library
private string GetRtfToC(string txt, TableOfContentsData tOfCData, VE_Font overrideFont)
{
StringBuilder _RtfSB = new StringBuilder();
- Volian.Controls.Library.DisplayText toctxt = new Volian.Controls.Library.DisplayText(txt, tOfCData.Font, false);
+ VEPROMS.CSLA.Library.DisplayText toctxt = new VEPROMS.CSLA.Library.DisplayText(txt, tOfCData.Font, false);
System.Drawing.Font myFont = toctxt.TextFont.WindowsFont;
if (overrideFont != null)
{
- toctxt = new Volian.Controls.Library.DisplayText(txt, overrideFont, false);
+ toctxt = new VEPROMS.CSLA.Library.DisplayText(txt, overrideFont, false);
myFont = overrideFont.WindowsFont;//toctxt.TextFont.WindowsFont;
}
_RtfSB.Append(vlnPrintObject.AddFontTable(myFont));
diff --git a/PROMS/Volian.Print.Library/vlnParagraph.cs b/PROMS/Volian.Print.Library/vlnParagraph.cs
index c0a747de..3b792532 100644
--- a/PROMS/Volian.Print.Library/vlnParagraph.cs
+++ b/PROMS/Volian.Print.Library/vlnParagraph.cs
@@ -993,7 +993,7 @@ namespace Volian.Print.Library
DVEnhancedDocuments dveds = MyItemInfo.MyDocVersion.DocVersionConfig.MyEnhancedDocuments;
foreach (EnhancedDocument ed in sc.MyEnhancedDocuments)
{
- DVEnhancedDocument dved = dveds[ed.Type];
+ DVEnhancedDocument dved = dveds.GetByType(ed.Type);
AddLinkToEnhancedDocument(cb, yLocation, ed.ItemID, dved.PdfToken, dved.PdfX);
}
// MyPageHelper.BottomContent = yLocation - Height;