예제 #1
0
        private void openToolStripMenuItem_Click(object sender, EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog()
            {
                Filter = "JSON files (*.json)|*.json"
            };

            using (ofd)
            {
                DialogResult ofdResult = ofd.ShowDialog(this);

                if (ofdResult == DialogResult.OK && File.Exists(ofd.FileName))
                {
                    if (service.AreParametersChanged)
                    {
                        ExitForm     exitForm = new ExitForm(service);
                        DialogResult result   = exitForm.ShowDialog(this);
                    }

                    service.ReadNewParameters(ofd.FileName);
                    selectedTemplate = service.Templates.FirstOrDefault();
                    SyncUIParams(true);
                }
            }
        }
예제 #2
0
        private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (service.ShowFinalDialog || service.IsNew)
            {
                if (service.AreParametersChanged)
                {
                    Unhook();

                    ExitForm     exitForm = new ExitForm(service);
                    DialogResult result   = exitForm.ShowDialog(this);
                    e.Cancel = result == DialogResult.Cancel;
                }
            }
            else
            {
                if (!service.TryWriteParameters())
                {
                    Error(SAVE_ERROR);
                }
            }
        }