using System;
using System.Collections.Generic;
using System.Drawing;
namespace DrawGraph
{
    public class FactEvents : EventObj
    {
        #region Model
        private int _id;
        private int? _eventtypeid;
        private int? _patientid;
        private int? _eventid;
        private string _eventname;
        private DateTime? _eventbegintime;
        private DateTime? _eventendtime;
        private int? _iscontinue;
        private string _remark;
        private string _operatorno;
        private string _operatorname;
        private DateTime? _operatedate; 
        private string eventValue;
        private string extend1;
        private string extend2;
        private string extend3;
        public string EventRemark;
        /// 
        /// 
        /// 
        public int Id
        {
            set { _id = value; }
            get { return _id; }
        }
        /// 
        /// 
        /// 
        public int? EventTypeId
        {
            set { _eventtypeid = value; }
            get { return _eventtypeid; }
        }
        /// 
        /// 
        /// 
        public int? PatientId
        {
            set { _patientid = value; }
            get { return _patientid; }
        }
        /// 
        /// 
        /// 
        public int? EventId
        {
            set { _eventid = value; }
            get { return _eventid; }
        }
        public string EventName
        {
            set { _eventname = value; }
            get { return _eventname; }
        }
        /// 
        /// 
        /// 
        public DateTime? EventBeginTime
        {
            set { _eventbegintime = value; }
            get { return _eventbegintime; }
        }
        /// 
        /// 
        /// 
        public DateTime? EventEndTime
        {
            set { _eventendtime = value; }
            get { return _eventendtime; }
        }
        /// 
        /// 
        /// 
        public int? IsContinue
        {
            set { _iscontinue = value; }
            get { return _iscontinue; }
        }
        /// 
        /// 
        /// 
        public string Remark
        {
            set { _remark = value; }
            get { return _remark; }
        }
        /// 
        /// 
        /// 
        public string OperatorNo
        {
            set { _operatorno = value; }
            get { return _operatorno; }
        }
        /// 
        /// 
        /// 
        public string OperatorName
        {
            set { _operatorname = value; }
            get { return _operatorname; }
        }
        /// 
        /// 
        /// 
        public DateTime? OperateDate
        {
            set { _operatedate = value; }
            get { return _operatedate; }
        }
        /// 
        /// 
        /// 
        public string EventValue
        {
            set { eventValue = value; }
            get { return eventValue; }
        }
        /// 
        /// 
        /// 
        public string Extend1
        {
            get { return extend1; }
            set { extend1 = value; }
        }
        /// 
        /// 
        /// 
        public string Extend2
        {
            get { return extend2; }
            set { extend2 = value; }
        }
        /// 
        /// 
        /// 
        public string Extend3
        {
            get { return extend3; }
            set { extend3 = value; }
        }
        #endregion Model
        /// 
        /// 清空所有与某条事件相关的控件。
        /// 
        /// 麻醉窗体
        public override void clearAddObj(ZedGraphControl zgc)
        {
            if (zgcAnas == null || zgcAnas != zgc) zgcAnas = zgc;
            //delAddEventObj("TD", AEvent.EventName.ToString());
            delAddObj(TextPrefix.DN + this.EventName + this.EventId.ToString());
            delAddObj(TextPrefix.DT + this.EventName + this.EventId.ToString());
            delAddObj(TextPrefix.DD + this.EventName + this.EventId.ToString());
            delAddObj(TextPrefix.DD + this.EventName + this.EventId.ToString() + "spicle");
            delAddArrows(TextPrefix.AR + this.EventName + this.EventId.ToString());
            delAddImg(TextPrefix.IM + this.EventName + this.EventId.ToString());
        }
        public override void clearDNAndDT(ZedGraphControl zgc)
        {
            if (zgcAnas == null || zgcAnas != zgc) zgcAnas = zgc;
            delAddObj(TextPrefix.DN + this.EventName  + this.EventId.ToString());
            delAddObj(TextPrefix.DT + this.EventName  + this.EventId.ToString());
            //delAddObj(TextPrefix.IM + this.EventRef.Name + this.EventId.ToString());
        }
        /// 
        /// 根据事件对象重画图片
        /// 
        /// 
        public void drawIMG(ZedGraphControl zgc, string picName, double y, double width)//EventRecord EventRecord)
        {
            if (zgcAnas == null || zgcAnas != zgc) zgcAnas = zgc;
            string resName = picName;
            DateTime ps = pageBegin;                                  //页面开始时间
            DateTime pe = pageEnd; //页面结束时间
            DateTime ads = EventBeginTime.Value.AddMinutes(-2);
            if (EventBeginTime.Value.Hour == pageBegin.Hour && EventBeginTime.Value.Minute - pageBegin.Minute <= 3) ads = EventBeginTime.Value;  //事件开始时间
            DateTime ade = EventEndTime.Value;                              //事件结束时间
            double x1 = getXPositinByXDate(ads);
            double height = width;
            //清除该图片重画
            delAddImg(TextPrefix.IM + this.EventName + this.EventId);
            if (ads < pe && ads >= ps)
            {
                ZUtil.DrawImage(resName, x1, y, width, height, zgcAnas, TextPrefix.IM + this.EventName + this.EventId);
            }
        }
        /// 
        /// 根据事件对象重画图片
        /// 
        /// 
        public void drawNumber(ZedGraphControl zgc, string picName, double y, int DValue, Color fontColor)//EventRecord EventRecord)
        {
            if (zgcAnas == null || zgcAnas != zgc) zgcAnas = zgc;
            string resName = picName;
            DateTime ps = pageBegin;                                  //页面开始时间
            DateTime pe = pageEnd; //页面结束时间
            DateTime ads = EventBeginTime.Value.AddMinutes(-3 - DValue);
            if (EventBeginTime.Value.Hour == pageBegin.Hour && EventBeginTime.Value.Minute - pageBegin.Minute <= 3) ads = EventBeginTime.Value;  //事件开始时间
            DateTime ade = EventEndTime.Value;                              //事件结束时间
            double x1 = getXPositinByXDate(ads);
            //清除该图片重画
            delAddImg(TextPrefix.DN + this.EventName + this.EventId);
            if (ads < pe.AddMinutes(2.5) && ads >= ps.AddMinutes(-2.5))
            {
                ZUtil.DrawText(picName, x1, y, zgcAnas, TextPrefix.DN + this.EventName + this.EventId, fontColor, 6.3f);
            }
        }
    }
    /// 
    /// 事件排序类
    /// 
    public class FactEventsComparer : IComparer
    {
        public int Compare(FactEvents x, FactEvents y)
        {
            return (x.EventBeginTime.Value.CompareTo(y.EventBeginTime.Value));
        }
    }
}