Ejemplo n.º 1
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);
            //string exeName = Process.GetCurrentProcess().ProcessName;
            //exeName = exeName.Replace(Path.GetExtension(exeName), ".exe");

            //if (AppDomain.CurrentDomain.IsDefaultAppDomain())
            //{
            //    int returnValue = 0;

            //    do
            //    {
            //        AppDomain _interopDomain = AppDomain.CreateDomain("Application Domain");

            //        try
            //        {
            //            returnValue = _interopDomain.ExecuteAssembly(exeName);
            //        }
            //        catch (System.Exception ex)
            //        {
            //            MessageBox.Show(ex.Message);
            //        }
            //        finally
            //        {
            //            AppDomain.Unload(_interopDomain);
            //        }

            //    } while (returnValue != 0);

            //    return returnValue;
            //}
            //else
            //{
            //    System.Windows.Forms.Application.EnableVisualStyles();
            //    System.Windows.Forms.Application.SetCompatibleTextRenderingDefault(false);
            //    System.Windows.Forms.Application.Run(new Application());

            //    var returnValue = AppDomain.CurrentDomain.GetData("ReturnValue");

            //    if (returnValue != null)
            //    {
            //        return (int)returnValue;
            //    }
            //    else
            //    {
            //        return 0;
            //    }
            //}
        }
Ejemplo n.º 2
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);
        }
Ejemplo n.º 3
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();
            }
        }
Ejemplo n.º 4
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));
        }
Ejemplo n.º 5
0
 private void nugetSolidEdgeCommunityReaderToolStripMenuItem_Click(object sender, EventArgs e)
 {
     try
     {
         Process.Start(Resources.NuGetSolidEdgeCommunityReader);
     }
     catch
     {
         GlobalExceptionHandler.HandleException();
     }
 }
Ejemplo n.º 6
0
 private void githubSamplesForSolidEdgeToolStripMenuItem_Click(object sender, EventArgs e)
 {
     try
     {
         Process.Start(Resources.GitHubSamples);
     }
     catch
     {
         GlobalExceptionHandler.HandleException();
     }
 }
Ejemplo n.º 7
0
 private void solidEdgeCommunityToolStripMenuItem_Click(object sender, EventArgs e)
 {
     try
     {
         Process.Start(Resources.GitHubSolidEdgeCommunityUrl);
     }
     catch
     {
         GlobalExceptionHandler.HandleException();
     }
 }
Ejemplo n.º 8
0
 private void documentationToolStripMenuItem_Click(object sender, EventArgs e)
 {
     try
     {
         Process.Start(Resources.CodePlexDocumentationurl);
     }
     catch
     {
         GlobalExceptionHandler.HandleException();
     }
 }
Ejemplo n.º 9
0
 private void projectForumsToolStripMenuItem_Click(object sender, EventArgs e)
 {
     try
     {
         Process.Start(Resources.CodePlexDiscussionsUrl);
     }
     catch
     {
         GlobalExceptionHandler.HandleException();
     }
 }
Ejemplo n.º 10
0
 private void linkCodeplex_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
 {
     try
     {
         Process.Start(e.Link.LinkData as string);
     }
     catch
     {
         GlobalExceptionHandler.HandleException();
     }
 }
Ejemplo n.º 11
0
 private void Application_FormClosing(object sender, FormClosingEventArgs e)
 {
     try
     {
         OleMessageFilter.Unregister();
     }
     catch
     {
         GlobalExceptionHandler.HandleException();
     }
 }
Ejemplo n.º 12
0
 private void aboutToolStripMenuItem_Click(object sender, EventArgs e)
 {
     try
     {
         using (AboutForm form = new AboutForm())
         {
             form.ShowDialog(this);
         }
     }
     catch
     {
         GlobalExceptionHandler.HandleException();
     }
 }
Ejemplo n.º 13
0
        private void SetupToolStripManager()
        {
            try
            {
                ToolStripManager.RenderMode = ToolStripManagerRenderMode.Professional;

                ToolStripProfessionalRenderer renderer = ToolStripManager.Renderer as ToolStripProfessionalRenderer;
                if (renderer != null)
                {
                    renderer.RoundedEdges = false;
                }
            }
            catch
            {
                GlobalExceptionHandler.HandleException();
            }
        }
Ejemplo n.º 14
0
        private void Application_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();
        }
Ejemplo n.º 15
0
        private void DisconnectFromSolidEdge(bool resetStartupTimer)
        {
            _connectionPointController.UnadviseAllSinks();

            HandleAutoResetEvent();

            globalParameterBrowser.SelectedObject = null;

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

            startupTimer.Enabled = resetStartupTimer;

            _application = null;
        }
Ejemplo n.º 16
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();
     }
 }
Ejemplo n.º 17
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);
        }