public GlobalParameterPropertyDescriptor(ref GlobalParameterProperty property, Attribute[] attrs) : base(property.Name, attrs) { _property = property; }
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())); }
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) { SolidEdgeFramework.ApplicationGlobalConstants globalConst = (SolidEdgeFramework.ApplicationGlobalConstants)variableInfo.ConstantValue; 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 { switch (globalConst) { case SolidEdgeFramework.ApplicationGlobalConstants.seApplicationGlobalColorLiveSectionEdge: case SolidEdgeFramework.ApplicationGlobalConstants.seApplicationGlobalColorLiveSectionCenterline: case SolidEdgeFramework.ApplicationGlobalConstants.seApplicationGlobalColorLiveSectionRegion: case SolidEdgeFramework.ApplicationGlobalConstants.seApplicationGlobalColorLiveSectionOpacity: case SolidEdgeFramework.ApplicationGlobalConstants.seApplicationGlobalColorSheetTab1: case SolidEdgeFramework.ApplicationGlobalConstants.seApplicationGlobalColorSheetTab2: case SolidEdgeFramework.ApplicationGlobalConstants.seApplicationGlobalColorActive: case SolidEdgeFramework.ApplicationGlobalConstants.seApplicationGlobalColorBackground: case SolidEdgeFramework.ApplicationGlobalConstants.seApplicationGlobalColorConstruction: case SolidEdgeFramework.ApplicationGlobalConstants.seApplicationGlobalColorDisabled: case SolidEdgeFramework.ApplicationGlobalConstants.seApplicationGlobalColorFailed: case SolidEdgeFramework.ApplicationGlobalConstants.seApplicationGlobalColorHandle: case SolidEdgeFramework.ApplicationGlobalConstants.seApplicationGlobalColorHighlight: case SolidEdgeFramework.ApplicationGlobalConstants.seApplicationGlobalColorProfile: case SolidEdgeFramework.ApplicationGlobalConstants.seApplicationGlobalColorSelected: case SolidEdgeFramework.ApplicationGlobalConstants.seApplicationGlobalColorSheet: case SolidEdgeFramework.ApplicationGlobalConstants.seApplicationGlobalOverlayColor: case SolidEdgeFramework.ApplicationGlobalConstants.seApplicationGlobalColorRefPlane: if (args[1] is int) { ; byte[] rgb = BitConverter.GetBytes((int)args[1]); Color color = Color.FromArgb(255, rgb[0], rgb[1], rgb[2]); 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)); } break; } } catch { } } } } catch { GlobalExceptionHandler.HandleException(); } } } } catch { GlobalExceptionHandler.HandleException(); } return new PropertyDescriptorCollection(list.ToArray()); }
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()); }