Beispiel #1
0
        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));
        }
Beispiel #2
0
        private static void Initialize()
        {
            _environmentConstantsMap.Clear();

            try
            {
                //Solid Edge Constants Type Library
                Guid typeLibGuid = new Guid("{C467A6F5-27ED-11D2-BE30-080036B4D502}");

                _constantsTypeLib = ComTypeManager.Instance.ComTypeLibraries.Where(x => x.Guid.Equals(typeLibGuid)).FirstOrDefault();

                if (_constantsTypeLib != null)
                {
                    for (int i = 0; i < _categoryConstantsMap.GetLength(0); i++)
                    {
                        Guid guid = new Guid(_categoryConstantsMap[i, 0]);
                        _environmentConstantsMap.Add(guid, _constantsTypeLib.Enums.Where(x => x.Name.Equals(_categoryConstantsMap[i, 1])).FirstOrDefault());
                    }
                }
            }
            catch
            {
                GlobalExceptionHandler.HandleException();
            }
        }
Beispiel #3
0
        private string GetSolidEdgeVersion()
        {
            object installData = null;

            try
            {
                Type type = Type.GetTypeFromProgID("SolidEdge.InstallData");

                if (type != null)
                {
                    installData = Activator.CreateInstance(type);

                    object version = installData.GetType().InvokeMember("GetVersion", BindingFlags.InvokeMethod, null, installData, null);

                    if (version != null)
                    {
                        return(version.ToString());
                    }
                }
            }
            catch
            {
                GlobalExceptionHandler.HandleException();
            }
            finally
            {
                if (installData != null)
                {
                    Marshal.FinalReleaseComObject(installData);
                }
            }

            return(String.Empty);
        }
Beispiel #4
0
 private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
 {
     try
     {
         OleMessageFilter.Unregister();
     }
     catch
     {
         GlobalExceptionHandler.HandleException();
     }
 }
Beispiel #5
0
 private void nugetSolidEdgeCommunityReaderToolStripMenuItem_Click(object sender, EventArgs e)
 {
     try
     {
         Process.Start(Resources.NuGetSolidEdgeCommunityReader);
     }
     catch
     {
         GlobalExceptionHandler.HandleException();
     }
 }
Beispiel #6
0
 private void githubSamplesForSolidEdgeToolStripMenuItem_Click(object sender, EventArgs e)
 {
     try
     {
         Process.Start(Resources.GitHubSamples);
     }
     catch
     {
         GlobalExceptionHandler.HandleException();
     }
 }
Beispiel #7
0
 private void solidEdgeCommunityToolStripMenuItem_Click(object sender, EventArgs e)
 {
     try
     {
         Process.Start(Resources.GitHubSolidEdgeCommunityUrl);
     }
     catch
     {
         GlobalExceptionHandler.HandleException();
     }
 }
Beispiel #8
0
 private void projectWebsiteToolStripMenuItem_Click(object sender, EventArgs e)
 {
     try
     {
         Process.Start(Resources.ProjectUrl);
     }
     catch
     {
         GlobalExceptionHandler.HandleException();
     }
 }
Beispiel #9
0
 private void linkCodeplex_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
 {
     try
     {
         Process.Start(e.Link.LinkData as string);
     }
     catch
     {
         GlobalExceptionHandler.HandleException();
     }
 }
Beispiel #10
0
 private void aboutToolStripMenuItem_Click(object sender, EventArgs e)
 {
     try
     {
         using (AboutForm form = new AboutForm())
         {
             form.ShowDialog(this);
         }
     }
     catch
     {
         GlobalExceptionHandler.HandleException();
     }
 }
Beispiel #11
0
        static int Main()
        {
            try
            {
                System.Windows.Forms.Application.EnableVisualStyles();
                System.Windows.Forms.Application.SetCompatibleTextRenderingDefault(false);
                System.Windows.Forms.Application.Run(new MainForm());
            }
            catch
            {
                GlobalExceptionHandler.HandleException();
            }

            return(0);
        }
