示例#1
0
        /// <summary>
        /// Method with required signature for ProgressDialogWithTask.RunTask, to invoke XmlTranslatedLists.ImportTranslatedListsForWs.
        /// Should only be called by the other overload of ImportTranslatedListsForWs.
        /// args must be a writing system identifier string and an LcmCache.
        /// </summary>
        /// <param name="dlg"></param>
        /// <param name="args"></param>
        /// <returns></returns>
        private static object ImportTranslatedListsForWs(IThreadedProgress dlg, object[] args)
        {
            var ws    = (string)args[0];
            var cache = (LcmCache)args[1];

            XmlTranslatedLists.ImportTranslatedListsForWs(ws, cache, FwDirectoryFinder.TemplateDirectory, dlg);
            return(null);
        }
        /// <summary>
        /// Method with required signature for ProgressDialogWithTask.RunTask, to invoke XmlTranslatedLists.ImportTranslatedListsForWs.
        /// Should only be called by the other overload of ImportTranslatedListsForWs.
        /// args must be a writing system identifier string and an FdoCache.
        /// </summary>
        /// <param name="dlg"></param>
        /// <param name="args"></param>
        /// <returns></returns>
        private static object ImportTranslatedListsForWs(IThreadedProgress dlg, object[] args)
        {
            var ws    = (string)args[0];
            var cache = (FdoCache)args[1];

            XmlTranslatedLists.ImportTranslatedListsForWs(ws, cache, dlg);
            return(null);
        }
示例#3
0
        // I made this region to hold methods that perform particular tasks involving wrapping this dialog around
        // some work.
        #region static methods to encapsulate usages of the dialog
        /// <summary>
        /// I'd like to put all this logic into XmlTranslatedLists, because it is common to most cases of
        /// calling ImportTranslatedListsForWs, which is the point of this method. Unfortunately FDO
        /// cannot reference the DLL that has ProgressDialogWithTask. I've made it public static so that
        /// anything that references FwControls can use it at least.
        /// </summary>
        /// <param name="cache"> </param>
        /// <param name="ws"></param>
        /// <param name="parentWindow"> </param>
        public static void ImportTranslatedListsForWs(Form parentWindow, LcmCache cache, string ws)
        {
            string path = XmlTranslatedLists.TranslatedListsPathForWs(ws, FwDirectoryFinder.TemplateDirectory);

            if (!File.Exists(path))
            {
                return;
            }
            using (var dlg = new ProgressDialogWithTask(parentWindow))
            {
                dlg.AllowCancel = true;
                dlg.Maximum     = 200;
                dlg.Message     = Path.GetFileName(path);
                dlg.Title       = XmlTranslatedLists.ProgressDialogCaption;
                dlg.RunTask(true, ImportTranslatedListsForWs, ws, cache);
            }
        }
示例#4
0
 private static bool CheckAndAddLanguagesInternal(FdoCache cache, Interlineartext interlinText, ILgWritingSystemFactory wsFactory, IThreadedProgress progress)
 {
     if (interlinText.languages != null)
     {
         if (!SomeLanguageSpecifiesVernacular(interlinText))
         {
             // Saymore file? something else that doesn't know to do this? We will confuse the user if we try to treat all as analysis.
             SetVernacularLanguagesByUsage(interlinText);
         }
         foreach (var lang in interlinText.languages.language)
         {
             bool fIsVernacular;
             var  writingSystem = SafelyGetWritingSystem(cache, wsFactory, lang, out fIsVernacular);
             if (fIsVernacular)
             {
                 if (!cache.LanguageProject.CurrentVernacularWritingSystems.Contains(writingSystem.Handle))
                 {
                     //we need to invoke the dialog on the main thread so we can use the progress dialog as the parent.
                     //otherwise the message box can be displayed behind everything
                     IAsyncResult asyncResult = progress.ThreadHelper.BeginInvoke(
                         new ShowDialogAboveProgressbarDelegate(ShowDialogAboveProgressbar),
                         new object[]
                     {
                         progress,
                         writingSystem.LanguageName + ITextStrings.ksImportVernacLangMissing,
                         ITextStrings.ksImportVernacLangMissingTitle,
                         MessageBoxButtons.OKCancel
                     });
                     var result = (DialogResult)progress.ThreadHelper.EndInvoke(asyncResult);
                     if (result == DialogResult.OK)
                     {
                         cache.LanguageProject.AddToCurrentVernacularWritingSystems((IWritingSystem)writingSystem);
                     }
                     else
                     {
                         return(false);
                     }
                 }
             }
             else
             {
                 if (!cache.LanguageProject.CurrentAnalysisWritingSystems.Contains(writingSystem.Handle))
                 {
                     IAsyncResult asyncResult = progress.ThreadHelper.BeginInvoke(
                         new ShowDialogAboveProgressbarDelegate(ShowDialogAboveProgressbar),
                         new object[]
                     {
                         progress,
                         writingSystem.LanguageName + ITextStrings.ksImportAnalysisLangMissing,
                         ITextStrings.ksImportAnalysisLangMissingTitle,
                         MessageBoxButtons.OKCancel
                     });
                     var result = (DialogResult)progress.ThreadHelper.EndInvoke(asyncResult);
                     //alert the user
                     if (result == DialogResult.OK)
                     {
                         //alert the user
                         cache.LanguageProject.AddToCurrentAnalysisWritingSystems((IWritingSystem)writingSystem);
                         // We already have progress indications up.
                         XmlTranslatedLists.ImportTranslatedListsForWs(writingSystem.Id, cache, null);
                     }
                     else
                     {
                         return(false);
                     }
                 }
             }
         }
     }
     return(true);
 }