private void compiler_AfterInput(object sender, EventArgs e) { Dyn.TypeDescriptor typeDescriptor = Dyn.TypeDescriptor.GetTypeDescriptor(propertyGrid.SelectedObject); PropertyDescriptorCollection propertyDescriptors = typeDescriptor.GetProperties(); foreach (Dyn.PropertyDescriptor propertyDescriptor in propertyDescriptors) { PropertyControlAttribute propertyControl = propertyDescriptor.Attributes[typeof(PropertyControlAttribute)] as PropertyControlAttribute; if (propertyControl != null && propertyControl.ControlType == ControlTypeEnum.ExpressionBox) { string newValue = compiler.GetValueOfSymbol(propertyDescriptor.Name); propertyDescriptor.SetValue(properties, newValue == null ? string.Empty : newValue); } } propertyGrid.Refresh(); }
private void propertyGrid_PropertyValueChanged(object s, PropertyValueChangedEventArgs e) { GridItem gridItem = e.ChangedItem; string itemSymbol = gridItem.PropertyDescriptor.Name; Dyn.TypeDescriptor typeDescriptor = Dyn.TypeDescriptor.GetTypeDescriptor(propertyGrid.SelectedObject); PropertyDescriptorCollection propertyDescriptors = typeDescriptor.GetProperties(); Dyn.PropertyDescriptor propertyDescriptor = propertyDescriptors[itemSymbol] as Dyn.PropertyDescriptor; PropertyControlAttribute propertyControl = propertyDescriptor.Attributes[typeof(PropertyControlAttribute)] as PropertyControlAttribute; if (propertyControl != null && propertyControl.ControlType == ControlTypeEnum.TextBox) { string value = propertyDescriptor.GetValue(this.properties) != null?propertyDescriptor.GetValue(this.properties).ToString() : null; compiler.Input(propertyDescriptor.Name, value); } else if (propertyControl != null && propertyControl.ControlType == ControlTypeEnum.OptionBox) { compiler.Input(propertyDescriptor.Name, propertyDescriptor.GetValue(this.properties).ToString()); } }