Esempio n. 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);
            }
        }
Esempio n. 2
0
        private void btnCalculate_Click(object sender, RoutedEventArgs e)
        {
            //TODO
            try
            {
                if (double.Parse(txtHeigt.Text.ToString()) <= 0 || double.Parse(txtWidht.Text.ToString()) <= 0 || double.Parse(txtFrameWidith.Text.ToString()) <= 0)
                {
                    MessageBox.Show("Syötetty arvo on 0 tai pienempi. Määritä todelliset arvot");
                    return;
                }

                double result;
                result            = BusinessLogicWindow.CalculatePerimeter(double.Parse(txtHeigt.Text.ToString()), double.Parse(txtWidht.Text.ToString()));
                txtPerimeter.Text = result.ToString();

                result = BusinessLogicWindow.CalculateWindowArea(double.Parse(txtHeigt.Text.ToString()),
                                                                 double.Parse(txtWidht.Text.ToString()),
                                                                 double.Parse(txtFrameWidith.Text.ToString()));
                txtWindowArea.Text = result.ToString();

                result = BusinessLogicWindow.CalculateFrameArea(double.Parse(txtHeigt.Text.ToString()),
                                                                double.Parse(txtWidht.Text.ToString()),
                                                                double.Parse(txtFrameWidith.Text.ToString()));
                txtFrameArea.Text = result.ToString();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                //yield to an user that everything okay
            }
        }
Esempio n. 3
0
 private void btnCalculate_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         double l = Math.Abs(double.Parse(txtWidth.Text));
         double h = Math.Abs(double.Parse(txtHeight.Text));
         double w = Math.Abs(double.Parse(txtFrameWidth.Text));
         txtResult1.Text = BusinessLogicWindow.CalculateWindowArea(l, h, w).ToString();
         txtResult2.Text = BusinessLogicWindow.CalculatePerimeter(l, h).ToString();
         txtResult3.Text = BusinessLogicWindow.CalculateFrameArea(l, h, w).ToString();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
     finally
     {
         //yield to an user that everything okay
     }
 }