/// <summary/> public string CreateNewLangProj(IThreadedProgress progressDialog, ISynchronizeInvoke threadHelper) { try { var defaultAnalysis = WritingSystemContainer.CurrentAnalysisWritingSystems.First(); var defaultVernacular = WritingSystemContainer.CurrentVernacularWritingSystems.First(); return(LcmCache.CreateNewLangProj(progressDialog, ProjectName, FwDirectoryFinder.LcmDirectories, threadHelper, defaultAnalysis, defaultVernacular, "en",// TODO: replicate original new HashSet <CoreWritingSystemDefinition>(WritingSystemContainer.AnalysisWritingSystems.Skip(1)), new HashSet <CoreWritingSystemDefinition>(WritingSystemContainer.VernacularWritingSystems.Skip(1)), AnthroModel.AnthroFileName)); } catch (WorkerThreadException wex) { Exception e = wex.InnerException; if (e is UnauthorizedAccessException) { if (MiscUtils.IsUnix) { // Tell Mono user he/she needs to logout and log back in MessageBoxUtils.Show(ResourceHelper.GetResourceString("ksNeedToJoinFwGroup")); } else { MessageBoxUtils.Show(string.Format(FwCoreDlgs.kstidErrorNewDb, e.Message), FwUtils.ksSuiteName); } } else if (e is ApplicationException) { MessageBoxUtils.Show(string.Format(FwCoreDlgs.kstidErrorNewDb, e.Message), FwUtils.ksSuiteName); } else if (e is LcmInitializationException) { MessageBoxUtils.Show(string.Format(FwCoreDlgs.kstidErrorNewDb, e.Message), FwUtils.ksSuiteName); } else { throw new Exception(FwCoreDlgs.kstidErrApp, e); } } return(null); }
/// <summary> /// Method with signature required by ProgressDialogWithTask.RunTask to create the project (and a cache for it) /// as a background task while showing the dialog. /// </summary> /// <param name="progress"></param> /// <param name="parameters">A specific list is required...see the first few lines of the method.</param> /// <returns></returns> private static object CreateProjectTask(IThreadedProgress progress, object[] parameters) { // Get required parameters. Ideally these would just be the signature of the method, but RunTask requires object[]. var liftPathname = (string)parameters[0]; var synchronizeInvoke = (ISynchronizeInvoke)parameters[1]; var anthroFile = (string)parameters[2]; var cacheReceiver = (LcmCache[])parameters[3]; CoreWritingSystemDefinition wsVern, wsAnalysis; RetrieveDefaultWritingSystemsFromLift(liftPathname, out wsVern, out wsAnalysis); string projectPath = LcmCache.CreateNewLangProj(progress, Directory.GetParent(Path.GetDirectoryName(liftPathname)).Parent.Name, // Get the new Flex project name from the Lift pathname. FwDirectoryFinder.LcmDirectories, synchronizeInvoke, wsAnalysis, wsVern, null, null, null, anthroFile); // This is a temporary cache, just to do the import, and AFAIK we have no access to the current // user WS. So create it as "English". Put it in the array to return to the caller. cacheReceiver[0] = LcmCache.CreateCacheFromLocalProjectFile(projectPath, "en", new SilentLcmUI(synchronizeInvoke), FwDirectoryFinder.LcmDirectories, new LcmSettings(), progress); return(projectPath); }