Example #1
0
 public void Show()
 {
     OutputForm = _instrumentFormFactory.Create(Type, Renderer
                                                );
     if (OutputForm != null && !OutputForm.Visible)
     {
         OutputForm.Show();
     }
 }
Example #2
0
        public static void ShowOutputForm(this OutputForm form, ref EventHandler eventHandler)
        {
            if (form == null)
            {
                throw new ArgumentNullException(nameof(form));
            }

            eventHandler      += form.TextEventHandler;
            form.StartPosition = FormStartPosition.CenterScreen;
            form.Show();
        }
Example #3
0
        private void CompileWithErrorHandler()
        {
            log.Info("编译程序启动");
            if (editor.Text == "")
            {
                log.Info("编辑框为空");
                if (System.Threading.Thread.CurrentThread.CurrentCulture.Name == "zh-CN")
                {
                    MessageBox.Show("错误:编辑框为空。", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    MessageBox.Show("The textbox is empty.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }

                return;
            }

            log.Info("正在进行编译");
            CompilerResults cr = CompilerManager.CompileFromString(editor.Text);

            log.Info("输出框弹出");
            OutputForm of = new OutputForm();

            of.Owner = this;
            string tempcr = System.Threading.Thread.CurrentThread.CurrentCulture.Name == "zh-CN"
                ? "================ Compiler Output ================"
                : "=================== 编译器输出 ===================";

            foreach (string str in cr.Output)
            {
                tempcr = tempcr + "\r\n" + str;
            }
            of.OutputText = tempcr;
            of.Show();

            log.Info("正在检查操作");
            if (!File.Exists("rcse_compiled.cache.lk"))
            {
                log.Info("返回: 未能找到被编译文件");
                MessageBox.Show("无法找到编译文件: 是否编译错误?", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            log.Info("编译成功,正在重命名文件");
            File.Move("rcse_compiled.cache.lk", "dbgcache.exe");
        }
Example #4
0
 public void childForm(Form parent, int switcher)
 {
     if (Application.OpenForms["InputForm"] == null && switcher == 1)
     {
         InputForm F1 = new InputForm();
         F1.MdiParent = parent;
         F1.Show();
     }
     if (Application.OpenForms["OutputForm"] == null && switcher == 2)
     {
         OutputForm F2 = new OutputForm();
         F2.MdiParent = parent;
         F2.Show();
     }
     if (Application.OpenForms["Settings"] == null && switcher == 3)
     {
         Settings F3 = new Settings();
         F3.ShowDialog();
     }
 }
Example #5
0
        private void FindInFiles(bool findOnly)
        {
            FindInFilesForm fiff = new FindInFilesForm(findOnly);

            /*
             * Restore search history to search form.
             */

            fiff.SetFindTextHistory(_findTextHistory);
            if (!findOnly)
            {
                fiff.SetReplaceTextHistory(_replaceTextHistory);
            }
            fiff.SetFileSpecHistory(_fileSpecHistory);
            fiff.UseRegex         = _useRegex;
            fiff.MatchCase        = _matchCase;
            fiff.SearchSubFolders = _searchSubFolders;

            /*
             * Show the form.
             */

            if (fiff.ShowDialog() == DialogResult.OK)
            {
                ApplicationManager applicationManager =
                    ApplicationManager.GetInstance();

                /*
                 * Optionally ensure the output window is visible.
                 */

                if (applicationManager.ClientProfile.HaveFlag(
                        ClientFlags.FindInFilesShowOutputOnFind))
                {
                    _output.Show();
                }

                /*
                 * Find the affected files.
                 */

                Finder finder = new Finder(_output);

                try
                {
                    _mainForm.Cursor = Cursors.WaitCursor;

                    finder.Find(fiff.FindText, fiff.ReplaceText, fiff.FileSpec,
                                fiff.SearchSubFolders, fiff.UseRegex, fiff.MatchCase, findOnly);
                }
                finally
                {
                    _mainForm.Cursor = Cursors.Default;
                }

                /*
                 * Update the search history from the form.
                 */

                AddHistoryItem(_findTextHistory, fiff.FindText);
                if (!findOnly)
                {
                    AddHistoryItem(_replaceTextHistory, fiff.ReplaceText);
                }
                AddHistoryItem(_fileSpecHistory, fiff.FileSpec);
                _useRegex         = fiff.UseRegex;
                _matchCase        = fiff.MatchCase;
                _searchSubFolders = fiff.SearchSubFolders;
            }
        }
Example #6
0
        private void button1_Click(object sender, EventArgs e)
        {
            double left, right, Nmax, U0, h, a, b, c, z, E;


            if (textBoxLeft.Text != "")
            {
                left = Convert.ToDouble(textBoxLeft.Text);
            }
            else
            {
                left = 0;
            }
            if (textBoxRight.Text != "")
            {
                right = Convert.ToDouble(textBoxRight.Text);
            }
            else
            {
                right = 1;
            }
            if (textBoxNmax.Text != "")
            {
                Nmax = Convert.ToDouble(textBoxNmax.Text);
            }
            else
            {
                Nmax = 100;
            }
            if (textBoxU0.Text != "")
            {
                U0 = Convert.ToDouble(textBoxU0.Text);
            }
            else
            {
                U0 = 0;
            }
            if (textBoxH.Text != "")
            {
                h = Convert.ToDouble(textBoxH.Text);
            }
            else
            {
                h = 0.1;
            }
            if (textBoxA.Text != "")
            {
                a = Convert.ToDouble(textBoxA.Text);
            }
            else
            {
                a = 0;
            }
            if (textBoxB.Text != "")
            {
                b = Convert.ToDouble(textBoxB.Text);
            }
            else
            {
                b = 0;
            }
            if (textBoxC.Text != "")
            {
                c = Convert.ToDouble(textBoxC.Text);
            }
            else
            {
                c = 0;
            }
            if (textBoxZ.Text != "")
            {
                z = Convert.ToDouble(textBoxZ.Text);
            }
            else
            {
                z = 0;
            }
            if (textBoxE.Text != "")
            {
                E = Convert.ToDouble(textBoxE.Text);
            }
            else
            {
                E = 0.0001;
            }

            double n = (right - left) / h;

            n = n > Nmax ? Nmax : n;
            Step[] allSteps  = new Step[(int)n + 1];
            Step[] allSteps2 = new Step[(int)n + 1];


            allSteps  = Functions.RKMdecision(left, right, Nmax, U0, h, a, b, c, E).Item1;
            allSteps2 = Functions.RKMdecision(left, right, Nmax, U0, h, a, b, c, E).Item2;

            OutputForm output = new OutputForm(allSteps, allSteps2);

            output.Show();
        }
Example #7
0
        //моделирование
        private void Modeling()
        {
            btnCancel.Enabled    = true;
            btnCalculate.Enabled = false;

            //инициализация параметров расчета
            Init();

            if (rbSeq.Checked)
            {
                InitSequential();
            }

            if (rbCUDA.Checked || rbOpenMP.Checked)
            {
                InitParallel();
            }

            //запуск расчета в отдельном потоке
            //просходит вызов метода CalculationSeq или CalculationParallel
            //подробнее смотри в файле Main.cs метод bgw_DoWork()
            bgw.RunWorkerAsync();

            //вывод скоростей графическом виде
            if (сbGraphicsProcess.Checked)
            {
                grForm = new GraphicsForm(X, Y, x0, len, rbSpeeds.Checked, rbTemp.Checked, scale: scale);
                grForm.Show();
                grForm.Closing += grForm_Closing;
            }

            bool error;

            //пока идет расчет
            while (bgw.IsBusy)
            {
                //вывод графики в процессе
                if (сbGraphicsProcess.Checked)
                {
                    error = grForm.DrawDisplay(Ux, Uy, Temp);
                    if (error)
                    {
                        bgw.CancelAsync();
                    }
                }
                //если расчет до установления
                if (rbSetSpeeds.Checked)
                {
                    pgb.Style   = ProgressBarStyle.Marquee;
                    lblPrc.Text = "Расчеты выполняются ...";
                }
                Application.DoEvents();
            }

            //вывод результатов  в текстовом виде
            if (cbTextFile.Checked)
            {
                outForm = new OutputForm {
                    X = X, Y = Y
                };
                outForm.Show();
                if (rbSpeeds.Checked)
                {
                    outForm.OutSpeeds(Ux, Uy);
                }
                if (rbTemp.Checked)
                {
                    outForm.OutTemp(Temp);
                }
            }


            //вывод результатов графики
            if (сbGraphicsResult.Checked)
            {
                grForm = new GraphicsForm(X, Y, x0, len, rbSpeeds.Checked, rbTemp.Checked, scale: scale);
                grForm.Show();
                grForm.DrawDisplay(Ux, Uy, Temp);
            }

            //освобождение ресурсов, если были использованы параллельные вычисления
            if (rbPU.Checked)
            {
                if (rbCUDA.Checked || rbOpenMP.Checked)
                {
                    parPU.Dispose();
                }
            }

            if (rbWPsi.Checked)
            {
                if (rbCUDA.Checked || rbOpenMP.Checked)
                {
                    parWPsi.Dispose();
                }
            }
        }
Example #8
0
        private void ProcessButton_Click(object sender, EventArgs e)
        {
            {
                double number; //for string exception

                //null exception
                if (selectedListBox.Items.Count == 0)
                { //variable
                    MessageBox.Show("You have to choose at least 1 variable!");
                }
                else if (string.IsNullOrWhiteSpace(textBox_m.Text) == true)
                { //particle
                    MessageBox.Show("Number of fuzzifier(m) shouldn't be empty!");
                }
                else if (string.IsNullOrWhiteSpace(textBox_konsa.Text) == true)
                {
                    MessageBox.Show("Coef (A) shouldn't be empty!");
                }
                else if (string.IsNullOrWhiteSpace(textBox_eta.Text) == true)
                {
                    MessageBox.Show("Number of fuzzifier(η) shouldn't be empty!");
                }
                else if (string.IsNullOrWhiteSpace(textBox_konsb.Text) == true)
                {
                    MessageBox.Show("Coef (B) shouldn't be empty!");
                }
                else if (string.IsNullOrWhiteSpace(textBox_konsk.Text) == true)
                {
                    MessageBox.Show("Coef (K) shouldn't be empty!");
                }
                else if (string.IsNullOrWhiteSpace(textBox_maxiter.Text) == true)
                {
                    MessageBox.Show("max iteration PFCM shouldn't be empty!");
                }
                else if (string.IsNullOrWhiteSpace(textBox_error.Text) == true)
                {
                    MessageBox.Show("error coef shouldn't be empty!");
                }
                else if (string.IsNullOrWhiteSpace(textBox_clus.Text) == true)
                {
                    MessageBox.Show("Number of cluster shouldn't be empty!");
                }


                //string exception
                else if (double.TryParse(textBox_m.Text, out number) == false)
                { //particle
                    MessageBox.Show("Number of fuzzifier(m) should be a natural number!");
                }
                else if (double.TryParse(textBox_konsa.Text, out number) == false)
                { //particle
                    MessageBox.Show("Coef (A) should be a number!");
                }
                else if (double.TryParse(textBox_eta.Text, out number) == false)
                { //mulai disini
                    MessageBox.Show("Number of fuzzifier(η) should be a  number!");
                }
                else if (double.TryParse(textBox_konsb.Text, out number) == false)
                { //particle
                    MessageBox.Show("Coef (B) should be a natural number!");
                }
                else if (double.TryParse(textBox_konsk.Text, out number) == false)
                { //particle
                    MessageBox.Show("Coef (K) should be a natural number!");
                }
                else if (double.TryParse(textBox_maxiter.Text, out number) == false)
                { //particle
                    MessageBox.Show("max iteration PFCM should be a natural number!");
                }
                else if (double.TryParse(textBox_error.Text, out number) == false)
                { //particle
                    MessageBox.Show("error coef should be a natural number!");
                }
                else if (double.TryParse(textBox_clus.Text, out number) == false)
                { //particle
                    MessageBox.Show("Number of cluster should be a number!");
                }


                else
                {
                    double ncluster = Convert.ToDouble(textBox_clus.Text);
                    double m        = Convert.ToDouble(textBox_m.Text);
                    double eta      = Convert.ToDouble(textBox_eta.Text);
                    double a        = Convert.ToDouble(textBox_konsa.Text);
                    double b        = Convert.ToDouble(textBox_konsb.Text);
                    double K        = Convert.ToDouble(textBox_konsk.Text);
                    double error    = Convert.ToDouble(textBox_error.Text);
                    double maxiter  = Convert.ToDouble(textBox_maxiter.Text);

                    DataTable dt = GetFromMainForm();

                    if (maxiter < 1)
                    {
                        MessageBox.Show("Maximum iteration should be greater or equal to 1!");
                    }
                    else if (maxiter % 1 != 0)
                    {
                        MessageBox.Show("Maximum iteration shouldn't be in decimal!");
                    }
                    else if (ncluster < 2)
                    {
                        MessageBox.Show("Number of cluster should be greater or equal to 2!");
                    }
                    else if (ncluster % 1 != 0)
                    {
                        MessageBox.Show("Number of cluster shouldn't be in decimal!");
                    }
                    else if (a < 1)
                    {
                        MessageBox.Show("Coef (A) should be equal or greater than 1");
                    }
                    else if (b <= 0)
                    {
                        MessageBox.Show("Coef (B) should be equal or greater than 1");
                    }
                    else if (K < 0)
                    {
                        MessageBox.Show("Coef (K) should be equal or greater than 1");
                    }
                    else if (error <= 0)
                    {
                        MessageBox.Show("Value of error should be greater than 0");
                    }
                    else if (m < 1)
                    {
                        MessageBox.Show("Fuzzifier (m) should be greater or equal to 1!");
                    }
                    else if (eta < 1)
                    {
                        MessageBox.Show("Fuzzifier (η) should be greater or equal to 1!");
                    }

                    else if (mapcheckBox.Checked == true && (string.IsNullOrWhiteSpace(maptextBox.Text) || datakeyListBox.Items.Count == 0))
                    {
                        MessageBox.Show("You have checked the map, so you must have a shapefile and its datakey or you can uncheck it!");
                    }

                    else
                    {
                        pb.Show();
                        ProcessButton.Enabled   = false;
                        fcmCancelButton.Enabled = false;
                        this.UseWaitCursor      = true;
                        processOutput();
                        OutputForm of = new OutputForm("Posibillistic - Fuzzy C-Means", parname, parval,
                                                       center, partition, allclusters, viname, vival, isnamed, mf.userlang.NumberFormat.NumberDecimalSeparator);
                        of.Show();
                        mf.WindowState     = FormWindowState.Minimized;
                        this.UseWaitCursor = false;
                        this.Close();
                        pb.Dispose();
                    }
                }
            }
        }