public void Disconnect(bool saveOriginOnDisconnection, string fileName, bool exitOriginOnDisconnection) { if (IsConnected()) { // Save the project if needed: if (saveOriginOnDisconnection) { string strFileName = fileName; if (!(strFileName.Length == 0)) { _originApp.Save(strFileName); } } // Exit Origin if needed: if (exitOriginOnDisconnection) { ExecuteOriginCMD("exit"); } System.Runtime.InteropServices.Marshal.ReleaseComObject(_originApp); _originApp = null; } return; }
public bool Connect(bool bConnectExisting) { if (IsConnected()) return true; try { if (bConnectExisting) _originApp = new Origin.ApplicationSIClass(); else _originApp = new Origin.ApplicationClass(); } catch (Exception e) { ShowErrorMessage(e.Message); } bool bConnected = IsConnected(); if (bConnected) { ShowOriginWindow(true); // show or not Origin window _originSaveProjectFileName = GetSaveAsFileName(); // init file name for saving } else { _originApp = null; ShowErrorMessage("Failed to access Origin instance!"); } return bConnected; }
public bool Connect(bool bConnectExisting) { if (IsConnected()) { return(true); } try { if (bConnectExisting) { _originApp = new Origin.ApplicationSIClass(); } else { _originApp = new Origin.ApplicationClass(); } } catch (Exception e) { ShowErrorMessage(e.Message); } bool bConnected = IsConnected(); if (bConnected) { ShowOriginWindow(true); // show or not Origin window _originSaveProjectFileName = GetSaveAsFileName(); // init file name for saving } else { _originApp = null; ShowErrorMessage("Failed to access Origin instance!"); } return(bConnected); }
public void Disconnect(bool saveOriginOnDisconnection, string fileName, bool exitOriginOnDisconnection) { if (IsConnected()) { // Save the project if needed: if (saveOriginOnDisconnection) { string strFileName = fileName; if (!(strFileName.Length == 0)) _originApp.Save(strFileName); } // Exit Origin if needed: if (exitOriginOnDisconnection) { ExecuteOriginCMD("exit"); } System.Runtime.InteropServices.Marshal.ReleaseComObject(_originApp); _originApp = null; } return; }