using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using DotNettyFrom.config;

namespace DotNettyFrom.dialog
{
    public partial class TcpPkgConfigDialog : Form
    {
        public TcpPkgConfigDialog()
        {
            InitializeComponent();
        }

        private void TcpPkgConfigDialog_Load(object sender, EventArgs e)
        {
            LengthFieldOffset.Value = SystemConfig.LengthFieldOffset;
            LengthFieldLength.Value = SystemConfig.LengthFieldLength;
            LengthAdjustment.Value = SystemConfig.LengthAdjustment;
            InitialBytesToStrip.Value = SystemConfig.InitialBytesToStrip;
        }

        private void buttonOk_Click(object sender, EventArgs e)
        {
            SystemConfig.LengthFieldOffset = (int) LengthFieldOffset.Value;
            SystemConfig.LengthFieldLength = (int) LengthFieldLength.Value;
            SystemConfig.LengthAdjustment = (int) LengthAdjustment.Value;
            SystemConfig.InitialBytesToStrip = (int) InitialBytesToStrip.Value;

            this.Close();
        }

        private void buttonWater2_Click(object sender, EventArgs e)
        {
            LengthFieldOffset.Value = 10;
            LengthFieldLength.Value = 1;
            LengthAdjustment.Value = 2;
            InitialBytesToStrip.Value = 0;
        }

        private void buttonDtu_Click(object sender, EventArgs e)
        {
            LengthFieldOffset.Value = 10;
            LengthFieldLength.Value = 2;
            LengthAdjustment.Value = 1;
            InitialBytesToStrip.Value = 0;
        }
    }
}