This commit is contained in:
parent
9541cd18f6
commit
90a4ca821f
@ -7,6 +7,7 @@ using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
using VEPROMS.CSLA.Library;
|
||||
using Volian.Controls.Library;
|
||||
using System.Reflection;
|
||||
|
||||
|
||||
namespace Volian.Controls.Library
|
||||
@ -112,22 +113,45 @@ namespace Volian.Controls.Library
|
||||
//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(MyDSOFile.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.LostFocus += new EventHandler(_MyDSOFramer_LostFocus);
|
||||
//this._MyDSOFramer.GotFocus += new EventHandler(_MyDSOFramer_GotFocus);
|
||||
//this._MyDSOFramer.Enter += new EventHandler(_MyDSOFramer_Enter);
|
||||
//this._MyDSOFramer.Leave += new EventHandler(_MyDSOFramer_Leave);
|
||||
//this._MyDSOFramer.OnActivationChange += new AxDSOFramer._DFramerCtlEvents_OnActivationChangeEventHandler(_MyDSOFramer_OnActivationChange);
|
||||
this.Enter += new EventHandler(DSOTabPanel_Enter);
|
||||
this.Leave += new EventHandler(DSOTabPanel_Leave);
|
||||
//this.GotFocus += new EventHandler(DSOTabPanel_GotFocus);
|
||||
//this.LostFocus += new EventHandler(DSOTabPanel_LostFocus);
|
||||
try
|
||||
{
|
||||
this._MyDSOFramer.Open(MyDSOFile.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.LostFocus += new EventHandler(_MyDSOFramer_LostFocus);
|
||||
//this._MyDSOFramer.GotFocus += new EventHandler(_MyDSOFramer_GotFocus);
|
||||
//this._MyDSOFramer.Enter += new EventHandler(_MyDSOFramer_Enter);
|
||||
//this._MyDSOFramer.Leave += new EventHandler(_MyDSOFramer_Leave);
|
||||
//this._MyDSOFramer.OnActivationChange += new AxDSOFramer._DFramerCtlEvents_OnActivationChangeEventHandler(_MyDSOFramer_OnActivationChange);
|
||||
this.Enter += new EventHandler(DSOTabPanel_Enter);
|
||||
this.Leave += new EventHandler(DSOTabPanel_Leave);
|
||||
//this.GotFocus += new EventHandler(DSOTabPanel_GotFocus);
|
||||
//this.LostFocus += new EventHandler(DSOTabPanel_LostFocus);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
string message = ShowException(ex);
|
||||
Console.WriteLine("\r\n-------------\r\n{0}{1}{2}\r\n-------------\r\n", MyDSOFile.MyFile.FullName, ex.GetType().Name, message);
|
||||
// TODO: Should output a message
|
||||
// TODO: Should try to do a direct open using Word.
|
||||
}
|
||||
}
|
||||
|
||||
private string ShowException(Exception ex)
|
||||
{
|
||||
string sep = "\r\n ";
|
||||
StringBuilder sb = new StringBuilder();
|
||||
do
|
||||
{
|
||||
sb.Append(sep + ex.Message);
|
||||
sep += " ";
|
||||
ex = ex.InnerException;
|
||||
} while (ex != null);
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
//void _MyDSOFramer_Leave(object sender, EventArgs e)
|
||||
@ -189,6 +213,7 @@ namespace Volian.Controls.Library
|
||||
/// <param name="e"></param>
|
||||
void _MyDSOFramer_OnSaveCompleted(object sender, AxDSOFramer._DFramerCtlEvents_OnSaveCompletedEvent e)
|
||||
{
|
||||
MyDSOFile.FullName = GetReflectiveProperty(_MyDSOFramer.ActiveDocument, "FullName");
|
||||
MyDSOFile.SaveFile();
|
||||
}
|
||||
/// <summary>
|
||||
@ -233,7 +258,8 @@ namespace Volian.Controls.Library
|
||||
if (_In_DSOTabPanel_Enter) return;
|
||||
//vlnStackTrace.ShowStack("DSOTabPanel_Enter {0} DocID {1} Index {2} {3}",_In_DSOTabPanel_Enter, this._MyDocumentInfo.DocID, _MyDisplayTabControl.MyBar.SelectedDockTab, sender.GetType().FullName);
|
||||
_In_DSOTabPanel_Enter = true;
|
||||
_MyDisplayTabControl.OnItemSelectedChanged(this,new ItemSelectedChangedEventArgs(MyDisplayTabItem.MyItemInfo));
|
||||
if (MyDisplayTabItem.MyItemInfo != null)
|
||||
_MyDisplayTabControl.OnItemSelectedChanged(this,new ItemSelectedChangedEventArgs(MyDisplayTabItem.MyItemInfo));
|
||||
_MyDSOFramer.Focus();
|
||||
_In_DSOTabPanel_Enter = false;
|
||||
}
|
||||
@ -250,6 +276,7 @@ namespace Volian.Controls.Library
|
||||
try
|
||||
{
|
||||
_MyDSOFramer.Save();
|
||||
MyDSOFile.FullName = GetReflectiveProperty(_MyDSOFramer.ActiveDocument, "FullName");
|
||||
MyDSOFile.SaveFile();
|
||||
}
|
||||
catch (Exception ex)
|
||||
@ -269,7 +296,8 @@ namespace Volian.Controls.Library
|
||||
if (_MyDSOFramer.IsDirty)
|
||||
{
|
||||
// TODO: Should be based upon Item rather than Document.
|
||||
if (MessageBox.Show("Save changes to " + _MyDisplayTabItem.MyItemInfo.TabTitle + "\r\n" + _MyDisplayTabItem.MyItemInfo.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)
|
||||
if (MessageBox.Show("Save changes to " + _MyDisplayTabItem.Text + "\r\n" + _MyDisplayTabItem.Tooltip, "Document has Changed", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
||||
return SaveDSO();
|
||||
return false;
|
||||
}
|
||||
@ -326,5 +354,32 @@ namespace Volian.Controls.Library
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
#region DocumentProperties
|
||||
|
||||
private string GetReflectiveProperty(object objectToInspect, string propertyName)
|
||||
{
|
||||
string returnString = "";
|
||||
//To use reflection on an object, you
|
||||
// first need to get an instance
|
||||
// of that object's type.
|
||||
Type objectType = objectToInspect.GetType();
|
||||
//After you have the object's type, you can get
|
||||
// information on that type. In this case, we're
|
||||
// asking the type to tell us all the
|
||||
// properties that it contains.
|
||||
PropertyInfo[] properties = objectType.GetProperties();
|
||||
//You can then use the PropertyInfo array
|
||||
// to loop through each property of the type.
|
||||
foreach (PropertyInfo property in properties)
|
||||
{
|
||||
//The interest part of this code
|
||||
// is the GetValue method. This method
|
||||
// returns the value of the property.
|
||||
if(property.Name == propertyName)
|
||||
return property.GetValue(objectToInspect, null).ToString();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
@ -16,6 +16,9 @@ namespace Volian.Controls.Library
|
||||
private StepTabPanel _MyStepTabPanel;
|
||||
private string _MyKey;
|
||||
private DSOTabPanel _MyDSOTabPanel;
|
||||
private DocumentInfo _MyDocumentInfo;
|
||||
|
||||
|
||||
#endregion
|
||||
#region Properties
|
||||
/// <summary>
|
||||
@ -59,6 +62,13 @@ namespace Volian.Controls.Library
|
||||
get { return _MyStepTabPanel.SelectedItemInfo; }
|
||||
set { _MyStepTabPanel.SelectedItemInfo = value; }
|
||||
}
|
||||
/// <summary>
|
||||
/// Current DocumentInfo for this page - only set if library document
|
||||
/// </summary>
|
||||
public DocumentInfo MyDocumentInfo
|
||||
{
|
||||
get { return _MyDocumentInfo; }
|
||||
}
|
||||
#endregion
|
||||
#region Constructors
|
||||
public DisplayTabItem(IContainer container, DisplayTabControl myDisplayTabControl, ItemInfo myItemInfo, string myKey)
|
||||
@ -69,16 +79,24 @@ namespace Volian.Controls.Library
|
||||
container.Add(this);
|
||||
InitializeComponent();
|
||||
this.Click += new EventHandler(DisplayTabItem_Click);
|
||||
//this.GotFocus += new EventHandler(DisplayTabItem_GotFocus);
|
||||
//this.LostFocus += new EventHandler(DisplayTabItem_LostFocus);
|
||||
//this.MouseDown += new System.Windows.Forms.MouseEventHandler(DisplayTabItem_MouseDown);
|
||||
//this.MouseUp += new System.Windows.Forms.MouseEventHandler(DisplayTabItem_MouseUp);
|
||||
if (myItemInfo.MyContent.MyEntry == null)
|
||||
SetupStepTabPanel();
|
||||
else
|
||||
SetupDSOTabPanel();
|
||||
Name = string.Format("DisplayTabItem {0}", myItemInfo.ItemID);
|
||||
}
|
||||
public DisplayTabItem(IContainer container, DisplayTabControl myDisplayTabControl, DocumentInfo myDocumentInfo, string myKey)
|
||||
{
|
||||
_MyKey = myKey;
|
||||
_MyDisplayTabControl = myDisplayTabControl;
|
||||
_MyDocumentInfo = myDocumentInfo;
|
||||
container.Add(this);
|
||||
InitializeComponent();
|
||||
this.Click += new EventHandler(DisplayTabItem_Click);
|
||||
SetupLibraryDocumentDSOTabPanel();
|
||||
Name = string.Format("DisplayTabLibraryDocument {0}", myDocumentInfo.DocID);
|
||||
}
|
||||
|
||||
protected override void OnDisplayedChanged()
|
||||
{
|
||||
//Console.WriteLine("=>=>=>=> OnDisplayedChanged");
|
||||
@ -168,13 +186,7 @@ namespace Volian.Controls.Library
|
||||
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[] {
|
||||
@ -182,15 +194,32 @@ namespace Volian.Controls.Library
|
||||
//
|
||||
// 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));
|
||||
}
|
||||
private void SetupLibraryDocumentDSOTabPanel()
|
||||
{
|
||||
_MyDSOTabPanel = new DSOTabPanel(_MyDocumentInfo, _MyDisplayTabControl);
|
||||
//
|
||||
// tabItem
|
||||
//
|
||||
Control = _MyDSOTabPanel;
|
||||
Name = "tabLibraryDocument " + _MyDocumentInfo.DocID;
|
||||
Text = _MyDocumentInfo.LibTitle;
|
||||
DocumentConfig dc = new DocumentConfig(_MyDocumentInfo);
|
||||
Tooltip = dc.LibDoc_Comment;
|
||||
_MyDisplayTabControl.Controls.Add(_MyDSOTabPanel);
|
||||
DSOTabPanel.IgnoreEnter = true;
|
||||
_MyDisplayTabControl.MyBar.Items.AddRange(new DevComponents.DotNetBar.BaseItem[] {
|
||||
this});
|
||||
//
|
||||
// tabPanel
|
||||
//
|
||||
_MyDisplayTabControl.SelectedDisplayTabItem = this;
|
||||
_MyDSOTabPanel.MyDisplayTabItem = this;
|
||||
DSOTabPanel.IgnoreEnter = false;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user