using System;
using System.ComponentModel;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;
using System.Drawing;
using VEPROMS.CSLA.Library;
namespace Volian.Controls.Library
{
public partial class DisplayTabItem : DevComponents.DotNetBar.DockContainerItem
{
#region Private Fields
private DisplayTabControl _MyDisplayTabControl;
private ItemInfo _MyItemInfo;
private StepTabPanel _MyStepTabPanel;
private string _MyKey;
private DSOTabPanel _MyDSOTabPanel;
#endregion
#region Properties
///
/// ItemInfo associated with this DisplayTabItem
///
public ItemInfo MyItemInfo
{
get { return _MyItemInfo; }
//set { _MyItemInfo = value; }
}
///
/// get Key Either:
/// "Item - " + Procedure ItemID for step pages
/// "Doc - " + DocumentID for Word Documents
///
public string MyKey
{
get { return _MyKey; }
}
///
/// Related StepTabPanel for a Step page
///
public StepTabPanel MyStepTabPanel
{
get { return _MyStepTabPanel; }
set { _MyStepTabPanel = value; }
}
///
/// Related DSOTabPanle for a Word page
///
public DSOTabPanel MyDSOTabPanel
{
get { return _MyDSOTabPanel; }
set { _MyDSOTabPanel = value; }
}
///
/// Current SelectedItemInfo for this page
///
public ItemInfo SelectedItemInfo
{
get { return _MyStepTabPanel.SelectedItemInfo; }
set { _MyStepTabPanel.SelectedItemInfo = value; }
}
#endregion
#region Constructors
public DisplayTabItem(IContainer container, DisplayTabControl myDisplayTabControl, ItemInfo myItemInfo, string myKey)
{
_MyKey = myKey;
_MyDisplayTabControl = myDisplayTabControl;
_MyItemInfo = myItemInfo;
container.Add(this);
InitializeComponent();
this.Click += new EventHandler(DisplayTabItem_Click);
if (myItemInfo.MyContent.MyEntry == null)
SetupStepTabPanel();
else
SetupDSOTabPanel();
Name = string.Format("DisplayTabItem {0}", myItemInfo.ItemID);
}
#endregion
#region Event Handlers
///
/// Updates SelectedStepItem when the user selects a DisplayTabItem
///
///
///
private void DisplayTabItem_Click(object sender, EventArgs e)
{
// Tell the TabControl that the ItemSelected has changed
DisplayTabItem myTabItem = sender as DisplayTabItem;
if(myTabItem == null)return;
StepTabPanel myTabPanel = myTabItem.MyStepTabPanel as StepTabPanel;
if(myTabPanel == null) return;
_MyDisplayTabControl.OnItemSelectedChanged(this,new ItemSelectedChangedEventArgs(MyStepTabPanel.SelectedStepItem));
}
#endregion
#region private Methods
///
/// Creates and sets-up a StepTabPanel
///
private void SetupStepTabPanel()
{
((System.ComponentModel.ISupportInitialize)(_MyDisplayTabControl.MyBar)).BeginInit();
_MyDisplayTabControl.MyBar.SuspendLayout();
_MyStepTabPanel = new StepTabPanel(_MyDisplayTabControl);
//
// tabItem
//
Control = _MyStepTabPanel;
Name = "tabItem Item " + _MyItemInfo.ItemID;
Text = _MyItemInfo.TabTitle;
Tooltip = _MyItemInfo.TabToolTip;
//
_MyDisplayTabControl.Controls.Add(_MyStepTabPanel);
_MyDisplayTabControl.MyBar.Items.Add(this);
//
// tabPanel
//
_MyStepTabPanel.MyDisplayTabItem = this;
((System.ComponentModel.ISupportInitialize)(_MyDisplayTabControl.MyBar)).EndInit();
_MyDisplayTabControl.MyBar.ResumeLayout(false);
}
///
/// Creates and sets-up a DSOTabPanel
///
private void SetupDSOTabPanel()
{
EntryInfo myEntry = _MyItemInfo.MyContent.MyEntry;
_MyDSOTabPanel = new DSOTabPanel(myEntry.MyDocument, _MyDisplayTabControl);
//
// tabItem
//
Control = _MyDSOTabPanel;
Name = "tabItem Item " + _MyItemInfo.ItemID;
Text = _MyItemInfo.TabTitle;
Tooltip = _MyItemInfo.TabToolTip;
//
//Console.WriteLine("this.Focus {0}", Name);
//this.Focus();
//Console.WriteLine("Controls.Add {0}", Name);
_MyDisplayTabControl.Controls.Add(_MyDSOTabPanel);
//Console.WriteLine("Enabled = false {0}", Name);
//_MyDisplayTabControl.MyBar.Enabled = false;
DSOTabPanel.IgnoreEnter = true;
Console.WriteLine("AddRange {0}", Name);
_MyDisplayTabControl.MyBar.Items.AddRange(new DevComponents.DotNetBar.BaseItem[] {
this});
//
// tabPanel
//
//Console.WriteLine("Enabled = true {0}", Name);
//_MyDisplayTabControl.MyBar.Enabled = true;
Console.WriteLine("SelectedDisplayTabItem {0}", Name);
_MyDisplayTabControl.SelectedDisplayTabItem = this;
Console.WriteLine("MyDisplayTabItem {0}", Name);
_MyDSOTabPanel.MyDisplayTabItem = this;
DSOTabPanel.IgnoreEnter = false;
_MyDisplayTabControl.OnItemSelectedChanged(this, new ItemSelectedChangedEventArgs(MyItemInfo));
}
#endregion
}
}