示例#1
0
        private void OpenProperty(Object sender, EventArgs e)
        {
            this.colUserControl = base.Component as EasyButton;
            var parentControl = (EasyButton)Control;
            var oldTabs       = parentControl.Controls;
            var propertyForm  = new EasyButtonProperty(parentControl);

            propertyForm.Show();
            //每一次都要改变
            //只改变BackColor进行Designer.cs的强制更新
            GetPropertyByName("BackColor").SetValue(colUserControl, parentControl.BackColor);
        }
        public static Control CreateControl(string ctrlName, string partialName)
        {
            try
            {
                Control ctrl;
                switch (ctrlName)
                {
                case "Label":
                    ctrl = new Label();
                    break;

                case "TextBox":
                    ctrl = new TextBox();
                    break;

                case "PictureBox":
                    ctrl = new PictureBox();
                    break;

                case "ListView":
                    ctrl = new ListView();
                    break;

                case "ComboBox":
                    ctrl = new ComboBox();
                    break;

                case "Button":
                    ctrl = new Button();
                    break;

                case "CheckBox":
                    ctrl = new CheckBox();
                    break;

                case "MonthCalender":
                    ctrl = new MonthCalendar();
                    break;

                case "DateTimePicker":
                    ctrl = new DateTimePicker();
                    break;

                case "EasyButton":
                    ctrl = new EasyButton();
                    break;

                default:
                    Assembly controlAsm  = Assembly.LoadWithPartialName(partialName);
                    Type     controlType = controlAsm.GetType(partialName + "." + ctrlName);
                    ctrl = (Control)Activator.CreateInstance(controlType);
                    break;
                }
                return(ctrl);
            }
            catch (Exception ex)
            {
                System.Diagnostics.Trace.WriteLine("create control failed:" + ex.Message);
                return(new Control());
            }
        }
 public EasyButtonProperty(EasyButton _ctrl)
 {
     InitializeComponent();
     _beforeCtrl  = ControlFactory.CloneCtrl(_ctrl);
     _changedCtrl = _ctrl;
 }