Exemple #1
0
        private void RefreshNode(ComTypeTreeNode node)
        {
            SetImageIndex(node);

            if (node is ComTypeLibraryTreeNode)
            {
                ComTypeLibraryTreeNode comTypeLibraryTreeNode = (ComTypeLibraryTreeNode)node;
                ComTypeLibrary         comTypeLibrary         = comTypeLibraryTreeNode.ComTypeLibrary;

                foreach (ComTypeInfo comTypeInfo in comTypeLibrary.ComTypeInfos)
                {
                    if (comTypeInfo.IsHidden)
                    {
                        continue;
                    }

                    ComTypeInfoTreeNode comTypeInfoTreeNode = new ComTypeInfoTreeNode(comTypeInfo);
                    comTypeLibraryTreeNode.Nodes.Add(comTypeInfoTreeNode);
                    RefreshNode(comTypeInfoTreeNode);
                }
            }
            else if (node is ComTypeInfoTreeNode)
            {
                ComTypeInfoTreeNode comTypeInfoTreeNode = (ComTypeInfoTreeNode)node;
                ComTypeInfo         comTypeInfo         = comTypeInfoTreeNode.ComTypeInfo;

                foreach (ComImplementedTypeInfo comImplementedTypeInfo in comTypeInfo.ImplementedTypes)
                {
                    ComTypeInfoTreeNode impComTypeInfoTreeNode = new ComTypeInfoTreeNode(comImplementedTypeInfo.ComTypeInfo);
                    comTypeInfoTreeNode.Nodes.Add(impComTypeInfoTreeNode);
                    RefreshNode(impComTypeInfoTreeNode);
                }
            }
        }
Exemple #2
0
 public ComTypeLibraryTreeNode(ComTypeLibrary comTypeLibrary)
     : base()
 {
     _comTypeLibrary = comTypeLibrary;
     Text            = _comTypeLibrary.Name;
     FullText        = _comTypeLibrary.Name;
 }
Exemple #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();
            }
        }
Exemple #4
0
        public void ScanForNodeAndSelect(ComTypeLibrary comTypeLibrary, TreeNodeCollection nodes)
        {
            if (comTypeLibrary == null)
            {
                return;
            }
            if (nodes == null)
            {
                return;
            }
            if (_scanComplete == true)
            {
                return;
            }

            foreach (TreeNode node in nodes)
            {
                ComTypeLibraryTreeNode comTypeLibraryTreeNode = node as ComTypeLibraryTreeNode;

                if (comTypeLibraryTreeNode != null)
                {
                    if (comTypeLibraryTreeNode.ComTypeLibrary.Name.Equals(comTypeLibrary.Name, StringComparison.OrdinalIgnoreCase))
                    {
                        _scanComplete = true;
                        node.TreeView.SelectedNode = node;
                        node.EnsureVisible();
                        return;
                    }
                }
            }
        }
        public void DescribeComTypeLibrary(ComTypeLibrary comTypeLibrary)
        {
            Clear();

            AppendText("Library ");
            AppendText(comTypeLibrary.Name, ForeColor, FontStyle.Bold);
            AppendText(Environment.NewLine);
            AppendText(String.Format("    {0}", comTypeLibrary.Filename));
            AppendText(Environment.NewLine);

            WriteSummary(comTypeLibrary.Description);
            WriteGuid(comTypeLibrary.Guid);
        }
Exemple #6
0
        void Instance_ComTypeLibrarySelected(object sender, ComTypeLibrary comTypeLibrary)
        {
            _scanComplete = false;

            try
            {
                if (comTypeTreeView.IsFiltered)
                {
                    comTypeTreeView.Filter = String.Empty;
                }

                if (comTypeTreeView.Nodes.Count == 0)
                {
                    comTypeTreeView.RefreshNodes();
                }

                ScanForNodeAndSelect(comTypeLibrary, comTypeTreeView.Nodes);
            }
            catch
            {
                GlobalExceptionHandler.HandleException();
            }
        }
 public ComTypeLibraryTreeNode(ComTypeLibrary comTypeLibrary)
     : base()
 {
     _comTypeLibrary = comTypeLibrary;
     Text = _comTypeLibrary.Name;
     FullText = _comTypeLibrary.Name;
 }
        public void DescribeComTypeLibrary(ComTypeLibrary comTypeLibrary)
        {
            Clear();

            AppendText("Library ");
            AppendText(comTypeLibrary.Name, ForeColor, FontStyle.Bold);
            AppendText(Environment.NewLine);
            AppendText(String.Format("    {0}", comTypeLibrary.Filename));
            AppendText(Environment.NewLine);

            WriteSummary(comTypeLibrary.Description);
            WriteGuid(comTypeLibrary.Guid);
        }
