Esempio n. 1
0
        private void btnCalculate_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                double width, height, borderWidth, result;
                width       = double.Parse(tbWindowWidth.Text);
                height      = double.Parse(tbWindowHeight.Text);
                borderWidth = double.Parse(tbBorderWidth.Text);

                result = BusinessLogicWindow.CalculateArea(width, height);
                lblDisplay_WindowArea.Content = result;

                result = BusinessLogicWindow.CalculatePerimeter(width, height);
                lblDisplay_BorderLength.Content = result;

                result = BusinessLogicWindow.CalculateBorderArea(width, height, borderWidth);
                lblDisplay_BorderArea.Content = result;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                //yield to an user that everything okay
            }
        }
Esempio n. 2
0
        private void btnCalculate_Click(object sender, RoutedEventArgs e)
        {
            double windowWidth  = double.Parse(txtWidth.Text);
            double windowHeight = double.Parse(txtHeight.Text);
            double windowBorder = double.Parse(txtBorder.Text);

            try
            {
                double area;
                area         = BusinessLogicWindow.CalculateArea(windowWidth, windowHeight);
                txtArea.Text = area.ToString("0.##") + " m^2";

                double perimeter;
                perimeter = BusinessLogicWindow.CalculatePerimeter(windowWidth, windowHeight);
                txtBorderPerimeter.Text = perimeter.ToString("0.##") + " m";

                double borderArea;
                borderArea         = BusinessLogicWindow.CalculateBorderArea(windowWidth, windowHeight, windowBorder);
                txtBorderArea.Text = borderArea.ToString("0.##") + " m^2";
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                //MessageBox.Show("Ikkunan koko laskettu");
            }
        }