public bool PromptModified()
        {
            if (!SolutionCollection.Modified)
            {
                return(true);
            }

            MessageBoxResult result = MessageBox.Show(
                R.modifiedPrompt, R.appTitle,
                MessageBoxButton.YesNoCancel,
                MessageBoxImage.Warning,
                MessageBoxResult.No);

            // ReSharper disable once SwitchStatementMissingSomeCases
            switch (result)
            {
            case MessageBoxResult.Cancel:
                return(false);

            case MessageBoxResult.Yes:
                return(SolutionCollection.Save());

            case MessageBoxResult.No:
                return(true);

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
예제 #2
0
 private void buttonOK_Click(object sender, EventArgs e)
 {
     SolutionCollection solutions = new SolutionCollection();
     for (int i = 0; i < dataGridViewSolution.Rows.Count; i++)
     {
         if (!dataGridViewSolution.Rows[i].IsNewRow)
         {
             DataGridViewRow row = dataGridViewSolution.Rows[i];
             string name = (string)GetCellValue("ColumnName", row);
             string text = (string)GetCellValue("ColumnText", row);
             string ip = (string)GetCellValue("ColumnIP", row);
             int port = (int)GetCellValue("ColumnPort", row);
             if (name != null && text != null && ip != null)
             {
                 string logindatabase = (string)row.Cells["ColumnLoginDataBase"].FormattedValue;
                 string loginsolution = (string)row.Cells["ColumnLoginSolution"].FormattedValue;
                 Solution.LanguageType language
                     = (Solution.LanguageType)Enum.Parse(typeof(Solution.LanguageType), (string)row.Cells["ColumnLanguage"].FormattedValue);
                 Solution sol = new Solution(name, text, ip,port, 8989, logindatabase, loginsolution, language);
                 solutions.Add(sol);
             }
             else
             {
                 DialogResult = DialogResult.None;
                 return;
             }
         }
     }
     XmlDocument xml = solutions.Save();
     try
     {
         xml.Save(string.Format("{0}\\{1}", Application.StartupPath, Config.SolutionFile));
     }
     catch
     {
         MessageBox.Show(this, "Can not save solution.xml, check it's property not readonly","Error"
             , MessageBoxButtons.OK, MessageBoxIcon.Error);
         DialogResult = DialogResult.None;
     }
 }
 private void OnSaveCollection(object obj)
 {
     SolutionCollection.Save();
 }