Open Enhanced Document from Procedure or Procedure from Enhanced Document

Added new feature to keep Background Document and Deviation Documents in Sync as the user moves through the procedure.
Support ReadOnly steps for Enhanced Documents linked steps.
This commit is contained in:
Rich 2015-09-12 15:47:44 +00:00
parent 551b71e525
commit a87decdbe3
3 changed files with 173 additions and 75 deletions

View File

@ -48,6 +48,12 @@ namespace Volian.Controls.Library
} }
public partial class DisplayTabControl : UserControl public partial class DisplayTabControl : UserControl
{ {
public event ItemSelectedChangedEvent OpenEnhancedDocument;
public void OnOpenEnhancedDocument(ItemSelectedChangedEventArgs args)
{
if (OpenEnhancedDocument != null)
OpenEnhancedDocument(this, args);
}
public event DisplayTabControlStatusEvent StatusChanged; public event DisplayTabControlStatusEvent StatusChanged;
public void ONStatusChanged(object Sender, DisplayTabControlStatusEventArgs args) public void ONStatusChanged(object Sender, DisplayTabControlStatusEventArgs args)
{ {
@ -92,8 +98,18 @@ namespace Volian.Controls.Library
public Dictionary<int, string> ItemsChangeIds = null; public Dictionary<int, string> ItemsChangeIds = null;
private ItemInfo _MyItemInfo = null; private ItemInfo _MyItemInfo = null;
private EditItem _MyEditItem = null; private EditItem _MyEditItem = null;
public EditItem MyEditItem
{
get { return _MyEditItem; }
set { _MyEditItem = value; }
}
private StepRTB _MyStepRTB = null; private StepRTB _MyStepRTB = null;
private bool _RibbonExpanded=true; private bool _RibbonExpanded=true;
public StepRTB MyStepRTB
{
get { return _MyStepRTB; }
}
public bool RibbonExpanded public bool RibbonExpanded
{ {
get { return _RibbonExpanded; } get { return _RibbonExpanded; }
@ -807,6 +823,22 @@ namespace Volian.Controls.Library
/// </summary> /// </summary>
/// <param name="myItemInfo"></param> /// <param name="myItemInfo"></param>
/// <returns></returns> /// <returns></returns>
public bool IsItemInfoProcedureOpen(ItemInfo ii)
{
ItemInfo proc = ii.MyProcedure; // Find procedure Item
if (dicEnhancedDocuments.ContainsKey(ii.MyProcedure.MyDocVersion))
{
frmEnhanced frm = dicEnhancedDocuments[ii.MyProcedure.MyDocVersion];
string key = "Item - " + proc.ItemID.ToString();
if (frm.MyDisplayTabClntrol._MyDisplayTabItems.ContainsKey(key))
return true;
}
// return true;
//return false;
return false;
}
public Dictionary<DocVersionInfo, frmEnhanced> dicEnhancedDocuments = new Dictionary<DocVersionInfo, frmEnhanced>();
private DisplayTabItem OpenStepTabPage(ItemInfo myItemInfo) private DisplayTabItem OpenStepTabPage(ItemInfo myItemInfo)
{ {
ItemInfo proc = myItemInfo.MyProcedure; // Find procedure Item ItemInfo proc = myItemInfo.MyProcedure; // Find procedure Item
@ -840,9 +872,19 @@ namespace Volian.Controls.Library
} }
Application.DoEvents(); Application.DoEvents();
pg.SelectedItemInfo = myItemInfo; // Select the item pg.SelectedItemInfo = myItemInfo; // Select the item
//StepConfig sc = new StepConfig(myItemInfo.MyContent.Config);
//if (sc.Step_SourceToBackground != null || sc.Step_SourceToDeviation != null)
// pg.MyStepTabPanel.MyStepTabRibbon.btnEnhancedDocSync.Visible = true;
//else
// pg.MyStepTabPanel.MyStepTabRibbon.btnEnhancedDocSync.Visible = false;
return pg; return pg;
} }
private bool _SyncEnhancedDocuments;
public bool SyncEnhancedDocuments
{
get { return _SyncEnhancedDocuments; }
set { _SyncEnhancedDocuments = value; }
}
public void HandleChangeId(ItemInfo myItemInfo, DisplayTabItem pg) public void HandleChangeId(ItemInfo myItemInfo, DisplayTabItem pg)
{ {
if (myItemInfo.ActiveFormat.PlantFormat.FormatData.ProcData.ChangeBarData.ChangeIds) if (myItemInfo.ActiveFormat.PlantFormat.FormatData.ProcData.ChangeBarData.ChangeIds)

View File

@ -410,11 +410,53 @@ namespace Volian.Controls.Library
/// </summary> /// </summary>
/// <param name="sender"></param> /// <param name="sender"></param>
/// <param name="e"></param> /// <param name="e"></param>
private bool _ProcessingEnter = false;
private void _StepRTB_Enter(object sender, EventArgs e) private void _StepRTB_Enter(object sender, EventArgs e)
{ {
if (MyStepPanel.DisplayItemChanging) return; if (MyStepPanel.DisplayItemChanging) return;
//vlnStackTrace.ShowStack("_StepRTB_Enter {0}",this.MyID); //vlnStackTrace.ShowStack("_StepRTB_Enter {0}",this.MyID);
MyStepPanel.SelectedEditItem = this; MyStepPanel.SelectedEditItem = this;
if (MyStepPanel.MyStepTabPanel.MyDisplayTabControl.SyncEnhancedDocuments)
{
if (!_ProcessingEnter)
{
_ProcessingEnter = true;
DisplayTabItem dti = null;
StepConfig sc = new StepConfig(MyItemInfo.MyContent.Config);
if (sc.Step_SourceToBackground != null && sc.Step_SourceToDeviation != null)
{
ItemInfo bii = ItemInfo.Get(int.Parse(sc.Step_SourceToBackground));
if (MyStepPanel.MyStepTabPanel.MyDisplayTabControl.IsItemInfoProcedureOpen(bii))
MyStepPanel.MyStepTabPanel.MyDisplayTabControl.OnOpenEnhancedDocument(new ItemSelectedChangedEventArgs(bii));
// dti = MyStepPanel.MyStepTabPanel.MyDisplayTabControl.OpenItem(bii);
ItemInfo dii = ItemInfo.Get(int.Parse(sc.Step_SourceToDeviation));
if (MyStepPanel.MyStepTabPanel.MyDisplayTabControl.IsItemInfoProcedureOpen(dii))
MyStepPanel.MyStepTabPanel.MyDisplayTabControl.OnOpenEnhancedDocument(new ItemSelectedChangedEventArgs(dii));
//dti = MyStepPanel.MyStepTabPanel.MyDisplayTabControl.OpenItem(dii);
if (dti != null)
dti.MyStepTabPanel.MyDisplayTabControl.OpenItem(this.MyItemInfo);
}
else if (sc.Step_SourceToBackground != null && sc.Step_SourceToDeviation == null)
{
ItemInfo bii = ItemInfo.Get(int.Parse(sc.Step_SourceToBackground));
if (MyStepPanel.MyStepTabPanel.MyDisplayTabControl.IsItemInfoProcedureOpen(bii))
MyStepPanel.MyStepTabPanel.MyDisplayTabControl.OnOpenEnhancedDocument(new ItemSelectedChangedEventArgs(bii));
//dti = MyStepPanel.MyStepTabPanel.MyDisplayTabControl.OpenItem(bii);
if (dti != null)
dti.MyStepTabPanel.MyDisplayTabControl.OpenItem(this.MyItemInfo);
}
else if (sc.Step_SourceToBackground == null && sc.Step_SourceToDeviation != null)
{
ItemInfo dii = ItemInfo.Get(int.Parse(sc.Step_SourceToDeviation));
if (MyStepPanel.MyStepTabPanel.MyDisplayTabControl.IsItemInfoProcedureOpen(dii))
MyStepPanel.MyStepTabPanel.MyDisplayTabControl.OnOpenEnhancedDocument(new ItemSelectedChangedEventArgs(dii));
//dti = MyStepPanel.MyStepTabPanel.MyDisplayTabControl.OpenItem(dii);
if (dti != null)
dti.MyStepTabPanel.MyDisplayTabControl.OpenItem(this.MyItemInfo);
}
_ProcessingEnter = false;
}
}
} }
/// <summary> /// <summary>
/// Pass the AttachmentClick event to the StepPanel control. /// Pass the AttachmentClick event to the StepPanel control.
@ -676,6 +718,7 @@ namespace Volian.Controls.Library
{ {
if (MyStepRTB.ReadOnly) return; if (MyStepRTB.ReadOnly) return;
if (!MyStepRTB.ActiveMode) return; if (!MyStepRTB.ActiveMode) return;
if (MyStepRTB.IsExperimenting) return;
if (MyStepRTB.MyItemInfo.MyContent.Number != null && !MyStepRTB.IsDirty && MyStepRTB.Text.Contains("(Resolved Transition Text)") == false) return; if (MyStepRTB.MyItemInfo.MyContent.Number != null && !MyStepRTB.IsDirty && MyStepRTB.Text.Contains("(Resolved Transition Text)") == false) return;
bool success = MyStepRTB.OrigDisplayText.Save((RichTextBox)MyStepRTB); bool success = MyStepRTB.OrigDisplayText.Save((RichTextBox)MyStepRTB);
if (success) if (success)

View File

@ -303,6 +303,12 @@ namespace Volian.Controls.Library
get { return OrigRTF != Rtf; } get { return OrigRTF != Rtf; }
} }
private bool _InitializingRTB; private bool _InitializingRTB;
private bool _IsExperimenting = false;
public bool IsExperimenting
{
get { return _IsExperimenting; }
set { _IsExperimenting = value; }
}
private IContainer _Container = null; private IContainer _Container = null;
private string _MyClassName=string.Empty; private string _MyClassName=string.Empty;
public string MyClassName public string MyClassName
@ -416,6 +422,7 @@ namespace Volian.Controls.Library
// RefreshDisplay is used to update the rtb for an entire Item as defined by MyItemInfo. // RefreshDisplay is used to update the rtb for an entire Item as defined by MyItemInfo.
public void RefreshDisplay(bool activeMode) public void RefreshDisplay(bool activeMode)
{ {
if (IsExperimenting) return;
ActiveMode = activeMode; ActiveMode = activeMode;
OnAdjustTableWidth(this, new StepRTBTableWidthEventArgs(true)); OnAdjustTableWidth(this, new StepRTBTableWidthEventArgs(true));
_InitializingRTB = true; _InitializingRTB = true;
@ -445,6 +452,12 @@ namespace Volian.Controls.Library
} }
RTBAPI.SetLineSpacing(this, RTBAPI.ParaSpacing.PFS_EXACT); RTBAPI.SetLineSpacing(this, RTBAPI.ParaSpacing.PFS_EXACT);
bool readOnlyStep = MyItemInfo == null || MyItemInfo.FormatStepData == null ? false : MyItemInfo.FormatStepData.ReadOnly; bool readOnlyStep = MyItemInfo == null || MyItemInfo.FormatStepData == null ? false : MyItemInfo.FormatStepData.ReadOnly;
if (!readOnlyStep)
{
StepConfig sc = new StepConfig(MyItemInfo.MyContent.Config);
if (sc.Step_BackgroundToSource != null || sc.Step_DeviationToSource != null)
readOnlyStep = true;
}
ReadOnly = readOnlyStep || VwMode == E_ViewMode.View || ActiveMode == false; ReadOnly = readOnlyStep || VwMode == E_ViewMode.View || ActiveMode == false;
AddRtfText(vlntxt.StartText); AddRtfText(vlntxt.StartText);
//AddRtfStyles(); //AddRtfStyles();
@ -497,8 +510,8 @@ namespace Volian.Controls.Library
// However, if the indent is followed immediately by an RO or Transition the // However, if the indent is followed immediately by an RO or Transition the
// RichTextBox will not allow the character to be removed this way and the RichTextBox // RichTextBox will not allow the character to be removed this way and the RichTextBox
// will beep. So, to keep from going in an infintie loop, the value of indchar is incremented. // will beep. So, to keep from going in an infintie loop, the value of indchar is incremented.
SelectedRtf = SelectedRtf.Replace(@"\'05", ""); SelectedRtf = SelectedRtf.Replace(@"\'05","");
indchar++;// Don't so the same one twice. indchar ++;// Don't so the same one twice.
} }
if (MyItemInfo != null && MyItemInfo.ActiveFormat != null if (MyItemInfo != null && MyItemInfo.ActiveFormat != null
&& MyItemInfo.ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.DontResetIndentOnNewline) && MyItemInfo.ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.DontResetIndentOnNewline)
@ -734,7 +747,7 @@ namespace Volian.Controls.Library
} }
void StepRTB_SelectionChanged(object sender, EventArgs e) void StepRTB_SelectionChanged(object sender, EventArgs e)
{ {
if (_InitializingRTB) return; if (_InitializingRTB || _IsExperimenting) return;
HandleSelectionChange(); HandleSelectionChange();
} }
private bool _MouseDown = false; private bool _MouseDown = false;
@ -1384,7 +1397,7 @@ namespace Volian.Controls.Library
#region TextAndContentsEvents #region TextAndContentsEvents
void StepRTB_TextChanged(object sender, EventArgs e) void StepRTB_TextChanged(object sender, EventArgs e)
{ {
if (_InitializingRTB) return; if (_InitializingRTB || _IsExperimenting) return;
// Was setting _IsDirty to true here, but this was getting called from // Was setting _IsDirty to true here, but this was getting called from
// 'dotnetbar' when text was NOT Changed. So _IsDirty was made into // 'dotnetbar' when text was NOT Changed. So _IsDirty was made into
// a property and compared original rtf versus current richtextbox's // a property and compared original rtf versus current richtextbox's