コード例 #1
0
 public static DialogResult ShowDialog(Exception ex, string caption, DialogResult enabledButtons)
 {
     ExceptionRetryDialog dlg = new ExceptionRetryDialog();
     dlg.PopulateWithException(ex);
     if (!string.IsNullOrWhiteSpace(caption))
         dlg.ExceptionName = caption;
     if (!enabledButtons.HasFlag(DialogResult.Abort))
         dlg.abortButton.Enabled = false;
     if (!enabledButtons.HasFlag(DialogResult.Ignore))
         dlg.ignoreButton.Enabled = false;
     if (!enabledButtons.HasFlag(DialogResult.Retry))
         dlg.retryButton.Enabled = false;
     return dlg.ShowDialog();
 }
コード例 #2
0
        private void BrowseBtn_Click(object sender, EventArgs e)
        {
            DialogResult Res = OpenDlg.ShowDialog();

            if (!Res.HasFlag(DialogResult.Cancel))
            {
                PathBox.Text = OpenDlg.FileName;
            }
        }
コード例 #3
0
ファイル: Form1.cs プロジェクト: bofhbug/printer_labs
        private void OpenBtn_Click(object sender, EventArgs e)
        {
            DialogResult Res = OpenDlg.ShowDialog();

            if (!Res.HasFlag(DialogResult.Cancel) && System.IO.File.Exists(OpenDlg.FileName))
            {
                Img          = new Bitmap(OpenDlg.FileName);
                PicBox.Image = Img;
            }
        }
コード例 #4
0
        private void select_button_Click(object sender, EventArgs e)
        {
            OpenFileDialog ofd    = new OpenFileDialog();
            DialogResult   result = ofd.ShowDialog();

            if (result.HasFlag(DialogResult.OK))
            {
                _pcProg     = ofd.FileName;
                label2.Text = _pcProg;
            }
        }
コード例 #5
0
ファイル: Form1.cs プロジェクト: Walax/SoundBoard
        private void ButtonOpen_Click(object sender, System.EventArgs e)
        {
            OpenFileDialog diag = new OpenFileDialog();
            DialogResult   res  = diag.ShowDialog();

            SoundBoardObject s;

            if (res.HasFlag(DialogResult.OK))
            {
                s = new SoundBoardObject(diag.FileName);
                manager.AddElement(s);
                manager.SaveSoundBoardConfig();
            }
        }
コード例 #6
0
        public static DialogResult ShowDialog(Exception ex, string caption, DialogResult enabledButtons)
        {
            ExceptionRetryDialog dlg = new ExceptionRetryDialog();

            dlg.PopulateWithException(ex);
            if (!string.IsNullOrWhiteSpace(caption))
            {
                dlg.ExceptionName = caption;
            }
            if (!enabledButtons.HasFlag(DialogResult.Abort))
            {
                dlg.abortButton.Enabled = false;
            }
            if (!enabledButtons.HasFlag(DialogResult.Ignore))
            {
                dlg.ignoreButton.Enabled = false;
            }
            if (!enabledButtons.HasFlag(DialogResult.Retry))
            {
                dlg.retryButton.Enabled = false;
            }
            return(dlg.ShowDialog());
        }
コード例 #7
0
        //private
        private void onBrowseBtnClick(object sender, EventArgs e)
        {
            OpenFileDialog dialog = new OpenFileDialog();

            dialog.Multiselect = true;

            DialogResult result = dialog.ShowDialog(this);

            if (result.HasFlag(DialogResult.OK))
            {
                fileTxt.Text = string.Join("; ", dialog.FileNames);
                files        = dialog.FileNames;
            }
        }
コード例 #8
0
        private void onKeyBrowseBtnClicked(object sender, EventArgs e)
        {
            OpenFileDialog dialog = new OpenFileDialog();

            dialog.Multiselect = false;

            DialogResult result = dialog.ShowDialog(this);

            if (result.HasFlag(DialogResult.OK))
            {
                keyTxt.Text = dialog.FileName;
                keyFile     = dialog.FileName;
            }
        }
コード例 #9
0
        private void btn_baja_cliente_Click(object sender, EventArgs e)
        {
            var cliente = SeleccionarCliente();

            if (cliente == null)
            {
                MessageBox.Show(this, "Error", "No se selecciono cliente a eliminar");
                return;
            }

            DialogResult result = MessageBox.Show(this, "Seguro que desea desvincular el cliente?", "", MessageBoxButtons.YesNo);

            if (!result.HasFlag(DialogResult.Yes))
            {
                return;
            }

            AplicarAccion(cliente, clienteBLL.DesvincularCliente);
        }
