コード例 #1
0
        private void m_btnOk_Click(object sender, EventArgs e)
        {
            DisableForm(true);

            QuoteSystem currentQuoteSystem = CurrentQuoteSystem;

            if (currentQuoteSystem == m_project.QuoteSystem)
            {
                if ((m_project.QuoteSystemStatus & QuoteSystemStatus.NotParseReady) > 0)
                {
                    m_project.QuoteSystemStatus = QuoteSystemStatus.Reviewed;
                    // Kicks off the quote parse (which we haven't run yet)
                    m_project.QuoteSystem = currentQuoteSystem;
                }
                else
                {
                    HandleAnalysisCompleted(this, null);
                }
                return;
            }

            string validationMessage;

            if (!ValidateQuoteSystem(currentQuoteSystem, out validationMessage))
            {
                MessageBox.Show(validationMessage, LocalizationManager.GetString("DialogBoxes.QuotationMarksDlg.QuoteSystemInvalid", "Quote System Invalid"));
                DisableForm(false);
                return;
            }
            if (m_project.Books.SelectMany(b => b.Blocks).Any(bl => bl.UserConfirmed) && m_project.IsQuoteSystemReadyForParse && m_project.QuoteSystem != null)
            {
                string part1 = LocalizationManager.GetString("DialogBoxes.QuotationMarksDlg.QuoteSystemChangePart1", "Changing the quote system will require the text to be broken up into speaking parts again.  An attempt will be made to preserve the work you have already completed, but some character assignments might be lost.  A backup of your project will be created before this occurs.");
                string part2 = LocalizationManager.GetString("DialogBoxes.QuotationMarksDlg.QuoteSystemChangePart2", "Are you sure you want to change the quote system?");
                string msg   = part1 + Environment.NewLine + Environment.NewLine + part2;
                string title = LocalizationManager.GetString("DialogBoxes.QuotationMarksDlg.ConfirmQuoteSystemChange", "Confirm Quote System Change");
                if (MessageBox.Show(msg, title, MessageBoxButtons.YesNo) != DialogResult.Yes)
                {
                    SetupQuoteMarksComboBoxes(m_project.QuoteSystem);
                    DisableForm(false);
                    return;
                }
            }

            if (m_project.QuoteSystemStatus == QuoteSystemStatus.Obtained)
            {
                Analytics.Track("ObtainedQuoteSystemChanged", new Dictionary <string, string>
                {
                    { "old", m_project.QuoteSystem != null ? m_project.QuoteSystem.ToString() : String.Empty },
                    { "new", currentQuoteSystem.ToString() }
                });
            }
            else if (m_project.QuoteSystemStatus != QuoteSystemStatus.UserSet)
            {
                Analytics.Track("GuessedQuoteSystemChanged", new Dictionary <string, string>
                {
                    { "old", m_project.QuoteSystem != null ? m_project.QuoteSystem.ToString() : String.Empty },
                    { "new", currentQuoteSystem.ToString() }
                });
            }

            // Want to set the status even if already UserSet because that triggers setting QuoteSystemDate
            m_project.QuoteSystemStatus = QuoteSystemStatus.UserSet;

            m_project.QuoteSystem = currentQuoteSystem;
        }
コード例 #2
0
        private void m_btnOk_Click(object sender, EventArgs e)
        {
            DisableForm(true);

            QuoteSystem currentQuoteSystem = CurrentQuoteSystem;

            if (currentQuoteSystem == m_project.QuoteSystem)
            {
                if ((m_project.QuoteSystemStatus & QuoteSystemStatus.NotParseReady) > 0)
                {
                    m_project.QuoteSystemStatus = QuoteSystemStatus.Reviewed;
                    // Kicks off the quote parse (which we haven't run yet)
                    m_project.QuoteSystem = currentQuoteSystem;
                }
                else
                {
                    HandleAnalysisCompleted(this, null);
                }
                return;
            }

            string validationMessage;

            if (!ValidateQuoteSystem(currentQuoteSystem, out validationMessage))
            {
                MessageBox.Show(validationMessage,
                                LocalizationManager.GetString("DialogBoxes.QuotationMarksDlg.QuoteSystemInvalid",
                                                              "Quote System Invalid"));
                DisableForm(false);
                return;
            }
            List <string> msgParts = new List <string>();

            if (m_project.IsLiveParatextProject)
            {
                msgParts.Add(String.Format(LocalizationManager.GetString("DialogBoxes.QuotationMarksDlg.QuoteSystemChange.GetDataFromParatext",
                                                                         "This requires {0} to retrieve the current text from {1} project {2}, so any textual changes made there " +
                                                                         "will now be incorporated into this {0} project.",
                                                                         "Param 0: \"Glyssen\" (product name); " +
                                                                         "Param 1: \"Paratext\" (product name); " +
                                                                         "Param 2: Paratext project short name (unique project identifier)"),
                                           GlyssenInfo.kProduct,
                                           ParatextScrTextWrapper.kParatextProgramName,
                                           m_project.ParatextProjectName));
            }
            if (m_project.Books.SelectMany(b => b.Blocks).Any(bl => bl.UserConfirmed) && m_project.IsQuoteSystemReadyForParse && m_project.QuoteSystem != null)
            {
                msgParts.Add(LocalizationManager.GetString("DialogBoxes.QuotationMarksDlg.QuoteSystemChange.WorkWillBePreserved",
                                                           "An attempt will be made to preserve the work you have already completed, but some character assignments might be lost."));
            }
            if (msgParts.Any())
            {
                msgParts.Insert(0, LocalizationManager.GetString("DialogBoxes.QuotationMarksDlg.QuoteSystemChange.Part1",
                                                                 "Changing the quote system will require the text to be broken up into speaking parts again."));
                msgParts.Add(LocalizationManager.GetString("DialogBoxes.QuotationMarksDlg.QuoteSystemChange.BackupWillBeCreated",
                                                           "A backup of your project will be created before this occurs."));
                string title = LocalizationManager.GetString("DialogBoxes.QuotationMarksDlg.ConfirmQuoteSystemChange",
                                                             "Confirm Quote System Change");
                if (MessageBox.Show(String.Join(Environment.NewLine, msgParts), title, MessageBoxButtons.OKCancel) == DialogResult.Cancel)
                {
                    SetupQuoteMarksComboBoxes(m_project.QuoteSystem);
                    DisableForm(false);
                    return;
                }
            }

            if (m_project.QuoteSystemStatus == QuoteSystemStatus.Obtained)
            {
                Analytics.Track("ObtainedQuoteSystemChanged", new Dictionary <string, string>
                {
                    { "old", m_project.QuoteSystem != null ? m_project.QuoteSystem.ToString() : String.Empty },
                    { "new", currentQuoteSystem.ToString() }
                });
            }
            else if (m_project.QuoteSystemStatus != QuoteSystemStatus.UserSet)
            {
                Analytics.Track("GuessedQuoteSystemChanged", new Dictionary <string, string>
                {
                    { "old", m_project.QuoteSystem != null ? m_project.QuoteSystem.ToString() : String.Empty },
                    { "new", currentQuoteSystem.ToString() }
                });
            }

            // Want to set the status even if already UserSet because that triggers setting QuoteSystemDate
            m_project.QuoteSystemStatus = QuoteSystemStatus.UserSet;

            m_project.QuoteSystem = currentQuoteSystem;
            // After setting this, the user could get a subsequent dialog box giving them the chance to review the settings,
            // but since we've already saved their changes, they can't really "Cancel" those saved changes anymore.
            m_btnCancel.DialogResult = DialogResult.OK;
        }