private void ResizeButton_Click(object sender, EventArgs e)
        {
            if (_emoteNames is null || _emoteNames.Length == 0 || OutputLink.Text == string.Empty)
            {
                return;
            }

            // Ensure the images in the folder are up-to-date
            _emoteNames = _emoteResizer.FetchEmoteNames(SourceTextBox.Text);

            // Update config object in preparation for the serialization
            _config.SourceDirectory = SourceTextBox.Text;
            _config.OutputDirectory = OutputTextBox.Text;

            try
            {
                _ = _emoteResizer.ProcessEmotes(_emoteNames, SourceTextBox.Text, OutputTextBox.Text); // Save emotes to output folder
                _uiService.SaveConfig(_config, _configPath);                                          // Save config file
                EmoteReporterLabel.Text = $"{_emoteNames.Length} images were successfully resized.";
            }
            catch (Exception ex)
            {
                new ErrorWindow($"Please, make sure the Source and Output folders exist and are not read-only. [{ex.Message}]").Show();
            }
        }
Exemple #2
0
        // When the user defines the directory folder to search images from.
        private void DirectoryTextBox_TextChanged(object sender, EventArgs e)
        {
            ResetWindow();

            if (!Directory.Exists(DirectoryTextBox.Text))
            {
                return;
            }

            FillFilenameListBox();
            _uiService.SaveConfig(DirectoryTextBox.Text);
        }
        public MainWindow(MainUiService uiService, EmoteResizer emoteResizer)
        {
            InitializeComponent();
            _uiService    = uiService;
            _emoteResizer = emoteResizer;

            // If config file doesn't exist, create it
            if (!File.Exists(_configPath))
            {
                _config = new ConfigModel();
                _uiService.SaveConfig(_config, _configPath);
            }
            else
            {
                _config = _uiService.LoadConfig(_configPath);
            }

            SourceTextBox.Text      = _config.SourceDirectory;
            OutputTextBox.Text      = _config.OutputDirectory;
            OutputLink.Text         = _config.OutputDirectory;
            EmoteReporterLabel.Text = string.Empty;
        }