Esempio n. 1
0
 public PropertyDescriptorActionData(InlineAction owner)
     : base("Action", new Attribute[] {
     new TypeConverterAttribute(typeof(ExpandableObjectConverter))
 })
 {
     _owner = owner;
 }
 public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
 {
     if (context != null && context.Instance != null && provider != null)
     {
         IWindowsFormsEditorService edSvc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));
         if (edSvc != null)
         {
             IInlineActionHolder iah = context.Instance as IInlineActionHolder;
             if (iah == null)
             {
                 PropertiesWrapper pw = context.Instance as PropertiesWrapper;
                 if (pw != null)
                 {
                     iah = pw.Owner as IInlineActionHolder;
                 }
             }
             if (iah != null && iah.Method != null)
             {
                 InlineAction ia  = value as InlineAction;
                 IAction      act = null;
                 if (ia != null)
                 {
                     act = ia.Action;
                 }
                 FrmObjectExplorer dlg = DesignUtil.CreateSelectActionDialog(iah.Method, act, null, false);
                 if (dlg != null)
                 {
                     if (edSvc.ShowDialog(dlg) == System.Windows.Forms.DialogResult.OK)
                     {
                         value = new InlineAction(dlg.SelectedAction);
                     }
                 }
             }
         }
     }
     return(value);
 }