Beispiel #12
0
        private void SetupToolStripManager()
        {
            try
            {
                ToolStripManager.RenderMode = ToolStripManagerRenderMode.Professional;

                ToolStripProfessionalRenderer renderer = ToolStripManager.Renderer as ToolStripProfessionalRenderer;
                if (renderer != null)
                {
                    renderer.RoundedEdges = false;
                }
            }
            catch
            {
                GlobalExceptionHandler.HandleException();
            }
        }
Beispiel #13
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            try
            {
                // Register with OLE to handle concurrency issues on the current thread.
                OleMessageFilter.Register();

                PreloadTypeLibraries();

                ComTypeManager.Instance.ComTypeLibrarySelected += Instance_ComTypeLibrarySelected;
                ComTypeManager.Instance.ComTypeInfoSelected    += Instance_ComTypeInfoSelected;
            }
            catch
            {
                GlobalExceptionHandler.HandleException();
            }

            SetupToolStripManager();
        }
Beispiel #14
0
        private void DisconnectFromSolidEdge(bool resetStartupTimer)
        {
            _connectionPointController.UnadviseAllSinks();

            HandleAutoResetEvent();

            globalParameterBrowser.SelectedObject = null;

            try
            {
                Marshal.FinalReleaseComObject(_application);
            }
            catch
            {
                GlobalExceptionHandler.HandleException();
            }

            startupTimer.Enabled = resetStartupTimer;

            _application = null;
        }
Beispiel #15
0
 private void PreloadTypeLibraries()
 {
     try
     {
         Version version = new Version(1, 0);
         ComTypeManager.Instance.LoadRegTypeLib(TypeLibGuid.RevisionManager, version);
         ComTypeManager.Instance.LoadRegTypeLib(TypeLibGuid.SEInstallDataLib, version);
         ComTypeManager.Instance.LoadRegTypeLib(TypeLibGuid.SolidEdgeAssembly, version);
         ComTypeManager.Instance.LoadRegTypeLib(TypeLibGuid.SolidEdgeConstants, version);
         ComTypeManager.Instance.LoadRegTypeLib(TypeLibGuid.SolidEdgeDraft, version);
         ComTypeManager.Instance.LoadRegTypeLib(TypeLibGuid.SolidEdgeFileProperties, version);
         ComTypeManager.Instance.LoadRegTypeLib(TypeLibGuid.SolidEdgeFramework, version);
         ComTypeManager.Instance.LoadRegTypeLib(TypeLibGuid.SolidEdgeFrameworkSupport, version);
         ComTypeManager.Instance.LoadRegTypeLib(TypeLibGuid.SolidEdgeGeometry, version);
         ComTypeManager.Instance.LoadRegTypeLib(TypeLibGuid.SolidEdgePart, version);
         ComTypeManager.Instance.LoadRegTypeLib(TypeLibGuid.StructureEditor, version);
     }
     catch
     {
         GlobalExceptionHandler.HandleException();
     }
 }
Beispiel #16
0
        private bool ConnectToSolidEdge()
        {
            ComPtr pApplication = IntPtr.Zero;

            try
            {
                if (MarshalEx.Succeeded(MarshalEx.GetActiveObject("SolidEdge.Application", out pApplication)))
                {
                    _application = pApplication.TryGetUniqueRCW <SolidEdgeFramework.Application>();
                    _connectionPointController.AdviseSink <SolidEdgeFramework.ISEApplicationEvents>(_application);

                    commandBrowser.ActiveEnvironment = _application.GetActiveEnvironment();
                    globalParameterBrowser.RefreshGlobalParameters();

                    objectBrowser.Connect();

                    // Older versions of Solid Edge don't have the ProcessID property.
                    try
                    {
                        processBrowser.ProcessId = _application.ProcessID;
                    }
                    catch
                    {
                    }

                    return(true);
                }
            }
            catch
            {
                GlobalExceptionHandler.HandleException();
            }
            finally
            {
                pApplication.Dispose();
            }

            return(false);
        }