Esempio n. 1
0
        private void LoadSettings()
        {
            string[] settings = File.ReadAllLines(Environment.CurrentDirectory + "/" + ConfigurationManager.AppSettings["ConfigPath"]);

            try
            {
                CreateAndUploadHotkey.Text = GetValueFromSetting(Work.CreateAndUploadHotkey.ToString(), settings);
                CreateAndSaveHotkey.Text   = GetValueFromSetting(Work.CreateAndSaveHotkey.ToString(), settings);
                //CreateAndUseSnippingToolHotkey.Text = GetValueFromSetting(Work.CreateAndUseSnippingToolHotkey.ToString(), settings);
                PathForScreenshotsTextBox.Text = GetValueFromSetting("PathForScreenshots", settings);
                if (!Directory.Exists(PathForScreenshotsTextBox.Text))
                {
                    PathForScreenshotsTextBox.Text = Environment.GetFolderPath(Environment.SpecialFolder.MyPictures);
                }

                _language = (Translation.Languages)(Enum.Parse(typeof(Translation.Languages), GetValueFromSetting("Language", settings)));
                SelectFormat(GetValueFromSetting("Format", settings));

                BindHotkeys();
            }
            catch (ArgumentException ex)
            {
                MessageBox.Show(
                    ex.Message,
                    Translation.GetTranslation(Translation.Phrases.Error, _language),
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Error);
                PathForScreenshotsTextBox.Text = Environment.GetFolderPath(Environment.SpecialFolder.MyPictures);
            }
        }
Esempio n. 2
0
        private void SaveButton_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                string settings = string.Empty;
                if (CreateAndUploadHotkey.Text == CreateAndSaveHotkey.Text)
                {
                    throw new ArgumentException();
                }

                Translation.Languages newLanguage = (Translation.Languages)LanguageCombobox.SelectedIndex;
                settings += Work.CreateAndUploadHotkey + ": " + CreateAndUploadHotkey.Text + Environment.NewLine;
                settings += Work.CreateAndSaveHotkey + ": " + CreateAndSaveHotkey.Text + Environment.NewLine;
                //settings += Work.CreateAndUseSnippingToolHotkey + ": " + CreateAndUseSnippingToolHotkey.Text + Environment.NewLine;
                settings += string.Format("PathForScreenshots: {0}" + Environment.NewLine,
                                          PathForScreenshotsTextBox.Text);
                settings    += string.Format("Language: {0}" + Environment.NewLine, newLanguage);
                settings    += string.Format("Format: {0}" + Environment.NewLine, _temporaryFormat ?? _imageFormat);
                _language    = newLanguage;
                _imageFormat = _temporaryFormat;

                File.WriteAllText(Environment.CurrentDirectory + "/" + ConfigurationManager.AppSettings["ConfigPath"],
                                  settings);
                BindHotkeys();
                LoadTranslations();
                LoadComboboxTranslations();
                MessageBox.Show(
                    Translation.GetTranslation(Translation.Phrases.AllSettingsSaved, _language),
                    Translation.GetTranslation(Translation.Phrases.Done, _language),
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Information);
            }
            catch (ArgumentException)
            {
                MessageBox.Show(
                    Translation.GetTranslation(Translation.Phrases.HotkeyNotSupported, _language),
                    Translation.GetTranslation(Translation.Phrases.Error, _language),
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Error);
            }
        }