using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; namespace FCC_Uber_MDX_Configurator { public partial class AddBackgroundImageForm : Form { public GlobalStaticClass.FusionImage_BackgroundImage CurrentBackgroundImage = null; public int _CurrentPage; public AddBackgroundImageForm(int input_currentPage) { InitializeComponent(); _CurrentPage = input_currentPage; } public AddBackgroundImageForm(GlobalStaticClass.FusionImage_BackgroundImage input_BackgroundImage) { InitializeComponent(); CurrentBackgroundImage = new GlobalStaticClass.FusionImage_BackgroundImage(input_BackgroundImage._path, input_BackgroundImage._image, input_BackgroundImage._imageLayout, _CurrentPage); UpdateForm(); } private void UpdateForm() { BTN_SAVE.Enabled = false; if (CurrentBackgroundImage == null) { return; } if (CurrentBackgroundImage._image == null) { return; } COMBO_LAYOUT.Text = GlobalStaticClass.FormatAllCapsString(CurrentBackgroundImage._imageLayout); if (CurrentBackgroundImage._image.Size.Width > PICT_PREVIEW.Size.Width || CurrentBackgroundImage._image.Size.Height > PICT_PREVIEW.Size.Height) { PICT_PREVIEW.BackgroundImageLayout = ImageLayout.Zoom; } else { PICT_PREVIEW.BackgroundImageLayout = ImageLayout.Center; } PICT_PREVIEW.BackgroundImage = CurrentBackgroundImage._image; BTN_SAVE.Enabled = true; } private void BTN_LOADIMAGE_Click(object sender, EventArgs e) { AddImageForm _tempAIF = null; if (CurrentBackgroundImage != null) { if (CurrentBackgroundImage._image != null && CurrentBackgroundImage._path != null) { _tempAIF = new AddImageForm(CurrentBackgroundImage._image, CurrentBackgroundImage._path); } else { _tempAIF = new AddImageForm(); } } else { _tempAIF = new AddImageForm(); } if (_tempAIF.ShowDialog() == DialogResult.OK) { this.DialogResult = DialogResult.None; if (CurrentBackgroundImage == null) { CurrentBackgroundImage = new GlobalStaticClass.FusionImage_BackgroundImage(_tempAIF.IMAGE_PATH, _tempAIF.IMAGE_BITMAP, COMBO_LAYOUT.Text, _CurrentPage); } else { CurrentBackgroundImage._image = _tempAIF.IMAGE_BITMAP; CurrentBackgroundImage._path = _tempAIF.IMAGE_PATH; } UpdateForm(); } this.DialogResult = DialogResult.None; } private void BTN_SAVE_Click(object sender, EventArgs e) { if (CurrentBackgroundImage == null) { (new ErrorForm("Invalid Background Image", "Image has not been fully setup")).ShowDialog(); return; } if (CurrentBackgroundImage._image == null) { (new ErrorForm("Invalid Image", "Image is invalid")).ShowDialog(); return; } if (!COMBO_LAYOUT.Items.Contains(COMBO_LAYOUT.Text)) { (new ErrorForm("Invalid Layout", "Image layout is invalid")).ShowDialog(); return; } CurrentBackgroundImage._imageLayout = COMBO_LAYOUT.Text; this.DialogResult = DialogResult.OK; } #region Verify a Proper Item has Been Selected in Combo Box private void Leave_VerifyCOMBOIsValid(object sender, EventArgs e) { try { ComboBox _senderBox = (ComboBox)sender; if (!_senderBox.Items.Contains(_senderBox.Text)) { (new ErrorForm(_senderBox.Name, "The value you selected or entered is not valid")).ShowDialog(); _senderBox.Focus(); _senderBox.SelectedIndex = 0; } } catch (Exception) { ErrorForm _tempErrorForm = new ErrorForm("Unknown Error", "There was an unexpected untraceable error caught in the application. If you can reproduce this error, please let me know at FusionControlCentre@gmail.com"); _tempErrorForm.ShowDialog(); } } #endregion } }