Esempio n. 1
0
        public override object EditValue(System.ComponentModel.ITypeDescriptorContext context, System.IServiceProvider provider, object value)
        {
            IWindowsFormsEditorService edSvc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));

            if (edSvc != null)
            {

                FAddressControl = new IPAddressControlLib.IPAddressControl();
                FAddressControl.Text = value.ToString();
                edSvc.DropDownControl(FAddressControl);

                return IPAddress.Parse(FAddressControl.Text);
            }
            return value;
        }
Esempio n. 2
0
        private void ValidateIPField(object sender, EventArgs e)
        {
            Regex validIpV4AddressRegex = new Regex(@"^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]).){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$", RegexOptions.IgnoreCase);

            IPAddressControlLib.IPAddressControl IPvalidate = (IPAddressControlLib.IPAddressControl)sender;
            IPAddress ip          = new IPAddress(new byte[] { 127, 0, 0, 1 });
            string    message     = "";
            int       VisibleTime = 1000; //in milliseconds
            ToolTip   tt          = new ToolTip();

            if (IPvalidate.AnyBlank)
            {
                message = "Blank address fields found";
            }
            else if (!validIpV4AddressRegex.IsMatch(IPvalidate.Text.Trim()))
            {
                message = "Invalid IP address";
            }

            if (!string.IsNullOrEmpty(message))
            {
                tt.Show(message, IPvalidate, 0, -20, VisibleTime);
            }
        }
