Esempio n. 1
0
        private void buttonX6_Click(object sender, EventArgs e)
        {
            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                Configsave data = DeserializeObject <Configsave>(File.ReadAllBytes(openFileDialog1.FileName));

                Port.Clear();
                Ipaddress.Clear();

                switch (data.BuffType)
                {
                case Protocol.ALL:
                {
                    radioButton1.Checked = true;
                }
                break;

                case Protocol.TCP:
                {
                    radioButton2.Checked = true;
                }
                break;

                case Protocol.UDP:
                {
                    radioButton3.Checked = true;
                }
                break;
                }


                if (data.AllIP)
                {
                    this.radioButton4.Checked = true;
                }
                else
                {
                    this.radioButton5.Checked  = true;
                    this.integerInput1.Enabled = true;
                    //this.ipAddressInput1.Value = ipaddress;

                    foreach (string ip in data.Ipaddress)
                    {
                        this.listViewEx1.Items.Add(new ListViewItem()
                        {
                            Text = ip
                        });
                    }
                }

                if (data.AllPort)
                {
                    this.radioButton6.Checked = true;
                }
                else
                {
                    this.radioButton7.Checked  = true;
                    this.integerInput1.Enabled = true;
                    //  this.integerInput1.Value = port;

                    foreach (int pt in data.Port)
                    {
                        this.listViewEx2.Items.Add(new ListViewItem()
                        {
                            Text = pt.ToString(), Tag = pt
                        });
                    }
                }
            }
        }
Esempio n. 2
0
        private void buttonX5_Click(object sender, EventArgs e)
        {
            if (saveFileDialog1.ShowDialog() == DialogResult.OK)
            {
                if (radioButton1.Checked)
                {
                    BuffType = Protocol.ALL;
                }
                if (radioButton2.Checked)
                {
                    BuffType = Protocol.TCP;
                }
                if (radioButton3.Checked)
                {
                    BuffType = Protocol.UDP;
                }

                AllIP = radioButton4.Checked;



                if (!radioButton4.Checked)
                {
                    Ipaddress.Clear();

                    foreach (ListViewItem p in listViewEx1.Items)
                    {
                        Ipaddress.Add(p.Text);
                    }
                }


                AllPort = radioButton6.Checked;

                if (!radioButton6.Checked)
                {
                    Port.Clear();
                    foreach (ListViewItem p in listViewEx2.Items)
                    {
                        Port.Add((int)p.Tag);
                    }
                }
                if (this.comboBoxEx1.SelectedItem != null)
                {
                    Encode = this.comboBoxEx1.SelectedItem as Encoding;
                }
                else
                {
                    Encode = Encoding.GetEncoding(this.comboBoxEx1.Text);
                }

                IsOk = true;


                Configsave tmp = new Configsave()
                {
                    BuffType  = BuffType,
                    AllIP     = AllIP,
                    AllPort   = AllPort,
                    Ipaddress = Ipaddress,
                    Port      = Port
                };


                File.WriteAllBytes(saveFileDialog1.FileName, SerializeObject(tmp));
            }
        }