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

@@ -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)