204 lines
6.0 KiB
C#
204 lines
6.0 KiB
C#
using System;
|
|
using System.ComponentModel;
|
|
using System.Collections.Generic;
|
|
using System.Diagnostics;
|
|
using System.Text;
|
|
using System.Drawing;
|
|
using System.Windows.Forms;
|
|
using VEPROMS.CSLA.Library;
|
|
using Volian.Controls.Library;
|
|
|
|
|
|
namespace Volian.Controls.Library
|
|
{
|
|
public partial class DSOTabPanel : DevComponents.DotNetBar.PanelDockContainer
|
|
{
|
|
private DisplayTabControl _MyTabControl;
|
|
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
|
private AxDSOFramer.AxFramerControl _MyDSOFramer;
|
|
private TransPanel _MyTransPanel;
|
|
private static int _Count = 0;
|
|
private DocumentInfo _MyDocument;
|
|
private int _MyCount;
|
|
public static int Count
|
|
{
|
|
get { return _Count; }
|
|
set { _Count = value; }
|
|
}
|
|
private DisplayTabItem _TabItem;
|
|
public DisplayTabItem TabItem
|
|
{
|
|
get { return _TabItem; }
|
|
set { _TabItem = value; }
|
|
}
|
|
//private frmPG _frm = null;
|
|
public DSOTabPanel(DocumentInfo documentInfo, DisplayTabControl myTabControl)
|
|
{
|
|
_MyTabControl = myTabControl;
|
|
InitializeComponent();
|
|
SetupDSOTabPanel();
|
|
_MyDocument = documentInfo;
|
|
SetupDSO();
|
|
//_frm = new frmPG(_MyDSOFramer);
|
|
//_frm.Show();
|
|
}
|
|
private void SetupDSOTabPanel()
|
|
{
|
|
Dock = System.Windows.Forms.DockStyle.Fill;
|
|
}
|
|
public DocumentInfo DocumentInfo
|
|
{
|
|
get { return _MyDocument; }
|
|
}
|
|
private DSOFile _DSOFile;
|
|
internal DSOFile DSOFile
|
|
{
|
|
get
|
|
{
|
|
if (_DSOFile == null)
|
|
_DSOFile = new DSOFile(_MyDocument);
|
|
return _DSOFile;
|
|
}
|
|
}
|
|
public bool IsDirty
|
|
{
|
|
get { return _MyDSOFramer.IsDirty; }
|
|
}
|
|
private void SetupDSO()
|
|
{
|
|
_Count++;
|
|
_MyCount = _Count;
|
|
this._MyTransPanel = new TransPanel();
|
|
this._MyDSOFramer = new AxDSOFramer.AxFramerControl();
|
|
((System.ComponentModel.ISupportInitialize)(this._MyDSOFramer)).BeginInit();
|
|
this.Controls.Add(this._MyDSOFramer);
|
|
this.Controls.Add(this._MyTransPanel);
|
|
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._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._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.Menubar = false;
|
|
this._MyDSOFramer.Titlebar = false;
|
|
//if (_MyCount < 20)
|
|
// this._MyDSOFramer.FrameHookPolicy = DSOFramer.dsoFrameHookPolicy.dsoResetNow;
|
|
this._MyDSOFramer.BeforeDocumentClosed += new AxDSOFramer._DFramerCtlEvents_BeforeDocumentClosedEventHandler(_MyDSOFramer_BeforeDocumentClosed);
|
|
this._MyDSOFramer.OnSaveCompleted += new AxDSOFramer._DFramerCtlEvents_OnSaveCompletedEventHandler(_MyDSOFramer_OnSaveCompleted);
|
|
//this._MyDSOFramer.OnActivationChange += new AxDSOFramer._DFramerCtlEvents_OnActivationChangeEventHandler(_MyDSOFramer_OnActivationChange);
|
|
this.Enter += new EventHandler(DSOTabPanel_Enter);
|
|
this.Leave += new EventHandler(DSOTabPanel_Leave);
|
|
}
|
|
void DSOTabPanel_Leave(object sender, EventArgs e)
|
|
{
|
|
_MyTransPanel.BringToFront();
|
|
}
|
|
void _MyTransPanel_Click(object sender, EventArgs e)
|
|
{
|
|
this.Select();
|
|
}
|
|
void _MyDSOFramer_OnSaveCompleted(object sender, AxDSOFramer._DFramerCtlEvents_OnSaveCompletedEvent e)
|
|
{
|
|
DSOFile.SaveFile();
|
|
}
|
|
void _MyDSOFramer_BeforeDocumentClosed(object sender, AxDSOFramer._DFramerCtlEvents_BeforeDocumentClosedEvent e)
|
|
{
|
|
try
|
|
{
|
|
SaveDirty();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
_MyLog.Warn("Before Closing Document ", ex);
|
|
}
|
|
}
|
|
void DSOTabPanel_Enter(object sender, EventArgs e)
|
|
{
|
|
_MyTransPanel.SendToBack();
|
|
try
|
|
{
|
|
_MyDSOFramer.EventsEnabled = true;
|
|
_MyDSOFramer.FrameHookPolicy = DSOFramer.dsoFrameHookPolicy.dsoResetNow;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
if (_MyLog.IsErrorEnabled) _MyLog.ErrorFormat("DSOTabPage_Enter", ex);
|
|
}
|
|
_MyTabControl.OnItemSelectedChanged(this, null);
|
|
_MyDSOFramer.Focus();
|
|
}
|
|
public bool SaveDSO()
|
|
{
|
|
bool result = true;
|
|
try
|
|
{
|
|
_MyDSOFramer.Save();
|
|
DSOFile.SaveFile();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
if (_MyLog.IsErrorEnabled) _MyLog.Error("SaveDSO", ex);
|
|
result = false;
|
|
}
|
|
return result;
|
|
}
|
|
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)
|
|
return SaveDSO();
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
public bool CloseDSO()
|
|
{
|
|
return CloseDSO(false);
|
|
}
|
|
public bool CloseDSO(bool force)
|
|
{
|
|
_MyLog.Debug("CloseDSO");
|
|
bool result = true;
|
|
try
|
|
{
|
|
_MyDSOFramer.Close();
|
|
Controls.Remove(_MyDSOFramer);
|
|
components.Remove(_MyDSOFramer);
|
|
_MyDSOFramer.Dispose();
|
|
_MyDSOFramer = null;
|
|
_Count--;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
if (_MyLog.IsErrorEnabled) _MyLog.Error("SaveDSO - " + this.Name, ex);
|
|
result = false;
|
|
}
|
|
return result;
|
|
}
|
|
public void Activate()
|
|
{
|
|
try
|
|
{
|
|
this._MyDSOFramer.Activate();
|
|
if (_MyCount < 20)
|
|
this._MyDSOFramer.FrameHookPolicy = DSOFramer.dsoFrameHookPolicy.dsoResetNow;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
if (_MyLog.IsErrorEnabled) _MyLog.Error("Activate", ex);
|
|
}
|
|
}
|
|
}
|
|
}
|