Exemple #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
            }
        }
Exemple #2
0
        private void btnCalculate_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                double width  = int.Parse(txtWidth.Text);
                double height = int.Parse(txtHeight.Text);
                double border = int.Parse(txtBorder.Text);

                double perimeter, area, borderArea;
                perimeter  = BusinessLogicWindow.CalculatePerimeter(width, height);
                area       = BusinessLogicWindow.CalculateWindowArea(width, height, border);
                borderArea = BusinessLogicWindow.CalculateBorderArea(width, height, border);

                tbResult.Text  = "";
                tbResult.Text += "Lasin pinta-ala: " + area.ToString() + "\n";
                tbResult.Text += "Karmin pinta-ala: " + borderArea.ToString() + "\n";
                tbResult.Text += "Karmin piiri: " + perimeter.ToString();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                //yield to an user that everything okay
            }
        }