Пример #1
0
        private void finish()
        {
            try
            {
                MutMethodFinshPerformed.WaitOne();
                if (!MethodFinishPerformed)
                {
                    updateProgressBar(1.0);
                    ThreadSafeLabelUpdate(labelOptimizing, Properties.Resources.OptimizationFinished);
                    ThreadSafeLabelUpdate(labelRemainingTime, 0.ToString());
                    buttonSave.Enabled = false;
                    buttonStop.Enabled = false;
                    bool   errCodeSuccess;
                    String errMsg;
                    int    errCode = Optimizer.GetErrCode(out errCodeSuccess);
                    if (errCodeSuccess)
                    {
                        try
                        {
                            MutIsFinished.WaitOne();
                            IsFinished = true;
                            MutIsFinished.ReleaseMutex();
                        }
                        catch (Exception e)
                        {
                            MessageBox.Show(Properties.Resources.UnknownError +
                                            "\n" + e.Message);
                            return;
                        }
                        if (processFinishErrCode(errCode, out errMsg))
                        {
                            Form resultForm = new FormShowResult(Optimizer.GetResult(), ModelName);
                            resultForm.ShowDialog();
                        }
                        else
                        {
                            MessageBox.Show(errMsg);
                        }
                    }
                    else
                    {
                        MessageBox.Show(Properties.Resources.CantGetErrCode);
                    }

                    MethodFinishPerformed = true;
                }
            }
            catch (Exception)
            {
                MessageBox.Show(Properties.Resources.UnknownError);
            }
        }
Пример #2
0
        private void buttonDisplayResult_Click(object sender, EventArgs e)
        {
            openFileDialogResultFile.ShowDialog();
            String path = openFileDialogResultFile.FileName;

            if (!String.IsNullOrEmpty(path))
            {
                OptimizerProxy     optimizer = new OptimizerProxy();
                OptimizationResult res       = optimizer.ReadResult(path);
                if (res != null)
                {
                    String[] pathSplitted = path.Split(Path.DirectorySeparatorChar);
                    Form     resultForm   = new FormShowResult(res,
                                                               pathSplitted[pathSplitted.Length - 1]);
                    resultForm.ShowDialog();
                }
                else
                {
                    MessageBox.Show(Properties.Resources.CantReadResult);
                }

                openFileDialogResultFile.FileName = null;
            }
        }