private void Button_Commit_Click(object sender, RoutedEventArgs e) { try {//包含了所有的计算 int operand = ComboBox_Operand.SelectedIndex; int num1, num2; num1 = Int32.Parse(TextBox_Operator1.Text); num2 = Int32.Parse(TextBox_Operator2.Text); switch (operand) { case 0: Label_ShowResult.Content = num1 + num2; break; case 1: Label_ShowResult.Content = num1 - num2; break; case 2: Label_ShowResult.Content = num1 * num2; break; case 3: if (num2 == 0) { alarmWindow = new WpfAppAlarmForm.MainWindow(); alarmWindow.setAlarm("0不能作为除数"); alarmWindow.ShowDialog(); } else { Label_ShowResult.Content = ((double)num1) / num2; } break; } } catch (FormatException) {//所输入的数字格式不对 alarmWindow = new WpfAppAlarmForm.MainWindow(); alarmWindow.setAlarm("输入数字格式错误"); alarmWindow.ShowDialog(); } catch (OverflowException) {//输入数字过大 alarmWindow = new WpfAppAlarmForm.MainWindow(); alarmWindow.setAlarm("输入数字过大"); alarmWindow.ShowDialog(); } }
void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) { switch (connectionId) { case 1: this.alarmWindow = ((WpfAppAlarmForm.MainWindow)(target)); return; case 2: this.label_Alarm = ((System.Windows.Controls.Label)(target)); return; case 3: this.button_OK = ((System.Windows.Controls.Button)(target)); return; } this._contentLoaded = true; }
void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) { switch (connectionId) { case 1: this.alarmWindow = ((WpfAppAlarmForm.MainWindow)(target)); return; case 2: this.label_Alarm = ((System.Windows.Controls.Label)(target)); return; case 3: this.button_OK = ((System.Windows.Controls.Button)(target)); #line 11 "..\..\AlarmWindow.xaml" this.button_OK.Click += new System.Windows.RoutedEventHandler(this.button_OK_Click); #line default #line hidden return; } this._contentLoaded = true; }