/// ------------------------------------------------------------------------------------ /// <summary> /// Prepares the selected files to be uploaded to REAP using RAMP. /// </summary> /// <param name="owner">RAMP dialog owner</param> /// <param name="dialogFont">RAMP dialog font (for localization and consistency)</param> /// <param name="localizationDialogIcon"></param> /// <param name="filesToArchive"></param> /// <param name="mediator"></param> /// <param name="thisapp"></param> /// <param name="cache"></param> /// <returns></returns> /// ------------------------------------------------------------------------------------ public bool ArchiveNow(Form owner, Font dialogFont, Icon localizationDialogIcon, IEnumerable<string> filesToArchive, Mediator mediator, FwApp thisapp, FdoCache cache) { var viProvider = new VersionInfoProvider(Assembly.LoadFile(thisapp.ProductExecutableFile), false); var wsMgr = cache.ServiceLocator.GetInstance<IWritingSystemManager>(); var appName = thisapp.ApplicationName; var title = cache.LanguageProject.ShortName; var uiLocale = wsMgr.Get(cache.DefaultUserWs).IcuLocale; var projectId = cache.LanguageProject.ShortName; var model = new RampArchivingDlgViewModel(Application.ProductName, title, projectId, /*appSpecificArchivalProcessInfo:*/ string.Empty, SetFilesToArchive(filesToArchive), GetFileDescription); // image files should be labeled as Graphic rather than Photograph (the default). model.ImagesArePhotographs = false; // show the count of media files, not the duration model.ShowRecordingCountNotLength = true; // set the general description, in each available language IMultiString descr = cache.LanguageProject.Description; var descriptions = new Dictionary<string, string>(); foreach (int wsid in descr.AvailableWritingSystemIds) { var descrText = descr.get_String(wsid).Text; if ((!string.IsNullOrEmpty(descrText)) && (descrText != "***")) descriptions[wsMgr.Get(wsid).GetIso3Code()] = descrText; } if (descriptions.Count > 0) model.SetDescription(descriptions); AddMetsPairs(model, viProvider.ShortNumericAppVersion, cache); const string localizationMgrId = "Archiving"; if (s_localizationMgr == null) { s_localizationMgr = LocalizationManager.Create( uiLocale, localizationMgrId, viProvider.ProductName, viProvider.NumericAppVersion, FwDirectoryFinder.GetCodeSubDirectory("ArchivingLocalizations"), Path.Combine(Application.CompanyName, appName), localizationDialogIcon, "*****@*****.**", "SIL.Archiving"); } else { LocalizationManager.SetUILanguage(uiLocale, true); } // create the dialog using (var dlg = new ArchivingDlg(model, localizationMgrId, dialogFont, new FormSettings())) using (var reportingAdapter = new PalasoErrorReportingAdapter(dlg, mediator)) { ErrorReport.SetErrorReporter(reportingAdapter); dlg.ShowDialog(owner); ErrorReport.SetErrorReporter(null); } return true; }
/// ------------------------------------------------------------------------------------ /// <summary> /// Protected constructor for initialization in tests /// </summary> /// <param name="projectsRootFolder">The root folder for projects (typically the /// default, but if these setings represent a project elsewhere, then this will be the /// root folder for this project).</param> /// <param name="projectName">Name of the project.</param> /// <param name="linkedFilesPath">The linked files path.</param> /// <param name="sharedProjectFolder">A possibly alternate project path that /// should be used for things that should be shared.</param> /// <param name="originalProjType">Type of the project before converting for backup.</param> /// <param name="destFolder">The destination folder.</param> /// ------------------------------------------------------------------------------------ protected BackupProjectSettings(string projectsRootFolder, string projectName, string linkedFilesPath, string sharedProjectFolder, FDOBackendProviderType originalProjType, string destFolder) : base(projectsRootFolder, linkedFilesPath, sharedProjectFolder) { ProjectName = projectName; DbVersion = FDOBackendProvider.ModelVersion; FwVersion = new VersionInfoProvider(Assembly.GetExecutingAssembly(), false).MajorVersion; // For DB4o projects, we need to convert them over to XML. We can't put the // converted project in the same directory so we convert them to a temporary // directory (see FWR-2813). DatabaseFolder = (originalProjType == FDOBackendProviderType.kXML || originalProjType == FDOBackendProviderType.kSharedXML) ? ProjectPath : Path.GetTempPath(); DestinationFolder = destFolder; BackupTime = DateTime.Now; }
/// ------------------------------------------------------------------------------------ /// <summary> /// When the window handle gets created we want to initialize the controls /// </summary> /// <param name="e"></param> /// ------------------------------------------------------------------------------------ protected override void OnHandleCreated(EventArgs e) { base.OnHandleCreated(e); try { // Set the Application label to the name of the app VersionInfoProvider viProvider = new VersionInfoProvider(ProductExecutableAssembly, true); lblName.Text = viProvider.ProductName; lblAppVersion.Text = viProvider.ApplicationVersion; lblFwVersion.Text = viProvider.MajorVersion; lblCopyright.Text = viProvider.CopyrightString + Environment.NewLine + viProvider.LicenseString + Environment.NewLine + viProvider.LicenseURL; // Set the title bar text Text = string.Format(m_sTitleFmt, viProvider.ProductName); string strRoot = Path.GetPathRoot(Application.ExecutablePath); // Set the memory information Win32.MemoryStatus ms = new Win32.MemoryStatus(); Win32.GlobalMemoryStatus(ref ms); edtAvailableMemory.Text = string.Format(m_sAvailableMemoryFmt, ms.dwAvailPhys / 1024, ms.dwTotalPhys / 1024); // Set the available disk space information. uint cSectorsPerCluster = 0, cBytesPerSector = 0, cFreeClusters = 0, cTotalClusters = 0; Win32.GetDiskFreeSpace(strRoot, ref cSectorsPerCluster, ref cBytesPerSector, ref cFreeClusters, ref cTotalClusters); uint cbKbFree = (uint)(((Int64)cFreeClusters * cSectorsPerCluster * cBytesPerSector) >> 10); edtAvailableDiskSpace.Text = string.Format(m_sAvailableDiskSpaceFmt, cbKbFree, strRoot); } catch { // ignore errors } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Initialize text of controls prior to display /// </summary> /// ------------------------------------------------------------------------------------ protected void InitControlLabels() { try { // Set the Application label to the name of the app if (m_productExecutableAssembly != null) { VersionInfoProvider viProvider = new VersionInfoProvider(m_productExecutableAssembly, m_fDisplaySILInfo); lblProductName.Text = viProvider.ProductName; Text = lblProductName.Text; lblAppVersion.Text = viProvider.ApplicationVersion; lblFwVersion.Text = viProvider.MajorVersion; lblCopyright.Text = viProvider.CopyrightString + Environment.NewLine + viProvider.LicenseString; } } catch { // ignore errors } }