Beispiel #1
0
        private void btnCalculate_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                double resultWindowArea, resultFrameSphere, resultFrameArea, windowWidht, windowHeight, frameWidht;

                // Default value of 0 is used if tryparse fails
                double.TryParse(txtWindowWidht.Text, out windowWidht);
                double.TryParse(txtWindowHeight.Text, out windowHeight);
                double.TryParse(txtFrameWidht.Text, out frameWidht);

                // Calculate results
                resultWindowArea  = BusinessLogicWindow.CalculateWindowArea(windowWidht, windowHeight);
                resultFrameSphere = BusinessLogicWindow.CalculateFrameSphere(windowWidht, windowHeight);
                resultFrameArea   = BusinessLogicWindow.CalculateFrameArea(windowWidht, windowHeight, frameWidht);


                // Show results
                txtWindowArea.Text  = resultWindowArea.ToString();
                txtFrameSphere.Text = resultFrameSphere.ToString();
                txtFrameArea.Text   = resultFrameArea.ToString();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }