コード例 #1
0
ファイル: PreferencesDialog.cs プロジェクト: vainamov/nUpdate
        private void editLanguageButton_Click(object sender, EventArgs e)
        {
            var lp = new LocalizationProperties();
            var name =
                new CultureInfo(
                    languagesComboBox.GetItemText(languagesComboBox.SelectedItem).Split('-')[1].Trim()).Name;

            var jsonEditorDialog = new JsonEditorDialog {LanguageContent = Serializer.Serialize(lp), CultureName = name};
            jsonEditorDialog.ShowDialog(this);
        }
コード例 #2
0
ファイル: MainDialog.cs プロジェクト: chantsunman/nUpdate
        ///// <summary>
        /////     Sets the language
        ///// </summary>
        //public void SetLanguage()
        //{
        //    string languageFilePath = Path.Combine(Program.LanguagesDirectory,
        //        String.Format("{0}.json", Settings.Default.Language.Name));
        //    if (File.Exists(languageFilePath))
        //        _lp = Serializer.Deserialize<LocalizationProperties>(File.ReadAllText(languageFilePath));
        //    else
        //    {
        //        File.WriteAllBytes(Path.Combine(Program.LanguagesDirectory, "en.json"), Resources.en);
        //        Settings.Default.Language = new CultureInfo("en");
        //        Settings.Default.Save();
        //        Settings.Default.Reload();
        //        _lp = Serializer.Deserialize<LocalizationProperties>(File.ReadAllText(languageFilePath));
        //    }
        //    Text = _lp.ProductTitle;
        //    headerLabel.Text = _lp.ProductTitle;
        //    infoLabel.Text = _lp.MainDialogInfoText;
        //    sectionsListView.Groups[0].Header = _lp.MainDialogProjectsGroupText;
        //    sectionsListView.Groups[1].Header = _lp.MainDialogInformationGroupText;
        //    sectionsListView.Groups[2].Header = _lp.MainDialogPreferencesGroupText;
        //    sectionsListView.Items[0].Text = _lp.MainDialogNewProjectText;
        //    sectionsListView.Items[1].Text = _lp.MainDialogOpenProjectText;
        //    sectionsListView.Items[4].Text = _lp.MainDialogFeedbackText;
        //    sectionsListView.Items[5].Text = _lp.MainDialogPreferencesText;
        //    sectionsListView.Items[6].Text = _lp.MainDialogInformationText;
        //}
        private void MainDialog_Load(object sender, EventArgs e)
        {
            if (Environment.OSVersion.Version.Major < 6)
            {
                var dr = MessageBox.Show("Your operating system is not supported.", String.Empty,
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Error);
                if (dr == DialogResult.OK)
                    Application.Exit();
            }

            try
            {
                var fai = new FileAssociationInfo(".nupdproj");
                if (!fai.Exists)
                {
                    fai.Create("nUpdate Administration");

                    var pai = new ProgramAssociationInfo(fai.ProgId);
                    if (!pai.Exists)
                    {
                        pai.Create("nUpdate Administration Project File",
                            new ProgramVerb("Open", String.Format("\"{0} %1\"", Application.ExecutablePath)));
                        pai.DefaultIcon = new ProgramIcon(Application.ExecutablePath);
                    }
                }
            }
            catch (UnauthorizedAccessException)
            {
                Popup.ShowPopup(this, SystemIcons.Warning, "Missing rights.", "The registry entry for the extension (.nupdproj) couldn't be created. Without that file extension nUpdate Administration won't work correctly. Please make sure to start the administration with admin privileges the first time.",
                    PopupButtons.Ok);
            }

            if (String.IsNullOrWhiteSpace(Settings.Default.ProgramPath))
                Settings.Default.ProgramPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
                    "nUpdate Administration");
            Program.LanguagesDirectory = Path.Combine(Program.Path, "Localization");
            if (!Directory.Exists(Program.LanguagesDirectory))
            {
                Directory.CreateDirectory(Program.LanguagesDirectory); // Create the directory

                // Save the language content
                var lang = new LocalizationProperties();
                var content = Serializer.Serialize(lang);
                File.WriteAllText(Path.Combine(Program.LanguagesDirectory, "en.json"), content);
            }

            if (!File.Exists(Program.ProjectsConfigFilePath))
            {
                using (File.Create(Program.ProjectsConfigFilePath))
                {
                }
            }

            if (!File.Exists(Program.StatisticServersFilePath))
            {
                using (File.Create(Program.StatisticServersFilePath))
                {
                }
            }

            var projectsPath = Path.Combine(Program.Path, "Projects");
            if (!Directory.Exists(projectsPath))
                Directory.CreateDirectory(projectsPath);

            //SetLanguage();
            sectionsListView.DoubleBuffer();
            Text = String.Format(Text, Program.VersionString);
            headerLabel.Text = String.Format(Text, Program.VersionString);
        }