Beispiel #1
0
        private void apply_Click(object sender, EventArgs e)
        {
            var selectedTheme = themes.SelectedItems[0];

            selectedTheme.Selected = false;

            if (_settings.ShowSaveWarning)
            {
                if (MessageBox.Show(_saveWarningMessage, this.Text, MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.No)
                {
                    return;
                }
            }

            if (selectedTheme.Text == _browse &&
                openFile.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    _helper.LoadShortcuts(openFile.FileName);

                    if (!_settings.CustomThemes.Contains(openFile.FileName))
                    {
                        AddCustomTheme(openFile.FileName);
                    }
                }
                catch (Exception)
                {
                    MessageBox.Show(_invalidFileMessage, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
            }
            else if (selectedTheme.Text == _flashDevelop)
            {
                _helper.ApplyDefault();
            }
            else if (selectedTheme.Text == _visualStudio)
            {
                using (var theme = ResourceHelper.GetFileStream(_visualStudio + ".keys"))
                {
                    _helper.LoadShortcuts(theme);
                }
            }
            else
            {
                var filename = (string)selectedTheme.Tag;
                try
                {
                    _helper.LoadShortcuts(filename);
                }
                catch (Exception)
                {
                    _settings.CustomThemes.Remove(filename);
                    themes.Items.Remove(selectedTheme);

                    MessageBox.Show(_invalidFileMessage, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
            }

            _helper.ApplyAllShortcuts();
        }