Beispiel #1
0
        private void CreatePreset_Click(object sender, EventArgs e)
        {
            _currentPreset.Name        = PresetName.Text;
            _currentPreset.Description = presetDescription.Text;
            _presetRepository.Update(_currentPreset);

            this.Close();
        }
Beispiel #2
0
        private void importButton_Click(object sender, EventArgs e)
        {
            string            message = "";
            string            caption = "";
            MessageBoxButtons buttons = MessageBoxButtons.OK;

            if (filePathImportTextBox.Text != "")
            {
                Preset currentPreset = JsonConverter.ConvertFromJson(_filePathImport);
                string newFilepath;
                #region Checks the value of the imported PresetSettings and requests new ones if needed
                foreach (PresetSetting presetSetting in currentPreset.PresetSettings)
                {
                    if (presetSetting.PresetSettingType == "File" || presetSetting.PresetSettingType == "Background")
                    {
                        if (!File.Exists(presetSetting.Value))
                        {
                            message = "Please select a valid file path for " + presetSetting.Name + "!";
                            caption = presetSetting.Name + " does not contain a valid file path!";
                            DialogResult importRequest = MessageBox.Show(message, caption, buttons);
                            newFilepath         = FileBrowserDialogue.GetFullFilePath();
                            presetSetting.Value = newFilepath;
                        }
                    }
                }
                #endregion
                _presetRepository.Update(currentPreset);
                message = "Successfully imported " + currentPreset.Name + "!";
                caption = "Import successful!";
                DialogResult importSuccessful = MessageBox.Show(message, caption, buttons);
                UpdateGrid();
            }
            else
            {
                message = "Please sellect a valid file path to import from!";
                caption = "Invalid import file path!";
                DialogResult success = MessageBox.Show(message, caption, buttons);
            }
        }