Пример #1
0
        private void okButton_Click(object sender, EventArgs e)
        {
            Table table;

            // make sure the commands and confirmations are in sync
            DataGridViewComboBoxColumn confirmColumn = commandsDataGridView.Columns[ConfirmationPromptRow.OptionColumnName] as DataGridViewComboBoxColumn;

            List <string> commandsToConfirm = CommonForm.GetOptionsRequiringConfirmation(commandsDataGridView);
            List <string> confirmations     = new List <string>();

            for (int i = 0; i < confirmationDataGridView.Rows.Count; i++)
            {
                string option = confirmationDataGridView.Rows[i].Cells[ConfirmationPromptRow.OptionColumnName].Value as string;

                // it's one row of nothing if there are no commands
                if (option == null)
                {
                    break;
                }

                // some old junk apparently had the [] in the confirmation option
                if (option.Length > 0)
                {
                    int firstBracket = option.IndexOf(Strings.LabelStartBracket);
                    int lastBracket  = option.IndexOf(Strings.LabelEndBracket);
                    if (firstBracket >= 0 && lastBracket >= 0 && lastBracket > firstBracket)
                    {
                        option = option.Remove(firstBracket, lastBracket - firstBracket + 1);
                    }
                }

                confirmations.Add(option);
            }

            List <string> errorCommands      = new List <string>();
            List <string> errorConfirmations = new List <string>();

            // make sure every command is covered
            foreach (string s in commandsToConfirm)
            {
                bool found = false;
                foreach (string t in confirmations)
                {
                    if (s.Trim().Equals(t.Trim()))
                    {
                        found = true;
                        break;
                    }
                }
                if (!found)
                {
                    errorCommands.Add(s);
                }
            }
            foreach (string s in confirmations)
            {
                bool found = false;
                foreach (string t in commandsToConfirm)
                {
                    if (s.Trim().Equals(t.Trim()))
                    {
                        found = true;
                        break;
                    }
                }
                if (!found && s.Trim().Length != 0)
                {
                    errorConfirmations.Add(s);
                }
            }

            if (errorCommands.Count > 0 || errorConfirmations.Count > 0)
            {
                string msg = string.Empty;
                if (errorCommands.Count > 0)
                {
                    msg += "The following commands require confirmation:";
                    foreach (string s in errorCommands)
                    {
                        if (s.Equals(string.Empty))
                        {
                            msg += "\n    (blank)";
                        }
                        else
                        {
                            msg += "\n    " + s;
                        }
                    }
                }
                if (errorConfirmations.Count > 0)
                {
                    if (errorCommands.Count > 0)
                    {
                        msg += "\n\n and the ";
                    }
                    else
                    {
                        msg += "The ";
                    }
                    msg += "following confirmations are not needed:";
                    foreach (string s in errorConfirmations)
                    {
                        if (s.Equals(string.Empty))
                        {
                            msg += "\n    (blank)";
                        }
                        else
                        {
                            msg += "\n    " + s;
                        }
                    }
                }

                msg += "\n\n" + "Are you sure you want to continue?";
                System.Windows.Forms.DialogResult result;
                result = System.Windows.Forms.MessageBox.Show(msg, "Confirmation Error", System.Windows.Forms.MessageBoxButtons.YesNo, System.Windows.Forms.MessageBoxIcon.Question);

                if (result == System.Windows.Forms.DialogResult.No)
                {
                    return;
                }
            }

            Hide();

            // State Name
            string stateId = CommonForm.UnloadStateIdTextBoxes(statePrefixTextBox, stateNumberTextBox, stateNameTextBox);

            shadow.SetStateId(stateId);

            // Prompts
            table = CommonForm.UnloadPromptTypeDataGridView(promptsDataGridView);
            shadow.SetPromptTypes(table);

            // Transitions
            table = CommonForm.UnloadCommandTransitionDataGridView(commandsDataGridView);
            shadow.SetCommandTransitions(table);

            // Confirmations
            table = CommonForm.UnloadConfirmationPromptGridView(confirmationDataGridView);
            shadow.SetConfirmationPrompts(table);

            // MaxHandling
            table = CommonForm.UnloadMaxHandlingGridView(maxHandlingDataGridView);
            shadow.SetMaxHandling(table);

            // Special Settings
            table = CommonForm.UnloadSpecialSettingsTextBox(specialSettingsTextBox);
            shadow.SetSpecialSettings(table);

            // Developer Notes
            table = CommonForm.UnloadDeveloperNotesTextBox(developerNotesTextBox);
            shadow.SetDeveloperNotes(table);

            // Design Notes
            table = CommonForm.UnloadDesignNotesTextBox(designNotesTextBox);
            shadow.SetDesignNotes(table);
        }