コード例 #10
0
        private void createResultsSetToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var createForm = new ResultSetCreate();

            createForm.QueriesDirectory = Configuration.Project.Directories[Configuration.DirectoryCollection.DirectoryType.Query].FullFileName;
            createForm.ResultsDirectory = Configuration.Project.Directories[Configuration.DirectoryCollection.DirectoryType.Expect].FullFileName;
            createForm.ConnectionString = Configuration.Project.ConnectionStrings[
                Configuration.ConnectionStringCollection.ConnectionClass.Oledb,
                Configuration.ConnectionStringCollection.ConnectionType.Expect
                                          ].Value;

            DialogResult dialogResult = createForm.ShowDialog();

            if (dialogResult.HasFlag(DialogResult.OK))
            {
                StartClick(null);
                QuerySetManager qsm = null;
                try
                {
                    qsm = QuerySetManager.BuildDefault(createForm.QueriesDirectory, createForm.ResultsDirectory, createForm.ConnectionString);
                    qsm.ProgressStatusChanged += new ProgressStatusHandler(ProgressStatus);
                    qsm.PersistResultSets();
                }

                catch (ConnectionException ex)
                {
                    MessageBox.Show(ex.Message, "Cannot connect with connectionString", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
                finally
                {
                    qsm.ProgressStatusChanged -= new ProgressStatusHandler(ProgressStatus);

                    Configuration.Project.Directories[Configuration.DirectoryCollection.DirectoryType.Query].FullFileName  = createForm.QueriesDirectory;
                    Configuration.Project.Directories[Configuration.DirectoryCollection.DirectoryType.Expect].FullFileName = createForm.ResultsDirectory;
                    Configuration.Project.ConnectionStrings[
                        Configuration.ConnectionStringCollection.ConnectionClass.Oledb,
                        Configuration.ConnectionStringCollection.ConnectionType.Expect
                    ].Value = createForm.ConnectionString;

                    EndClick(null);
                }
            }
        }
コード例 #11
0
        private void button_Click(object sender, EventArgs e)
        {
            try
            {
                if (DialogResult.HasFlag(DialogResult.OK))
                {
                    // Creates a new SetObjectType
                    if (!Form.TemplatesColors.ContainsKey(comboBox1.Text))
                    {
                        Form.TemplatesColors.Add(comboBox1.Text, new SetObjectType());
                    }

                    var setObject = new SetObject(
                        Form.TemplatesColors[comboBox1.Text], comboBox1.Text, GenerateID(Form.SetData));
                    MainForm.WriteDefaultCustomData(setObject);
                    Form.SetData.Objects.Add(setObject);
                }
            }
            catch { }
        }
コード例 #12
0
ファイル: Program.cs プロジェクト: Fayrik/MapMerge
        internal static string FileDialogue(bool save, bool dmm)
        {
            string defaultExt = "*";
            string filter     = "All files (*.*)|*.*";

            if (dmm)
            {
                defaultExt = "dmm";  filter = "Map files (*.dmm)|*.dmm|All files (*.*)|*.*";
            }
            if (!save)
            {
                OpenFileDialog ofd = new OpenFileDialog
                {
                    CheckPathExists = true, CheckFileExists = true, DefaultExt = defaultExt, Filter = filter
                };
                DialogResult dr = ofd.ShowDialog();
                if (!dr.HasFlag(DialogResult.OK) || !System.IO.File.Exists(ofd.FileName))
                {
                    return(null);
                }

                return(ofd.FileName);
            }
            else
            {
                SaveFileDialog sfd = new SaveFileDialog
                {
                    CheckPathExists = true, OverwritePrompt = false, DefaultExt = defaultExt, Filter = filter
                };
                DialogResult dr = sfd.ShowDialog();
                if (!dr.HasFlag(DialogResult.OK))
                {
                    return(null);
                }

                return(sfd.FileName);
            }
        }
コード例 #13
0
        void upload()
        {
            // Запрашиваем у пользователя, действительно ли он хочет очистить форму приложения
            DialogResult dr = MessageBox.Show("Вы действительно хотите очистить окно приложения?", "", MessageBoxButtons.YesNo);

            if (dr.HasFlag(DialogResult.No))
            {
                return;
            }
            clearData();
            clearTable1();
            clearTable2();
            // Выводим окно выбора файла
            OpenFileDialog fd = new OpenFileDialog();

            fd.ShowDialog();
            // Проверяем наличие файла.
            // Если файл существует, то загружаем.
            // Если файл не существует, то выводим сообщение.
            if (System.IO.File.Exists(fd.FileName))
            {
                // После загрузки файла читаем его в массив строк
                String[] lines = System.IO.File.ReadAllLines(fd.FileName);
                // Разбираем строки, выводя данные в окно программы
                tFIO.Text              = lines[0].Split(':')[1];
                tContract.Text         = lines[1].Split(':')[1];
                cProcent.SelectedValue = lines[2].Split(':')[1];
                tBankProcent.Text      = lines[3].Split(':')[1];
                tPassport.Text         = lines[4].Split(':')[1];
                cBankName.Text         = lines[5].Split(':')[1];
                dtpBeginContract.Value = DateTime.Parse(lines[6].Split(':')[1]);
                dtpLastContract.Value  = DateTime.Parse(lines[7].Split(':')[1]);
                dtpCalcDate.Value      = DateTime.Parse(lines[8].Split(':')[1]);
                tAddress.Text          = lines[9].Split(':')[1];
                tNomer.Text            = lines[10].Split(':')[1];

                int j = 0;

                try {
                    for (int i = 12; i < lines.Length - 1; i = i + 7)
                    {
                        table.Rows.Add();
                        table2.Rows.Add();
                        table.Rows[j].Cells[0].Value = lines[i].Split(':')[1];
                        table.Rows[j].Cells[1].Value = lines[i + 1].Split(':')[1];
                        table.Rows[j].Cells[2].Value = lines[i + 2].Split(':')[1];
                        table.Rows[j].Cells[3].Value = lines[i + 3].Split(':')[1];
                        table.Rows[j].Cells[4].Value = lines[i + 4].Split(':')[1];

                        table2.Rows[j].Cells[0].Value = lines[i].Split(':')[1];
                        table2.Rows[j].Cells[1].Value = lines[i + 1].Split(':')[1];
                        table2.Rows[j].Cells[2].Value = lines[i + 5].Split(':')[1];
                        table2.Rows[j].Cells[3].Value = lines[i + 6].Split(':')[1];

                        j++;
                    }
                } catch (System.ArgumentOutOfRangeException ex) {
                    MessageBox.Show(ex.Message);
                }
                MessageBox.Show("Загрузка завершена");
            }
            else
            {
                MessageBox.Show("Нет файла с таким именем");
                return;
            }
        }
コード例 #14
0
        private void training()
        {
            float tweakAmount = 0.0001F;

            count = 0;
            bool Active      = true;
            bool adjustTweak = true;

            while (Active)
            {
                float[] output = Brain.Think(ParseDatabase.ByteToFloat(Images[count]));
                outputNum = Training.OutputNumber(output);
                float cost = Training.CalculateCost(output, Labels[count]);
                Training.Backpropagate(Brain, tweakAmount, outputNum, Labels[count]);
                int expected = Labels[count];

                // Normalerweise trennt man die Prüfdaten von den Trainingsdaten,
                // um zu gucken ob das Netz nicht nur auswendig lernt, sondern auch generalisiert
                if (count % 1000 == 0)
                {
                    good = 0;                    //reset statistic every 1000 steps
                }
                if (expected == outputNum)
                {
                    good++;
                }
                double accuracy = good / (count % 1000 + 1.0);
                int    percent  = (int)(100 * accuracy);

                if (count % 100 == 90)
                {
                    Console.Write("accuracy: " + percent + "% cost: " + cost + " \r");
                    if (percent > 50 && adjustTweak)
                    {
                        tweakAmount = tweakAmount / 10;
                        adjustTweak = false;// only once
                    }
                }
                //this.Invoke(new MethodInvoker(delegate {
                //    this.Refresh();
                //    outputNum_label.Text =outputNum + " accuracy: " + percent+ "%";
                //    //show_output(output);
                //}));

                count++;

                if (count >= 59999)
                {
                    count = 0;
                    string path = @"save.brain";
                    File.Create(path).Close();
                    File.WriteAllText(path, Brain.BrainStructure);

                    DialogResult res = MessageBox.Show("Finished", "Training", MessageBoxButtons.OKCancel);
                    if (res.HasFlag(DialogResult.Cancel))
                    {
                        Active = false;
                    }
                }
            }
        }
コード例 #15
0
        private void training()
        {
            float tweakAmount = 0.0005F;

            count = 0;
            bool Active = true;

            while (Active)
            {
                float[] output = Brain.Think(ParseDatabase.ByteToFloat(Images[count]), Neuron.ReLU);
                outputNum = Training.OutputNumber(output);
                float cost = Training.CalculateCost(output, Labels[count]);
                Training.Backpropagate(Brain, tweakAmount, outputNum, Labels[count]);
                int expected = Labels[count];

                // Normalerweise trennt man die Prüfdaten von den Trainingsdaten,
                // um zu gucken ob das Netz nicht nur auswendig lernt, sondern auch generalisiert
                if (count % 1000 == 0)
                {
                    good = 0;                    //reset statistic every 1000 steps
                }
                if (expected == outputNum)
                {
                    totalSuccess++;
                    good++;
                }

                double accuracy = good / (count % 1000 + 1.0);
                int    percent  = (int)(100 * accuracy);

                int totalAccuracy = Convert.ToInt32(totalSuccess * 100 / (count + 1));

                Console.Write("accuracy: " + percent + "% cost: " + cost + "total:" + totalAccuracy + "% \r");

                if (display)
                {
                    this.Invoke(new MethodInvoker(delegate {
                        this.Refresh();
                        outputNum_label.Text = outputNum + " accuracy: " + percent + "%";
                        show_output(output);
                    }));
                }

                count++;

                if (count >= trainingAmount - 1)
                {
                    count        = 0;
                    totalSuccess = 0;
                    string path = @"save.brain";
                    File.Create(path).Close();
                    File.WriteAllText(path, Brain.BrainStructureString);

                    DialogResult res = MessageBox.Show("Finished", "Training", MessageBoxButtons.OKCancel);
                    if (res.HasFlag(DialogResult.Cancel))
                    {
                        Active = false;
                    }
                }
            }
        }
コード例 #16
0
        private void buildTestSuiteToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var tsCreate = new TestSuiteCreate();

            tsCreate.Actual.QueriesDirectory = Configuration.Project.Directories[Configuration.DirectoryCollection.DirectoryType.Query].FullFileName;
            tsCreate.Actual.ConnectionString = Configuration.Project.ConnectionStrings[
                Configuration.ConnectionStringCollection.ConnectionClass.Oledb,
                Configuration.ConnectionStringCollection.ConnectionType.Expect
                                               ].Value;
            tsCreate.Expect.ResultSetsDirectory = Configuration.Project.Directories[Configuration.DirectoryCollection.DirectoryType.Expect].FullFileName;

            DialogResult dialogResult = tsCreate.ShowDialog();

            if (dialogResult.HasFlag(DialogResult.OK))
            {
                StartClick(null);
                try
                {
                    var          tsb = new TestSuiteBuilder();
                    TestSuiteXml ts  = null;

                    tsb.DefineActual(tsCreate.Actual.QueriesDirectory, tsCreate.Actual.ConnectionString);
                    if (tsCreate.Expect.IsResultSetsBased)
                    {
                        tsb.DefineExpect(tsCreate.Expect.ResultSetsDirectory);
                    }
                    else
                    {
                        tsb.DefineExpect(tsCreate.Expect.QueriesDirectory, tsCreate.Expect.ConnectionString);
                    }

                    ts = tsb.Build();

                    var xm = new XmlManager();

                    using (var sfd = new SaveFileDialog())
                    {
                        sfd.InitialDirectory = Configuration.Project.Directories[Configuration.DirectoryCollection.DirectoryType.TestSuite].FullPath;
                        sfd.FileName         = Configuration.Project.Directories[Configuration.DirectoryCollection.DirectoryType.TestSuite].FilenameWithoutExtension;
                        sfd.Filter           = "Xml|*.xml";
                        if (sfd.ShowDialog() == DialogResult.OK)
                        {
                            Configuration.Project.Directories[Configuration.DirectoryCollection.DirectoryType.TestSuite].FullFileName = sfd.FileName;
                            xm.Persist(sfd.FileName, ts);
                        }
                    }
                }
                finally
                {
                    Configuration.Project.Directories[Configuration.DirectoryCollection.DirectoryType.Query].FullFileName = tsCreate.Actual.QueriesDirectory;
                    Configuration.Project.ConnectionStrings[
                        Configuration.ConnectionStringCollection.ConnectionClass.Oledb,
                        Configuration.ConnectionStringCollection.ConnectionType.Actual
                    ].Value = tsCreate.Actual.ConnectionString;

                    if (tsCreate.Expect.IsResultSetsBased)
                    {
                        Configuration.Project.Directories[Configuration.DirectoryCollection.DirectoryType.Expect].FullFileName = tsCreate.Expect.ResultSetsDirectory;
                    }
                    EndClick(null);
                }
            }
        }