Пример #1
0
        ////////////////////////////////////////////////////////////////////////////////////////////////////
        /// \fn private void Button_Select_Click(object sender, RoutedEventArgs e)
        ///
        /// \brief Event handler. Called by Button_Select for click events.
        ///
        /// \par Description.
        ///
        /// \par Algorithm.
        ///
        /// \par Usage Notes.
        ///
        /// \author Ilanh
        /// \date 29/08/2017
        ///
        /// \param sender  (object) - Source of the event.
        /// \param e       (RoutedEventArgs) - Routed event information.
        ////////////////////////////////////////////////////////////////////////////////////////////////////

        private void Button_Select_Click(object sender, RoutedEventArgs e)
        {
            // If the source and the target are not equal generate a message that the user code
            // will be overridden
            List <string> algorithms      = TypesUtility.GetAlgorithms();
            string        targetAlgorithm = Selection_TargetSubject.GetSelection().selectionText + "." + Selection_TargetAlgorithm.GetSelection().selectionText;
            string        sourceAlgorithm = Selection_SourceSubject.GetSelection().selectionText + "." + Selection_SourceAlgorithm.GetSelection().selectionText;

            if (algorithms.Any(a => a == targetAlgorithm))
            {
                newAlgorithm = false;
                if (sourceAlgorithm == targetAlgorithm)
                {
                    string messageResult = CustomizedMessageBox.Show(new List <string> {
                        "The algorithm already exist",
                        "Your code files Should not be re-generated",
                        "Select Replace to regenerate the user code files (and delete your implementation)",
                        "Select OK to replace only the automatically generated code file",
                        "Select Cancel to replace the selection"
                    },
                                                                     "SourceTargetAlgorithmsSelect Message",
                                                                     new List <string> {
                        "Replace", "OK", "Cancel"
                    },
                                                                     Icons.Question);
                    switch (messageResult)
                    {
                    case "Replace":
                        replaceUserCodeFiles = true;
                        break;

                    case "OK":
                        replaceUserCodeFiles = false;
                        break;

                    case "Cancel":
                        return;
                    }
                }
                else
                {
                    string messageResult = CustomizedMessageBox.Show(new List <string> {
                        "The algorithm already exist",
                        "You selected another algorithm as your source algorithm",
                        "Select Replace to replace the code files of the existing algorithm (Backup will be produced)",
                        "Select OK to replace only the auto generated code file",
                        "Select Cancel to replace the selection"
                    },
                                                                     "SourceTargetAlgorithmsSelect Message",
                                                                     new List <string> {
                        "Replace", "OK", "Cancel"
                    },
                                                                     Icons.Question);
                    switch (messageResult)
                    {
                    case "Replace":
                        replaceUserCodeFiles = true;
                        break;

                    case "OK":
                        replaceUserCodeFiles = false;
                        break;

                    case "Cancel":
                        return;
                    }
                }
            }
            else
            {
                newAlgorithm         = true;
                replaceUserCodeFiles = true;
            }

            selectResults = new List <SelectResults>();
            selectResults.Add(Selection_SourceSubject.GetSelection());
            selectResults.Add(Selection_SourceAlgorithm.GetSelection());
            selectResults.Add(Selection_TargetSubject.GetSelection());
            selectResults.Add(Selection_TargetAlgorithm.GetSelection());
            result = SelectResult.Select;
            Close();
        }