Enhanced: Additional context menu items for create missing & unlink; allow insert hls if in enhanced
This commit is contained in:
parent
be3fb618b6
commit
d4c0f2098d
@ -139,11 +139,14 @@ namespace Volian.Controls.Library
|
||||
// have links to enhanced, but should.
|
||||
List<string> existingEnhancedButtons = new List<string>();
|
||||
foreach (DevComponents.DotNetBar.ButtonItem bi in myButtonItem.SubItems)
|
||||
if (bi.Name.StartsWith("btnEnhancedTo"))
|
||||
if (bi.Name.StartsWith("btnEnhanced"))
|
||||
existingEnhancedButtons.Add(bi.Name);
|
||||
bool inSource = dveds[0].Type != 0; // for later, only 'create missing' enhanced if in Source document
|
||||
if (dveds.Count > existingEnhancedButtons.Count) // add buttons
|
||||
bool inSource = dveds[0].Type != 0;
|
||||
int buttonsNeeded = inSource ? dveds.Count : (dveds.Count * 2); // enhanced items need unlink button also.
|
||||
if (MyItemInfo.IsSection && !MyItemInfo.IsStepSection) buttonsNeeded = 0; // no buttons for word sections
|
||||
if (buttonsNeeded > existingEnhancedButtons.Count) // add buttons
|
||||
{
|
||||
// may need to change the following to add more buttons if a new working draft level was made
|
||||
foreach (DVEnhancedDocument dved in dveds)
|
||||
{
|
||||
string buttonName = string.Format("btnEnhancedTo{0}", dved.Type);
|
||||
@ -151,24 +154,39 @@ namespace Volian.Controls.Library
|
||||
biEnhanced.Click += btnEnhancedGoTo_Click;
|
||||
myButtonItem.SubItems.Add(biEnhanced);
|
||||
existingEnhancedButtons.Add(biEnhanced.Name);
|
||||
if (!inSource)
|
||||
{
|
||||
// add unlink buttons:
|
||||
buttonName = string.Format("btnEnhancedUnlink{0}", dved.Type);
|
||||
biEnhanced = new DevComponents.DotNetBar.ButtonItem(buttonName, "Unlink " + dved.Name + " Document");
|
||||
biEnhanced.Click += btnEnhancedGoTo_Click;
|
||||
myButtonItem.SubItems.Add(biEnhanced);
|
||||
existingEnhancedButtons.Add(biEnhanced.Name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Now handle specific cases for the Item that user is positioned on.
|
||||
// If a link exists, the menu item should be 'go to'.
|
||||
// If a link exists, the menu item should be 'go to' and 'Unlink' if on an enhanced item.
|
||||
// If link doesn't exist
|
||||
// if in source & on high, note or caution, the menu item should be 'create missing'
|
||||
// if in source & on procedure, section, high, note or caution, the menu item should be 'create missing'
|
||||
// else the menu item should be made invisible.
|
||||
StepRTB myStepRTB = sender as StepRTB ?? _MyStepRTB;
|
||||
StepConfig sc = new StepConfig(myStepRTB.MyItemInfo.MyContent.Config);
|
||||
EnhancedDocuments eds = myStepRTB.MyItemInfo.GetMyEnhancedDocuments();
|
||||
foreach (string btnenh in existingEnhancedButtons)
|
||||
{
|
||||
DevComponents.DotNetBar.ButtonItem biEnhanced = myButtonItem.SubItems[btnenh] as DevComponents.DotNetBar.ButtonItem;
|
||||
int edtypebtn = System.Convert.ToInt32(biEnhanced.Name.Substring(biEnhanced.Name.Length - 1));
|
||||
bool itemHasLink = false;
|
||||
foreach (EnhancedDocument ed in sc.MyEnhancedDocuments)
|
||||
if (myStepRTB.MyItemInfo.MyContent.Text == "") // empty text represents a newly inserted step - don't do any enhanced buttons until saved (moved off)
|
||||
biEnhanced.Visible = false;
|
||||
else
|
||||
{
|
||||
foreach (EnhancedDocument ed in eds)
|
||||
{
|
||||
if (edtypebtn == ed.Type) // this button is for this document:
|
||||
{
|
||||
if (biEnhanced.Name.StartsWith("btnEnhancedTo"))
|
||||
{
|
||||
biEnhanced.Visible = true;
|
||||
biEnhanced.Text = "Go To " + dveds.GetByType(ed.Type).Name + " Document";
|
||||
@ -176,50 +194,109 @@ namespace Volian.Controls.Library
|
||||
itemHasLink = true;
|
||||
break;
|
||||
}
|
||||
else // this is for 'unlink'
|
||||
{
|
||||
biEnhanced.Visible = true;
|
||||
biEnhanced.Tag = ed.ItemID;
|
||||
itemHasLink = true;
|
||||
break;
|
||||
|
||||
}
|
||||
if (!itemHasLink)
|
||||
}
|
||||
}
|
||||
// if there is no link & item is in the 'source document', allow the user to create missing
|
||||
// enhanced items
|
||||
if (!itemHasLink && inSource)
|
||||
{
|
||||
// don't put up 'create missing' if the enhanced procedure does not have a section for this step:
|
||||
ItemInfo sectInfo = MyItemInfo.ActiveSection;
|
||||
SectionConfig sectConfig = sectInfo.MyConfig as SectionConfig;
|
||||
bool hasEnhSect = false;
|
||||
foreach (EnhancedDocument edsect in sectConfig.MyEnhancedDocuments)
|
||||
// need to handle procedures, sections and steps differently:
|
||||
if (MyItemInfo.IsProcedure)
|
||||
{
|
||||
if (edsect.Type == edtypebtn)
|
||||
biEnhanced.Visible = true;
|
||||
biEnhanced.Text = string.Format("Create Missing Enhanced {0} Document Procedure", dveds.GetByType(edtypebtn).Name);
|
||||
biEnhanced.Tag = MyItemInfo.ItemID;
|
||||
}
|
||||
else if (MyItemInfo.IsSection)
|
||||
{
|
||||
hasEnhSect = true;
|
||||
// verify that procedure has enhanced procedure for this type
|
||||
EnhancedDocuments peds = MyItemInfo.MyProcedure.GetMyEnhancedDocuments();
|
||||
bool didMenuItem = false;
|
||||
foreach (EnhancedDocument ped in peds)
|
||||
{
|
||||
if (edtypebtn == ped.Type && MyItemInfo.IsStepSection) // this button is for this document:
|
||||
{
|
||||
biEnhanced.Visible = true;
|
||||
biEnhanced.Text = string.Format("Create Missing Enhanced {0} Document Section", dveds.GetByType(edtypebtn).Name);
|
||||
biEnhanced.Tag = MyItemInfo.ItemID;
|
||||
didMenuItem = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (inSource && hasEnhSect && (MyItemInfo.IsHigh || ((MyItemInfo.IsCaution || MyItemInfo.IsNote) && MyItemInfo.MyHLS.GetMyEnhancedDocuments().Count > 0)))
|
||||
if (!didMenuItem) biEnhanced.Visible = false;
|
||||
}
|
||||
else if (MyItemInfo.IsHigh || MyItemInfo.IsCaution || MyItemInfo.IsNote)
|
||||
{
|
||||
EnhancedDocuments seds = MyItemInfo.ActiveSection.GetMyEnhancedDocuments();
|
||||
bool didMenuItem = false;
|
||||
foreach (EnhancedDocument sed in seds)
|
||||
{
|
||||
if (sed.Type == edtypebtn)
|
||||
{
|
||||
if (MyItemInfo.IsHigh || ((MyItemInfo.IsCaution || MyItemInfo.IsNote) && MyItemInfo.MyHLS.GetMyEnhancedDocuments().Count > 0))
|
||||
{
|
||||
biEnhanced.Visible = true;
|
||||
biEnhanced.Text = string.Format("Create Missing Enhanced {0} Document Step", dveds.GetByType(edtypebtn).Name);
|
||||
biEnhanced.Tag = MyItemInfo.ItemID;
|
||||
didMenuItem = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!didMenuItem) biEnhanced.Visible = false;
|
||||
}
|
||||
else
|
||||
biEnhanced.Visible = false;
|
||||
}
|
||||
else if (!itemHasLink && !inSource)
|
||||
biEnhanced.Visible = false;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
public ItemInfo enhUseExist = null;
|
||||
void btnEnhancedGoTo_Click(object sender, EventArgs e)
|
||||
{
|
||||
DevComponents.DotNetBar.BaseItem btn = sender as DevComponents.DotNetBar.BaseItem;
|
||||
ItemInfo ii = ItemInfo.Get(int.Parse(btn.Tag.ToString()));
|
||||
if (ii.ItemID != MyItemInfo.ItemID)
|
||||
{
|
||||
//StepTabPanel tmp = Parent as StepTabPanel;
|
||||
//tmp.MyDisplayTabControl.OpenItem(ii);
|
||||
// OpenEnhancedDocument(this, new StepTabRibbonEventArgs(ii));
|
||||
MyEditItem.MyStepPanel.MyStepTabPanel.MyDisplayTabControl.OnOpenEnhancedDocument(new ItemSelectedChangedEventArgs(ii));
|
||||
// if button name starts with btnEnhancedTo... open it, otherwise, unlink:
|
||||
if (btn.Name.StartsWith("btnEnhancedTo"))
|
||||
{
|
||||
MyEditItem.SaveContents();
|
||||
MyEditItem.MyStepPanel.MyStepTabPanel.MyDisplayTabControl.OnOpenEnhancedDocument(new ItemSelectedChangedEventArgs(ii)); // is this creating ONE?
|
||||
}
|
||||
else if (btn.Name.Contains("Unlink"))
|
||||
MyEditItem.UnlinkEnhanced(MyEditItem.MyItemInfo);
|
||||
}
|
||||
else
|
||||
{
|
||||
// have to create it.
|
||||
int edtype = System.Convert.ToInt32(btn.Name.Replace("btnEnhancedTo", ""));
|
||||
MyEditItem.AddMissingEnhancedStep(ii, edtype);
|
||||
// have to create it. This will bring up a dialog to either create a new step or
|
||||
// link to an existing step:
|
||||
enhUseExist = null;
|
||||
int enhtype = System.Convert.ToInt32(btn.Name.Replace("btnEnhancedTo", ""));
|
||||
dlgEnhMissingItem enhMissDlg = new dlgEnhMissingItem(this, ii, enhtype);
|
||||
DialogResult dr = enhMissDlg.ShowDialog(this.Parent);
|
||||
if (dr == DialogResult.OK)
|
||||
{
|
||||
if (enhUseExist == null)
|
||||
{
|
||||
ItemInfo newEnh = MyEditItem.AddMissingEnhancedStep(ii, enhtype);
|
||||
if (ii.IsProcedure && newEnh != null) OnAddProcToDVInTree(new StepTabRibbonEventArgs(newEnh));
|
||||
}
|
||||
else
|
||||
MyEditItem.CreateLinksEnhancedSteps(ii, enhUseExist, enhtype);
|
||||
MyEditItem.SetFocus();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -790,6 +867,12 @@ namespace Volian.Controls.Library
|
||||
if (ContActionSummaryRequest != null)
|
||||
ContActionSummaryRequest(this, args);
|
||||
}
|
||||
public event StepTabRibbonEvent AddProcToDVInTree;
|
||||
private void OnAddProcToDVInTree(StepTabRibbonEventArgs args)
|
||||
{
|
||||
if (AddProcToDVInTree != null)
|
||||
AddProcToDVInTree(this, args);
|
||||
}
|
||||
void _MyStepRTB_LinkChanged(object sender, StepPanelLinkEventArgs args)
|
||||
{
|
||||
// do all Transition and ReferencedObject menu items/buttons based on whether a 'link is selected' and the link type.
|
||||
@ -1385,7 +1468,8 @@ 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 || (MyItemInfo.IsStepSection && MyItemInfo.IsEnhancedSection)) ? false : true; // allow hls from step section
|
||||
//btnInsHLS.Enabled = (!MyItemInfo.IsStepSection || (MyItemInfo.IsStepSection && MyItemInfo.IsEnhancedSection)) ? false : true; // allow hls from step section
|
||||
btnInsHLS.Enabled = !MyItemInfo.IsStepSection ? 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)
|
||||
{
|
||||
@ -1413,7 +1497,8 @@ namespace Volian.Controls.Library
|
||||
StepData sd = MyItemInfo.FormatStepData;
|
||||
actable = sd.StepEditData.AcTable;
|
||||
if (actable == null) actable = 0;
|
||||
btnInsHLS.Enabled = !MyItemInfo.IsEnhancedStep && MyItemInfo.MyHLS != null && !MyItemInfo.MyHLS.IsEnhancedStep; // (actable & E_AccStep.EnhancedLinkedStep) == 0;
|
||||
//btnInsHLS.Enabled = !MyItemInfo.IsEnhancedStep && MyItemInfo.MyHLS != null && !MyItemInfo.MyHLS.IsEnhancedStep; // (actable & E_AccStep.EnhancedLinkedStep) == 0;
|
||||
btnInsHLS.Enabled = MyItemInfo.MyHLS != null; // (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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user