public void Refresh() { if (Instance == null) { Properties = new ObservableCollection<Item>(); } else { var properties = new PropertyCollection(Instance, !Categorized, AutomaticlyExpandObjects, Filter.ToLower(), ReadOnly); Properties = properties.Items; if (Instance != null) { /// Fill the Instance type and Name with the Data if (Template != null) { object myInstanceType = Template.FindName("PART_InstanceType", this); if (myInstanceType != null && myInstanceType is TextBlock) { string myType = Instance.GetType().ToString(); myType = myType.Substring(myType.LastIndexOf('.') + 1); ((TextBlock) myInstanceType).Text = myType; } object myInstanceName = Template.FindName("PART_InstanceName", this); if (myInstanceName != null && myInstanceName is TextBlock) { if (Instance is FrameworkElement) ((TextBlock) myInstanceName).Text = ((FrameworkElement) Instance).Name; else if (Instance is System.Windows.Forms.Control) ((TextBlock) myInstanceName).Text = ((System.Windows.Forms.Control) Instance).Name; else ((TextBlock) myInstanceName).Text = ""; } } } } }
public void Refresh() { if (Instance == null) { this.Visibility = Visibility.Hidden; } else { this.Visibility = Visibility.Visible; var properties = new PropertyCollection(Instance, !Categorized, AutomaticlyExpandObjects, Filter.ToLower()); Properties = properties.Items; if (Instance != null) { /// Fill the Instance type and Name with the Data if (Template != null) { object myInstanceType = Template.FindName("PART_InstanceType", this); if (myInstanceType != null && myInstanceType is TextBlock) { string myType = TypeDescriptor.GetClassName(Instance); myType = myType.Substring(myType.LastIndexOf('.') + 1); ((TextBlock) myInstanceType).Text = myType; } object myInstanceName = Template.FindName("PART_InstanceName", this); if (myInstanceName != null && myInstanceName is TextBlock) { if (Instance is FrameworkElement) ((TextBlock) myInstanceName).Text = ((FrameworkElement) Instance).Name; else if (Instance is System.Windows.Forms.Control) ((TextBlock) myInstanceName).Text = ((System.Windows.Forms.Control) Instance).Name; else ((TextBlock) myInstanceName).Text = ""; } } } } }
public void Refresh() { if (Instance == null) { Properties = new ObservableCollection<Item>(); } else { var properties = new PropertyCollection(Instance, !Categorized, AutomaticlyExpandObjects, Filter.ToLower()); Properties = properties.Items; if (Instance != null) { /// Fill the Instance type and Name with the Data if (Template != null) { object myInstanceType = Template.FindName("PART_InstanceType", this); if (myInstanceType != null && myInstanceType is TextBlock) { string myType = ""; Object[] myAttributes = Instance.GetType().GetCustomAttributes(false); if (myAttributes.Length > 0) { foreach (Object attr in myAttributes) { if (attr is System.ComponentModel.DisplayNameAttribute) { myType = ((System.ComponentModel.DisplayNameAttribute)attr).DisplayName; } } } if (myType.Length == 0) { myType = Instance.GetType().ToString(); myType = myType.Substring(myType.LastIndexOf('.') + 1); } if (myType.Equals("componentType")) { myType = Asterics.ACS.Properties.Resources.PropertyEditorModelComponentAlias; } else if (myType.Equals("inputPortType")) { myType = Asterics.ACS.Properties.Resources.PropertyEditorInputPortTypeAlias; } else if (myType.Equals("outputPortType")) { myType = Asterics.ACS.Properties.Resources.PropertyEditorOutputPortTypeAlias; } ((TextBlock)myInstanceType).Text = myType; } object myInstanceName = Template.FindName("PART_InstanceName", this); if (myInstanceName != null && myInstanceName is TextBlock) { if (Instance is FrameworkElement) ((TextBlock)myInstanceName).Text = ((FrameworkElement)Instance).Name; else if (Instance is System.Windows.Forms.Control) ((TextBlock)myInstanceName).Text = ((System.Windows.Forms.Control)Instance).Name; else if (DisplayName != "") ((TextBlock)myInstanceName).Text = DisplayName; // new code for AsTeRICS else { ((TextBlock)myInstanceName).Text = ""; PropertyInfo pi = Instance.GetType().GetProperty("Name"); if (pi != null) ((TextBlock)myInstanceName).Text = (string)pi.GetValue(Instance, null); } } } } } }