Object and Property name changes for consistency
This commit is contained in:
@@ -13,81 +13,106 @@ namespace Volian.Controls.Library
|
||||
{
|
||||
public partial class DSOTabPanel : DevComponents.DotNetBar.PanelDockContainer
|
||||
{
|
||||
private DisplayTabControl _MyTabControl;
|
||||
#region Private Fields
|
||||
private DisplayTabControl _MyDisplayTabControl;
|
||||
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
||||
private AxDSOFramer.AxFramerControl _MyDSOFramer;
|
||||
private TransPanel _MyTransPanel;
|
||||
private TransparentPanel _MyTransparentPanel;
|
||||
private static int _Count = 0;
|
||||
private DocumentInfo _MyDocument;
|
||||
private DocumentInfo _MyDocumentInfo;
|
||||
private int _MyCount;
|
||||
private DisplayTabItem _MyDisplayTabItem;
|
||||
private DSOFile _DSOFile;
|
||||
#endregion
|
||||
#region Public Properties
|
||||
/// <summary>
|
||||
/// Count of DSO Pages open. Limited to 18 in DisplayTabControl
|
||||
/// </summary>
|
||||
public static int Count
|
||||
{
|
||||
get { return _Count; }
|
||||
set { _Count = value; }
|
||||
}
|
||||
private DisplayTabItem _TabItem;
|
||||
public DisplayTabItem TabItem
|
||||
/// <summary>
|
||||
/// Pointer to the related DisplayTabItem
|
||||
/// </summary>
|
||||
public DisplayTabItem MyDisplayTabItem
|
||||
{
|
||||
get { return _TabItem; }
|
||||
set { _TabItem = value; }
|
||||
get { return _MyDisplayTabItem; }
|
||||
set { _MyDisplayTabItem = value; }
|
||||
}
|
||||
//private frmPG _frm = null;
|
||||
public DSOTabPanel(DocumentInfo documentInfo, DisplayTabControl myTabControl)
|
||||
/// <summary>
|
||||
/// DocumentInfo record for the Word document
|
||||
/// </summary>
|
||||
public DocumentInfo MyDocumentInfo
|
||||
{
|
||||
_MyTabControl = myTabControl;
|
||||
InitializeComponent();
|
||||
SetupDSOTabPanel();
|
||||
_MyDocument = documentInfo;
|
||||
SetupDSO();
|
||||
//_frm = new frmPG(_MyDSOFramer);
|
||||
//_frm.Show();
|
||||
get { return _MyDocumentInfo; }
|
||||
}
|
||||
private void SetupDSOTabPanel()
|
||||
{
|
||||
Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
}
|
||||
public DocumentInfo DocumentInfo
|
||||
{
|
||||
get { return _MyDocument; }
|
||||
}
|
||||
private DSOFile _DSOFile;
|
||||
internal DSOFile DSOFile
|
||||
/// <summary>
|
||||
/// Temporary Word file used for editing.
|
||||
/// </summary>
|
||||
internal DSOFile MyDSOFile
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_DSOFile == null)
|
||||
_DSOFile = new DSOFile(_MyDocument);
|
||||
_DSOFile = new DSOFile(_MyDocumentInfo);
|
||||
return _DSOFile;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Dirty status. Only saved if dirty.
|
||||
/// </summary>
|
||||
public bool IsDirty
|
||||
{
|
||||
get { return _MyDSOFramer.IsDirty; }
|
||||
}
|
||||
#endregion
|
||||
//private frmPG _frm = null;
|
||||
#region Constructors
|
||||
public DSOTabPanel(DocumentInfo documentInfo, DisplayTabControl myDisplayTabControl)
|
||||
{
|
||||
_MyDisplayTabControl = myDisplayTabControl;
|
||||
InitializeComponent();
|
||||
SetupDSOTabPanel();
|
||||
_MyDocumentInfo = documentInfo;
|
||||
SetupDSO();
|
||||
//_frm = new frmPG(_MyDSOFramer);
|
||||
//_frm.Show();
|
||||
}
|
||||
#endregion
|
||||
#region Private Methods
|
||||
private void SetupDSOTabPanel()
|
||||
{
|
||||
Dock = System.Windows.Forms.DockStyle.Fill; // Automatically Fill the panel
|
||||
}
|
||||
private void SetupDSO()
|
||||
{
|
||||
_Count++;
|
||||
_Count++; // Increment the count of open Word documents (Limit in DisplayTabControl)
|
||||
_MyCount = _Count;
|
||||
this._MyTransPanel = new TransPanel();
|
||||
this._MyTransparentPanel = new TransparentPanel();
|
||||
this._MyDSOFramer = new AxDSOFramer.AxFramerControl();
|
||||
((System.ComponentModel.ISupportInitialize)(this._MyDSOFramer)).BeginInit();
|
||||
this.Controls.Add(this._MyDSOFramer);
|
||||
this.Controls.Add(this._MyTransPanel);
|
||||
this.Controls.Add(this._MyTransparentPanel); // A transparent panel is added over top of the DSO Framer window so that
|
||||
// the related tab can be activated when the user clicks on a Word Document. Since the Word document is actually running
|
||||
// in a different thread, it does not behave properly with focus events.
|
||||
this.components.Add(this._MyDSOFramer);
|
||||
this.components.Add(this._MyTransPanel);
|
||||
this._MyTransPanel.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this._MyTransPanel.Font = new System.Drawing.Font("Tahoma", 14.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this._MyTransPanel.ForeColor = System.Drawing.Color.Brown;
|
||||
this.components.Add(this._MyTransparentPanel);
|
||||
this._MyTransparentPanel.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this._MyTransparentPanel.Font = new System.Drawing.Font("Tahoma", 14.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this._MyTransparentPanel.ForeColor = System.Drawing.Color.Brown; // This is the color used to show InActive on the right side on the Word
|
||||
// document menu line.
|
||||
//this._MyTransPanel.Location = new System.Drawing.Point(0, 0);
|
||||
//this._MyTransPanel.Name = "transPanel1";
|
||||
//this._MyTransPanel.Size = new System.Drawing.Size(370, 423);
|
||||
//this._MyTransPanel.TabIndex = 1;
|
||||
this._MyTransPanel.Click += new EventHandler(_MyTransPanel_Click);
|
||||
this._MyTransparentPanel.Click += new EventHandler(_MyTransparentPanel_Click);
|
||||
this._MyDSOFramer.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
//System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(WordDSOTab));
|
||||
//this._DSOFramer.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("_FC.OcxState")));
|
||||
((System.ComponentModel.ISupportInitialize)(this._MyDSOFramer)).EndInit();
|
||||
this._MyDSOFramer.Open(DSOFile.MyFile.FullName);
|
||||
this._MyDSOFramer.Open(MyDSOFile.MyFile.FullName);
|
||||
this._MyDSOFramer.Menubar = false;
|
||||
this._MyDSOFramer.Titlebar = false;
|
||||
//if (_MyCount < 20)
|
||||
@@ -98,18 +123,40 @@ namespace Volian.Controls.Library
|
||||
this.Enter += new EventHandler(DSOTabPanel_Enter);
|
||||
this.Leave += new EventHandler(DSOTabPanel_Leave);
|
||||
}
|
||||
#endregion
|
||||
#region Event Handlers
|
||||
/// <summary>
|
||||
/// When the user leaves a Word document, place the transparent frame on top with the words "InActive" in the upper right
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
void DSOTabPanel_Leave(object sender, EventArgs e)
|
||||
{
|
||||
_MyTransPanel.BringToFront();
|
||||
_MyTransparentPanel.BringToFront();
|
||||
}
|
||||
void _MyTransPanel_Click(object sender, EventArgs e)
|
||||
/// <summary>
|
||||
/// Force this item to be selected when the transparent window is clicked.
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
void _MyTransparentPanel_Click(object sender, EventArgs e)
|
||||
{
|
||||
this.Select();
|
||||
}
|
||||
/// <summary>
|
||||
/// If the user presses the save button, tell the file to save it's contents to the database
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
void _MyDSOFramer_OnSaveCompleted(object sender, AxDSOFramer._DFramerCtlEvents_OnSaveCompletedEvent e)
|
||||
{
|
||||
DSOFile.SaveFile();
|
||||
MyDSOFile.SaveFile();
|
||||
}
|
||||
/// <summary>
|
||||
/// Before a document closes check to see if it's contents should be saved.
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
void _MyDSOFramer_BeforeDocumentClosed(object sender, AxDSOFramer._DFramerCtlEvents_BeforeDocumentClosedEvent e)
|
||||
{
|
||||
try
|
||||
@@ -121,9 +168,15 @@ namespace Volian.Controls.Library
|
||||
_MyLog.Warn("Before Closing Document ", ex);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// When a Word document is selected make sure it's tab is activated and
|
||||
/// the SelectedItem for the DisplayTabControl is updated.
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
void DSOTabPanel_Enter(object sender, EventArgs e)
|
||||
{
|
||||
_MyTransPanel.SendToBack();
|
||||
_MyTransparentPanel.SendToBack();
|
||||
try
|
||||
{
|
||||
_MyDSOFramer.EventsEnabled = true;
|
||||
@@ -133,16 +186,23 @@ namespace Volian.Controls.Library
|
||||
{
|
||||
if (_MyLog.IsErrorEnabled) _MyLog.ErrorFormat("DSOTabPage_Enter", ex);
|
||||
}
|
||||
_MyTabControl.OnItemSelectedChanged(this, null);
|
||||
_MyDisplayTabControl.OnItemSelectedChanged(this, null);
|
||||
_MyDSOFramer.Focus();
|
||||
}
|
||||
#endregion
|
||||
#region Public Methods
|
||||
/// <summary>
|
||||
/// Save the contents of the Word Document to a file
|
||||
/// and save the file to the database
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public bool SaveDSO()
|
||||
{
|
||||
bool result = true;
|
||||
try
|
||||
{
|
||||
_MyDSOFramer.Save();
|
||||
DSOFile.SaveFile();
|
||||
MyDSOFile.SaveFile();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -151,21 +211,35 @@ namespace Volian.Controls.Library
|
||||
}
|
||||
return result;
|
||||
}
|
||||
/// <summary>
|
||||
/// Check to see if a Word document should be saved. If it is dirty ask the user if the
|
||||
/// changes should be changed. Save the changes if the user says "yes".
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public bool SaveDirty()
|
||||
{
|
||||
if (_MyDSOFramer.IsDirty)
|
||||
{
|
||||
// TODO: Should be based upon Item rather than Document.
|
||||
if (MessageBox.Show("Save changes to " + _TabItem.MyItem.TabTitle + "\r\n" + _TabItem.MyItem.TabToolTip, "Document has Changed", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
||||
if (MessageBox.Show("Save changes to " + _MyDisplayTabItem.MyItemInfo.TabTitle + "\r\n" + _MyDisplayTabItem.MyItemInfo.TabToolTip, "Document has Changed", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
||||
return SaveDSO();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
/// <summary>
|
||||
/// Cleans-up the DSO Framer window
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public bool CloseDSO()
|
||||
{
|
||||
return CloseDSO(false);
|
||||
}
|
||||
/// <summary>
|
||||
/// Cleans-up the DSO Framer window
|
||||
/// </summary>
|
||||
/// <param name="force"></param>
|
||||
/// <returns></returns>
|
||||
public bool CloseDSO(bool force)
|
||||
{
|
||||
_MyLog.Debug("CloseDSO");
|
||||
@@ -186,6 +260,9 @@ namespace Volian.Controls.Library
|
||||
}
|
||||
return result;
|
||||
}
|
||||
/// <summary>
|
||||
/// Activates the current DSO Framer window (Word)
|
||||
/// </summary>
|
||||
public void Activate()
|
||||
{
|
||||
try
|
||||
@@ -199,5 +276,6 @@ namespace Volian.Controls.Library
|
||||
if (_MyLog.IsErrorEnabled) _MyLog.Error("Activate", ex);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user