private void NewUpdateDialog_Load(object sender, EventArgs e) { _lp = LocalizationHelper.GetLocalizationProperties(Updater.LanguageCulture, Updater.CultureFilePaths); headerLabel.Text = string.Format( Updater.PackageConfigurations.Count() > 1 ? _lp.NewUpdateDialogMultipleUpdatesHeader : _lp.NewUpdateDialogSingleUpdateHeader, Updater.PackageConfigurations.Count()); infoLabel.Text = string.Format(_lp.NewUpdateDialogInfoText, Application.ProductName); var availableVersions = Updater.PackageConfigurations.Select(item => new UpdateVersion(item.LiteralVersion)).ToArray(); newestVersionLabel.Text = string.Format(_lp.NewUpdateDialogAvailableVersionsText, Updater.PackageConfigurations.Count() <= 2 ? string.Join(", ", availableVersions.Select(item => item.FullText)) : $"{UpdateVersion.GetLowestUpdateVersion(availableVersions).FullText} - {UpdateVersion.GetHighestUpdateVersion(availableVersions).FullText}"); currentVersionLabel.Text = string.Format(_lp.NewUpdateDialogCurrentVersionText, Updater.CurrentVersion.FullText); changelogLabel.Text = _lp.NewUpdateDialogChangelogText; cancelButton.Text = _lp.CancelButtonText; installButton.Text = _lp.InstallButtonText; var size = SizeHelper.ConvertSize(Updater.TotalSize); updateSizeLabel.Text = $"{string.Format(_lp.NewUpdateDialogSizeText, size.Item1)} {size.Item2}"; Icon = _appIcon; Text = Application.ProductName; iconPictureBox.Image = _appIcon.ToBitmap(); iconPictureBox.BackgroundImageLayout = ImageLayout.Center; foreach (var updateConfiguration in Updater.PackageConfigurations) { var versionText = new UpdateVersion(updateConfiguration.LiteralVersion).FullText; var changelogText = updateConfiguration.Changelog.ContainsKey(Updater.LanguageCulture) ? updateConfiguration.Changelog.First(item => Equals(item.Key, Updater.LanguageCulture)).Value : updateConfiguration.Changelog.First(item => item.Key.Name == "en").Value; if (Updater.TotalSize > GB) { changelogTextBox.Text += _lp.NewUpdateDialogBigPackageWarning; } changelogTextBox.Text += string.Format(string.IsNullOrEmpty(changelogTextBox.Text) ? "{0}:\n{1}" : "\n\n{0}:\n{1}", versionText, changelogText); } AddShieldToButton(installButton); if (OperationAreas == null || OperationAreas.Count == 0) { accessLabel.Text = $"{_lp.NewUpdateDialogAccessText} -"; _allowCancel = true; return; } accessLabel.Text = $"{_lp.NewUpdateDialogAccessText} {string.Join(", ", LocalizationHelper.GetLocalizedEnumerationValues(_lp, OperationAreas.Cast<object>().GroupBy(item => item).Select(item => item.First()).ToArray()))}"; _allowCancel = true; }
public ChangelogViewModel(UpdateManager manager) { UpdateManager = manager; DoInstall = new RelayCommand(o => DoInstall_Execute(), o => true); Abort = new RelayCommand(o => Abort_Execute(), o => true); LocProperties = LocalizationHelper.GetLocalizationProperties(UpdateManager.LanguageCulture, UpdateManager.CultureFilePaths); Header = string.Format( UpdateManager.PackageConfigurations.Count() > 1 ? LocProperties.NewUpdateDialogMultipleUpdatesHeader : LocProperties.NewUpdateDialogSingleUpdateHeader, UpdateManager.PackageConfigurations.Count()); WindowIcon = GetIcon(_appIcon); WindowTitle = string.Format(LocProperties.NewUpdateDialogSingleUpdateHeader, UpdateManager.PackageConfigurations.Count()); InfoText = string.Format(LocProperties.NewUpdateDialogInfoText, Application.ProductName); var availableVersions = UpdateManager.PackageConfigurations.Select(item => new UpdateVersion(item.LiteralVersion)).ToArray(); AviableVersionText = string.Format(LocProperties.NewUpdateDialogAvailableVersionsText, UpdateManager.PackageConfigurations.Count() <= 2 ? string.Join(", ", availableVersions.Select(item => item.FullText)) : $"{UpdateVersion.GetLowestUpdateVersion(availableVersions).FullText} - {UpdateVersion.GetHighestUpdateVersion(availableVersions).FullText}"); CurrentVersionText = string.Format(LocProperties.NewUpdateDialogCurrentVersionText, UpdateManager.CurrentVersion.FullText); var size = SizeHelper.ConvertSize((long)UpdateManager.TotalSize); UpdateSizeText = $"{string.Format(LocProperties.NewUpdateDialogSizeText, size)}"; foreach (var updateConfiguration in UpdateManager.PackageConfigurations) { var versionText = new UpdateVersion(updateConfiguration.LiteralVersion).FullText; var changelogText = updateConfiguration.Changelog.ContainsKey(UpdateManager.LanguageCulture) ? updateConfiguration.Changelog.First(item => Equals(item.Key, UpdateManager.LanguageCulture)).Value : updateConfiguration.Changelog.First(item => item.Key.Name == "en").Value; ChangelogText += string.Format(string.IsNullOrEmpty(ChangelogText) ? "{0}:\n{1}" : "\n\n{0}:\n{1}", versionText, changelogText); } if (OperationAreas == null || OperationAreas.Count == 0) { AccessesText = $"{LocProperties.NewUpdateDialogAccessText} -"; return; } AccessesText = $"{LocProperties.NewUpdateDialogAccessText} {string.Join(", ", LocalizationHelper.GetLocalizedEnumerationValues(LocProperties, OperationAreas.Cast<object>().GroupBy(item => item).Select(item => item.First()).ToArray()))}"; }
private void NewUpdateDialog_Load(object sender, EventArgs e) { if (!String.IsNullOrEmpty(LanguageFilePath)) { try { _lp = Serializer.Deserialize <LocalizationProperties>(File.ReadAllText(LanguageFilePath)); } catch (Exception) { _lp = new LocalizationProperties(); } } else if (String.IsNullOrEmpty(LanguageFilePath) && LanguageName != "en") { string resourceName = String.Format("nUpdate.Core.Localization.{0}.json", LanguageName); using (Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(resourceName)) { _lp = Serializer.Deserialize <LocalizationProperties>(stream); } } else if (String.IsNullOrEmpty(LanguageFilePath) && LanguageName == "en") { _lp = new LocalizationProperties(); } headerLabel.Text = String.Format(PackageConfigurations.Count() > 1 ? _lp.NewUpdateDialogMultipleUpdatesHeader : _lp.NewUpdateDialogSingleUpdateHeader, PackageConfigurations.Count()); infoLabel.Text = String.Format(_lp.NewUpdateDialogInfoText, Application.ProductName); var availableVersions = PackageConfigurations.Select(item => new UpdateVersion(item.LiteralVersion)).ToArray(); newestVersionLabel.Text = String.Format(_lp.NewUpdateDialogAvailableVersionsText, PackageConfigurations.Count() <= 2 ? String.Join(", ", availableVersions.Select(item => item.FullText)) : String.Format("{0} - {1}", UpdateVersion.GetLowestUpdateVersion(availableVersions).FullText, UpdateVersion.GetHighestUpdateVersion(availableVersions).FullText)); currentVersionLabel.Text = String.Format(_lp.NewUpdateDialogCurrentVersionText, CurrentVersion.FullText); changelogLabel.Text = _lp.NewUpdateDialogChangelogText; cancelButton.Text = _lp.CancelButtonText; installButton.Text = _lp.InstallButtonText; var size = SizeHelper.ConvertSize(PackageSize); updateSizeLabel.Text = String.Format("{0} {1}", String.Format(_lp.NewUpdateDialogSizeText, size.Item1), size.Item2); Icon = _appIcon; Text = Application.ProductName; iconPictureBox.Image = _appIcon.ToBitmap(); iconPictureBox.BackgroundImageLayout = ImageLayout.Center; foreach (var updateConfiguration in PackageConfigurations) { var versionText = new UpdateVersion(updateConfiguration.LiteralVersion).FullText; var changelogText = updateConfiguration.Changelog.ContainsKey(new CultureInfo(LanguageName)) ? updateConfiguration.Changelog.First(item => item.Key.Name == LanguageName).Value : updateConfiguration.Changelog.First(item => item.Key.Name == "en").Value; if (PackageSize > GB) { changelogTextBox.Text += _lp.NewUpdateDialogBigPackageWarning; } changelogTextBox.Text += String.Format(String.IsNullOrEmpty(changelogTextBox.Text) ? "{0}:\n{1}" : "\n\n{0}:\n{1}", versionText, changelogText); } AddShieldToButton(installButton); if (OperationAreas == null || OperationAreas.Count == 0) { accessLabel.Text = String.Format("{0} -", _lp.NewUpdateDialogAccessText); _allowCancel = true; return; } accessLabel.Text = String.Format("{0} {1}", _lp.NewUpdateDialogAccessText, String.Join(", ", LocalizationHelper.GetLocalizedEnumerationValues(_lp, OperationAreas.Cast <object>().GroupBy(item => item).Select(item => item.First()).ToArray()))); _allowCancel = true; }