This commit is contained in:
@@ -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
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user