using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Foto_Scanner_New
{
    /// <summary>
    /// Class for settings
    /// </summary>
    public partial class Settings : Form
    {
        private int _dpi = 300;
        
        
        public Settings(int __dpi)
        {
            InitializeComponent();
            this.textBoxDPI.Text = __dpi.ToString();
        }

        /// <summary>
        /// Close
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void buttonCancel_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        /// <summary>
        /// OK
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void buttonOK_Click(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.OK;

            //DPI
            int dpi = 300;
            try {
                
                dpi = Convert.ToInt32(this.textBoxDPI.Text);

                if (dpi <= 10)
                {
                    dpi = 300;
                    _dpi = dpi;
                }
                else
                {
                    _dpi = dpi;
                    this.textBoxDPI.Text = _dpi.ToString();
                }
            }
            catch (Exception e1)
            {
                MessageBox.Show("Wert ungültig!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                this.textBoxDPI.Text = "300";
                dpi = 300;
                _dpi = dpi;
            }
            
        }

        /// <summary>
        /// Return dpi value.
        /// </summary>
        /// <returns>Dpi</returns>
        public int getDPI()
        {
            return _dpi;
        }

    }
}
