Enhanced Documents, handle enhanced steps

Enhanced Documents, delete items
Enhanced Documents button disable/enable
Enhanced Documents, tree view support for insert/delete/copy-paste
Move DisplayText.cs to CSLA
Enhanced Documents adding links (method added in docversion)
This commit is contained in:
2016-01-20 16:46:31 +00:00
parent 6366af8b47
commit 1e3324aa7b
8 changed files with 488 additions and 145 deletions

View File

@@ -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<string> unusedEnhancedButtons = new List<string>();
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:<NewID> ");
tmpForLink = Regex.Replace(tmpForLink, @"#Link:Transition:([0-9]+) [0-9]+ ", @"#Link:Transition:$1 <NewID> ");
tmpForLink = Regex.Replace(tmpForLink, @"#Link:TransitionRange:([0-9]+) [0-9]+ ", @"#Link:TransitionRange:$1 <NewID> ");
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("<NewID>")) _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() { ; }