Object and Property name changes for consistency
This commit is contained in:
@@ -13,48 +13,127 @@ namespace Volian.Controls.Library
|
||||
{
|
||||
public partial class DisplayTabControl : UserControl
|
||||
{
|
||||
private Dictionary<string, DisplayTabItem> _MyPages;
|
||||
public event DisplayPanelEvent ItemClick;
|
||||
private List<DisplayTabItem> _RemovedItems = null;
|
||||
internal void OnItemClick(object sender, DisplayPanelEventArgs args)
|
||||
#region Private Fields
|
||||
/// <summary>
|
||||
/// This is a lookup table for all of the DisplayTabItems that are currently open
|
||||
/// The key is:
|
||||
/// "Item - " + Procedure ItemID for step pages
|
||||
/// "Doc - " + DocumentID for Word Documents
|
||||
/// </summary>
|
||||
private Dictionary<string, DisplayTabItem> _MyDisplayTabItems;
|
||||
/// <summary>
|
||||
/// When a Tab is closed it is added to this list.
|
||||
/// When another Tab is opened, any Tabs in this list are closed
|
||||
/// </summary>
|
||||
private List<DisplayTabItem> _RemovedDisplayTabItems = null;
|
||||
/// <summary>
|
||||
/// This stores a UniqueID for Bars as they are opened.
|
||||
/// A bar is the docking location for the DisplayTabItems.
|
||||
/// </summary>
|
||||
private int _UniqueBarCount;
|
||||
#endregion
|
||||
#region Events
|
||||
/// <summary>
|
||||
/// This event is raised when a the "Tab" of a DisplayItem is clicked with a mouse.
|
||||
/// So far this has just been used for demo purposes. It could be used to select a
|
||||
/// step and it's children for the purpose of copying.
|
||||
/// </summary>
|
||||
public event StepPanelEvent ItemClick;
|
||||
/// <summary>
|
||||
/// Checks to see if the ItemClick event is handled and launches it
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="args"></param>
|
||||
internal void OnItemClick(object sender, StepPanelEventArgs args)
|
||||
{
|
||||
if (ItemClick != null) ItemClick(sender, args);
|
||||
}
|
||||
public event DisplayPanelLinkEvent LinkActiveChanged;
|
||||
internal void OnLinkActiveChanged(object sender, DisplayLinkEventArgs args)
|
||||
/// <summary>
|
||||
/// This occurs when the user moves onto or off of a link within a RichTextBox
|
||||
/// or moves between RichTextBoxes or Pages.
|
||||
/// </summary>
|
||||
public event StepPanelLinkEvent LinkActiveChanged;
|
||||
/// <summary>
|
||||
/// Checks to see if the LinkActiveChanged event is handled and launches it
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="args"></param>
|
||||
internal void OnLinkActiveChanged(object sender, StepPanelLinkEventArgs args)
|
||||
{
|
||||
if (LinkActiveChanged != null) LinkActiveChanged(sender, args);
|
||||
else MessageBox.Show(args.LinkInfo.LinkText, "Unhandled Link Active Changed", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
else MessageBox.Show(args.LinkInfoText, "Unhandled Link Active Changed", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
public event DisplayPanelLinkEvent LinkInsertTran;
|
||||
internal void OnLinkInsertTran(object sender, DisplayLinkEventArgs args)
|
||||
/// <summary>
|
||||
/// This occurs when a Transition is inserted
|
||||
/// </summary>
|
||||
public event StepPanelLinkEvent LinkInsertTran;
|
||||
/// <summary>
|
||||
/// Checks to see if the 'LinkInsertTran' event is handled and launches it
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="args"></param>
|
||||
internal void OnLinkInsertTran(object sender, StepPanelLinkEventArgs args)
|
||||
{
|
||||
if (LinkInsertTran != null) LinkInsertTran(sender, args);
|
||||
else MessageBox.Show(args.LinkInfo.LinkText, "Unhandled Link Insert Tran", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
else MessageBox.Show(args.LinkInfoText, "Unhandled Link Insert Tran", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
public event DisplayPanelLinkEvent LinkInsertRO;
|
||||
internal void OnLinkInsertRO(object sender, DisplayLinkEventArgs args)
|
||||
/// <summary>
|
||||
/// This occurs when an RO is inserted
|
||||
/// </summary>
|
||||
public event StepPanelLinkEvent LinkInsertRO;
|
||||
/// <summary>
|
||||
/// Checks to see if the 'LinkInsertRO' event is handled and launches it
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="args"></param>
|
||||
internal void OnLinkInsertRO(object sender, StepPanelLinkEventArgs args)
|
||||
{
|
||||
if (LinkInsertRO != null) LinkInsertRO(sender, args);
|
||||
else MessageBox.Show(args.LinkInfo.LinkText, "Unhandled Link Insert RO", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
else MessageBox.Show(args.LinkInfoText, "Unhandled Link Insert RO", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
public event DisplayPanelLinkEvent LinkModifyTran;
|
||||
internal void OnLinkModifyTran(object sender, DisplayLinkEventArgs args)
|
||||
/// <summary>
|
||||
/// This occurs when a Transition is modified
|
||||
/// </summary>
|
||||
public event StepPanelLinkEvent LinkModifyTran;
|
||||
/// <summary>
|
||||
/// Checks to see if the 'LinkModifyTran' event is handled and launches it
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="args"></param>
|
||||
internal void OnLinkModifyTran(object sender, StepPanelLinkEventArgs args)
|
||||
{
|
||||
if (LinkModifyTran != null) LinkModifyTran(sender, args);
|
||||
else MessageBox.Show(args.LinkInfo.LinkText, "Unhandled Link Modify Tran", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
else MessageBox.Show(args.LinkInfoText, "Unhandled Link Modify Tran", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
public event DisplayPanelLinkEvent LinkModifyRO;
|
||||
internal void OnLinkModifyRO(object sender, DisplayLinkEventArgs args)
|
||||
/// <summary>
|
||||
/// This occurs when an RO is modified
|
||||
/// </summary>
|
||||
public event StepPanelLinkEvent LinkModifyRO;
|
||||
/// <summary>
|
||||
/// Checks to see if the 'LinkModifyRO' event is handled and launches it
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="args"></param>
|
||||
internal void OnLinkModifyRO(object sender, StepPanelLinkEventArgs args)
|
||||
{
|
||||
if (LinkModifyRO != null) LinkModifyRO(sender, args);
|
||||
else MessageBox.Show(args.LinkInfo.LinkText, "Unhandled Link Modify RO", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
else MessageBox.Show(args.LinkInfoText, "Unhandled Link Modify RO", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
public event DisplayPanelEvent ItemSelectedChanged;
|
||||
internal void OnItemSelectedChanged(object sender, DisplayPanelEventArgs args)
|
||||
/// <summary>
|
||||
/// Occurs when the user selects a different item or page
|
||||
/// </summary>
|
||||
public event StepPanelEvent ItemSelectedChanged;
|
||||
/// <summary>
|
||||
/// Checks to see if the 'ItemSelectedChanged' event is handled and launches it
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="args"></param>
|
||||
internal void OnItemSelectedChanged(object sender, StepPanelEventArgs args)
|
||||
{
|
||||
if (ItemSelectedChanged != null) ItemSelectedChanged(sender, args);
|
||||
}
|
||||
#endregion
|
||||
#region Contructor & Setup
|
||||
public DisplayTabControl()
|
||||
{
|
||||
InitializeComponent();
|
||||
@@ -62,18 +141,13 @@ namespace Volian.Controls.Library
|
||||
}
|
||||
private void SetUp()
|
||||
{
|
||||
_RemovedItems = new List<DisplayTabItem>();
|
||||
_RemovedDisplayTabItems = new List<DisplayTabItem>();
|
||||
Dock = DockStyle.Fill;
|
||||
dotNetBarManager1.Style = DevComponents.DotNetBar.eDotNetBarStyle.Office2007;
|
||||
_MyPages = new Dictionary<string, DisplayTabItem>();
|
||||
_MyDisplayTabItems = new Dictionary<string, DisplayTabItem>();
|
||||
SetupBar(_MyBar);
|
||||
dotNetBarManager1.BarTearOff += new EventHandler(dotNetBarManager1_BarTearOff);
|
||||
}
|
||||
void dotNetBarManager1_BarTearOff(object sender, EventArgs e)
|
||||
{
|
||||
Bar myBar = sender as Bar;
|
||||
myBar.Enter += new EventHandler(myBar_Enter);
|
||||
}
|
||||
private void SetupBar(Bar myBar)
|
||||
{
|
||||
if (myBar.DockTabControl != null)
|
||||
@@ -88,16 +162,38 @@ namespace Volian.Controls.Library
|
||||
myBar.Visible = true;
|
||||
myBar.RecalcLayout();
|
||||
}
|
||||
#endregion
|
||||
#region Internal Event Handlers
|
||||
/// <summary>
|
||||
/// This is code recommended by DotNetBar
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
void dotNetBarManager1_BarTearOff(object sender, EventArgs e)
|
||||
{
|
||||
Bar myBar = sender as Bar;
|
||||
myBar.Enter += new EventHandler(myBar_Enter);
|
||||
}
|
||||
/// <summary>
|
||||
/// This sets-up the bar after it is selected.
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
void myBar_Enter(object sender, EventArgs e)
|
||||
{
|
||||
Bar myBar = sender as Bar;
|
||||
myBar.Enter -= new EventHandler(myBar_Enter);
|
||||
SetupBar(sender as Bar);
|
||||
}
|
||||
/// <summary>
|
||||
/// This handles the closing of a document page
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
void myBar_DockTabClosing(object sender, DockTabClosingEventArgs e)
|
||||
{
|
||||
e.RemoveDockTab = true;
|
||||
_RemovedItems.Add((DisplayTabItem)e.DockContainerItem);
|
||||
_RemovedDisplayTabItems.Add((DisplayTabItem)e.DockContainerItem);
|
||||
DisplayTabItem myTabItem = e.DockContainerItem as DisplayTabItem;
|
||||
if (myTabItem != null)
|
||||
{
|
||||
@@ -117,6 +213,30 @@ namespace Volian.Controls.Library
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
#region Public Methods
|
||||
/// <summary>
|
||||
/// Open a Step Item or a Word Item
|
||||
/// </summary>
|
||||
/// <param name="myItemInfo"></param>
|
||||
/// <returns></returns>
|
||||
public DisplayTabItem OpenItem(ItemInfo myItemInfo)
|
||||
{
|
||||
while (_RemovedDisplayTabItems.Count > 0) // Clean-up any items that have been closed.
|
||||
{
|
||||
DisplayTabItem myTabItem = _RemovedDisplayTabItems[0];
|
||||
_RemovedDisplayTabItems.RemoveAt(0);
|
||||
RemoveItem(myTabItem);
|
||||
}
|
||||
_MyBar = GetParentBar(myItemInfo); // Get the docking bar associated with this item.
|
||||
if (myItemInfo.MyContent.MyEntry == null) // If it is a Word document open it in Word
|
||||
return OpenStepTabPage(myItemInfo);
|
||||
else // Otherwise open it in the step editor
|
||||
return OpenDSOTabPage(myItemInfo);
|
||||
}
|
||||
/// <summary>
|
||||
/// Look for a tab and set it to active.
|
||||
/// </summary>
|
||||
private void ActivateRemainingTab()
|
||||
{
|
||||
foreach (Bar myBar in dotNetBarManager1.Bars)
|
||||
@@ -132,12 +252,18 @@ namespace Volian.Controls.Library
|
||||
// No Document Tabs Remaining - need to raise OnItemSelectedChanged
|
||||
OnItemSelectedChanged(this, null);
|
||||
}
|
||||
private int _UniqueBarCount;
|
||||
#endregion
|
||||
#region Public Properties
|
||||
public DevComponents.DotNetBar.Bar MyBar
|
||||
{
|
||||
get { return _MyBar; }
|
||||
}
|
||||
public DisplayTabItem SelectedTab
|
||||
#endregion
|
||||
#region Private Methods
|
||||
/// <summary>
|
||||
/// Gets and sets the SelectedDisplayTabItem (Active Tab)
|
||||
/// </summary>
|
||||
public DisplayTabItem SelectedDisplayTabItem
|
||||
{
|
||||
get { return (DisplayTabItem)_MyBar.SelectedDockContainerItem; }
|
||||
set
|
||||
@@ -149,33 +275,25 @@ namespace Volian.Controls.Library
|
||||
}
|
||||
}
|
||||
}
|
||||
public DisplayTabItem OpenItem(ItemInfo myItem)
|
||||
{
|
||||
while (_RemovedItems.Count > 0)
|
||||
{
|
||||
DisplayTabItem myTabItem = _RemovedItems[0];
|
||||
_RemovedItems.RemoveAt(0);
|
||||
RemoveItem(myTabItem);
|
||||
}
|
||||
_MyBar = GetParentBar(myItem);
|
||||
if (myItem.MyContent.MyEntry == null)
|
||||
return OpenDisplayTabPage(myItem);
|
||||
else
|
||||
return OpenDSOTabPage(myItem);
|
||||
}
|
||||
private Bar GetParentBar(ItemInfo myItem)
|
||||
/// <summary>
|
||||
/// This returns the parent bar (current docking location) for an item.
|
||||
/// It creates a bar if none exist
|
||||
/// </summary>
|
||||
/// <param name="myItemInfo"></param>
|
||||
/// <returns></returns>
|
||||
private Bar GetParentBar(ItemInfo myItemInfo)
|
||||
{
|
||||
Bar myBar = null;
|
||||
foreach (Bar b in dotNetBarManager1.Bars)
|
||||
{
|
||||
if (b.DockSide == eDockSide.Document && b.Visible)
|
||||
{
|
||||
if(myBar == null)myBar = b;
|
||||
if(myBar == null)myBar = b;// Remember the first available bar if a specific bar cannot be found
|
||||
foreach (object itm in b.Items)
|
||||
{
|
||||
DisplayTabItem myTabItem = itm as DisplayTabItem;
|
||||
if (myTabItem != null && myTabItem.MyTabPanel != null)
|
||||
if (myTabItem.MyTabPanel.MyItem.ItemID == myItem.MyProcedure.ItemID)
|
||||
if (myTabItem != null && myTabItem.MyStepTabPanel != null)
|
||||
if (myTabItem.MyStepTabPanel.MyProcedureItemInfo.ItemID == myItemInfo.MyProcedure.ItemID)
|
||||
return b;
|
||||
}
|
||||
}
|
||||
@@ -192,64 +310,81 @@ namespace Volian.Controls.Library
|
||||
}
|
||||
return myBar;
|
||||
}
|
||||
private DisplayTabItem OpenDisplayTabPage(ItemInfo myItem)
|
||||
/// <summary>
|
||||
/// This opens a Step page based upon a ItemInfo.
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="myItemInfo"></param>
|
||||
/// <returns></returns>
|
||||
private DisplayTabItem OpenStepTabPage(ItemInfo myItemInfo)
|
||||
{
|
||||
ItemInfo proc = myItem.MyProcedure; // Find procedure Item
|
||||
ItemInfo proc = myItemInfo.MyProcedure; // Find procedure Item
|
||||
string key = "Item - " + proc.ItemID.ToString();
|
||||
DisplayTabItem pg = null;
|
||||
if (_MyPages.ContainsKey(key)) // If Procedure Open use it
|
||||
if (_MyDisplayTabItems.ContainsKey(key)) // If procedure page open use it
|
||||
{
|
||||
pg = _MyPages[key];
|
||||
pg = _MyDisplayTabItems[key];
|
||||
pg.Selected = true;
|
||||
SelectedTab = pg;
|
||||
SelectedDisplayTabItem = pg;
|
||||
}
|
||||
else
|
||||
else // If not already open, create a new Page
|
||||
{
|
||||
pg = new DisplayTabItem(this.components, this, proc, key); // Open a new Procedure Tab
|
||||
_MyPages.Add(key, pg);
|
||||
_MyDisplayTabItems.Add(key, pg);
|
||||
pg.Selected = true;
|
||||
SelectedTab = pg;
|
||||
pg.MyTabPanel.MyItem = proc;
|
||||
SelectedDisplayTabItem = pg;
|
||||
pg.MyStepTabPanel.MyProcedureItemInfo = proc;
|
||||
}
|
||||
Application.DoEvents();
|
||||
pg.ItemSelected = myItem; // Select the item
|
||||
pg.SelectedItemInfo = myItemInfo; // Select the item
|
||||
#if (DEBUG)
|
||||
pg.MyTabPanel.MyPanel.BackColor = SystemColors.Control;
|
||||
pg.MyStepTabPanel.MyStepPanel.BackColor = SystemColors.Control;
|
||||
#else
|
||||
pg.MyTabPanel.MyPanel.BackColor = Color.White;
|
||||
#endif
|
||||
return pg;
|
||||
}
|
||||
internal void RemoveItem(DisplayTabItem myItem)
|
||||
{
|
||||
_MyPages.Remove(myItem.MyKey);
|
||||
// Can I dispose the Panel
|
||||
if(myItem.MyTabPanel!=null)
|
||||
myItem.MyTabPanel.Dispose();
|
||||
if (myItem.MyDSOTabPanel != null)
|
||||
myItem.MyDSOTabPanel.CloseDSO();
|
||||
components.Remove(myItem);
|
||||
myItem.Dispose();
|
||||
}
|
||||
private DisplayTabItem OpenDSOTabPage(ItemInfo myItem)
|
||||
/// <summary>
|
||||
/// This opens a Word page based upon an itemInfo. Since a word document may be a library
|
||||
/// document, the related DocID is used for the Word document.
|
||||
/// </summary>
|
||||
/// <param name="myItemInfo"></param>
|
||||
/// <returns></returns>
|
||||
private DisplayTabItem OpenDSOTabPage(ItemInfo myItemInfo)
|
||||
{
|
||||
DisplayTabItem pg = null;
|
||||
EntryInfo myEntry = myItem.MyContent.MyEntry;
|
||||
EntryInfo myEntry = myItemInfo.MyContent.MyEntry;
|
||||
string key = "Doc - " + myEntry.DocID;
|
||||
if (_MyPages.ContainsKey(key)) // If Procedure Open use it
|
||||
pg = _MyPages[key];
|
||||
if (_MyDisplayTabItems.ContainsKey(key)) // If document page open use it
|
||||
pg = _MyDisplayTabItems[key];
|
||||
else
|
||||
{
|
||||
if (DSOTabPanel.Count > 18)
|
||||
if (DSOTabPanel.Count > 18) // Limit the number of open document pages to 18
|
||||
{
|
||||
MessageBox.Show("Too many Word Documents Open. Please close one of the Documents before attempting to open another");
|
||||
return null;
|
||||
}
|
||||
pg = new DisplayTabItem(this.components, this, myItem,key); // Open a new Procedure Tab
|
||||
_MyPages.Add(key, pg);
|
||||
pg = new DisplayTabItem(this.components, this, myItemInfo,key); // Open a new document page
|
||||
_MyDisplayTabItems.Add(key, pg);
|
||||
}
|
||||
SelectedTab = pg;
|
||||
SelectedDisplayTabItem = pg;
|
||||
return pg;
|
||||
}
|
||||
/// <summary>
|
||||
/// Clean-up after a page is closed
|
||||
/// </summary>
|
||||
/// <param name="myDisplayTabItem"></param>
|
||||
internal void RemoveItem(DisplayTabItem myDisplayTabItem)
|
||||
{
|
||||
_MyDisplayTabItems.Remove(myDisplayTabItem.MyKey);
|
||||
// Dispose the Panel
|
||||
if(myDisplayTabItem.MyStepTabPanel!=null)
|
||||
myDisplayTabItem.MyStepTabPanel.Dispose();
|
||||
if (myDisplayTabItem.MyDSOTabPanel != null)
|
||||
myDisplayTabItem.MyDSOTabPanel.CloseDSO();
|
||||
components.Remove(myDisplayTabItem);
|
||||
myDisplayTabItem.Dispose();
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user