public void BeforeQuit() { string eventString = Resources.BeforeQuitFormat; string environmentName = String.Empty; string environmentCaption = String.Empty; string environmentCATID = String.Empty; try { SolidEdgeFramework.Environment environment = _application.GetActiveEnvironment(); environment.GetInfo(out environmentName, out environmentCaption, out environmentCATID); } catch { } _eventQueue.Enqueue(new Forms.EventMonitorItem(eventString, environmentName, environmentCaption, environmentCATID)); this.BeginInvokeIfRequired(frm => { frm.DisconnectFromSolidEdge(true); }); _uiAutoResetEvent.WaitOne(2000); _uiAutoResetEvent.Reset(); }
public void BeforeWindowDeactivate(object theWindow) { string eventString = Resources.BeforeWindowDeactivateFormat; string environmentName = String.Empty; string environmentCaption = String.Empty; string environmentCATID = String.Empty; try { SolidEdgeFramework.Environment environment = _application.GetActiveEnvironment(); environment.GetInfo(out environmentName, out environmentCaption, out environmentCATID); } catch { } try { eventString = String.Format(eventString, theWindow.SafeInvokeGetProperty("Caption", "IUnknown")); } catch { } _eventQueue.Enqueue(new Forms.EventMonitorItem(eventString, environmentName, environmentCaption, environmentCATID)); }
public void AfterNewDocumentOpen(object theDocument) { string eventString = Resources.AfterNewDocumentOpenFormat; string environmentName = String.Empty; string environmentCaption = String.Empty; string environmentCATID = String.Empty; try { SolidEdgeFramework.Environment environment = _application.GetActiveEnvironment(); environment.GetInfo(out environmentName, out environmentCaption, out environmentCATID); } catch { } try { eventString = String.Format(eventString, theDocument.SafeInvokeGetProperty("Name", "IUnknown")); } catch { } _eventQueue.Enqueue(new Forms.EventMonitorItem(eventString, environmentName, environmentCaption, environmentCATID)); this.BeginInvokeIfRequired(frm => { frm.HandleAutoResetEvent(); }); _uiAutoResetEvent.WaitOne(2000); _uiAutoResetEvent.Reset(); }
public void BeforeDocumentPrint(object theDocument, int hDC, ref double ModelToDC, ref int Rect) { string eventString = Resources.BeforeDocumentPrintFormat; string environmentName = String.Empty; string environmentCaption = String.Empty; string environmentCATID = String.Empty; try { SolidEdgeFramework.Environment environment = _application.GetActiveEnvironment(); environment.GetInfo(out environmentName, out environmentCaption, out environmentCATID); } catch { } try { eventString = String.Format(eventString, theDocument.SafeInvokeGetProperty("Name", "IUnknown"), hDC, ModelToDC, Rect); } catch { } _eventQueue.Enqueue(new Forms.EventMonitorItem(eventString, environmentName, environmentCaption, environmentCATID)); }
public void BeforeCommandRun(int theCommandID) { string eventString = Resources.BeforeCommandRunFormat; string environmentName = String.Empty; string environmentCaption = String.Empty; string environmentCATID = String.Empty; try { SolidEdgeFramework.Environment environment = _application.GetActiveEnvironment(); environment.GetInfo(out environmentName, out environmentCaption, out environmentCATID); } catch { } try { eventString = String.Format(eventString, CommandHelper.ResolveCommandId(_application, theCommandID)); } catch { } _eventQueue.Enqueue(new Forms.EventMonitorItem(eventString, environmentName, environmentCaption, environmentCATID)); }
public static string ResolveCommandId(SolidEdgeFramework.Application application, int theCommandID) { ComVariableInfo variableInfo = null; if (_environmentConstantsMap.Count == 0) { Initialize(); } try { ComEnumInfo enumInfo = null; SolidEdgeFramework.Environment environment = application.GetActiveEnvironment(); Guid environmentGuid = environment.GetGuid(); if (_environmentConstantsMap.TryGetValue(environmentGuid, out enumInfo)) { variableInfo = enumInfo.Variables.Where(x => x.ConstantValue != null).Where(x => x.ConstantValue.Equals(theCommandID)).FirstOrDefault(); if (variableInfo != null) { return(String.Format("{0} [{1}.{2}]", theCommandID, variableInfo.ComTypeInfo.Name, variableInfo.Name)); } } } catch { GlobalExceptionHandler.HandleException(); } return(String.Format("{0} [Undefined]", theCommandID)); }
public void BeforeDocumentClose(object theDocument) { string eventString = Resources.BeforeDocumentCloseFormat; string environmentName = String.Empty; string environmentCaption = String.Empty; string environmentCATID = String.Empty; try { SolidEdgeFramework.Environment environment = _application.GetActiveEnvironment(); environment.GetInfo(out environmentName, out environmentCaption, out environmentCATID); } catch { } try { eventString = String.Format(eventString, theDocument.SafeInvokeGetProperty("Name", "IUnknown")); } catch { } _eventQueue.Enqueue(new Forms.EventMonitorItem(eventString, environmentName, environmentCaption, environmentCATID)); try { SolidEdgeFramework.SolidEdgeDocument document = theDocument as SolidEdgeFramework.SolidEdgeDocument; if ((document != null) && (document.IsTemporary() == false)) { this.BeginInvokeIfRequired(frm => { frm.HandleAutoResetEvent(); }); _uiAutoResetEvent.WaitOne(2000); _uiAutoResetEvent.Reset(); } } catch { } }
public void AfterEnvironmentActivate(object theEnvironment) { string eventString = Resources.AfterEnvironmentActivateFormat; string environmentName = String.Empty; string environmentCaption = String.Empty; string environmentCATID = String.Empty; SolidEdgeFramework.Environment environment = null; try { environment = _application.GetActiveEnvironment(); environment.GetInfo(out environmentName, out environmentCaption, out environmentCATID); } catch { } try { commandBrowser.BeginInvokeIfRequired(ctl => { ctl.ActiveEnvironment = environment; }); } catch { } try { eventString = String.Format(eventString, theEnvironment.SafeInvokeGetProperty("Name", "IUnknown")); } catch { } _eventQueue.Enqueue(new Forms.EventMonitorItem(eventString, environmentName, environmentCaption, environmentCATID)); //this.BeginInvokeIfRequired(frm => //{ // frm.RefreshGlobalPropertiesPropertyGrid(); //}); }
/// <summary> /// Implementation of SolidEdgeFramework.ISolidEdgeAddIn.OnConnectToEnvironment(). /// </summary> public void OnConnectToEnvironment(string EnvCatID, object pEnvironmentDispatch, bool bFirstTime) { Guid envGuid = new Guid(EnvCatID); SolidEdgeFramework.Environment environment = (SolidEdgeFramework.Environment)pEnvironmentDispatch; // Demonstrate working with CategoryIDs. if (envGuid.Equals(CategoryIDs.CATID_SEPart)) { } else if (envGuid.Equals(CategoryIDs.CATID_SEDMPart)) { } // Some things only need to be done during bFirstTime. if (bFirstTime) { } }
/// <summary> /// Called during SolidEdgeFramework.ISolidEdgeAddIn.OnConnectToEnvironment(). /// </summary> public virtual void OnConnectToEnvironment(SolidEdgeFramework.Environment environment, bool firstTime) { }
public override void OnConnectToEnvironment(SolidEdgeFramework.Environment environment, bool firstTime) { }
/// <summary> /// Returns a Type representing the corresponding command constants for a particular environment. /// </summary> /// <param name="environment"></param> /// <returns></returns> public static Type GetCommandConstantType(this SolidEdgeFramework.Environment environment) { var categoryId = environment.GetCategoryId(); if (categoryId.Equals(SolidEdgeSDK.EnvironmentCategories.Application)) { return(typeof(SolidEdgeConstants.SolidEdgeCommandConstants)); } else if (categoryId.Equals(SolidEdgeSDK.EnvironmentCategories.Assembly)) { return(typeof(SolidEdgeConstants.AssemblyCommandConstants)); } else if (categoryId.Equals(SolidEdgeSDK.EnvironmentCategories.DMAssembly)) { return(typeof(SolidEdgeConstants.AssemblyCommandConstants)); } else if (categoryId.Equals(SolidEdgeSDK.EnvironmentCategories.CuttingPlaneLine)) { return(typeof(SolidEdgeConstants.CuttingPlaneLineCommandConstants)); } else if (categoryId.Equals(SolidEdgeSDK.EnvironmentCategories.Draft)) { return(typeof(SolidEdgeConstants.DetailCommandConstants)); } else if (categoryId.Equals(SolidEdgeSDK.EnvironmentCategories.DrawingViewEdit)) { return(typeof(SolidEdgeConstants.DrawingViewEditCommandConstants)); } else if (categoryId.Equals(SolidEdgeSDK.EnvironmentCategories.Explode)) { return(typeof(SolidEdgeConstants.ExplodeCommandConstants)); } else if (categoryId.Equals(SolidEdgeSDK.EnvironmentCategories.Layout)) { return(typeof(SolidEdgeConstants.LayoutCommandConstants)); } else if (categoryId.Equals(SolidEdgeSDK.EnvironmentCategories.Sketch)) { return(typeof(SolidEdgeConstants.LayoutInPartCommandConstants)); } else if (categoryId.Equals(SolidEdgeSDK.EnvironmentCategories.Motion)) { return(typeof(SolidEdgeConstants.MotionCommandConstants)); } else if (categoryId.Equals(SolidEdgeSDK.EnvironmentCategories.Part)) { return(typeof(SolidEdgeConstants.PartCommandConstants)); } else if (categoryId.Equals(SolidEdgeSDK.EnvironmentCategories.DMPart)) { return(typeof(SolidEdgeConstants.PartCommandConstants)); } else if (categoryId.Equals(SolidEdgeSDK.EnvironmentCategories.Profile)) { return(typeof(SolidEdgeConstants.ProfileCommandConstants)); } else if (categoryId.Equals(SolidEdgeSDK.EnvironmentCategories.ProfileHole)) { return(typeof(SolidEdgeConstants.ProfileHoleCommandConstants)); } else if (categoryId.Equals(SolidEdgeSDK.EnvironmentCategories.ProfilePattern)) { return(typeof(SolidEdgeConstants.ProfilePatternCommandConstants)); } else if (categoryId.Equals(SolidEdgeSDK.EnvironmentCategories.ProfileRevolved)) { return(typeof(SolidEdgeConstants.ProfileRevolvedCommandConstants)); } else if (categoryId.Equals(SolidEdgeSDK.EnvironmentCategories.SheetMetal)) { return(typeof(SolidEdgeConstants.SheetMetalCommandConstants)); } else if (categoryId.Equals(SolidEdgeSDK.EnvironmentCategories.DMSheetMetal)) { return(typeof(SolidEdgeConstants.SheetMetalCommandConstants)); } else if (categoryId.Equals(SolidEdgeSDK.EnvironmentCategories.Simplify)) { return(typeof(SolidEdgeConstants.SimplifyCommandConstants)); } else if (categoryId.Equals(SolidEdgeSDK.EnvironmentCategories.Studio)) { return(typeof(SolidEdgeConstants.StudioCommandConstants)); } else if (categoryId.Equals(SolidEdgeSDK.EnvironmentCategories.XpresRoute)) { return(typeof(SolidEdgeConstants.TubingCommandConstants)); } else if (categoryId.Equals(SolidEdgeSDK.EnvironmentCategories.Weldment)) { return(typeof(SolidEdgeConstants.WeldmentCommandConstants)); } return(null); }
/// <summary> /// Returns a Guid representing the environment category. /// </summary> public static Guid GetCategoryId(this SolidEdgeFramework.Environment environment) { return(new Guid(environment.CATID)); }
public static void GetInfo(this SolidEdgeFramework.Environment environment, out string name, out string caption, out string catid) { name = environment.Name; caption = environment.Caption; catid = environment.CATID; }