예제 #1
0
        public Converter()
        {
            InitializeComponent();
            #region Speed
            //set default value for both combobox 
            //combobox1 default value is **Miles per hour**
            //combobox2 default value is **Feets per second**
            comboBox1.SelectedIndex = 0;
            comboBox2.SelectedIndex = 1;
            this.ActiveControl = textBox1;
            // Clear button set value of text boxes to 0 (lambda using)
            btnClear.Click += (sender, e) => { textBox1.Text = "0"; textBox2.Text = "0"; textBox1.Focus(); textBox1.SelectAll(); };
            #endregion
            #region Lenth tab contol
            //Clear text bot for Lenth Tab
            Lenth_Clear_Btn.Click += (sender, e) =>{
            Lenth_FromValue_TBox.Text = "0"; Lenth_ToValue_TBox.Text = "0"; Lenth_FromValue_TBox.Focus();
            Lenth_FromValue_TBox.SelectAll();
            };
            Lenth_FromValue_CBox.SelectedIndex = 0;
            Lenth_ToValue_CBox.SelectedIndex = 1;
            Lenth_FromValue_TBox.KeyPress += (sender, e) => { CorrectInput.OnlyNumbers(sender,e); };
            Lenth_ToValue_CBox.TextChanged += (s, e) => { this.LenthConvert(); };
            Lenth_FromValue_CBox.TextChanged += (s, e) => { this.LenthConvert(); };
            Lenth_Convert_Btn.Click += (s, e) => { this.LenthConvert(); };


            #endregion
            #region Temperature tab control
            Temperature_FromValue_CBox.SelectedIndex = 0;
            Temperature_ToValue_Cbox.SelectedIndex = 1;
            Temperature_FromValue_TBox.KeyPress += (sender, e) => { CorrectInput.OnlyNumbers(sender, e); };
            Temperature_Clear_Btn.Click += (sender, e) => { Temperature_FromValue_TBox.Text ="0"; Temperature_ToValue_TBox.Text = "0";Temperature_FromValue_TBox.Focus(); Temperature_FromValue_TBox.SelectAll(); };
            Temperature_ToValue_Cbox.TextChanged += (sender, e) => TemperatureConvert();
            Temperature_Convert_Btn.Click += (sender, e) => TemperatureConvert();
            Temperature_FromValue_CBox.TextChanged += (sender, e) => TemperatureConvert();

            #endregion
            #region Angle tab control
            Angle_FromValue_CBox.SelectedIndex = 0;
            Angle_ToValue_CBox.SelectedIndex = 1;
            Angle_FromValue_TBox.KeyPress += (sender, e) => { CorrectInput.OnlyNumbers(sender, e); };
            Angle_Clear_Btn.Click += (sender, e) => { Angle_FromValue_TBox.Text = "0"; Angle_ToValue_TBox.Text = "0";Angle_FromValue_TBox.Focus(); Angle_FromValue_TBox.SelectAll(); };
            Angle_Convert_Btn.Click += (sender, e) => { AngleConvert(); };
            Angle_FromValue_CBox.TextChanged += (s, a) => { if (Angle_FromValue_TBox.Text != 0.ToString()) AngleConvert(); };
            #endregion
            #region Time 
            Time_FromValue_Cbox.SelectedIndex = 0;
            Time_ToValue_Cbox.SelectedIndex = 1;
            Time_FromValue_Tbox.KeyPress += (sender, e) => { CorrectInput.OnlyNumbers(sender, e); };
            Time_Clear_Btn.Click += (s, a) =>
            { Time_FromValue_Tbox.Text = "0"; Time_ToValue_Tbox.Text = "0"; Time_FromValue_Tbox.Focus(); Time_FromValue_Tbox.SelectAll(); };
            Time_Convert_Btn.Click += (s, a) => { TimeConvert(); };
            Time_FromValue_Cbox.TextChanged += (s, a) => { TimeConvert(); };
            #endregion
        }
예제 #2
0
 private void textBox5_KeyPress(object sender, KeyPressEventArgs e)
 {
     CorrectInput.OnlyNumbers(sender, e);
     Enter(sender, e);
 }
예제 #3
0
 private void textBox2_KeyPress(object sender, KeyPressEventArgs e)
 {
     CorrectInput.OnlyNumbers(sender, e);
     textBox2.Text = "0";
 }