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>
    /// Settings for the scanner
    /// Mod 5 - Auto
    /// Mod 3 - DPI A4
    /// Mod 4 - DPI cm
    /// Mod 0 - Noe settings
    /// </summary>
    public partial class ScanMODE2 : Form
    {
        public static int Mod = 0;
        public static double _ho = 0;
        public static double _br = 0;
        public static int DPI = 0;
        public static bool buttonOK = false;

        public ScanMODE2(int dpi)
        {
            InitializeComponent();
            //comboBox1.SelectedIndex = 0;
            DPI = dpi;
            textBox3.Text = DPI.ToString();
            Mod = 5;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            buttonOK = true;
            this.Close();
        }

        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
        //    int ind = comboBox1.SelectedIndex;
        //    Mod = ind;
        }

        private void textBox1_TextChanged(object sender, EventArgs e)
        {
            try
            {
                _ho = Convert.ToDouble(textBoxh.Text);
                _br = Convert.ToDouble(textBoxb.Text);
            }
            catch (Exception e1)
            {
                MessageBox.Show("Werte ungültig! A4 wird verwendet ...", "Warnung", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                textBoxh.Text = "29,7";
                textBoxb.Text = "21";
                _ho = Convert.ToDouble(textBoxh.Text);
                _br = Convert.ToDouble(textBoxb.Text);
            }
           // Console.Out.WriteLine("H  : " + _ho);
           // Console.Out.WriteLine("B  : " + _br);
        }

        private void radioButton2_CheckedChanged(object sender, EventArgs e)
        {
            this.textBoxh.Enabled = false;
            this.textBoxb.Enabled = false;
            Mod = 3;
           // Console.Out.WriteLine("Mod: " + Mod);
        }

        private void radioButton3_CheckedChanged(object sender, EventArgs e)
        {
            Mod = 4;
            this.textBoxh.Enabled = true;
            this.textBoxb.Enabled = true;
            try {
                _ho = Convert.ToDouble(textBoxh.Text);
                _br = Convert.ToDouble(textBoxb.Text);
                //textBoxb.Text = "21";
            }
            catch (Exception e1)
            {
                MessageBox.Show("Werte ungültig! A4 wird verwendet ...", "Warnung", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                textBoxh.Text = "29,7";
                textBoxb.Text = "21";
                _ho = Convert.ToDouble(textBoxh.Text);
                _br = Convert.ToDouble(textBoxb.Text);
            }
        
          //  Console.Out.WriteLine("Mod: " + Mod);
          //  Console.Out.WriteLine("H  : " + _ho);
          //  Console.Out.WriteLine("B  : " + _br);
        }

        private void radioButton4_CheckedChanged(object sender, EventArgs e)
        {
            this.textBoxh.Enabled = false;
            this.textBoxb.Enabled = false;
            Mod = 0;
          //  Console.Out.WriteLine("Mod: " + Mod);
        }

        private void radioButton1_CheckedChanged(object sender, EventArgs e)
        {
            this.textBoxh.Enabled = false;
            this.textBoxb.Enabled = false;
            Mod = 5;
          //  Console.Out.WriteLine("Mod: " + Mod);
        }

        private void textBox3_TextChanged(object sender, EventArgs e)
        {
            try
            {
                DPI = Convert.ToInt32(textBox3.Text);
            }
            catch (Exception e1)
            {
                MessageBox.Show("Wert ungültig! DPI 300 wird verwendet ...", "Warnung", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                DPI = 300;
            }
            if (DPI < 0) {
                MessageBox.Show("Wert ungültig! DPI 300 wird verwendet ...", "Warnung", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                DPI = 300;
            }

            this.textBox3.Text = DPI.ToString();
          //  Console.Out.WriteLine("DPI: " + DPI);
        }

        private void textBoxb_TextChanged(object sender, EventArgs e)
        {
            try
            {
                _br = Convert.ToDouble(textBoxb.Text);
            }
            catch (Exception e1)
            {
                MessageBox.Show("Werte ungültig! A4 wird verwendet ...", "Warnung", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                textBoxh.Text = "29,7";
                textBoxb.Text = "21,0";
                _ho = Convert.ToDouble(textBoxh.Text);
                _br = Convert.ToDouble(textBoxb.Text);
            }
        //    Console.Out.WriteLine("H  : " + _ho);
        //    Console.Out.WriteLine("B  : " + _br);
        }
    }
}