Exemple #9
0
        public PropertyDescriptorCollection GetProperties(Attribute[] attributes)
        {
            if ((_pApplication == null) || (_pApplication.IsInvalid))
            {
                return(new PropertyDescriptorCollection(new PropertyDescriptor[] { }));
            }

            List <GlobalParameterPropertyDescriptor> list = new List <GlobalParameterPropertyDescriptor>();

            try
            {
                ComTypeLibrary comTypeLibrary = ComTypeManager.Instance.ComTypeLibraries.Where(x => x.Name.Equals("SolidEdgeFramework")).FirstOrDefault();

                if (comTypeLibrary != null)
                {
                    ComEnumInfo enumInfo = comTypeLibrary.Enums.Where(x => x.Name.Equals("ApplicationGlobalConstants")).FirstOrDefault();

                    foreach (ComVariableInfo variableInfo in enumInfo.Variables)
                    {
                        if (String.IsNullOrEmpty(_filter) == false)
                        {
                            if (variableInfo.Name.IndexOf(_filter, StringComparison.OrdinalIgnoreCase) == -1)
                            {
                                continue;
                            }
                        }

                        SolidEdgeFramework.ApplicationGlobalConstants globalConst = (SolidEdgeFramework.ApplicationGlobalConstants)variableInfo.ConstantValue;

                        // There is a known bug where seApplicationGlobalOpenAsReadOnly3DFile causes SE to display the read-only icon on
                        // files after GetGlobalParameter() is called.
                        if (globalConst.Equals(SolidEdgeFramework.ApplicationGlobalConstants.seApplicationGlobalOpenAsReadOnly3DFile))
                        {
                            continue;
                        }

                        try
                        {
                            object[] args        = new object[] { globalConst, new VariantWrapper(null) };
                            object   returnValue = null;

                            if (MarshalEx.Succeeded(_pApplication.TryInvokeMethod("GetGlobalParameter", args, out returnValue)))
                            {
                                if (args[1] != null)
                                {
                                    Type propertyType = args[1].GetType();

                                    string        name        = variableInfo.Name.Replace("seApplicationGlobal", string.Empty);
                                    StringBuilder description = new StringBuilder();
                                    description.AppendLine(variableInfo.Description);
                                    description.AppendLine(String.Format("Application.GetGlobalParameter({0}.{1}, out value)", enumInfo.FullName, variableInfo.Name));

                                    GlobalParameterProperty property = new GlobalParameterProperty(name, description.ToString(), args[1], propertyType, true);

                                    list.Add(new GlobalParameterPropertyDescriptor(ref property, attributes));

                                    try
                                    {
                                        if (_colorGlobalConstants.Contains(globalConst))
                                        {
                                            var color = Color.Empty;

                                            if (args[1] is int)
                                            {
                                                byte[] rgb = BitConverter.GetBytes((int)args[1]);
                                                color = Color.FromArgb(255, rgb[0], rgb[1], rgb[2]);
                                            }
                                            else if (args[1] is uint)
                                            {
                                                byte[] rgb = BitConverter.GetBytes((uint)args[1]);
                                                color = Color.FromArgb(255, rgb[0], rgb[1], rgb[2]);
                                            }
                                            else
                                            {
#if DEBUG
                                                //System.Diagnostics.Debugger.Break();
#endif
                                            }

                                            if (color.IsEmpty == false)
                                            {
                                                description = new StringBuilder();
                                                description.AppendLine(property.Description);
                                                description.AppendLine("byte[] rgb = BitConverter.GetBytes((int)value)");
                                                description.AppendLine("Color color = Color.FromArgb(255, rgb[0], rgb[1], rgb[2]");

                                                property = new GlobalParameterProperty(String.Format("{0} (converted to color)", property.Name), description.ToString(), color, color.GetType(), true);

                                                list.Add(new GlobalParameterPropertyDescriptor(ref property, attributes));
                                            }
                                        }
                                    }
                                    catch
                                    {
                                    }
                                }
                            }
                        }
                        catch
                        {
                            GlobalExceptionHandler.HandleException();
                        }
                    }
                }
            }
            catch
            {
                GlobalExceptionHandler.HandleException();
            }

            return(new PropertyDescriptorCollection(list.ToArray()));
        }
Exemple #10
0
 void Instance_ComTypeLibrarySelected(object sender, ComTypeLibrary comTypeLibrary)
 {
     tabControl.SelectedIndex = TabPageTypeBrowserIndex;
 }
Exemple #11
0
 void Instance_ComTypeLibrarySelected(object sender, ComTypeLibrary comTypeLibrary)
 {
     tabControl.SelectedIndex = TabPageTypeBrowserIndex;
 }
 public ComEnumInfo(ComTypeLibrary parent, ITypeInfo typeInfo, IntPtr pTypeAttr)
     : base(parent, typeInfo, pTypeAttr)
 {
 }
 public ComTypeInfo(ComTypeLibrary comTypeLibrary, ITypeInfo typeInfo, IntPtr pTypeAttr)
 {
     _comTypeLibrary = comTypeLibrary;
     _typeInfo = typeInfo;
     _pTypeAttr = pTypeAttr;
     _typeAttr = _pTypeAttr.ToStructure<System.Runtime.InteropServices.ComTypes.TYPEATTR>();
     _typeInfo.GetDocumentation(-1, out _name, out _description, out _helpContext, out _helpFile);
 }
        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();
            }
        }
        private ComTypeLibrary GetComTypeLibrary(ITypeLib typeLib)
        {
            Guid typeLibGuid = typeLib.GetGuid();
            Version typeLibVersion = typeLib.GetVersion();

            ComTypeLibrary comTypeLibrary = _typeLibraries.Where(
                x => x.Guid.Equals(typeLibGuid)).Where(
                x => x.Version.Equals(typeLibVersion)
                ).FirstOrDefault();

            if (comTypeLibrary == null)
            {
                comTypeLibrary = new ComTypeLibrary(typeLib);
                _typeLibraries.Add(comTypeLibrary);
                _typeLibraries.Sort(delegate(ComTypeLibrary a, ComTypeLibrary b)
                {
                    return a.Name.CompareTo(b.Name);
                });
            }

            return comTypeLibrary;
        }