public void UITypeEditor_PaintValue_Invoke_Nop(PaintValueEventArgs e) { using (var image = new Bitmap(10, 10)) using (var graphics = Graphics.FromImage(image)) { var editor = new UITypeEditor(); editor.PaintValue(e); } }
private void OpenDropDownEditor() { if (m_isEditing) { return; } try { m_isEditing = true; object oldValue, value; var oldContext = m_context; // Alan Beckus: save references to all the required objects to perform the transaction. // Because EditValue(...) enters modal loop using Application.DonEvent() // consequently selectedObjects, transaction and event m_context itself can change // before returning from EditValue(...). // note: previous attempt to solve this issue was to cache selected objects inside // m_context but it failed to solve the issue because the cache was cleared // by PropertyView before it can be used. List <object> selection = new List <object>(m_context.SelectedObjects); var transactionContext = m_context.TransactionContext; var descriptor = m_context.Descriptor; oldValue = m_context.GetValue(); UITypeEditor editor = WinFormsPropertyUtils.GetUITypeEditor(m_descriptor, this); // Bring up the editor which can cause Bind() to be called, so make sure that we use the // correct context and selection after this EditValue call. value = editor.EditValue(this, this, oldValue); transactionContext.DoTransaction(delegate { foreach (object selectedObject in selection) { PropertyUtils.SetProperty(selectedObject, descriptor, value); } }, string.Format("Edit: {0}".Localize(), descriptor.DisplayName)); // notify that we just changed a value NotifyPropertyEdit(oldValue, value); // Refresh text box, paint rect if (oldContext == m_context) { SetTextBoxFromProperty(); EnableTextBox(); } Invalidate(); } finally { m_isEditing = false; } }
private void EditVideoMap(VideoMap map) { PropertyDescriptor pd = TypeDescriptor.GetProperties(map)["Lines"]; UITypeEditor editor = (UITypeEditor)pd.GetEditor(typeof(UITypeEditor)); RuntimeServiceProvider serviceProvider = new RuntimeServiceProvider(); editor.EditValue(serviceProvider, serviceProvider, map.Lines); LoadListBox(); }
protected override void OnDoubleClick(EventArgs e) { base.OnDoubleClick(e); UITypeEditor imageEditor = (UITypeEditor)TypeDescriptor.GetEditor(typeof(Image), typeof(UITypeEditor)); _serviceContext.SetInstance(this, TypeDescriptor.GetProperties(this)["Image"]); this.Image = imageEditor.EditValue(_serviceContext, _serviceContext, this.Image) as Image; }
public override bool GetPaintValueSupported(ITypeDescriptorContext context) { UITypeEditor editor = lookUpEditor(context); if (editor != null) { return(editor.GetPaintValueSupported(context)); } return(base.GetPaintValueSupported(context)); }
private UITypeEditor CreateEditor(PropertyDescriptor property) { UITypeEditor result = null; if (this.PhraseDescriptor != null) { result = this.PhraseDescriptor.CreateEditor(property); } return(result); }
protected void DoEditorCustom() { UITypeEditor uITypeEditor = (UITypeEditor)TypeDescriptor.GetEditor(base.Component, typeof(UITypeEditor)); if (uITypeEditor != null && uITypeEditor is UITypeEditorGeneric) { (uITypeEditor as UITypeEditorGeneric).IForceDesignerChange = this; (uITypeEditor as UITypeEditorGeneric).EditValue(null, null, base.Component); } }
public DataFieldUI(UITypeEditor editor, Component component) { this.editor = editor; foreach (String dataField in GetStandardValues(component)) { base.Items.Add(dataField); } }
private UITypeEditor GetActualEditor(ITypeDescriptorContext context) { if (context == null) { return(this.actualEditor); } XmlPropertySetting instance = (XmlPropertySetting)context.Instance; if (instance.Property == null) { this.actualEditor = (UITypeEditor)null; return((UITypeEditor)null); } string[] strArray = instance.Property.Split('.'); if (strArray.Length > 1) { string propertyName = strArray[strArray.Length - 1]; string className = string.Join(".", strArray, 0, strArray.Length - 1); RadProperty safe = RadProperty.FindSafe(className, propertyName); this.currProperty = safe; if (safe != null) { TypeConverter converter = TypeDescriptor.GetConverter(safe.PropertyType); this.actualPropertyType = safe.PropertyType; if (converter == null || !converter.CanConvertFrom(typeof(string)) || !converter.CanConvertTo(typeof(string))) { if (!converter.CanConvertFrom(typeof(string))) { int num1 = (int)MessageBox.Show("Converter can't convert from string"); } else if (!converter.CanConvertTo(typeof(string))) { int num2 = (int)MessageBox.Show("Converter can't convert to string"); } else { int num3 = (int)MessageBox.Show("Converter for type not found"); } this.actualEditor = (UITypeEditor)null; return((UITypeEditor)null); } this.actualConverter = converter; PropertyDescriptor propertyDescriptor = TypeDescriptor.GetProperties(safe.OwnerType).Find(safe.Name, false); this.actualEditor = propertyDescriptor == null ? (UITypeEditor)TypeDescriptor.GetEditor(safe.PropertyType, typeof(UITypeEditor)) : (UITypeEditor)propertyDescriptor.GetEditor(typeof(UITypeEditor)); return(this.actualEditor); } int num = (int)MessageBox.Show("Can't find property " + instance.Property + ". Property " + propertyName + "not registered for RadObject" + className); this.actualEditor = (UITypeEditor)null; return((UITypeEditor)null); } int num4 = (int)MessageBox.Show("Invalid property name. Property consist of type FullName\".\"PropertyName."); this.actualEditor = (UITypeEditor)null; return((UITypeEditor)null); }
public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value) { UITypeEditor editor = lookUpEditor(context); if (editor != null) { return(editor.EditValue(context, provider, value)); } return(base.EditValue(context, provider, value)); }
internal static T EditValue <T>(this UITypeEditor editor, T value) where T : class { var runtimeServiceProvider = new RuntimeUIServiceProvider(); object obj = editor.EditValue(runtimeServiceProvider, runtimeServiceProvider, value); if (typeof(T) == typeof(string)) { return(obj?.ToString() as T); } return((T)obj); }
public static UITypeEditor GetRegisteredUITypeEditor(Type type) { UITypeEditor result = null; Type editorType = null; if (registeredEditors.TryGetValue(type, out editorType)) { result = Activator.CreateInstance(editorType) as UITypeEditor; } return(result); }
/// <summary> /// Invokes the editor for the columns of the designed ImageListView. /// </summary> public void EditColumns() { // TODO: Column editing cannot be undone in the designer. property = TypeDescriptor.GetProperties(imageListView)["Columns"]; UITypeEditor editor = (UITypeEditor)property.GetEditor(typeof(UITypeEditor)); object value = imageListView.Columns;// property.GetValue(imageListView); value = editor.EditValue(this, this, value); SetProperty("Columns", value); designerService.Refresh(Component); }
/// <summary> /// Construct a Model. Based on the Type specified the Constructor populate AllowNull, DefaultValue, TypeConverter, StandardValues, StandardValueExclusive /// </summary> /// <param name="p_Type">The type of this model</param> public EditorUITypeEditor(Type p_Type) : base(p_Type) { object l_Editor = System.ComponentModel.TypeDescriptor.GetEditor(p_Type, typeof(System.Drawing.Design.UITypeEditor)); if (l_Editor == null) { throw new MEDDataGridException("Type not valid, no editor associated to this type"); } this.uiTypeEditor = (System.Drawing.Design.UITypeEditor)l_Editor; }
public AdhocProperty(string sName, object value, bool bReadOnly, bool bVisible) { this.sName = sName; this.objValue = value; this.bReadOnly = bReadOnly; this.bVisible = bVisible; m_DisplayName = this.sName; m_Description = this.sName; m_Category = String.Empty; m_Converter = null; m_Editor = null; }
/// <include file='doc\COM2AboutBoxPropertyDescriptor.uex' path='docs/doc[@for="Com2AboutBoxPropertyDescriptor.GetEditor"]/*' /> /// <devdoc> /// Retrieves an editor of the requested type. /// </devdoc> public override object GetEditor(Type editorBaseType) { if (editorBaseType == typeof(UITypeEditor)) { if (editor == null) { editor = new AboutBoxUITypeEditor(); } } return(editor); }
//public bool ShouldSerializeUITypeEditor() //{ // return m_UITypeEditor != m_DefaultUITypeEditor; //} protected override void ApplyValidatorRules() { base.ApplyValidatorRules(); if (m_UITypeEditor == null && Validator != null) { object tmp = System.ComponentModel.TypeDescriptor.GetEditor(Validator.ValueType, typeof(UITypeEditor)); if (tmp is UITypeEditor) { m_UITypeEditor = (UITypeEditor)tmp; } } }
public virtual void PaintValue(Graphics gfx, Rectangle rect) { UITypeEditor editor = GetEditor(); if (editor != null) { try { editor.PaintValue(this.ValueText, gfx, rect); } catch { // Some of our Editors throw NotImplementedException } } }
/// <summary> /// Constructor /// </summary> /// <param name="key">Internal name/key of setting</param> /// <param name="val">The current value of the setting</param> /// <param name="desc">The setting's description</param> /// <param name="category">The setting's category</param> /// <param name="update">An eventhandler that will be called if CustomPropertyGrid.InstantUpdate is true</param> /// <param name="editor">Editor for Property</param> public Setting(string key, string desc, string category, object val, SettingEventHandler update, UITypeEditor editor) { this.key = key; this.desc = desc; this.category = category; this.val = val; if (update != null) { ValueChanged += update; } this.editor = editor; }
public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context) { UITypeEditor editor = lookUpEditor(context); if (editor != null) { return(editor.GetEditStyle(context)); } else { return(base.GetEditStyle(context)); } }
public override void PaintValue(PaintValueEventArgs e) { UITypeEditor editor = lookUpEditor(e.Context); if (editor != null) { PaintValueEventArgs e2 = new PaintValueEventArgs(e.Context, e.Value, e.Graphics, e.Bounds); editor.PaintValue(e2); return; //return editor.GetPaintValueSupported(context); } base.PaintValue(e); }
private void OnEditSharedEditors(object sender, EventArgs e) { PropertyDescriptor propdef = TypeDescriptor.GetProperties(Control)["RowTemplateList"]; if (propdef == null) { return; } UITypeEditor editor = (UITypeEditor)propdef.GetEditor(typeof(UITypeEditor)); RuntimeServiceProvider serviceProvider = new RuntimeServiceProvider(this.Control, this.Component, propdef); editor.EditValue(serviceProvider, serviceProvider, propdef.GetValue(this.Control)); }
public virtual UITypeEditor CreateEditor(PropertyDescriptor property) { UITypeEditor result = null; if (this.Type2UIEditor != null && property != null) { Type nullableTypeArgument = WinformsHelper.GetNullableTypeArgument(property.PropertyType); Type type = this.Type2UIEditor[nullableTypeArgument] as Type; if (typeof(UITypeEditor).IsAssignableFrom(type)) { result = (Activator.CreateInstance(type) as UITypeEditor); } } return(result); }
/// <summary> /// Initializes a new instance of <see cref="PopupEditorBindableProperty"/>. /// </summary> /// <param name="property">The underlying <see cref="Property"/> instance.</param> public PopupEditorBindableProperty(Property property) : base(property) { this.property = property; this.popupEditor = property.Attributes .OfType <EditorAttribute>() .Where(x => Type.GetType(x.EditorBaseTypeName, false) == typeof(UITypeEditor)) .Select(x => Type.GetType(x.EditorTypeName)) .Select(x => Activator.CreateInstance(x)) .Cast <UITypeEditor>() .First(); textReadOnly = property.Attributes.OfType <EditorWithReadOnlyTextAttribute>().Where(x => x.ReadonlyText).Any(); }
public override object GetEditor(Type editorBaseType) { if (m_editor == null) { if (m_editorType != null) { m_editor = Activator.CreateInstance(m_editorType) as UITypeEditor; return(m_editor); } } else { return(m_editor); } return(base.GetEditor(editorBaseType)); }
public static void EditValue(IWin32Window owner, object component, string propertyName) { PropertyDescriptor prop = TypeDescriptor.GetProperties(component)[propertyName]; if (prop == null) throw new ArgumentException("propertyName"); UITypeEditor editor = (UITypeEditor)prop.GetEditor(typeof(UITypeEditor)); MyHelper ctx = new MyHelper(owner, component, prop); if (editor != null && editor.GetEditStyle(ctx) == UITypeEditorEditStyle.Modal) { object value = prop.GetValue(component); value = editor.EditValue(ctx, ctx, value); if (!prop.IsReadOnly) { prop.SetValue(component, value); } } }
/// <summary> /// Create the editor control /// </summary> /// <returns></returns> protected override Control CreateControl() { DevAge.Windows.Forms.TextBoxUITypeEditor editor = new DevAge.Windows.Forms.TextBoxUITypeEditor(); editor.BorderStyle = DevAge.Drawing.BorderStyle.None; editor.Validator = this; object objEditor = System.ComponentModel.TypeDescriptor.GetEditor(base.ValueType, typeof(System.Drawing.Design.UITypeEditor)); UITypeEditor uiEditor = null; if (editor != null) { uiEditor = (System.Drawing.Design.UITypeEditor)objEditor; } editor.UITypeEditor = uiEditor; return(editor); }
private void OpenDropDownEditor() { try { m_isEditing = true; PropertyEditorControlContext oldContext = m_context; object oldValue, value; try { // Certain property editing controls like the FlagsUITypeEditor's private CheckedListBox will // not lose focus until the user clicks away, and the user's click may change the // PropertyEditorControlContext's selection, so let's temporarily freeze the selection. oldContext.CacheSelection(); oldValue = m_context.GetValue(); UITypeEditor editor = WinFormsPropertyUtils.GetUITypeEditor(m_descriptor, this); // Bring up the editor which can cause Bind() to be called, so make sure that we use the // correct context and selection after this EditValue call. value = editor.EditValue(this, this, oldValue); oldContext.SetValue(value); } finally { oldContext.ClearCachedSelection(); } // notify that we just changed a value NotifyPropertyEdit(oldValue, value); // Refresh text box, paint rect if (oldContext == m_context) { SetTextBoxFromProperty(); EnableTextBox(); } Invalidate(); } finally { m_isEditing = false; } }
/// <summary> /// Draws the property editing representation, in the same way that the control /// presents the property in the GUI. Use this method to draw inactive properties /// when multitasking a single PropertyEditingControl.</summary> /// <param name="descriptor">Property descriptor</param> /// <param name="context">Type descriptor context</param> /// <param name="bounds">Bounds containing graphics</param> /// <param name="font">Font to use for rendering property text</param> /// <param name="brush">Brush for rendering property text</param> /// <param name="g">Graphics object</param> public static void DrawProperty( PropertyDescriptor descriptor, ITypeDescriptorContext context, Rectangle bounds, Font font, Brush brush, Graphics g) { object owner = context.Instance; if (owner == null) { return; } UITypeEditor editor = WinFormsPropertyUtils.GetUITypeEditor(descriptor, context); if (editor != null) { if (editor.GetPaintValueSupported(context)) { object value = descriptor.GetValue(owner); Rectangle paintRect = new Rectangle( bounds.Left + 1, bounds.Top + 1, PaintRectWidth, PaintRectHeight); editor.PaintValue(new PaintValueEventArgs(context, value, g, paintRect)); bounds.X += PaintRectTextOffset; bounds.Width -= PaintRectTextOffset; g.DrawRectangle(SystemPens.ControlDark, paintRect); } } string valueString = PropertyUtils.GetPropertyText(owner, descriptor); bounds.Height = font.Height; if (s_textFormat.CustomFlags == CustomStringFormatFlags.TrimLeftWithEllipses) { valueString = TrimStringLeftWithEllipses(valueString, bounds, font, g); } g.DrawString(valueString, font, brush, bounds, s_textFormat.Format); }
///<summary> ///Gets an editor of the specified type. ///</summary> /// ///<returns> ///An instance of the requested editor type, or null if an editor cannot be found. ///</returns> /// ///<param name="editorBaseType">The base type of editor, which is used to differentiate between multiple editors that a property supports. </param> public override object GetEditor(Type editorBaseType) { if (IsReadOnly) { return(null); } if (editorBaseType == typeof(UITypeEditor)) { UITypeEditor typeEditor = (UITypeEditor)innerProperyDescriptor.GetEditor(editorBaseType); if (typeEditor != null) { return(new UITypeEditorProxy(typeEditor, actualInstance)); } return(null); } return(base.GetEditor(editorBaseType)); }
<Editor(GetType(ImageComboItemEditor), GetType(UITypeEditor)), _