Tab Controls
This commit is contained in:
187
PROMS/Volian.Controls.Library/DSOTabPanel.cs
Normal file
187
PROMS/Volian.Controls.Library/DSOTabPanel.cs
Normal file
@@ -0,0 +1,187 @@
|
||||
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 static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
||||
private AxDSOFramer.AxFramerControl _MyDSOFramer;
|
||||
private static int _Count = 0;
|
||||
private DocumentInfo _MyDocument;
|
||||
private int _MyCount;
|
||||
private DisplayTabItem _TabItem;
|
||||
public DisplayTabItem TabItem
|
||||
{
|
||||
get { return _TabItem; }
|
||||
set { _TabItem = value; }
|
||||
}
|
||||
public DSOTabPanel(DocumentInfo documentInfo)
|
||||
{
|
||||
InitializeComponent();
|
||||
SetupDSOTabPanel();
|
||||
_MyDocument = documentInfo;
|
||||
SetupDSO();
|
||||
|
||||
}
|
||||
|
||||
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._MyDSOFramer = new AxDSOFramer.AxFramerControl();
|
||||
((System.ComponentModel.ISupportInitialize)(this._MyDSOFramer)).BeginInit();
|
||||
//this.SuspendLayout();
|
||||
this.Controls.Add(this._MyDSOFramer);
|
||||
this.components.Add(this._MyDSOFramer);
|
||||
this._MyDSOFramer.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
//this._MyDSOFramer.Enabled = true;
|
||||
//this._MyDSOFramer.Location = new System.Drawing.Point(0, 0);
|
||||
//this._MyDSOFramer.Name = "_DSOFramer";
|
||||
//System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(WordDSOTab));
|
||||
//this._DSOFramer.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("_FC.OcxState")));
|
||||
//this._MyDSOFramer.Size = new System.Drawing.Size(657, 453);
|
||||
//this._MyDSOFramer.TabIndex = 0;
|
||||
((System.ComponentModel.ISupportInitialize)(this._MyDSOFramer)).EndInit();
|
||||
//this.ResumeLayout(false);
|
||||
this._MyDSOFramer.EventsEnabled = true;
|
||||
this._MyDSOFramer.Open(DSOFile.MyFile.FullName);
|
||||
this._MyDSOFramer.Menubar = false;
|
||||
this._MyDSOFramer.Titlebar = false;
|
||||
//this._DSOFramer.FrameHookPolicy = DSOFramer.dsoFrameHookPolicy.dsoSetOnFirstOpen;
|
||||
if (_MyCount < 20)
|
||||
this._MyDSOFramer.FrameHookPolicy = DSOFramer.dsoFrameHookPolicy.dsoResetNow;
|
||||
this._MyDSOFramer.Invalidated += new InvalidateEventHandler(_DSOFramer_Invalidated);
|
||||
this._MyDSOFramer.BeforeDocumentClosed += new AxDSOFramer._DFramerCtlEvents_BeforeDocumentClosedEventHandler(_MyDSOFramer_BeforeDocumentClosed);
|
||||
//this.Resize += new EventHandler(DSOTabPage_Resize);
|
||||
this.Enter += new EventHandler(DSOTabPanel_Enter);
|
||||
}
|
||||
void _MyDSOFramer_BeforeDocumentClosed(object sender, AxDSOFramer._DFramerCtlEvents_BeforeDocumentClosedEvent e)
|
||||
{
|
||||
try
|
||||
{
|
||||
SaveDirty();
|
||||
//if(SaveDirty()) e.cancel = true;
|
||||
//throw new System.Data.DataException();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_MyLog.Warn("Before Closing Document ", ex);
|
||||
}
|
||||
}
|
||||
void DSOTabPanel_Enter(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
_MyDSOFramer.FrameHookPolicy = DSOFramer.dsoFrameHookPolicy.dsoResetNow;
|
||||
_MyDSOFramer.Focus();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (_MyLog.IsErrorEnabled) _MyLog.ErrorFormat("DSOTabPage_Enter", ex);
|
||||
}
|
||||
}
|
||||
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 " + this.Name, "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)
|
||||
{
|
||||
bool result = true;
|
||||
try
|
||||
{
|
||||
_MyDSOFramer.Close();
|
||||
Controls.Remove(_MyDSOFramer);
|
||||
components.Remove(_MyDSOFramer);
|
||||
_MyDSOFramer.Dispose();
|
||||
_MyDSOFramer = null;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (_MyLog.IsErrorEnabled) _MyLog.Error("SaveDSO - " + this.Name, ex);
|
||||
result = false;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
void _DSOFramer_Invalidated(object sender, InvalidateEventArgs e)
|
||||
{
|
||||
//ConsoleWriteLine("_DSOFramer_Invalidated");
|
||||
if (_MyCount >= 20)
|
||||
_MyDSOFramer.Activate();
|
||||
}
|
||||
//void DSOTabPage_Resize(object sender, EventArgs e)
|
||||
//{
|
||||
// //_DSOFramer.Refresh();
|
||||
//}
|
||||
public void Activate()
|
||||
{
|
||||
try
|
||||
{
|
||||
this._MyDSOFramer.Activate();
|
||||
if (_MyCount < 20)
|
||||
this._MyDSOFramer.FrameHookPolicy = DSOFramer.dsoFrameHookPolicy.dsoResetNow;
|
||||
//this._DSOFramer.FrameHookPolicy = DSOFramer.dsoFrameHookPolicy.dsoSetOnFirstOpen;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (_MyLog.IsErrorEnabled) _MyLog.Error("Activate", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user