private void btnCalculate_Click(object sender, RoutedEventArgs e) { double WindowWidth; double WindowHeight; double FrameHorizontal; double FrameVertical; double WidthWithFrame; double HeightWithFrame; double area; double perimeter; double FrameArea; //TODO try { double FrameWidth = double.Parse((txtWidthFrame.Text)); area = BusinessLogicWindow.CalculateWindowArea(WindowWidth = double.Parse(txtWidthWindow.Text), WindowHeight = double.Parse(txtHeightWindow.Text)) / 1000000; tbWindowAreaResult.Text = area.ToString("0.##") + " m^2"; perimeter = BusinessLogicWindow.CalculateFramePerimeter(FrameHorizontal = WindowWidth, FrameVertical = WindowHeight + double.Parse((txtWidthFrame.Text)) * 2) / 1000; tbFramePerimeterResult.Text = perimeter.ToString("0.##") + " m"; FrameArea = BusinessLogicWindow.CalculateFrameArea(WidthWithFrame = WindowWidth + FrameWidth * 2, HeightWithFrame = WindowHeight + FrameWidth * 2, WindowWidth, WindowHeight) / 1000000; tbFrameAreaResult.Text = FrameArea.ToString("0.###") + " m^2"; } catch (Exception ex) { MessageBox.Show("Joku kenttä jäi tyhjäksi!"); } finally { //tell user that everything is okay } }
private void btnCalculate_Click(object sender, RoutedEventArgs e) { try { double width = double.Parse(txtWidth.Text); double height = double.Parse(txtHeight.Text); double frameWidth = double.Parse(txtFrameWidth.Text); double windowArea = BusinessLogicWindow.CalculateWindowArea(width, height) * (1E-6); double frameArea = BusinessLogicWindow.CalculateFrameArea(width, height, frameWidth) * (1E-6); double framePerimeter = BusinessLogicWindow.CalculatePerimeter(width, height, frameWidth); txtWindowArea.Text = windowArea.ToString() + "m\xB2"; txtFrameArea.Text = frameArea.ToString() + "m\xB2"; txtFramePerimeter.Text = framePerimeter.ToString() + "mm"; } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public static double CalculateFrameArea(double width, double height, double windowwidth, double windowheight) { double area = (width * height) - BusinessLogicWindow.CalculateWindowArea(windowwidth, windowheight); return(area); }