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

namespace UHFReaderDS7Demo
{
    public partial class fSetdlg : Form
    {
        public void _usename(string usename)
        {
            textBox1.Text = usename;
        }
        public void _dsname(string dsname)
        {
            textBox2.Text = dsname;
        }
        public void _MAC(string MAC)
        {
            textBox3.Text = MAC;
        }
        public void _IP(string IP)
        {
            textBox4.Text = IP;
        }
        public void _portnum(string portnum)
        {
            textBox5.Text = portnum;
        }
        public void _tup(string tup)
        {
            comboBox1.SelectedIndex = Convert.ToInt32(tup);
        }
        public void _rm(string rm)
        {
            comboBox2.SelectedIndex = Convert.ToInt32(rm);
        }
        public void _di(string di)
        {
            textBox6.Text = di;
        }
        public void _gi(string gi)
        {
            textBox7.Text = gi;
        }
        public void _nm(string nm)
        {
            textBox8.Text = nm;
        }
        public void _dp(string dp)
        {
            textBox9.Text = dp;
        }
        
        public void _br(string br)
        {
            comboBox3.SelectedIndex = Convert.ToInt32(br);
        }
        public void _pr(string pr)
        {
            comboBox4.SelectedIndex = Convert.ToInt32(pr);
        }
        public void _bb(string bb)
        {
            comboBox5.SelectedIndex = Convert.ToInt32(bb);
        }
        public void _dt(string dt)
        {
            comboBox6.SelectedIndex = Convert.ToInt32(dt);
        }
        public void _fc(string fc)
        {
            comboBox7.SelectedIndex = Convert.ToInt32(fc);
        }
      
        public fSetdlg()
        {
            InitializeComponent();
        }

        private void label2_Click(object sender, EventArgs e)
        {
            
        }

        private void button1_Click(object sender, EventArgs e)
        {
            fNhSetDlg fnhSetDlg = new fNhSetDlg();
            fnhSetDlg._cm(Information.cm);
            fnhSetDlg._ct(Information.ct);
            DialogResult result=fnhSetDlg.ShowDialog();
            if (result == DialogResult.OK)
            {
                try
                {
                    Information.cm=fnhSetDlg.cm;
                    Information.ct = fnhSetDlg.ct;
                }
                catch (System.Exception ex)
                {
                    ex.ToString();
                }
            }
            fnhSetDlg.Dispose();
        }

        private void button4_Click(object sender, EventArgs e)
        {
            fPhSetDlg fphSetDlg = new fPhSetDlg();
            fphSetDlg._md(Information.md);
            fphSetDlg._ml(Information.ml);
            fphSetDlg._rc(Information.rc);
            DialogResult result = fphSetDlg.ShowDialog();
            if (result == DialogResult.OK)
            {
                try
                {
                    Information.md = fphSetDlg.md;
                    Information.ml = fphSetDlg.ml;
                    Information.rc = fphSetDlg.rc;
                }
                catch (System.Exception ex)
                {
                    ex.ToString();
                }
            }
            fphSetDlg.Dispose();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            Information.usename = textBox1.Text.Trim();
            Information.dsname = textBox2.Text.Trim();
            Information.mac = textBox3.Text.Trim();
            Information.IP = textBox4.Text.Trim();
            Information.portnum = textBox5.Text.Trim();
            Information.tup = Convert.ToString(comboBox1.SelectedIndex);
            Information.rm = Convert.ToString(comboBox2.SelectedIndex);
            Information.di = textBox6.Text.Trim();
            Information.gi = textBox7.Text.Trim();
            Information.nm = textBox8.Text.Trim();
            Information.dp = textBox9.Text.Trim();
            Information.br = Convert.ToString(comboBox3.SelectedIndex);
            Information.pr = Convert.ToString(comboBox4.SelectedIndex);
            Information.bb = Convert.ToString(comboBox5.SelectedIndex);
            Information.dt = Convert.ToString(comboBox6.SelectedIndex);
            Information.fc = Convert.ToString(comboBox7.SelectedIndex); 
            this.DialogResult = DialogResult.OK;
        }

        private void button3_Click(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.Cancel;
        }

        private void comboBox2_SelectedIndexChanged(object sender, EventArgs e)
        {
            if(comboBox2.SelectedIndex==0)
            {
                textBox6.ReadOnly = true;
                textBox7.ReadOnly = true;
                textBox8.ReadOnly = true;
                textBox9.ReadOnly = true;
            }
            else
            {
                textBox6.ReadOnly = false;
                textBox7.ReadOnly = false;
                textBox8.ReadOnly = false;
                textBox9.ReadOnly = false;
            }
        }

        private void fSetdlg_Load(object sender, EventArgs e)
        {
            this.Text = ResourceCulture.GetString("Property_Setting");
            tabPage1.Text = ResourceCulture.GetString("network_Setting");
            tabPage2.Text = ResourceCulture.GetString("serial_Setting");

            label1.Text = ResourceCulture.GetString("User_Name");
            label2.Text = ResourceCulture.GetString("Device_Name");
            label5.Text = ResourceCulture.GetString("source_port");
            label6.Text = ResourceCulture.GetString("hint_Protocol");
            label7.Text = ResourceCulture.GetString("Work_Mode");
            label8.Text = ResourceCulture.GetString("Remote_IP");
            label11.Text = ResourceCulture.GetString("Remote_port");
            label9.Text = ResourceCulture.GetString("Getway_IP");
            label10.Text = ResourceCulture.GetString("hint_mask");
            button1.Text = ResourceCulture.GetString("Advanced_option");

            label12.Text = ResourceCulture.GetString("Baud_Rate");
            label13.Text = ResourceCulture.GetString("hint_Parity");
            label14.Text = ResourceCulture.GetString("hint_Data_Bits");
            label15.Text = ResourceCulture.GetString("hint_dtr_setting");
            label16.Text = ResourceCulture.GetString("hint_rts_setting");

            button4.Text = ResourceCulture.GetString("Advanced_option");
            button2.Text = ResourceCulture.GetString("hint_ok");
            button3.Text = ResourceCulture.GetString("hint_cancel");
        }
    }
}