Beispiel #1
0
        /// <summary>
        ///     Crea el editor.
        /// </summary>
        protected virtual Control CreateEditor(string name, ErrorProvider errorProvider)
        {
            IFormModel formModel = this.FormModel;

            PropertyDescription propDescription = formModel.GetDescription(name);
            Type tipo = formModel.GetPropertyType(name);

            // Se busca la fabrica de editores.
            IEditorFactory editorFactory = propDescription.EditorFactory ?? this.DefaultEditorFactory;

            Contract.Assert(editorFactory != null);

            ViewProperties[] viewProperties  = formModel.GetViewProperties(name).ToArray();
            IServiceProvider serviceProvider = this.GetServiceProvider();

            // Se crea el control mediante la fabrica de editores.
            Control editor = (Control)editorFactory.Create(tipo, viewProperties, serviceProvider);

            if (editor == null)
            {
                Log <FormViewControl <TControl> > .ErrorFormat("No se encuentra mapeo para la propiedad de formulario {0} [{1}]", formModel, name);

                editor      = new System.Windows.Forms.Label();
                editor.Text = "<ERROR>";
            }

            //editor.Site = mySite;
            editor.Name     = name;
            editor.Enabled  = true;
            editor.AutoSize = this.EditorAutoSize;
            editor.Anchor   = this.EditorAnchor;
            editor.Dock     = this.EditorDock;
            editor.Padding  = this.EditorPadding;
            editor.Margin   = this.EditorMargin;

            string description = propDescription.Description;

            if (!string.IsNullOrEmpty(description))
            {
                ToolTip toolTip = new ToolTip();
                toolTip.SetToolTip(editor, description);
            }

            ControlExchange exchange = ControlExchange.Get(editor);

            if (exchange != null)
            {
                exchange.PopertyName = name;
            }

            return(editor);
        }
        private void InitializeComponent()
        {
            this._pnlHeader = new HeaderPanel();
            this._lblHeader = new HeaderLabel();
            this._glAttributes = new GroupLabel();
            this._glType = new GroupLabel();
            this._txtType = new System.Windows.Forms.TextBox();
            this._pnlMain = new System.Windows.Forms.Panel();
            this._filterList = new EditableTreeList();
            this._rbCompare = new System.Windows.Forms.RadioButton();
            this._lblCompare = new System.Windows.Forms.Label();
            this._dialogButtons = new DefaultDialogButtons();
            this._lblType = new System.Windows.Forms.Label();
            this._txtMethod = new System.Windows.Forms.TextBox();
            this._txtArgument = new System.Windows.Forms.TextBox();
            this._pnlRight = new System.Windows.Forms.Panel();
            this._lblMethod = new System.Windows.Forms.Label();
            this._rbDelegate = new System.Windows.Forms.RadioButton();
            this._pnlCompare = new System.Windows.Forms.Panel();
            this._cbCompare = new System.Windows.Forms.ComboBox();
            this._lblArgument = new System.Windows.Forms.Label();
            this._pnlDelegate = new System.Windows.Forms.Panel();
            this._txtType.Location = new System.Drawing.Point(0, 20);
            this._txtType.Size = new System.Drawing.Size(211, 20);

            this._lblHeader.Location = new System.Drawing.Point(0, 0);
            this._lblHeader.Size = new System.Drawing.Size(434, 16);
            this._lblHeader.Anchor = (System.Windows.Forms.AnchorStyles.Top
                | System.Windows.Forms.AnchorStyles.Left);
            this._pnlHeader.Controls.AddRange(new System.Windows.Forms.Control[] {
                this._lblHeader
            });
            this._pnlHeader.Location = new System.Drawing.Point(6, 5);
            this._pnlHeader.Size = new System.Drawing.Size(434, 16);
            this._pnlHeader.Anchor = (System.Windows.Forms.AnchorStyles.Top
                | System.Windows.Forms.AnchorStyles.Left);
            this._pnlMain.Controls.AddRange(new System.Windows.Forms.Control[] {this._dialogButtons,
                                                                                  this._pnlRight,
                                                                                  this._filterList});
            this._pnlMain.Location = new System.Drawing.Point(6, 27);
            this._pnlMain.Size = new System.Drawing.Size(434, 253);
            this._pnlMain.Anchor = (System.Windows.Forms.AnchorStyles.Bottom
                | System.Windows.Forms.AnchorStyles.Left);
            this._filterList.Size = new System.Drawing.Size(198, 224);
            this._filterList.Location = new System.Drawing.Point(0, 0);
            this._rbCompare.Location = new System.Drawing.Point(8, 21);
            this._rbCompare.Size = new System.Drawing.Size(211, 17);
            this._lblCompare.Location = new System.Drawing.Point(0, 4);
            this._lblCompare.Size = new System.Drawing.Size(211, 16);
            this._dialogButtons.Location = new System.Drawing.Point(197, 230);
            this._dialogButtons.Size = new System.Drawing.Size(237, 23);
            this._lblType.Location = new System.Drawing.Point(0, 4);
            this._lblType.Size = new System.Drawing.Size(211, 16);
            this._txtMethod.Location = new System.Drawing.Point(0, 64);
            this._txtMethod.Size = new System.Drawing.Size(211, 20);
            this._txtArgument.Location = new System.Drawing.Point(0, 64);
            this._txtArgument.Size = new System.Drawing.Size(211, 20);
            this._pnlRight.Controls.AddRange(new System.Windows.Forms.Control[] {this._pnlCompare,
                                                                                 this._pnlDelegate,
                                                                                 this._glAttributes,
                                                                                 this._glType,
                                                                                 this._rbDelegate,
                                                                                 this._rbCompare});
            this._pnlRight.Location = new System.Drawing.Point(215, 0);
            this._pnlRight.Size = new System.Drawing.Size(219, 226);
            this._lblMethod.Location = new System.Drawing.Point(0, 48);
            this._lblMethod.Size = new System.Drawing.Size(211, 16);
            this._glAttributes.Location = new System.Drawing.Point(0, 73);
            this._glAttributes.Size = new System.Drawing.Size(216, 16);
            this._rbDelegate.Location = new System.Drawing.Point(8, 46);
            this._rbDelegate.Size = new System.Drawing.Size(211, 17);
            this._glType.Size = new System.Drawing.Size(216, 16);
            this._pnlCompare.Controls.AddRange(new System.Windows.Forms.Control[] {this._txtArgument,
                                                                                     this._lblArgument,
                                                                                     this._cbCompare,
                                                                                     this._lblCompare});
            this._pnlCompare.Location = new System.Drawing.Point(8, 90);
            this._pnlCompare.Size = new System.Drawing.Size(211, 136);
            this._cbCompare.DropDownWidth = 211;
            this._cbCompare.Location = new System.Drawing.Point(0, 20);
            this._cbCompare.Size = new System.Drawing.Size(211, 21);
            this._cbCompare.Sorted = true;
            this._lblArgument.Location = new System.Drawing.Point(0, 48);
            this._lblArgument.Size = new System.Drawing.Size(211, 16);
            this._pnlDelegate.Controls.AddRange(new System.Windows.Forms.Control[] {this._txtType,
                                                                                      this._txtMethod,
                                                                                      this._lblMethod,
                                                                                      this._lblType});
            this._pnlDelegate.Location = new System.Drawing.Point(8, 90);
            this._pnlDelegate.Size = new System.Drawing.Size(211, 136);
            this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
            this.ClientSize = new System.Drawing.Size(448, 289);
            this.AcceptButton = _dialogButtons.CmdOK;
            this.CancelButton = _dialogButtons.CmdCancel;
            this.Controls.AddRange(new System.Windows.Forms.Control[] {this._pnlHeader, this._pnlMain});
        }
        private void InitializeComponent()
        {
            this._pnlHeader        = new HeaderPanel();
            this._lblHeader        = new HeaderLabel();
            this._glAttributes     = new GroupLabel();
            this._glType           = new GroupLabel();
            this._txtType          = new System.Windows.Forms.TextBox();
            this._pnlMain          = new System.Windows.Forms.Panel();
            this._filterList       = new EditableTreeList();
            this._rbCompare        = new System.Windows.Forms.RadioButton();
            this._lblCompare       = new System.Windows.Forms.Label();
            this._dialogButtons    = new DefaultDialogButtons();
            this._lblType          = new System.Windows.Forms.Label();
            this._txtMethod        = new System.Windows.Forms.TextBox();
            this._txtArgument      = new System.Windows.Forms.TextBox();
            this._pnlRight         = new System.Windows.Forms.Panel();
            this._lblMethod        = new System.Windows.Forms.Label();
            this._rbDelegate       = new System.Windows.Forms.RadioButton();
            this._pnlCompare       = new System.Windows.Forms.Panel();
            this._cbCompare        = new System.Windows.Forms.ComboBox();
            this._lblArgument      = new System.Windows.Forms.Label();
            this._pnlDelegate      = new System.Windows.Forms.Panel();
            this._txtType.Location = new System.Drawing.Point(0, 20);
            this._txtType.Size     = new System.Drawing.Size(211, 20);

            this._lblHeader.Location = new System.Drawing.Point(0, 0);
            this._lblHeader.Size     = new System.Drawing.Size(434, 16);
            this._lblHeader.Anchor   = (System.Windows.Forms.AnchorStyles.Top
                                        | System.Windows.Forms.AnchorStyles.Left);
            this._pnlHeader.Controls.AddRange(new System.Windows.Forms.Control[] {
                this._lblHeader
            });
            this._pnlHeader.Location = new System.Drawing.Point(6, 5);
            this._pnlHeader.Size     = new System.Drawing.Size(434, 16);
            this._pnlHeader.Anchor   = (System.Windows.Forms.AnchorStyles.Top
                                        | System.Windows.Forms.AnchorStyles.Left);
            this._pnlMain.Controls.AddRange(new System.Windows.Forms.Control[] { this._dialogButtons,
                                                                                 this._pnlRight,
                                                                                 this._filterList });
            this._pnlMain.Location = new System.Drawing.Point(6, 27);
            this._pnlMain.Size     = new System.Drawing.Size(434, 253);
            this._pnlMain.Anchor   = (System.Windows.Forms.AnchorStyles.Bottom
                                      | System.Windows.Forms.AnchorStyles.Left);
            this._filterList.Size        = new System.Drawing.Size(198, 224);
            this._filterList.Location    = new System.Drawing.Point(0, 0);
            this._rbCompare.Location     = new System.Drawing.Point(8, 21);
            this._rbCompare.Size         = new System.Drawing.Size(211, 17);
            this._lblCompare.Location    = new System.Drawing.Point(0, 4);
            this._lblCompare.Size        = new System.Drawing.Size(211, 16);
            this._dialogButtons.Location = new System.Drawing.Point(197, 230);
            this._dialogButtons.Size     = new System.Drawing.Size(237, 23);
            this._lblType.Location       = new System.Drawing.Point(0, 4);
            this._lblType.Size           = new System.Drawing.Size(211, 16);
            this._txtMethod.Location     = new System.Drawing.Point(0, 64);
            this._txtMethod.Size         = new System.Drawing.Size(211, 20);
            this._txtArgument.Location   = new System.Drawing.Point(0, 64);
            this._txtArgument.Size       = new System.Drawing.Size(211, 20);
            this._pnlRight.Controls.AddRange(new System.Windows.Forms.Control[] { this._pnlCompare,
                                                                                  this._pnlDelegate,
                                                                                  this._glAttributes,
                                                                                  this._glType,
                                                                                  this._rbDelegate,
                                                                                  this._rbCompare });
            this._pnlRight.Location     = new System.Drawing.Point(215, 0);
            this._pnlRight.Size         = new System.Drawing.Size(219, 226);
            this._lblMethod.Location    = new System.Drawing.Point(0, 48);
            this._lblMethod.Size        = new System.Drawing.Size(211, 16);
            this._glAttributes.Location = new System.Drawing.Point(0, 73);
            this._glAttributes.Size     = new System.Drawing.Size(216, 16);
            this._rbDelegate.Location   = new System.Drawing.Point(8, 46);
            this._rbDelegate.Size       = new System.Drawing.Size(211, 17);
            this._glType.Size           = new System.Drawing.Size(216, 16);
            this._pnlCompare.Controls.AddRange(new System.Windows.Forms.Control[] { this._txtArgument,
                                                                                    this._lblArgument,
                                                                                    this._cbCompare,
                                                                                    this._lblCompare });
            this._pnlCompare.Location     = new System.Drawing.Point(8, 90);
            this._pnlCompare.Size         = new System.Drawing.Size(211, 136);
            this._cbCompare.DropDownWidth = 211;
            this._cbCompare.Location      = new System.Drawing.Point(0, 20);
            this._cbCompare.Size          = new System.Drawing.Size(211, 21);
            this._cbCompare.Sorted        = true;
            this._lblArgument.Location    = new System.Drawing.Point(0, 48);
            this._lblArgument.Size        = new System.Drawing.Size(211, 16);
            this._pnlDelegate.Controls.AddRange(new System.Windows.Forms.Control[] { this._txtType,
                                                                                     this._txtMethod,
                                                                                     this._lblMethod,
                                                                                     this._lblType });
            this._pnlDelegate.Location = new System.Drawing.Point(8, 90);
            this._pnlDelegate.Size     = new System.Drawing.Size(211, 136);
            this.FormBorderStyle       = System.Windows.Forms.FormBorderStyle.FixedDialog;
            this.ClientSize            = new System.Drawing.Size(448, 289);
            this.AcceptButton          = _dialogButtons.CmdOK;
            this.CancelButton          = _dialogButtons.CmdCancel;
            this.Controls.AddRange(new System.Windows.Forms.Control[] { this._pnlHeader, this._pnlMain });
        }
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            if (ipTextBox.IsEnabled)
            {
                string        error  = "";
                string        ip     = ipTextBox.Text;
                List <string> bytess = ip.Split('.').ToList <string>();
                if (bytess.Count != 4)
                {
                    WMessageBox.Show("less than 4 bytes");
                }
                else
                {
                    if (!IsAnInt(bytess[0]))
                    {
                        error += bytess[0];
                    }
                    if (!IsAnInt(bytess[1]))
                    {
                        if (error.Length != 0)
                        {
                            error += "." + bytess[1];
                        }
                        else
                        {
                            error += bytess[1];
                        }
                    }
                    if (!IsAnInt(bytess[2]))
                    {
                        if (error.Length != 0)
                        {
                            error += "." + bytess[2];
                        }
                        else
                        {
                            error += bytess[2];
                        }
                    }
                    if (!IsAnInt(bytess[3]))
                    {
                        if (error.Length != 0)
                        {
                            error += "." + bytess[3];
                        }
                        else
                        {
                            error += bytess[3];
                        }
                    }
                    if (error.Length != 0)
                    {
                        Forms.Form  f       = new Forms.Form();
                        Forms.Label messge1 = new Forms.Label(),
                                    messge2 = new Forms.Label(),
                                    l       = new Forms.Label();
                        messge1.AutoSize = true;
                        l.AutoSize       = true;
                        messge2.AutoSize = true;
                        messge1.Text     = "the IP address";
                        messge1.Location = new System.Drawing.Point(0, 0);



                        l.Text = error;

                        l.ForeColor = System.Drawing.Color.Red;

                        l.Location   = new System.Drawing.Point(messge1.Width + 1, 0);
                        messge2.Text = "has an error please fix the error";

                        messge2.Location = new System.Drawing.Point(l.Width + messge1.Width, 0);

                        f.SetBounds(1500, 800, l.Width + messge1.Width + messge2.Width + 100, 70);
                        f.Controls.Add(messge1);

                        f.Controls.Add(l);

                        f.Controls.Add(messge2);

                        f.Show();
                    }
                    else
                    {
                        ipTextBox.IsEnabled = false;
                        snMask.IsEnabled    = true;
                        nHosts.IsEnabled    = true;
                        Submit2.IsEnabled   = true;
                        Submit1.Content     = "Change IP";
                    }
                }
            }
            else
            {
                ipTextBox.IsEnabled = true;
                snMask.IsEnabled    = false;
                nHosts.IsEnabled    = false;
                Submit2.IsEnabled   = false;
                Submit1.Content     = "Submit";
            }
        }