Пример #2
0
        private void OK_Click(object sender, EventArgs e)
        {
            Table table;

            Hide();

            // Default Settings
            string mode               = CommonForm.UnloadModeComboBox(modeComboBox);
            string bargeIn            = CommonForm.UnloadYNComboBox(bargeInComboBox);
            string promptIdFormat     = CommonForm.UnloadPromptIdFormatComboBox(promptIdFormatComboBox);
            string retries            = CommonForm.UnloadYNComboBox(retriesComboBox);
            string timeouts           = CommonForm.UnloadYNComboBox(timeoutsComboBox);
            string disconfirms        = CommonForm.UnloadYNComboBox(disconfirmsComboBox);
            string sortOrder          = CommonForm.UnloadSortOrderComboBox(sortOrderComboBox);
            string defaultConfirmType = CommonForm.UnloadDefaultConfirmTypeComboBox(defaultConfirmTypeComboBox);

            table = shadow.GetDefaultSettings();
            for (int r = 0; r < table.GetNumRows(); r++)
            {
                string name = table.GetData(r, (int)TableColumns.NameValuePairs.Name);
                if (name.Equals(Strings.DefaultSettingsMode))
                {
                    CommonForm.SetTableDataAndDateIfNecessary(table, r, mode, TableColumns.NameValuePairs.Value, TableColumns.NameValuePairs.ValueDateStamp);
                }
                else if (name.Equals(Strings.DefaultSettingsBargeIn))
                {
                    CommonForm.SetTableDataAndDateIfNecessary(table, r, bargeIn, TableColumns.NameValuePairs.Value, TableColumns.NameValuePairs.ValueDateStamp);
                }
                else if (name.Equals(Strings.DefaultSettingsPromptIDFormat))
                {
                    CommonForm.SetTableDataAndDateIfNecessary(table, r, promptIdFormat, TableColumns.NameValuePairs.Value, TableColumns.NameValuePairs.ValueDateStamp);
                }
                else if (name.Equals(Strings.DefaultSettingsRetriesInTotalErrors))
                {
                    CommonForm.SetTableDataAndDateIfNecessary(table, r, retries, TableColumns.NameValuePairs.Value, TableColumns.NameValuePairs.ValueDateStamp);
                }
                else if (name.Equals(Strings.DefaultSettingsTimeoutsInTotalErrors))
                {
                    CommonForm.SetTableDataAndDateIfNecessary(table, r, timeouts, TableColumns.NameValuePairs.Value, TableColumns.NameValuePairs.ValueDateStamp);
                }
                else if (name.Equals(Strings.DefaultSettingsDisconfirmsInTotalErrors))
                {
                    CommonForm.SetTableDataAndDateIfNecessary(table, r, disconfirms, TableColumns.NameValuePairs.Value, TableColumns.NameValuePairs.ValueDateStamp);
                }
                else if (name.Equals(Strings.DefaultSettingsStateSortOrder))
                {
                    CommonForm.SetTableDataAndDateIfNecessary(table, r, sortOrder, TableColumns.NameValuePairs.Value, TableColumns.NameValuePairs.ValueDateStamp);
                }
                else if (name.Equals(Strings.DefaultSettingsConfirmMode))
                {
                    CommonForm.SetTableDataAndDateIfNecessary(table, r, defaultConfirmType, TableColumns.NameValuePairs.Value, TableColumns.NameValuePairs.ValueDateStamp);
                }
            }

            shadow.SetDefaultSettings(table);

            // Initialization Name/Value Pairs
            table = CommonForm.UnloadNameValuePairDataGridView(initializationDataGridView);
            shadow.SetInitialization(table);

            // Initialize Global Prompt Types
            table = CommonForm.UnloadPromptTypeDataGridView(promptsDataGridView);
            shadow.SetPromptTypes(table);

            // Initialize Global Command Transitions
            table = CommonForm.UnloadStartCommandTransitionDataGridView(commandsDataGridView);
            shadow.SetCommandTransitions(table);

            // Initialize Global Confirmation Prompts
            table = CommonForm.UnloadConfirmationPromptGridView(confirmationsDataGridView);
            shadow.SetConfirmationPrompts(table);

            // Initialize Max Handling
            table = CommonForm.UnloadMaxHandlingGridView(maxHandlingDataGridView);
            shadow.SetMaxHandling(table);
        }