public static void Localize(String localizePrefix, IWizardPage page) { String title = InstallerResources.GetString(localizePrefix + "_Title"); if (title != null) { page.PageTitle = title; } String subtitle = InstallerResources.GetString(localizePrefix + "_Subtitle"); if (subtitle != null) { page.PageSubtitle = subtitle; } //////////////////// if (page.WizardForm != null) { page.WizardForm.BackText = InstallerResources.GetString("Wiz_Prev"); page.WizardForm.NextText = InstallerResources.GetString("Wiz_Next"); page.WizardForm.CancelText = InstallerResources.GetString("Wiz_Cancel"); } //////////////////// Control control = page as Control; if (control != null) { RecurseLocalizeControl(localizePrefix, control); } }
public static void Localize(String localizePrefix, Form form) { form.Text = InstallerResources.GetString(localizePrefix + "_Title"); form.RightToLeft = InstallerResources.CurrentLanguage.RightToLeft ? RightToLeft.Yes : RightToLeft.No; RecurseLocalizeControl(localizePrefix, form); }
private static void wiz_CancelClicked(object sender, EventArgs e) { String message = InstallerResources.GetString("Wiz_CancelConfirm"); if (MessageBox.Show(message, "Anolis Installer", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes) { Application.Exit(); } }
private static void RecurseLocalizeControl(String localizePrefix, Control c) { String key = localizePrefix + '_' + c.Name.Replace("__", ""); String text = InstallerResources.GetString(key); if (text != null) { c.Text = text; } else { nulls.Add(key + "\t" + c.GetType().Name); } foreach (Control child in c.Controls) { RecurseLocalizeControl(localizePrefix, child); } }
public static void Main(String[] args) { try { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); InstallerResources.CurrentLanguageChanged += new EventHandler(InstallerResources_CurrentLanguageChanged); InstallationInfo.ProgramMode = ProgramMode.None; #region Initial PackageInfo Options // set this here because there's nowhere else to put it // HACK: Devise a shortlist of known languages that have this problem // also, does this affect Vista? if (Environment.OSVersion.Version.Major == 5) { PackageInfo.LiteMode = System.Globalization.CultureInfo.InstalledUICulture.DisplayName.IndexOf("English", StringComparison.OrdinalIgnoreCase) == -1; } if (InstallerResources.IsCustomized) { PackageInfo.IgnoreCondition = InstallerResources.CustomizedSettings.DisablePackageCheck; } PackageInfo.SystemRestore = true; InstallationInfo.FeedbackSend = true; #endregion if (args.Length > 0) { ////////////////////////////////////////// // Pause if (args.IndexOf("/pause") > -1) { MessageBox.Show("Paused", "Anolis Installer", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1); } ////////////////////////////////////////// // Package Condition if (args.IndexOf("/ignoreCondition") > -1) { PackageInfo.IgnoreCondition = true; } ////////////////////////////////////////// // Uninstall Mode String uninstall = GetUninstallation(args); if (uninstall != null) { InstallationInfo.UninstallPackage = new FileInfo(uninstall); InstallationInfo.ProgramMode = ProgramMode.UninstallPackage; } ////////////////////////////////////////// // Jump-to-Package // // String filename = args[0]; // if( File.Exists( filename ) ) { // // String ext = Path.GetExtension( filename ).ToUpperInvariant(); // if(ext == ".ANOP") { // package archive // // } else if( ext == ".XML") { // package definition // // } // // } } // preload resources System.Drawing.Image image = InstallerResources.GetImage("Background"); image = InstallerResources.GetImage("Banner"); // Set up the wizard // create the pages PageAWelcome = new WelcomePage(); PageBMainAction = new MainActionPage(); PageCASelectPackage = new SelectPackagePage(); PageCBExtracting = new ExtractingPage(); PageCCUpdatePackage = new UpdatePackagePage(); PageCDReleaseNotes = new ReleaseNotesPage(); PageCE1Selector = new SelectorPage(); PageCE2ModifyPackage = new ModifyPackagePage(); PageCFInstallOpts = new InstallationOptionsPage(); PageCFInstallOptForm = new InstallationOptionsForm(); PageCGInstalling = new InstallingPage(); PageDADestination = new DestinationPage(); PageDBDownloading = new DownloadingPage(); PageEASelectBackup = new SelectBackupPage(); PageFFinished = new FinishedPage(); WizardForm = InstallationInfo.CreateWizard(); WizardForm.CancelClicked += new EventHandler(wiz_CancelClicked); WizardForm.HasHelp = false; WizardForm.Title = InstallationInfo.InstallerTitle; WizardForm.Icon = InstallerResources.GetIcon("Package"); WizardForm.NextText = InstallerResources.GetString("Wiz_Next"); WizardForm.BackText = InstallerResources.GetString("Wiz_Prev"); WizardForm.CancelText = InstallerResources.GetString("Wiz_Cancel"); InstallerResources.ForceLocalize(); } catch (Exception ex) { StringBuilder sb = new StringBuilder(); while (ex != null) { sb.Append(ex.Message); sb.Append("\r\n"); sb.Append(ex.StackTrace); if (ex.InnerException != null) { sb.Append("\r\n\r\n"); } ex = ex.InnerException; } MessageBox.Show(sb.ToString(), "Anolis Installer - Initialisation Exception", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1); return; } switch (InstallationInfo.ProgramMode) { case ProgramMode.UninstallPackage: WizardForm.LoadPage(PageEASelectBackup); break; case ProgramMode.None: default: WizardForm.LoadPage(PageAWelcome); break; } WizardForm.Run(); // Clean-up if (PackageInfo.Package != null && (PackageInfo.Source == PackageSource.Embedded || PackageInfo.Source == PackageSource.Archive)) { PackageInfo.Package.DeleteFiles(); } }