Exemplo n.º 1
0
 public static TextField enabled(this TextField field, bool value)
 {
     Reflection_ExtensionMethods_Properties
     .prop(field.htmlElement(),
           "disabled",
           !value);
     return(field);
 }
 public void setWikiApi(O2MediaWikiAPI newWikiApi)
 {
     //perform a shallow copy from newWikiApi to WikiApi)
     //"before:{0}".info(WikiApi.HostUrl);
     foreach (var property in WikiApi.type().properties())
     {
         Reflection_ExtensionMethods_Properties.prop(WikiApi, property.Name, newWikiApi.prop(property.Name));
     }
     //"after:{0}".info(WikiApi.HostUrl);
 }
        }               //Todo: refactor with one below

        public static ToolStripButton   add_Button(this ToolStrip toolStrip, string text, string resourceName, Image image, Action onClick)
        {
            if (toolStrip.isNull())
            {
                "[ToolStripButton][add_Button] provided toolStrip was null".error();
                return(null);
            }
            return(toolStrip.invokeOnThread(
                       () =>
            {
                var button = new ToolStripButton();
                toolStrip.Items.Add(button);
                try
                {
                    if (resourceName.valid())
                    {
                        button.DisplayStyle = ToolStripItemDisplayStyle.ImageAndText;
                        button.applyResources(resourceName);
                    }
                    if (image.notNull())
                    {
                        button.Image = image;
                    }
                    if (text.valid())
                    {
                        button.Text = text;
                    }

                    button.Click += (sender, e) =>
                    {
                        if (onClick.notNull())
                        {
                            onClick();
                        }
                    };
                }
                catch (Exception ex)
                {
                    ex.log("inside toolStrip add_Button");
                }
                Application.DoEvents();
                if (button.toolStrip() != toolStrip)
                {
                    "[ToolStripButton][add_Button] parent was not set, so setting it manuallly".error();
                    //button.prop("Parent", toolStrip);
                    Reflection_ExtensionMethods_Properties.prop("button", "Parent", toolStrip);
                }
                return button;
            }));
        }