コード例 #1
0
ファイル: HelpMenu.cs プロジェクト: vip57884381/Paint.Net
        private void MenuHelpLanguage_DropDownOpening(object sender, EventArgs e)
        {
            this.menuHelpLanguage.DropDownItems.Clear();

            string[] locales = PdnResources.GetInstalledLocales();

            MenuTitleAndLocale[] mtals = new MenuTitleAndLocale[locales.Length];

            for (int i = 0; i < locales.Length; ++i)
            {
                string      locale = locales[i];
                CultureInfo ci     = new CultureInfo(locale);
                mtals[i] = new MenuTitleAndLocale(ci.DisplayName, locale);
            }

            Array.Sort(
                mtals,
                delegate(MenuTitleAndLocale x, MenuTitleAndLocale y)
            {
                return(string.Compare(x.title, y.title, StringComparison.InvariantCultureIgnoreCase));
            });

            foreach (MenuTitleAndLocale mtal in mtals)
            {
                ToolStripMenuItem menuItem = new ToolStripMenuItem();
                menuItem.Text   = GetCultureInfoName(new CultureInfo(mtal.locale));
                menuItem.Tag    = mtal.locale;
                menuItem.Click += new EventHandler(LanguageMenuItem_Click);

                if (0 == string.Compare(mtal.locale, CultureInfo.CurrentUICulture.Name, StringComparison.InvariantCultureIgnoreCase))
                {
                    menuItem.Checked = true;
                }

                this.menuHelpLanguage.DropDownItems.Add(menuItem);
            }
        }
コード例 #2
0
        protected override void OnLoad(EventArgs e)
        {
            // Setup default install dir
            string targetSubDir     = PdnResources.GetString("SetupWizard.InstallDirPage.DefaultTargetSubDir");
            string programFilesDir  = GetProgramFilesDir();
            string defaultTargetDir = Path.Combine(programFilesDir, targetSubDir);
            string targetDir        = GetMsiProperty(PropertyNames.TargetDir, defaultTargetDir);

            // Set other default properties
            string jpgPngBmpEditor = GetMsiProperty(PropertyNames.JpgPngBmpEditor, "1");
            string tgaEditor       = GetMsiProperty(PropertyNames.TgaEditor, "1");
            string checkForUpdates = GetMsiProperty(PropertyNames.CheckForUpdates, "1");
            string checkForBetas   = GetMsiProperty(PropertyNames.CheckForBetas, PropertyNames.CheckForBetasDefault);

            if (!PdnInfo.IsFinalBuild)
            {
                checkForBetas = "1";
            }

            this.pdnBanner.BannerFont = this.HeadingTextFont;

            if (this.wizardPage == null || this.wizardPage.GetType() == typeof(IntroPage))
            {
                // Populate the language combo box
                string[]             locales = PdnResources.GetInstalledLocales();
                CultureNameAndInfo[] cnais   = new CultureNameAndInfo[locales.Length];

                for (int i = 0; i < locales.Length; ++i)
                {
                    string             locale = locales[i];
                    CultureInfo        ci     = new CultureInfo(locale);
                    CultureNameAndInfo cnai   = new CultureNameAndInfo(ci, GetCultureInfoName(ci));
                    cnais[i] = cnai;
                }

                Array.Sort(
                    cnais,
                    delegate(CultureNameAndInfo lhs, CultureNameAndInfo rhs)
                {
                    return(string.Compare(lhs.DisplayName, rhs.DisplayName,
                                          StringComparison.InvariantCultureIgnoreCase));
                });

                this.languageBox.DataSource    = cnais;
                this.languageBox.DisplayMember = "DisplayName";

                // Choose the current locale

                // First find English
                CultureNameAndInfo englishCnai;

                englishCnai = Array.Find(
                    cnais,
                    delegate(CultureNameAndInfo cnai)
                {
                    if (cnai.CultureInfo.Name.Length == 0 || cnai.CultureInfo.Name == "en-US")
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                });

                // Next, figure out what culture we're currently set to
                CultureNameAndInfo currentCnai;

                currentCnai = Array.Find(
                    cnais,
                    delegate(CultureNameAndInfo cnai)
                {
                    return(cnai.CultureInfo == PdnResources.Culture);
                });

                if (currentCnai == null)
                {
                    this.languageBox.SelectedItem = englishCnai;
                }
                else
                {
                    this.languageBox.SelectedItem = currentCnai;
                }

                this.languageInitDone = true;

                // Go to the appropriate page
                if (this.skipConfig)
                {
                    GoToPage(typeof(InstallingPage));
                }
                else
                {
                    GoToPage(typeof(IntroPage));
                }
            }

            base.OnLoad(e);
        }