private async void button5_Click(object sender, EventArgs e) { try { switch (_currentGraph) { case GraphType.MonochromaticRadiationN1: if (_dotPlot) { await CreateOneLineDot(DataController.GetFirstPoints()); break; } await CreateOneLine(DataController.GetFirstPoints()); break; case GraphType.MonochromaticRadiationN2: if (_dotPlot) { await CreateOneLineDot(DataController.GetSecondPoints()); break; } await CreateOneLine(DataController.GetSecondPoints()); break; case GraphType.TwoWaves: if (_dotPlot) { await CreateOneLineDot(DataController.GetThirdPoints()); break; } await CreateOneLine(DataController.GetThirdPoints()); break; case GraphType.WavelengthRange: if (_dotPlot) { await CreateOneLineDot(DataController.GetFourthPoints()); break; } await CreateOneLine(DataController.GetFourthPoints()); break; case GraphType.DependenceRadiusRings: if (_dotPlot) { await CreateTwoLinesDot( DataHandler.LinePointsInRadiusDependence( DataHandler.FindMaxInAllData(DataController.GetFirstPoints()), DataHandler.FindMinInAllData(DataController.GetFirstPoints())), DataHandler.LinePointsInRadiusDependence( DataHandler.FindMaxInAllData(DataController.GetSecondPoints()), DataHandler.FindMinInAllData(DataController.GetSecondPoints()))); break; } await CreateTwoLines( DataHandler.LinePointsInRadiusDependence( DataHandler.FindMaxInAllData(DataController.GetFirstPoints()), DataHandler.FindMinInAllData(DataController.GetFirstPoints())), DataHandler.LinePointsInRadiusDependence( DataHandler.FindMaxInAllData(DataController.GetSecondPoints()), DataHandler.FindMinInAllData(DataController.GetSecondPoints()))); break; case GraphType.VisibilityFunctionTwoWaves: if (textBox1.Text == null) { throw new TextBoxException(); } var opticalPathDifference = VisibilityFunctionMethods.OpticalPathDifference( VisibilityFunctionMethods.FindRAverage( DataHandler.FindMaxInAllData(DataController.GetThirdPoints()), DataHandler.FindMinInAllData(DataController.GetThirdPoints())), DataHandler.FindRByN( DataHandler.FindMaxInAllData(DataController.GetThirdPoints()), double.Parse(textBox1.Text))); var vExperimental = VisibilityFunctionMethods.FindVExperimental( DataHandler.FindMaxInAllData(DataController.GetThirdPoints()), DataHandler.FindMinInAllData(DataController.GetThirdPoints())); var vTheoretical = VisibilityFunctionMethods.FindVTheoretical( opticalPathDifference, VisibilityFunctionMethods.FindL(opticalPathDifference), VisibilityFunctionMethods.FindErrorL( opticalPathDifference, VisibilityFunctionMethods.FindL(opticalPathDifference))); if (_dotPlot) { await CreateTwoLinesDot( VisibilityFunctionMethods.CreatePointForVisibility( opticalPathDifference, vExperimental), VisibilityFunctionMethods.CreatePointForVisibility( opticalPathDifference, vTheoretical)); break; } await CreateTwoLines( VisibilityFunctionMethods.CreatePointForVisibility( opticalPathDifference, vExperimental), VisibilityFunctionMethods.CreatePointForVisibility( opticalPathDifference, vTheoretical) ); break; case GraphType.VisibilityFunctionWavelengthRange: if (textBox1.Text == null) { throw new TextBoxException(); } opticalPathDifference = VisibilityFunctionMethods.OpticalPathDifference( VisibilityFunctionMethods.FindRAverage( DataHandler.FindMaxInAllData(DataController.GetFourthPoints()), DataHandler.FindMinInAllData(DataController.GetFourthPoints())), DataHandler.FindRByN( DataHandler.FindMaxInAllData(DataController.GetFourthPoints()), double.Parse(textBox1.Text))); vExperimental = VisibilityFunctionMethods.FindVExperimental( DataHandler.FindMaxInAllData(DataController.GetFourthPoints()), DataHandler.FindMinInAllData(DataController.GetFourthPoints())); vTheoretical = VisibilityFunctionMethods.FindVTheoretical( opticalPathDifference, VisibilityFunctionMethods.FindL(opticalPathDifference), VisibilityFunctionMethods.FindErrorL( opticalPathDifference, VisibilityFunctionMethods.FindL(opticalPathDifference))); if (_dotPlot) { await CreateTwoLinesDot( VisibilityFunctionMethods.CreatePointForVisibility( opticalPathDifference, vExperimental), VisibilityFunctionMethods.CreatePointForVisibility( opticalPathDifference, vTheoretical)); break; } await CreateTwoLines( VisibilityFunctionMethods.CreatePointForVisibility( opticalPathDifference, vExperimental), VisibilityFunctionMethods.CreatePointForVisibility( opticalPathDifference, vTheoretical) ); break; case GraphType.VisibilityFunctionPicture: if (textBox1.Text == null) { throw new TextBoxException(); } if (ImageMethods.FindCircleNum() == 0 && ImageMethods.FindCircleCenterX() == 0 && ImageMethods.FindCircleCenterY() == 0) { MessageBox.Show(@"Попробуйте другую картинку. На этой не получается найти полное кольцо"); break; } ImageMethods.DrawContours(); _picturesForm.GetCenter(ImageMethods.FindCircleCenterX(), ImageMethods.FindCircleCenterY()); _picturesForm.GetOutputPicture(DataController.GetImageWithContour()); var points = ImageMethods.FindPointsForVisibilityFunction(); var approximation = ImageMethods.ApproximationPoints(points); opticalPathDifference = VisibilityFunctionMethods.OpticalPathDifference( VisibilityFunctionMethods.FindRAverage( DataHandler.FindMaxInAllData(approximation), DataHandler.FindMinInAllData(approximation)), DataHandler.FindRByN( DataHandler.FindMaxInAllData(approximation), double.Parse(textBox1.Text))); vExperimental = VisibilityFunctionMethods.FindVExperimental( DataHandler.FindMaxInAllData(approximation), DataHandler.FindMinInAllData(approximation)); if (_dotPlot) { await CreateOneLineDot(DataHandler.SortPointsByX(VisibilityFunctionMethods.CreatePointForVisibility( opticalPathDifference, vExperimental))); break; } await CreateOneLine(DataHandler.SortPointsByX(VisibilityFunctionMethods.CreatePointForVisibility( opticalPathDifference, vExperimental))); break; case GraphType.PictureGraphic: if (ImageMethods.FindCircleNum() == 0 && ImageMethods.FindCircleCenterX() == 0 && ImageMethods.FindCircleCenterY() == 0) { MessageBox.Show(@"Попробуйте другую картинку. На этой не получается найти полное кольцо"); break; } ImageMethods.DrawContours(); _picturesForm.GetCenter(ImageMethods.FindCircleCenterX(), ImageMethods.FindCircleCenterY()); _picturesForm.GetOutputPicture(DataController.GetImageWithContour()); points = ImageMethods.FindPointsForVisibilityFunction(); approximation = ImageMethods.ApproximationPoints(points); if (_dotPlot) { await CreateTwoLinesDot(points, approximation); break; } //await CreateOneLine(points); await CreateTwoLines(points, approximation); //await CreateOneLine(approximation); break; default: throw new ArgumentOutOfRangeException(); } } catch (Exception exception) { MessageBox.Show(exception.Message); } }