Exemplo n.º 1
0
        private void graphicButton_Click(object sender, RoutedEventArgs e)
        {
            GraphicWindow winGraphic = new GraphicWindow();

            winGraphic.Owner = this;
            winGraphic.Show();
        }
 private void AskShowGraphic(Graphic graphic)
 {
     if (MessageBox.Show("Rada", "Do wniosku za³¹czona jest grafika czy chcesz j¹ zobaczyæ?",
                         MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
     {
         _viewModel.GraphicPath = _viewModel._currentGraphicFolderPath + "\\" + graphic.graphicPath;
         GraphicWindow window = new GraphicWindow(_viewModel);
         window.Show();
     }
 }
Exemplo n.º 3
0
 void ResetBools()
 {
     this.isMethodParams   = false;
     this.isFuncParams     = false;
     this.isCalculating    = false;
     this.isLogsNeed       = true;
     this.isWorkNotStarted = true;
     currentMethodSettings = null;
     graphic = null;
     DihtomiaPanel.Enabled = true;
     ModMetPanel.Enabled   = true;
 }
Exemplo n.º 4
0
        void SetupSolutionParams()
        {
            SolutionPanel.SolveButtonHandler = solution;
            void solution(bool isGraphic)
            {
                GraphicSettings settings = null;

                SolutionPanel.button1.Enabled = false;
                if (isMethodParams && isFuncParams)
                {
                    if (isGraphic)
                    {
                        this.graphicFirstDimension  = (int)SolutionPanel.firstVar.Value;
                        this.graphicSecondDimension = ((int)SolutionPanel.secondVar.Value != graphicFirstDimension) ? (int)SolutionPanel.secondVar.Value : ((int)SolutionPanel.secondVar.Value != (int)SolutionPanel.secondVar.Maximum) ? Math.Min(this.graphicFirstDimension + 1, (int)SolutionPanel.secondVar.Maximum): this.graphicFirstDimension - 1;
                        graphic = new GraphicWindow(graphicWindowHeight, graphicWindowWidth, graphicWindowFPS, graphicWindowVsync, graphicWindowAnit);
                        graphic.SetRectangleLimit(rectangleLimit);
                        RectangleHandler handler = new RectangleHandler(graphic.GetRectangleFromMethod);
                        settings = new GraphicSettings(handler, graphicFirstDimension, graphicSecondDimension);
                        graphic?.Window.SetActive(false);
                    }
                    if (isDihtomiaCurrentMethod)
                    {
                        var           method       = currentMethodSettings as DihtomiaParams;
                        double        funcMin      = 0;
                        int           counter      = 0;
                        int           optimal      = 0;
                        List <double> optimalPoint = null;
                        FormTimer.Start();
                        watch.Restart();
                        Task.Run(() =>
                        {
                            this.isCalculating = true;
                            var solve          = MNPD.Solve(method.Function, method.Lipzits, method.Precision, method.LipzitsParametr, method.LowerPoint, method.UpperPoint, method.Rule, settings);
                            funcMin            = solve.FunctionMinimum;
                            counter            = solve.counter;
                            optimal            = solve.optimal;
                            optimalPoint       = solve.optimalPoint;
                            this.Invoke(new Action(() =>
                            {
                                watch.Stop();
                                Logs($"Мин. значение функции={funcMin}\nЧисло итерации={counter}\nИтерация оптимального значения={optimal}");
                                Logs(string.Join("\r\n", optimalPoint.Select((point, index) => $"x{index} = {String.Format("{0:F8}", point)}")));
                                graphic?.ShowWindow();
                                SolutionPanel.button1.Enabled = false;
                            }
                                                   ));
                        }).ContinueWith((taskRes) =>
                        {
                            this.isCalculating = false;
                            this.Invoke(new Action(() =>
                            {
                                SolutionPanel.button1.Enabled = true;
                                FormTimer.Stop();
                            }));
                            //TODO: NORMAL RESET
                        });
                    }
                    else
                    {
                        var           method       = currentMethodSettings as ModificatedParams;
                        double        funcMin      = 0;
                        int           counter      = 0;
                        int           optimal      = 0;
                        List <double> optimalPoint = null;
                        FormTimer.Start();
                        watch.Restart();
                        Task.Run(() =>
                        {
                            this.isCalculating = true;
                            var solve          = MNPANK.Solve(method.Function, method.Lipzits, method.Precision, method.LipzitsParametr, method.LowerPoint, method.UpperPoint, method.SubRule, method.MainRule, settings);
                            funcMin            = solve.FunctionMinimum;
                            counter            = solve.counter;
                            optimal            = solve.optimal;
                            optimalPoint       = solve.optimalPoint;
                            this.Invoke(new Action(() =>
                            {
                                watch.Stop();
                                Logs($"\r\nМин. значение функции={funcMin}\r\nЧисло итерации={counter}\r\nИтерация оптимального значения={optimal}\r\n");
                                Logs("Точка оптимума:");
                                Logs(string.Join("\r\n", optimalPoint.Select((point, index) => $"x{index} = {String.Format("{0:F8}", point)}")));
                                graphic?.ShowWindow();
                                SolutionPanel.button1.Enabled = false;
                            }
                                                   ));
                            //graphic?.Window.SetActive(true);
                        }).ContinueWith((taskRes) =>
                        {
                            this.isCalculating = false;
                            this.Invoke(new Action(() =>
                            {
                                SolutionPanel.button1.Enabled = true;

                                FormTimer.Stop();
                            }));
                        });
                    }
                }
                GC.Collect();
            }
        }