B2017-133 EDraw - DSO Framer Replacement
This commit is contained in:
parent
8048416576
commit
3f31210ccf
@ -17,7 +17,7 @@ namespace Volian.Controls.Library
|
||||
#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 AxEDWordLib.AxEDWord _MyEdWord; // B2017-133 Edraw DSO Framer Replacement
|
||||
private TransparentPanel _MyTransparentPanel;
|
||||
private static int _Count = 0;
|
||||
private DocumentInfo _MyDocumentInfo;
|
||||
@ -80,9 +80,10 @@ namespace Volian.Controls.Library
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_MyDSOFramer == null) return false;
|
||||
LBDocumentClass doc = new LBDocumentClass(_MyDSOFramer.ActiveDocument);
|
||||
return !doc.Saved;
|
||||
if (_MyEdWord == null) return false; // B2017-133 Edraw Is Dirty Property
|
||||
return _MyEdWord.IsDirty();
|
||||
//LBDocumentClass doc = new LBDocumentClass(_MyEdWord.ActiveDocument());
|
||||
//return !doc.Saved;
|
||||
}
|
||||
}
|
||||
private bool _OverrideClose = false;
|
||||
@ -108,16 +109,48 @@ namespace Volian.Controls.Library
|
||||
_MyDocumentInfo = documentInfo;
|
||||
SetupDSO();
|
||||
_RefreshTimer = new Timer(); // Enabled is false and interval is 1/10th of second.
|
||||
_RefreshTimer.Interval = 1000;// B2017-133 Edraw
|
||||
ClientSizeChanged += new EventHandler(DSOTabPanel_ClientSizeChanged);
|
||||
_RefreshTimer.Tick += new EventHandler(_RefreshTimer_Tick);
|
||||
_MyEdWord.BeforeDocumentClosed += _MyEdWord_BeforeDocumentClosed;// B2017-133 Edraw
|
||||
_MyEdWord.BeforeDocumentOpened += _MyEdWord_BeforeDocumentOpened;// B2017-133 Edraw
|
||||
_MyEdWord.BeforeDocumentSaved += _MyEdWord_BeforeDocumentSaved;// B2017-133 Edraw
|
||||
//_frm = new frmPG(_MyDSOFramer);
|
||||
//_frm.Show();
|
||||
}
|
||||
void _MyEdWord_BeforeDocumentSaved(object sender, EventArgs e)// B2017-133 Edraw
|
||||
{
|
||||
SaveDSO();
|
||||
}
|
||||
void _MyEdWord_BeforeDocumentOpened(object sender, EventArgs e)// B2017-133 Edraw
|
||||
{
|
||||
_MyEdWord.DisableFileCommand(EDWordLib.WdUIType.wdUIDisableClose, true);
|
||||
_MyEdWord.DisableFileCommand(EDWordLib.WdUIType.wdUIDisableNew, true);
|
||||
_MyEdWord.DisableFileCommand(EDWordLib.WdUIType.wdUIDisablePrint, true);
|
||||
_MyEdWord.DisableFileCommand(EDWordLib.WdUIType.wdUIDisablePrintPreview, true);
|
||||
_MyEdWord.DisableFileCommand(EDWordLib.WdUIType.wdUIDisablePrintQuick, true);
|
||||
_MyEdWord.DisableFileCommand(EDWordLib.WdUIType.wdUIDisableSave, false);
|
||||
_MyEdWord.DisableFileCommand(EDWordLib.WdUIType.wdUIDisableSaveAs, true);
|
||||
_MyEdWord.DisableStandardCommand(EDWordLib.CommandType.cmdTypeSave, true);
|
||||
_MyEdWord.DisableStandardCommand(EDWordLib.CommandType.cmdTypeClose, true);
|
||||
_MyEdWord.DisableStandardCommand(EDWordLib.CommandType.cmdTypePrint, true);
|
||||
_MyEdWord.DisableSaveHotKey(true);
|
||||
_MyEdWord.DisablePrintHotKey(true);
|
||||
}
|
||||
void _MyEdWord_BeforeDocumentClosed(object sender, EventArgs e)// B2017-133 Edraw
|
||||
{
|
||||
Console.WriteLine("B2017-133 Edraw Before Document Closed");
|
||||
}
|
||||
void _RefreshTimer_Tick(object sender, EventArgs e)
|
||||
{
|
||||
_RefreshTimer.Enabled = false;
|
||||
if(_MyDSOFramer != null)
|
||||
_MyDSOFramer.Focus();
|
||||
if (_MyEdWord != null)// B2017-133 Edraw
|
||||
{
|
||||
_MyEdWord.Focus();
|
||||
_MyEdWord.GotoItem(EDWordLib.WdGoToItem.wdGoToStart, EDWordLib.WdGoToDirection.wdGoToFirst);
|
||||
//_MyEdWord.BringToFront();
|
||||
//_MyEdWord.EndInit();
|
||||
}
|
||||
}
|
||||
void DSOTabPanel_ClientSizeChanged(object sender, EventArgs e)
|
||||
{
|
||||
@ -135,13 +168,13 @@ namespace Volian.Controls.Library
|
||||
_Count++; // Increment the count of open Word documents (Limit = MSWordLimit)
|
||||
_MyCount = _Count;
|
||||
this._MyTransparentPanel = new TransparentPanel();
|
||||
this._MyDSOFramer = new AxDSOFramer.AxFramerControl();
|
||||
((System.ComponentModel.ISupportInitialize)(this._MyDSOFramer)).BeginInit();
|
||||
this.Controls.Add(this._MyDSOFramer);
|
||||
this._MyEdWord = new AxEDWordLib.AxEDWord();// B2017-133 Edraw
|
||||
_MyEdWord.BeginInit();
|
||||
this.Controls.Add(this._MyEdWord);
|
||||
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._MyEdWord);// B2017-133 Edraw
|
||||
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)));
|
||||
@ -152,20 +185,20 @@ namespace Volian.Controls.Library
|
||||
//this._MyTransPanel.Size = new System.Drawing.Size(370, 423);
|
||||
//this._MyTransPanel.TabIndex = 1;
|
||||
this._MyTransparentPanel.Click += new EventHandler(_MyTransparentPanel_Click);
|
||||
this._MyDSOFramer.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this._MyEdWord.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();
|
||||
_MyEdWord.EndInit();
|
||||
try
|
||||
{
|
||||
try
|
||||
{
|
||||
this._MyDSOFramer.Open(MyDSOFile.MyFile.FullName);
|
||||
//this._MyDSOFramer.Open(MyDSOFile.MyFile.FullName,false,"Word.Document","","");
|
||||
this._MyEdWord.LicenseName = "Volian7573291802";// B2017-133 Edraw
|
||||
this._MyEdWord.LicenseCode = "EDW8-5527-1201-AB8A";// B2017-133 Edraw
|
||||
this._MyEdWord.Open(MyDSOFile.MyFile.FullName);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_MyLog.Warn("dso fraimer error", ex); // put exception message in the error log
|
||||
System.IO.FileStream fs = MyDSOFile.MyFile.Create();
|
||||
using (DocumentAuditInfoList dail = DocumentAuditInfoList.Get(MyDocumentInfo.DocID))
|
||||
{
|
||||
@ -194,36 +227,14 @@ namespace Volian.Controls.Library
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
|
||||
}
|
||||
fs.Close();
|
||||
this._MyDSOFramer.Open(MyDSOFile.MyFile.FullName);
|
||||
this._MyEdWord.Open(MyDSOFile.MyFile.FullName);// B2017-133 Edraw
|
||||
}
|
||||
LBDocumentClass doc = new LBDocumentClass(_MyDSOFramer.ActiveDocument);
|
||||
LBDocumentClass doc = new LBDocumentClass(_MyEdWord.ActiveDocument());
|
||||
Console.WriteLine("Version {0}", doc.Application.Version);
|
||||
float ver;
|
||||
if (!float.TryParse(doc.Application.Version, out ver))
|
||||
ver = 12.0F;
|
||||
this._MyDSOFramer.Menubar = ver < 12.0F;
|
||||
this._MyDSOFramer.set_EnableFileCommand(DSOFramer.dsoFileCommandType.dsoFileClose, false);
|
||||
this._MyDSOFramer.set_EnableFileCommand(DSOFramer.dsoFileCommandType.dsoFileNew, false);
|
||||
this._MyDSOFramer.set_EnableFileCommand(DSOFramer.dsoFileCommandType.dsoFilePageSetup, false);
|
||||
this._MyDSOFramer.set_EnableFileCommand(DSOFramer.dsoFileCommandType.dsoFilePrint, false);
|
||||
this._MyDSOFramer.set_EnableFileCommand(DSOFramer.dsoFileCommandType.dsoFilePrintPreview, false);
|
||||
this._MyDSOFramer.set_EnableFileCommand(DSOFramer.dsoFileCommandType.dsoFileProperties, false);
|
||||
this._MyDSOFramer.set_EnableFileCommand(DSOFramer.dsoFileCommandType.dsoFileSave, false);
|
||||
this._MyDSOFramer.set_EnableFileCommand(DSOFramer.dsoFileCommandType.dsoFileSaveAs, 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);
|
||||
Application.DoEvents();
|
||||
// The following line corrects Symbol characters in MSWord Sections
|
||||
// CheckForSymbolCharacters(doc);
|
||||
@ -240,7 +251,7 @@ namespace Volian.Controls.Library
|
||||
}
|
||||
public void FixSymbolCharacters()
|
||||
{
|
||||
CheckForSymbolCharacters(new LBDocumentClass(_MyDSOFramer.ActiveDocument));
|
||||
CheckForSymbolCharacters(new LBDocumentClass(_MyEdWord.ActiveDocument()));// B2017-133 Edraw
|
||||
}
|
||||
private void CheckForSymbolCharacters(LBDocumentClass doc)
|
||||
{
|
||||
@ -298,7 +309,7 @@ namespace Volian.Controls.Library
|
||||
{
|
||||
if (SearchString == null) return;
|
||||
// Get the Document
|
||||
LBDocumentClass wordDoc = new LBDocumentClass(_MyDSOFramer.ActiveDocument);
|
||||
LBDocumentClass wordDoc = new LBDocumentClass(_MyEdWord.ActiveDocument());
|
||||
//LBSelection sel = wordDoc.Application.Selection;
|
||||
LBFind find = wordDoc.Application.Selection.Find;
|
||||
find.ClearFormatting();
|
||||
@ -314,7 +325,7 @@ namespace Volian.Controls.Library
|
||||
{
|
||||
if (txt == null || txt.Length == 0) return; //nothing to insert
|
||||
// Get the Document
|
||||
LBDocumentClass wordDoc = new LBDocumentClass(_MyDSOFramer.ActiveDocument);
|
||||
LBDocumentClass wordDoc = new LBDocumentClass(_MyEdWord.ActiveDocument());
|
||||
//This will get the selected range or just the current cursor position
|
||||
LBSelection sel = wordDoc.Application.Selection;
|
||||
// This will replace the selection or insert at current position
|
||||
@ -323,7 +334,7 @@ namespace Volian.Controls.Library
|
||||
|
||||
public string GetSelectedString()
|
||||
{
|
||||
LBDocumentClass wordDoc = new LBDocumentClass(_MyDSOFramer.ActiveDocument);
|
||||
LBDocumentClass wordDoc = new LBDocumentClass(_MyEdWord.ActiveDocument());
|
||||
//This will get the selected range or just the current cursor position
|
||||
LBSelection sel = wordDoc.Application.Selection;
|
||||
// if the start & end are the same, nothing is selected:
|
||||
@ -415,10 +426,10 @@ namespace Volian.Controls.Library
|
||||
MessageBox.Show("Currently in VIEW mode,\r\n cannot Save " + _MyDisplayTabItem.Tooltip);
|
||||
return;
|
||||
}
|
||||
LBDocumentClass doc = new LBDocumentClass(_MyDSOFramer.ActiveDocument);
|
||||
while (doc.Saved = false)
|
||||
Application.DoEvents();
|
||||
string tmp = GetReflectiveProperty(_MyDSOFramer.ActiveDocument, "FullName");
|
||||
LBDocumentClass doc = new LBDocumentClass(_MyEdWord.ActiveDocument());
|
||||
//while (doc.Saved = false)
|
||||
// Application.DoEvents();
|
||||
string tmp = GetReflectiveProperty(_MyEdWord.ActiveDocument(), "FullName");
|
||||
if (System.IO.File.Exists(tmp))
|
||||
MyDSOFile.FullName = tmp;
|
||||
else
|
||||
@ -475,51 +486,6 @@ namespace Volian.Controls.Library
|
||||
_MyLog.Warn("Before Closing Document ", ex);
|
||||
}
|
||||
}
|
||||
public static bool IgnoreEnter = false;
|
||||
private bool _In_DSOTabPanel_Enter=false;
|
||||
/// <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>
|
||||
private void DSOTabPanel_Enter(object sender, EventArgs e)
|
||||
{
|
||||
if (IgnoreEnter) return;
|
||||
_MyTransparentPanel.SendToBack();
|
||||
|
||||
// Set whether this worddoc is in view/edit mode by checking whether the
|
||||
// procedure is in view/edit mode (based on the steppanel. This occurs on
|
||||
// the enter event so that the mode is determined any time this panel becomes
|
||||
// active.
|
||||
// find steptabpanel and its view/edit. If it doesn't have a steptabpanel
|
||||
// use default - edit. Later when we have ownership, need to use that.
|
||||
PanelViewEditMode = E_ViewMode.Edit; // default to edit
|
||||
if (MyDisplayTabItem.MyItemInfo != null) // lib doc with no associated active procedure defaults to edit
|
||||
{
|
||||
StepTabPanel stpanel = _MyDisplayTabControl.GetProcedureTabPanel(MyDisplayTabItem.MyItemInfo);
|
||||
PanelViewEditMode = (stpanel == null) ? E_ViewMode.Edit : stpanel.MyStepPanel.VwMode;
|
||||
}
|
||||
try
|
||||
{
|
||||
//_MyDSOFramer.EventsEnabled = true;
|
||||
_MyDSOFramer.FrameHookPolicy = DSOFramer.dsoFrameHookPolicy.dsoResetNow;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (_MyLog.IsErrorEnabled) _MyLog.ErrorFormat("DSOTabPage_Enter", ex);
|
||||
}
|
||||
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;
|
||||
if (MyDisplayTabItem.MyItemInfo != null)
|
||||
_MyDisplayTabControl.OnItemSelectedChanged(this,new ItemSelectedChangedEventArgs(MyDisplayTabItem.MyItemInfo));
|
||||
_MyDSOFramer.Focus();
|
||||
_In_DSOTabPanel_Enter = false;
|
||||
_MyDisplayTabControl.SelectedDisplayTabItem = MyDisplayTabItem;
|
||||
}
|
||||
#endregion
|
||||
#region Public Methods
|
||||
/// <summary>
|
||||
/// Save the contents of the Word Document to a file
|
||||
/// and save the file to the database
|
||||
@ -530,7 +496,8 @@ namespace Volian.Controls.Library
|
||||
bool result = true;
|
||||
try
|
||||
{
|
||||
_MyDSOFramer.Save();
|
||||
bool stat = _MyEdWord.Save();// B2017-133 Edraw
|
||||
Console.WriteLine("Save = {0}", stat);
|
||||
SaveDSO_Phase2();
|
||||
//_MyDSOFramer_OnSaveCompleted(this, null);
|
||||
// These are handled in the method above
|
||||
@ -570,6 +537,51 @@ namespace Volian.Controls.Library
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public static bool IgnoreEnter = false;
|
||||
private bool _In_DSOTabPanel_Enter=false;
|
||||
/// <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>
|
||||
private void DSOTabPanel_Enter(object sender, EventArgs e)
|
||||
{
|
||||
if (IgnoreEnter) return;
|
||||
_MyTransparentPanel.SendToBack();
|
||||
|
||||
// Set whether this worddoc is in view/edit mode by checking whether the
|
||||
// procedure is in view/edit mode (based on the steppanel. This occurs on
|
||||
// the enter event so that the mode is determined any time this panel becomes
|
||||
// active.
|
||||
// find steptabpanel and its view/edit. If it doesn't have a steptabpanel
|
||||
// use default - edit. Later when we have ownership, need to use that.
|
||||
PanelViewEditMode = E_ViewMode.Edit; // default to edit
|
||||
if (MyDisplayTabItem.MyItemInfo != null) // lib doc with no associated active procedure defaults to edit
|
||||
{
|
||||
StepTabPanel stpanel = _MyDisplayTabControl.GetProcedureTabPanel(MyDisplayTabItem.MyItemInfo);
|
||||
PanelViewEditMode = (stpanel == null) ? E_ViewMode.Edit : stpanel.MyStepPanel.VwMode;
|
||||
}
|
||||
try
|
||||
{
|
||||
//_MyDSOFramer.EventsEnabled = true;
|
||||
//_MyEdWord.FrameHookPolicy = DSOFramer.dsoFrameHookPolicy.dsoResetNow;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (_MyLog.IsErrorEnabled) _MyLog.ErrorFormat("DSOTabPage_Enter", ex);
|
||||
}
|
||||
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;
|
||||
if (MyDisplayTabItem.MyItemInfo != null)
|
||||
_MyDisplayTabControl.OnItemSelectedChanged(this,new ItemSelectedChangedEventArgs(MyDisplayTabItem.MyItemInfo));
|
||||
_MyEdWord.Focus();
|
||||
_In_DSOTabPanel_Enter = false;
|
||||
_MyDisplayTabControl.SelectedDisplayTabItem = MyDisplayTabItem;
|
||||
}
|
||||
#endregion
|
||||
#region Public Methods
|
||||
private bool _IsBeingDeleted = false;
|
||||
public bool IsBeingDeleted
|
||||
{
|
||||
@ -595,14 +607,14 @@ namespace Volian.Controls.Library
|
||||
bool result = true;
|
||||
try
|
||||
{
|
||||
if (_MyDSOFramer != null)
|
||||
if (_MyEdWord != null)
|
||||
{
|
||||
SaveDSO_Phase1();
|
||||
_MyDSOFramer.Close();
|
||||
Controls.Remove(_MyDSOFramer);
|
||||
components.Remove(_MyDSOFramer);
|
||||
_MyDSOFramer.Dispose();
|
||||
_MyDSOFramer = null;
|
||||
_MyEdWord.CloseDoc();
|
||||
Controls.Remove(_MyEdWord);
|
||||
components.Remove(_MyEdWord);
|
||||
_MyEdWord.Dispose();
|
||||
_MyEdWord = null;
|
||||
_Count--;
|
||||
}
|
||||
}
|
||||
@ -620,9 +632,9 @@ namespace Volian.Controls.Library
|
||||
{
|
||||
try
|
||||
{
|
||||
this._MyDSOFramer.Activate();
|
||||
if (_MyCount <= MSWordLimit)
|
||||
this._MyDSOFramer.FrameHookPolicy = DSOFramer.dsoFrameHookPolicy.dsoResetNow;
|
||||
//this._MyEdWord.Activate();
|
||||
//if (_MyCount <= MSWordLimit)
|
||||
// this._MyEdWord.FrameHookPolicy = DSOFramer.dsoFrameHookPolicy.dsoResetNow;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user