コード例 #1
0
        /// <summary>
        /// Saves the chosen locale and restarts
        /// the application
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void StartButton_Click(object sender, RoutedEventArgs e)
        {
            Properties.Settings.Default.LanguageCode      = LocalizationController.GetLanguage();
            Properties.Settings.Default.HasPickedLanguage = true;
            Properties.Settings.Default.Save();

            _isStarting = true;
            Close();
        }
コード例 #2
0
        /// <summary>
        /// Adds menu options under "Server" on the menu
        /// strip for each Language in LocalizationController
        /// </summary>
        private void SetupServerList()
        {
            // Get the current Language to add a check on
            // the option and loop through the Languages enum
            string currentLanguage = LocalizationController.GetLanguageFromCode(LocalizationController.GetLanguage());

            for (int i = 0; i < ((LocalizationController.Language[])Enum.GetValues(typeof(LocalizationController.Language))).Length; ++i)
            {
                // Add the menu option and the click event
                LocalizationController.Language language = (LocalizationController.Language)i;
                ToolStripItem newLanguage = ServerToolStripMenuItem.DropDownItems.Add(language.ToString());
                newLanguage.Click += (s, e) =>
                {
                    // No need to do anything if the current language
                    // is clicked on since that won't change anything
                    if (((ToolStripMenuItem)newLanguage).Checked)
                    {
                        return;
                    }

                    // Make sure the user wants to switch
                    if (MessageBox.Show(Strings.SwitchServer, Strings.Restart, MessageBoxButtons.YesNo,
                                        MessageBoxIcon.Question) != DialogResult.Yes)
                    {
                        return;
                    }
                    LocalizationController.SetLanguage(language);

                    // Restart the program
                    ProcessStartInfo startInfo = Process.GetCurrentProcess().StartInfo;
                    startInfo.FileName  = Application.ExecutablePath;
                    startInfo.Arguments = $"{ProgramController.ParameterPrefix}restart";
                    var exit = typeof(Application).GetMethod("ExitInternal",
                                                             System.Reflection.BindingFlags.NonPublic |
                                                             System.Reflection.BindingFlags.Static);
                    exit?.Invoke(null, null);
                    Process.Start(startInfo);
                };

                // Check the current Language
                if (currentLanguage == language.ToString())
                {
                    ((ToolStripMenuItem)ServerToolStripMenuItem.DropDownItems[i]).Checked = true;
                }
            }
        }
コード例 #3
0
        /// <summary>
        /// Adds menu options under "Server" on the menu
        /// strip for each Language in LocalizationController
        /// </summary>
        private void SetupServerList()
        {
            string currentLanguage = LocalizationController.GetLanguageFromCode(LocalizationController.GetLanguage());

            for (int i = 0; i < ((LocalizationController.Language[])Enum.GetValues(typeof(LocalizationController.Language))).Length; ++i)
            {
                LocalizationController.Language language = (LocalizationController.Language)i;

                MenuItem menuItem = new MenuItem
                {
                    Header = language.ToString()
                };

                LanguageToolStripMenuItem.Items.Add(menuItem);
                menuItem.Click += (s, e) =>
                {
                    if (menuItem.IsChecked)
                    {
                        return;
                    }

                    CultureInfo cultureInfo = new CultureInfo(LocalizationController.GetCodeFromLanguage(language));
                    if (MessageBox.Show(Strings.ResourceManager.GetString("SwitchServer", cultureInfo),
                                        Strings.ResourceManager.GetString("Restart", cultureInfo), MessageBoxButton.YesNo,
                                        MessageBoxImage.Question) != MessageBoxResult.Yes)
                    {
                        return;
                    }
                    LocalizationController.SetLanguage(language);

                    isRestarting = true;

                    ProcessStartInfo startInfo = Process.GetCurrentProcess().StartInfo;
                    startInfo.FileName  = AppController.ExecutablePath;
                    startInfo.Arguments = $"{AppController.ParameterPrefix}restart";
                    Process.Start(startInfo);

                    System.Windows.Application.Current.Shutdown();
                };

                if (currentLanguage == language.ToString())
                {
                    menuItem.IsChecked = true;
                }
            }
        }
コード例 #4
0
        /// <summary>
        /// Displays some information about the program
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void AboutToolStripMenuItem_Click(object sender, EventArgs e)
        {
            // ReSharper disable once UnreachableCode
            // ReSharper disable once ConditionIsAlwaysTrueOrFalse
#pragma warning disable 162
            MessageBox.Show(string.Format(Strings.About, ProgramController.Version, ProgramController.IsBetaVersion ? Strings.Beta : string.Empty, LocalizationController.GetLanguageFromCode(LocalizationController.GetLanguage()), ProgramController.ServerIPs[0], ProgramController.ServerIPs[1]), Strings.Information, MessageBoxButtons.OK, MessageBoxIcon.Information);
#pragma warning restore 162
        }