Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Instead of serializing your buttons to the resource file, you could try to serialize them to the code behind. For this you need to implement a custom <code>TypeDescriptor</code> for your <code>CompactButton</code> type and there handle convertion to an <code>InstanceDescriptor</code>. Look at <a href="http://msdn.microsoft.com/en-us/library/ayybcxe5.aspx" rel="nofollow">How to Implement a TypeConverter</a>. Example:</p> <pre><code>[TypeConverter(typeof(CompactButtonTypeConverter))] public class CompactButton: ... { ... } public class CompactButtonTypeConverter: TypeConverter { public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType) { if (destinationType == typeof(InstanceDescriptor)) return true; return base.CanConvertTo(context, destinationType); } public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType) { if (destinationType == typeof(InstanceDescriptor) &amp;&amp; value is CompactButton) { // This assumes you have a public default constructor on your type. ConstructorInfo ctor = typeof(CompactButton).GetConstructor(); if (ctor != null) return new InstanceDescriptor(ctor, new object[0], false); } return base.ConvertTo(context, culture, value, destinationType); } } </code></pre> <p>For more information also see the <a href="http://msdn.microsoft.com/en-us/library/system.componentmodel.design.serialization.instancedescriptor.aspx" rel="nofollow">InstanceDescriptor</a> class.</p> <p><strong>UPDATE</strong>: As for your <code>UITypeEditor</code> and the CompactButtons property, you do not need a setter. Change your CompactButtons property as follows:</p> <pre><code>[DesignerSerializationVisibility(DesignerSerializationVisibility.Content), Editor(typeof(ButtonPanelXEditor), typeof(UITypeEditor))] public List&lt;CompactButton&gt; CompactButtons { get { return _compactButtons; } // _compactButtons must of course be initialized. } </code></pre> <p>Then you could implement the EditValue method of <code>UITypeEditor</code> like so:</p> <pre><code>public override object EditValue(System.ComponentModel.ITypeDescriptorContext context, IServiceProvider provider, object value) { if (context == null || provider == null) return null; var b = context.Instance as ButtonPanel; if (b == null) return value; var editorService = (IWindowsFormsEditorService) provider.GetService(typeof(IWindowsFormsEditorService)); if (editorService == null) return null; // This constructor should copy the buttons in its own list. using (var form = new FooBar(b.CompactButtons)) { if (editorService.ShowDialog(form) == DialogResult.OK &amp;&amp; context.OnComponentChanging()) { b.CompactButtons.Clear(); b.CompactButtons.AddRange(form.Buttons); context.OnComponentChanged(); } } return value; } </code></pre> <p>If your editor form is not very specialized you could maybe try out the <a href="http://msdn.microsoft.com/en-us/library/system.componentmodel.design.collectioneditor.aspx" rel="nofollow">CollectionEditor</a>.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload