![]() |
Sylloge
A C# helper library
|
00001 00002 00003 00004 00005 00006 00007 00008 00009 00010 00011 00012 00013 00014 00015 00016 00018 using System; 00019 using System.Collections.Generic; 00020 using System.ComponentModel; 00021 using System.Drawing; 00022 using System.Data; 00023 using System.Text; 00024 using System.Windows.Forms; 00025 00026 namespace Sylloge.Controls 00027 { 00028 public partial class IpPort : System.Windows.Forms.UserControl 00029 { 00030 public delegate void DelegatePortChanged(int port); 00034 public event DelegatePortChanged PortChanged; 00035 00036 private void OnPortChanged() 00037 { 00038 if (this.PortChanged != null) { this.PortChanged(this.Port); } 00039 } 00040 00044 public IpPort() 00045 { 00046 this.InitializeComponent(); 00047 } 00048 00049 ~IpPort() 00050 { 00051 } 00052 00056 public int Port 00057 { 00058 get 00059 { 00060 return Convert.ToInt32(this.c_TextBoxPort.Text); 00061 } 00062 set 00063 { 00064 this.c_TextBoxPort.Text = value.ToString(); 00065 } 00066 } 00067 00071 public bool HasError 00072 { 00073 get 00074 { 00075 return !(this.c_Error.GetError(this.c_TextBoxPort) == null); 00076 } 00077 } 00078 00083 public override string ToString() 00084 { 00085 return this.Port.ToString(); 00086 } 00087 00088 private void c_TextBoxPort_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e) 00089 { 00090 e.Handled = !Char.IsDigit(e.KeyChar) && !char.IsControl(e.KeyChar); 00091 } 00092 00093 private void c_TextBoxPort_TextChanged(object sender, System.EventArgs e) 00094 { 00095 if (this.c_TextBoxPort.Text == string.Empty || this.c_TextBoxPort.Text == null) { this.c_TextBoxPort.Text = "0"; } 00096 if (Convert.ToInt32(this.c_TextBoxPort.Text) < 0) { this.c_TextBoxPort.Text = "0"; } 00097 if (Convert.ToInt32(this.c_TextBoxPort.Text) > 65535) { this.c_TextBoxPort.Text = "65535"; } 00098 this.OnPortChanged(); 00099 } 00100 } 00101 }
1.7.4