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

using INT69DB_2A.Forms;

namespace INT69DB_2A.DialogForms
{
    public partial class DialogFormDataViewerFilter : Form
    {
        #region Field
        private FormDataViewer m_ParentForm;
        #endregion

        #region Constructor
        public DialogFormDataViewerFilter(FormDataViewer parent)
        {
            InitializeComponent();

            this.ParentForm = parent;

            this.InitializeDesign();
            this.InitializeContnrol();
            this.DefaultSetting();
        } 
        #endregion

        #region Property
        public FormDataViewer ParentForm
        {
            get { return this.m_ParentForm; }
            set { this.m_ParentForm = value; }
        }
        #endregion

        #region Method
        private void InitializeDesign()
        {
            if (this.ParentForm.ParentForm.SystemConfig.Language == DataStore.LanguageID.Chinese)
            {

            }
            else if (this.ParentForm.ParentForm.SystemConfig.Language == DataStore.LanguageID.Czech)
            {

            }
            else if (this.ParentForm.ParentForm.SystemConfig.Language == DataStore.LanguageID.German)
            {
             
            }
            else
            {

            }
        }
        private void InitializeContnrol()
        {
            int x = 0, y = 0;

            x = Screen.PrimaryScreen.Bounds.Width / 2 - this.Size.Width / 2;
            y = Screen.PrimaryScreen.Bounds.Height / 2 - this.Size.Height / 2;

            this.Location = new Point(x, y);

            this.Size = new Size(450, 165);
        }
        private void DefaultSetting()
        {
            this.UpdateDisplay(this.ParentForm.ParentForm.CurrentDataViewerFilter);            
        }

        private void UpdateDisplay(DataViewerFilter filter)
        {
            this.checkBoxTypeAlarm.Checked = filter.TpyeAlarm;
            this.checkBoxTypeOperation.Checked = filter.TypeOperation;
            this.checkBoxTypeParameter.Checked = filter.TypeParameter;
        }

        public void DisplayRefresh()
        {
            this.UpdateDisplay(this.ParentForm.ParentForm.CurrentDataViewerFilter);
        }
        #endregion

        #region Event Handler
        private void buttonOk_Click(object sender, EventArgs e)
        {
            this.ParentForm.ParentForm.CurrentDataViewerFilter.TpyeAlarm = this.checkBoxTypeAlarm.Checked;
            this.ParentForm.ParentForm.CurrentDataViewerFilter.TypeOperation = this.checkBoxTypeOperation.Checked;
            this.ParentForm.ParentForm.CurrentDataViewerFilter.TypeParameter = this.checkBoxTypeParameter.Checked;

            this.DialogResult = DialogResult.OK;
            this.Close();
        }

        private void buttonCancel_Click(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.Cancel;
            this.Close();
        }
        #endregion
    }
}