Esempio n. 3
0
        private bool bHex; // 十六进制显示

        private void InitializeComponent()
        {
            this.components = new System.ComponentModel.Container();
            System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(frmUDPClient));
            this.label1         = new System.Windows.Forms.Label();
            this.label2         = new System.Windows.Forms.Label();
            this.txtPortTarget  = new System.Windows.Forms.TextBox();
            this.txtSend        = new System.Windows.Forms.TextBox();
            this.btnSend        = new System.Windows.Forms.Button();
            this.ipCtrTarget    = new IPAddressControlLib.IPAddressControl();
            this.label5         = new System.Windows.Forms.Label();
            this.txtPortLocal   = new System.Windows.Forms.TextBox();
            this.btnLink        = new System.Windows.Forms.Button();
            this.lbxRecv        = new System.Windows.Forms.ListBox();
            this.btnClearRecv   = new System.Windows.Forms.Button();
            this.groupBox1      = new System.Windows.Forms.GroupBox();
            this.chkAutoSend    = new System.Windows.Forms.CheckBox();
            this.label7         = new System.Windows.Forms.Label();
            this.txtboxInterval = new System.Windows.Forms.TextBox();
            this.label6         = new System.Windows.Forms.Label();
            this.txtCountSend   = new System.Windows.Forms.TextBox();
            this.label4         = new System.Windows.Forms.Label();
            this.groupBox2      = new System.Windows.Forms.GroupBox();
            this.cbxHex         = new System.Windows.Forms.CheckBox();
            this.txtCountRecv   = new System.Windows.Forms.TextBox();
            this.label3         = new System.Windows.Forms.Label();
            this.timer1         = new System.Windows.Forms.Timer(this.components);
            this.groupBox1.SuspendLayout();
            this.groupBox2.SuspendLayout();
            this.SuspendLayout();
            //
            // label1
            //
            this.label1.AutoSize = true;
            this.label1.Location = new System.Drawing.Point(6, 32);
            this.label1.Name     = "label1";
            this.label1.Size     = new System.Drawing.Size(43, 17);
            this.label1.TabIndex = 0;
            this.label1.Text     = "目标IP";
            //
            // label2
            //
            this.label2.AutoSize = true;
            this.label2.Location = new System.Drawing.Point(6, 97);
            this.label2.Name     = "label2";
            this.label2.Size     = new System.Drawing.Size(56, 17);
            this.label2.TabIndex = 2;
            this.label2.Text     = "目标端口";
            //
            // txtPortTarget
            //
            this.txtPortTarget.Location = new System.Drawing.Point(67, 94);
            this.txtPortTarget.Name     = "txtPortTarget";
            this.txtPortTarget.Size     = new System.Drawing.Size(73, 23);
            this.txtPortTarget.TabIndex = 1;
            this.txtPortTarget.Text     = "2000";
            //
            // txtSend
            //
            this.txtSend.BackColor    = System.Drawing.SystemColors.Window;
            this.txtSend.ImeMode      = System.Windows.Forms.ImeMode.On;
            this.txtSend.Location     = new System.Drawing.Point(162, 58);
            this.txtSend.Multiline    = true;
            this.txtSend.Name         = "txtSend";
            this.txtSend.ScrollBars   = System.Windows.Forms.ScrollBars.Both;
            this.txtSend.Size         = new System.Drawing.Size(540, 201);
            this.txtSend.TabIndex     = 2;
            this.txtSend.TextChanged += new System.EventHandler(this.txtSend_TextChanged);
            //
            // btnSend
            //
            this.btnSend.Location = new System.Drawing.Point(162, 25);
            this.btnSend.Name     = "btnSend";
            this.btnSend.Size     = new System.Drawing.Size(82, 30);
            this.btnSend.TabIndex = 4;
            this.btnSend.Text     = "发送(&S)";
            this.btnSend.UseVisualStyleBackColor = true;
            this.btnSend.Click += new System.EventHandler(this.btnSend_Click);
            //
            // ipCtrTarget
            //
            this.ipCtrTarget.BackColor   = System.Drawing.SystemColors.Window;
            this.ipCtrTarget.Location    = new System.Drawing.Point(9, 58);
            this.ipCtrTarget.MinimumSize = new System.Drawing.Size(131, 23);
            this.ipCtrTarget.Name        = "ipCtrTarget";
            this.ipCtrTarget.ReadOnly    = false;
            this.ipCtrTarget.Size        = new System.Drawing.Size(131, 23);
            this.ipCtrTarget.TabIndex    = 0;
            //
            // label5
            //
            this.label5.AutoSize = true;
            this.label5.Location = new System.Drawing.Point(6, 133);
            this.label5.Name     = "label5";
            this.label5.Size     = new System.Drawing.Size(56, 17);
            this.label5.TabIndex = 10;
            this.label5.Text     = "本地端口";
            //
            // txtPortLocal
            //
            this.txtPortLocal.Location = new System.Drawing.Point(68, 130);
            this.txtPortLocal.Name     = "txtPortLocal";
            this.txtPortLocal.Size     = new System.Drawing.Size(72, 23);
            this.txtPortLocal.TabIndex = 2;
            this.txtPortLocal.Text     = "2718";
            //
            // btnLink
            //
            this.btnLink.Location = new System.Drawing.Point(67, 168);
            this.btnLink.Name     = "btnLink";
            this.btnLink.Size     = new System.Drawing.Size(73, 30);
            this.btnLink.TabIndex = 3;
            this.btnLink.Text     = "连接(&L)";
            this.btnLink.UseVisualStyleBackColor = true;
            this.btnLink.Click += new System.EventHandler(this.btnLink_Click);
            //
            // lbxRecv
            //
            this.lbxRecv.FormattingEnabled   = true;
            this.lbxRecv.HorizontalScrollbar = true;
            this.lbxRecv.ItemHeight          = 17;
            this.lbxRecv.Location            = new System.Drawing.Point(162, 26);
            this.lbxRecv.Name     = "lbxRecv";
            this.lbxRecv.Size     = new System.Drawing.Size(540, 157);
            this.lbxRecv.TabIndex = 14;
            //
            // btnClearRecv
            //
            this.btnClearRecv.Location = new System.Drawing.Point(68, 81);
            this.btnClearRecv.Name     = "btnClearRecv";
            this.btnClearRecv.Size     = new System.Drawing.Size(73, 30);
            this.btnClearRecv.TabIndex = 0;
            this.btnClearRecv.Text     = "清空(&C)";
            this.btnClearRecv.UseVisualStyleBackColor = true;
            this.btnClearRecv.Click += new System.EventHandler(this.btnClearRecv_Click);
            //
            // groupBox1
            //
            this.groupBox1.Controls.Add(this.chkAutoSend);
            this.groupBox1.Controls.Add(this.label7);
            this.groupBox1.Controls.Add(this.txtboxInterval);
            this.groupBox1.Controls.Add(this.label6);
            this.groupBox1.Controls.Add(this.btnSend);
            this.groupBox1.Controls.Add(this.txtCountSend);
            this.groupBox1.Controls.Add(this.label4);
            this.groupBox1.Controls.Add(this.label1);
            this.groupBox1.Controls.Add(this.ipCtrTarget);
            this.groupBox1.Controls.Add(this.label2);
            this.groupBox1.Controls.Add(this.txtSend);
            this.groupBox1.Controls.Add(this.txtPortTarget);
            this.groupBox1.Controls.Add(this.label5);
            this.groupBox1.Controls.Add(this.btnLink);
            this.groupBox1.Controls.Add(this.txtPortLocal);
            this.groupBox1.Location = new System.Drawing.Point(12, 12);
            this.groupBox1.Name     = "groupBox1";
            this.groupBox1.Size     = new System.Drawing.Size(722, 277);
            this.groupBox1.TabIndex = 19;
            this.groupBox1.TabStop  = false;
            this.groupBox1.Text     = "发送区";
            //
            // chkAutoSend
            //
            this.chkAutoSend.AutoSize = true;
            this.chkAutoSend.Location = new System.Drawing.Point(281, 31);
            this.chkAutoSend.Name     = "chkAutoSend";
            this.chkAutoSend.Size     = new System.Drawing.Size(75, 21);
            this.chkAutoSend.TabIndex = 24;
            this.chkAutoSend.Text     = "自动发送";
            this.chkAutoSend.UseVisualStyleBackColor = true;
            this.chkAutoSend.CheckedChanged         += new System.EventHandler(this.chkAutoSend_CheckedChanged);
            //
            // label7
            //
            this.label7.AutoSize = true;
            this.label7.Location = new System.Drawing.Point(499, 32);
            this.label7.Name     = "label7";
            this.label7.Size     = new System.Drawing.Size(25, 17);
            this.label7.TabIndex = 23;
            this.label7.Text     = "ms";
            //
            // txtboxInterval
            //
            this.txtboxInterval.Location = new System.Drawing.Point(441, 29);
            this.txtboxInterval.Name     = "txtboxInterval";
            this.txtboxInterval.Size     = new System.Drawing.Size(52, 23);
            this.txtboxInterval.TabIndex = 22;
            //
            // label6
            //
            this.label6.AutoSize = true;
            this.label6.Location = new System.Drawing.Point(379, 32);
            this.label6.Name     = "label6";
            this.label6.Size     = new System.Drawing.Size(56, 17);
            this.label6.TabIndex = 21;
            this.label6.Text     = "间隔时间";
            //
            // txtCountSend
            //
            this.txtCountSend.BackColor = System.Drawing.Color.White;
            this.txtCountSend.Location  = new System.Drawing.Point(68, 228);
            this.txtCountSend.Name      = "txtCountSend";
            this.txtCountSend.ReadOnly  = true;
            this.txtCountSend.Size      = new System.Drawing.Size(73, 23);
            this.txtCountSend.TabIndex  = 19;
            //
            // label4
            //
            this.label4.AutoSize = true;
            this.label4.Location = new System.Drawing.Point(6, 231);
            this.label4.Name     = "label4";
            this.label4.Size     = new System.Drawing.Size(56, 17);
            this.label4.TabIndex = 18;
            this.label4.Text     = "发送计数";
            //
            // groupBox2
            //
            this.groupBox2.Controls.Add(this.cbxHex);
            this.groupBox2.Controls.Add(this.txtCountRecv);
            this.groupBox2.Controls.Add(this.label3);
            this.groupBox2.Controls.Add(this.lbxRecv);
            this.groupBox2.Controls.Add(this.btnClearRecv);
            this.groupBox2.Location = new System.Drawing.Point(12, 295);
            this.groupBox2.Name     = "groupBox2";
            this.groupBox2.Size     = new System.Drawing.Size(722, 198);
            this.groupBox2.TabIndex = 20;
            this.groupBox2.TabStop  = false;
            this.groupBox2.Text     = "接收区";
            //
            // cbxHex
            //
            this.cbxHex.AutoSize = true;
            this.cbxHex.Location = new System.Drawing.Point(41, 147);
            this.cbxHex.Name     = "cbxHex";
            this.cbxHex.Size     = new System.Drawing.Size(99, 21);
            this.cbxHex.TabIndex = 21;
            this.cbxHex.Text     = "十六进制显示";
            this.cbxHex.UseVisualStyleBackColor = true;
            this.cbxHex.CheckedChanged         += new System.EventHandler(this.cbxHex_CheckedChanged);
            //
            // txtCountRecv
            //
            this.txtCountRecv.BackColor = System.Drawing.Color.White;
            this.txtCountRecv.Location  = new System.Drawing.Point(68, 42);
            this.txtCountRecv.Name      = "txtCountRecv";
            this.txtCountRecv.ReadOnly  = true;
            this.txtCountRecv.Size      = new System.Drawing.Size(73, 23);
            this.txtCountRecv.TabIndex  = 20;
            //
            // label3
            //
            this.label3.AutoSize = true;
            this.label3.Location = new System.Drawing.Point(6, 45);
            this.label3.Name     = "label3";
            this.label3.Size     = new System.Drawing.Size(56, 17);
            this.label3.TabIndex = 19;
            this.label3.Text     = "接收计数";
            //
            // timer1
            //
            this.timer1.Interval = 1000;
            this.timer1.Tick    += new System.EventHandler(this.timer1_Tick);
            //
            // frmUDPClient
            //
            this.BackColor  = System.Drawing.SystemColors.Control;
            this.ClientSize = new System.Drawing.Size(752, 506);
            this.Controls.Add(this.groupBox2);
            this.Controls.Add(this.groupBox1);
            this.Font          = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
            this.Icon          = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
            this.MaximizeBox   = false;
            this.Name          = "frmUDPClient";
            this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
            this.Text          = "UDP客户端";
            this.FormClosed   += new System.Windows.Forms.FormClosedEventHandler(this.frmUDPClient_FormClosed);
            this.Load         += new System.EventHandler(this.frmUDPClient_Load);
            this.groupBox1.ResumeLayout(false);
            this.groupBox1.PerformLayout();
            this.groupBox2.ResumeLayout(false);
            this.groupBox2.PerformLayout();
            this.ResumeLayout(false);
        }