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 INT63DC_6CH.Forms;

namespace INT63DC_6CH.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.InitializeControl();
            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.E_LanguageID.Chinese)
            {

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

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

            }
        }
        private void InitializeControl()
        {
            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(710, 470);
        }
        private void DefaultSetting()
        {
            this.UpdateDisplay(this.ParentForm.ParentForm.CurrentDataViewerFilter);            
        }

        private void UpdateDisplay(DataViewerFilter filter)
        {
            this.checkBoxTypeAlarm.Checked = filter.TypeAlarm;
            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.TypeAlarm = 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
    }
}