예제 #1
0
        // InitializeLocalization Method
        private void InitializeLocalization()
        {
            if (ConfigurationUtil.ConfigurationJsonModel == null || ConfigurationUtil.ConfigurationJsonModel.Language == null || ConfigurationUtil.ConfigurationJsonModel.Language == String.Empty)
            {
                LoggingUtil.Warning("ConfigurationJsonModel was null, LANGUAGE was null or LANGUAGE was empty.");

                ConfigurationUtil.ConfigurationJsonModel = new ConfigurationJsonModel
                {
                    Language = Configuration.LANGUAGES[0] // Set the default language to english.
                };
                ConfigurationUtil.Save();
            }
            else
            {
                ConfigurationUtil.Load();

                int index = 0;
                foreach (var language in Configuration.LANGUAGES)
                {
                    if (ConfigurationUtil.ConfigurationJsonModel.Language.Equals(language))
                    {
                        Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo(language);
                        ComboBox_Language.SelectedIndex       = index;
                        break;
                    }
                    index++;
                }
            }
        }
예제 #2
0
        /*public void SetImage(int i)
         * {
         *  Dispatcher.Invoke(new Action(() => {
         *      var imageUriSource = new Uri(ApplicationManager.Webspace.Image[i], UriKind.Absolute);
         *      Image_Holder.Source = new BitmapImage(imageUriSource);
         *  }), DispatcherPriority.Render);
         * }*/

        private void ComboBox_Language_DropDownClosed(object sender, EventArgs e)
        {
            if (ConfigurationUtil.ConfigurationJsonModel.Language != Configuration.LANGUAGES[ComboBox_Language.SelectedIndex])
            {
                ConfigurationUtil.ConfigurationJsonModel.Language = Configuration.LANGUAGES[ComboBox_Language.SelectedIndex];
                ConfigurationUtil.Save();

                // release the mutex
                App.mutex.ReleaseMutex();

                // restart a new application and turn off the current
                System.Windows.Forms.Application.Restart();
                Application.Current.Shutdown();
            }
        }
예제 #3
0
        // InitializeConfiguration Method
        private void InitializeConfiguration()
        {
            if (ConfigurationUtil.ConfigurationJsonModel == null || ConfigurationUtil.ConfigurationJsonModel.BaseDirectoryPath == null || ConfigurationUtil.ConfigurationJsonModel.BaseDirectoryPath == String.Empty)
            {
                LoggingUtil.Warning("ConfigurationJsonModel was null, BASE_DIRECTORY_PATH was null or BASE_DIRECTORY_PATH was empty.");

                using (var folderBrowserDialog = new System.Windows.Forms.FolderBrowserDialog())
                {
                    folderBrowserDialog.Description = ApplicationManager.Localization.GetString("FOLDER_BROWSER_DIALOG_DESC");
                    System.Windows.Forms.DialogResult dialogResult = folderBrowserDialog.ShowDialog();

                    string directoryPath = null;

                    if (dialogResult == System.Windows.Forms.DialogResult.OK)
                    {
                        directoryPath = folderBrowserDialog.SelectedPath;
                    }
                    else
                    {
                        Environment.Exit(0);
                    }

                    MessageBoxResult messageBoxResult = MessageBox.Show(directoryPath + "\n\n" + ApplicationManager.Localization.GetString("FOLDER_BROWSER_RESULT_BODY"),
                                                                        ApplicationManager.Localization.GetString("FOLDER_BROWSER_RESULT_HEADER"), MessageBoxButton.YesNoCancel, MessageBoxImage.None,
                                                                        MessageBoxResult.None, MessageBoxOptions.DefaultDesktopOnly);

                    if (messageBoxResult == MessageBoxResult.No)
                    {
                        InitializeConfiguration();
                    }
                    else if (messageBoxResult == MessageBoxResult.Cancel)
                    {
                        Environment.Exit(0);
                    }
                    else
                    {
                        LoggingUtil.Info("The BASE_DIRECTORY_PATH has now a valid value.");
                        ConfigurationUtil.ConfigurationJsonModel.BaseDirectoryPath = directoryPath;
                        ConfigurationUtil.Save();
                    }
                }
            }
        }