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


namespace vmsnet.HMI
{
    [TypeConverterAttribute(typeof(ExpandableObjectConverter)), Serializable()]
    public partial class CWINDOW
    {
        private int idx;
        private String title;
        private String matrix;
       // public RectangleF R = new RectangleF(0, 0, 0, 0);
        public Single _itemwidth;
        public Single _itemheight;
        private int rowcount;
        private int columncount;
        //private Single alamh;
        //private Single alaml;
        private Boolean _debug=false;

        ////연결종료된시간이있다.
        //public UInt16 disconnecttime = 0;
        //public UInt16 restarttime = 0;
      
               
        public delegate void OnChangeDataHandler();
        public event OnChangeDataHandler OnChangeData;

        public CWINDOW()
        {
            idx = 0;
            title = "WINDOW";
            matrix = "1x1";
            _itemwidth = 0;
            _itemheight = 0;
        }

        public CWINDOW(String ptitle, String pMatrix, Single iw, Single ih)
        {
            this.title = ptitle;
            this.matrix = pMatrix;
            this._itemheight = ih;
            this._itemwidth = iw;
            //this.R = r;
        }

        [DesignerSerializationVisibility(DesignerSerializationVisibility.Content), Category("개발자"), Description("debug Mode")]
        public Boolean Debug
        {
            get { return _debug; }
            set { _debug = value; }
        }


        //[DesignerSerializationVisibility(DesignerSerializationVisibility.Content), Category("알람설정"), Description("상위 알람값입니다.")]
        //public Single HIGH
        //{
        //    get { return alamh; }
        //    set { alamh = value;
        //    try { OnChangeData(); }
        //    catch { }
        //    }
        //}

        //[DesignerSerializationVisibility(DesignerSerializationVisibility.Content), Category("알람설정"), Description("하위 알람값입니다.")]
        //public Single LOW
        //{
        //    get { return alaml; }
        //    set { alaml = value;
        //    try { OnChangeData(); }
        //    catch { }
        //    }
        //}

        [DesignerSerializationVisibility(DesignerSerializationVisibility.Content), Category("x"), Description("x"),Browsable(false)]
        public Single ITEMWIDTH
        {
            get { return _itemwidth; }
        }

        [DesignerSerializationVisibility(DesignerSerializationVisibility.Content), Category("x"), Description("x"), Browsable(false)]
        public Single ITEMHEIGHT
        {
            get { return _itemheight; }
        }


        [DesignerSerializationVisibility(DesignerSerializationVisibility.Content), Category("Appearance"), Description("Appearance and Style"),Browsable(true)]
        public int IDX
        {
            get { return idx; }
            set { idx = value; }
        }

        [DesignerSerializationVisibility(DesignerSerializationVisibility.Content), Category("일반"), Description("해당 윈도우의 이름입니다.")]
        public String 이름
        {
            get { return title; }
            set { title = value;
            if (OnChangeData != null) OnChangeData();        
            }
        }

        [DesignerSerializationVisibility(DesignerSerializationVisibility.Content), Category("Appearance"), Description("Appearance and Style"),Browsable(false)]
        public String MATRIX
        {
            get { return matrix; }
            set
            {
                matrix = value.Replace("*","x").Replace("X","x");                
                this.rowcount = Int32.Parse(matrix.Split(new Char[] { 'x' })[0]);
                this.columncount = Int32.Parse(matrix.Split(new Char[] { 'x' })[1]);
            }
        }
         [DesignerSerializationVisibility(DesignerSerializationVisibility.Content), Category("Appearance"), Description("Appearance and Style"), Browsable(false)]
        public int RowCount
        {
            get
            {
                if (this.rowcount == 0)
                {
                    this.rowcount = Int32.Parse(matrix.Split(new Char[] { 'x' })[0]);

                }
                return this.rowcount;
            }
        }

         [DesignerSerializationVisibility(DesignerSerializationVisibility.Content), Category("Appearance"), Description("Appearance and Style"), Browsable(false)]
        public int CoulumnCount
        {
            get
            {
                if (this.columncount == 0)
                {
                    this.columncount = Int32.Parse(matrix.Split(new Char[] { 'x' })[1]);
                }
                return this.columncount;
            }
        }
  
    }
}
