コード例 #1
0
 private void m_btnUpdateFromBundle_Click(object sender, EventArgs e)
 {
     using (var dlg = new SelectProjectDlg(false, m_model.BundlePath))
     {
         if (dlg.ShowDialog() == DialogResult.OK)
         {
             var selectedBundlePath = dlg.FileName;
             var bundle             = new GlyssenBundle(selectedBundlePath);
             if (ConfirmProjectUpdateFromBundle(bundle))
             {
                 m_model.BundlePath = dlg.FileName;
                 UpdatedBundle      = bundle;
                 HandleOkButtonClick(sender, e);
             }
             else
             {
                 Analytics.Track("CancelledUpdateProjectFromBundleData", new Dictionary <string, string>
                 {
                     { "bundleLanguage", bundle.LanguageIso },
                     { "projectLanguage", m_model.IsoCode },
                     { "bundleID", bundle.Id },
                     { "projectID", m_model.PublicationId },
                     { "recordingProjectName", m_model.RecordingProjectName },
                     { "bundlePathChanged", (m_model.BundlePath != selectedBundlePath).ToString() }
                 });
                 bundle.Dispose();
             }
         }
     }
 }
コード例 #2
0
        public static bool GiveUserChanceToFindOriginalBundle(Project project)
        {
            using (var dlg = new SelectProjectDlg(false))
                if (dlg.ShowDialog() == DialogResult.OK)
                {
                    string invalidMessage = LocalizationManager.GetString("File.InvalidBundleMsg", "The selected file is not a valid text bundle. Would you like to try again?");
                    string invalidCaption = LocalizationManager.GetString("File.InvalidBundleMsg", "Invalid Bundle");
                    string bundlePath     = dlg.FileName;
                    if (Path.GetExtension(bundlePath) == DblBundleFileUtils.kDblBundleExtension)
                    {
                        try
                        {
                            var bundle = new GlyssenBundle(bundlePath);
                            if (bundle.Id != project.Id)
                            {
                                string message = LocalizationManager.GetString("File.WrongBundleMsg", "The ID of the selected text bundle does not match this project. Would you like to try again?");
                                string caption = LocalizationManager.GetString("File.WrongBundle", "Wrong Bundle");
                                return(ErrorMessageWithRetry(message, caption, project));
                            }

                            project.OriginalBundlePath = bundlePath;
                            return(true);
                        }
                        catch
                        {
                            return(ErrorMessageWithRetry(invalidMessage, invalidCaption, project));
                        }
                    }
                    return(ErrorMessageWithRetry(invalidMessage, invalidCaption, project));
                }
            return(false);
        }
コード例 #3
0
 private void m_linkTextReleaseBundle_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
 {
     using (var dlg = new SelectProjectDlg())
     {
         if (dlg.ShowDialog() == DialogResult.OK)
         {
             SelectedProject = dlg.FileName;
             if (Path.GetExtension(SelectedProject) == Constants.kProjectFileExtension)
             {
                 Type = ProjectType.ExistingProject;
             }
             else
             {
                 Type = ProjectType.TextReleaseBundle;
             }
             DialogResult = DialogResult.OK;
             Close();
         }
     }
 }
コード例 #4
0
        private void m_btnQuoteMarkSettings_Click(object sender, EventArgs e)
        {
            bool reparseOkay = false;

            if (m_model.Project.IsSampleProject)
            {
                string msg   = LocalizationManager.GetString("Project.CannotChangeSampleMsg", "The Quote Mark Settings cannot be modified for the Sample project.");
                string title = LocalizationManager.GetString("Project.CannotChangeSample", "Cannot Change Sample Project");
                MessageBox.Show(msg, title);
            }
            else
            {
                if (!m_model.Project.IsReparseOkay())
                {
                    string msg = string.Format(LocalizationManager.GetString("Project.UnableToLocateTextBundleMsg",
                                                                             "The original text bundle for the project is no longer in its original location ({0}). " +
                                                                             "The Quote Mark Settings cannot be modified without access to the original text bundle."), m_model.Project.OriginalBundlePath) +
                                 Environment.NewLine + Environment.NewLine +
                                 LocalizationManager.GetString("Project.LocateBundleYourself", "Would you like to locate the text bundle yourself?");
                    string title = LocalizationManager.GetString("Project.UnableToLocateTextBundle", "Unable to Locate Text Bundle");
                    if (DialogResult.Yes == MessageBox.Show(msg, title, MessageBoxButtons.YesNo))
                    {
                        reparseOkay = SelectProjectDlg.GiveUserChanceToFindOriginalBundle(m_model.Project);
                    }
                }
                else
                {
                    reparseOkay = true;
                }
            }

            using (var viewModel = new BlockNavigatorViewModel(m_model.Project, BlocksToDisplay.AllExpectedQuotes, m_model))
                using (var dlg = new QuotationMarksDlg(m_model.Project, viewModel, !reparseOkay))
                {
                    MainForm.LogDialogDisplay(dlg);
                    if (dlg.ShowDialog(this) == DialogResult.OK)
                    {
                        UpdateQuotePageDisplay();
                    }
                }
        }