/// <summary>
 /// 斷線偵測畫面
 /// </summary>
 /// <param name="ewatch_MySqlComponent">資料庫方法</param>
 public EwatchConnectionUserControl(Ewatch_MySqlComponent ewatch_MySqlComponent)
 {
     Ewatch_MySqlComponent = ewatch_MySqlComponent;
     CaseSettings          = ewatch_MySqlComponent.CaseSettings;
     AiSettings            = ewatch_MySqlComponent.AiSettings;
     ElectricSettings      = ewatch_MySqlComponent.ElectricSettings;
     InitializeComponent();
     #region AI斷線資訊
     AigridControl.DataSource           = AiSettings;
     gridView1.OptionsBehavior.Editable = false;
     gridView1.OptionsSelection.EnableAppearanceFocusedCell = false;
     for (int i = 0; i < gridView1.Columns.Count; i++)
     {
         gridView1.Columns[i].BestFit();
     }
     gridView1.Columns["PK"].Visible             = false;
     gridView1.Columns["NotifyFlag"].Visible     = false;
     gridView1.Columns["CaseNo"].Caption         = "案場名稱";
     gridView1.Columns["AiNo"].Caption           = "Ai編號";
     gridView1.Columns["AiName"].Caption         = "Ai名稱";
     gridView1.Columns["NotifyFlag"].Visible     = false;
     gridView1.Columns["TimeoutSpan"].Visible    = false;
     gridView1.Columns["MTimeoutSpan"].Visible   = false;
     gridView1.Columns["SendTime"].Visible       = false;
     gridView1.Columns["ConnectionFlag"].Caption = "連線狀態";
     #region 案場名稱顯示功能
     gridView1.CustomColumnDisplayText += (s, e) =>
     {
         if (e.Column.FieldName.ToString() == "CaseNo")
         {
             string cellValue = e.Value.ToString();
             var    data      = CaseSettings.SingleOrDefault(g => g.CaseNo == cellValue);
             if (data != null)
             {
                 e.DisplayText = data.TitleName;
             }
         }
     };
     #endregion
     #region 斷線燈號顯示功能
     gridView1.CustomDrawCell += (s, e) =>
     {
         e.Appearance.TextOptions.HAlignment = HorzAlignment.Center;
         e.Appearance.Options.UseTextOptions = true;
         e.DefaultDraw();
         if (e.Column.FieldName == "ConnectionFlag")
         {
             Color  color;
             string cellValue = e.CellValue.ToString();
             if (cellValue == "不使用")
             {
                 color = normalPriority;
             }
             else if (cellValue == "斷線")
             {
                 color = highPriority;
             }
             else
             {
                 color = lowPriority;
             }
             e.Cache.FillEllipse(e.Bounds.X + 204, e.Bounds.Y + 1, markWidth, markWidth, color);
         }
     };
     #endregion
     #endregion
     #region 電表斷線資訊
     ElectricgridControl.DataSource     = ElectricSettings;
     gridView2.OptionsBehavior.Editable = false;
     gridView2.OptionsSelection.EnableAppearanceFocusedCell = false;
     for (int i = 0; i < gridView2.Columns.Count; i++)
     {
         gridView2.Columns[i].BestFit();
     }
     gridView2.Columns["PK"].Visible             = false;
     gridView2.Columns["CaseNo"].Caption         = "案場編號";
     gridView2.Columns["ElectricNo"].Caption     = "電表編號";
     gridView2.Columns["PhaseTypeEnum"].Caption  = "相位類型";
     gridView2.Columns["ElectricName"].Caption   = "電表名稱";
     gridView2.Columns["NotifyFlag"].Visible     = false;
     gridView2.Columns["TimeoutSpan"].Visible    = false;
     gridView2.Columns["MTimeoutSpan"].Visible   = false;
     gridView2.Columns["SendTime"].Visible       = false;
     gridView2.Columns["ConnectionFlag"].Caption = "連線狀態";
     #region 相位類型顯示功能
     gridView2.CustomColumnDisplayText += (s, e) =>
     {
         if (e.Column.FieldName.ToString() == "PhaseTypeEnum")
         {
             int cellValue = Convert.ToInt32(e.Value);
             if (cellValue == 0)
             {
                 e.DisplayText = "三相";
             }
             else if (cellValue == 1)
             {
                 e.DisplayText = "單相";
             }
         }
         else if (e.Column.FieldName.ToString() == "CaseNo")
         {
             string cellValue = e.Value.ToString();
             var    data      = CaseSettings.SingleOrDefault(g => g.CaseNo == cellValue);
             if (data != null)
             {
                 e.DisplayText = data.TitleName;
             }
         }
     };
     #endregion
     #region 斷線燈號顯示功能
     gridView2.CustomDrawCell += (s, e) =>
     {
         e.Appearance.TextOptions.HAlignment = HorzAlignment.Center;
         e.Appearance.Options.UseTextOptions = true;
         e.DefaultDraw();
         if (e.Column.FieldName == "ConnectionFlag")
         {
             Color  color;
             string cellValue = e.CellValue.ToString();
             if (cellValue == "不使用")
             {
                 color = normalPriority;
             }
             else if (cellValue == "斷線")
             {
                 color = highPriority;
             }
             else
             {
                 color = lowPriority;
             }
             e.Cache.FillEllipse(e.Bounds.X + 150, e.Bounds.Y + 1, markWidth, markWidth, color);
         }
     };
     #endregion
     #endregion
 }
 public ChumgHsinConnectionUserControl(ChungHsin_MySqlComponent chungHsin_MySqlComponent)
 {
     ChungHsin_MySqlComponent = chungHsin_MySqlComponent;
     CaseSettings             = chungHsin_MySqlComponent.CaseSettings;
     ReceiveSettings          = chungHsin_MySqlComponent.ReceiveSettings;
     DeviceConfigs            = chungHsin_MySqlComponent.DeviceConfigs;
     InitializeComponent();
     #region Receive斷線資訊
     AigridControl.DataSource           = ReceiveSettings;
     gridView1.OptionsBehavior.Editable = false;
     gridView1.OptionsSelection.EnableAppearanceFocusedCell = false;
     for (int i = 0; i < gridView1.Columns.Count; i++)
     {
         gridView1.Columns[i].BestFit();
     }
     gridView1.Columns["PK"].Visible             = false;
     gridView1.Columns["NotifyFlag"].Visible     = false;
     gridView1.Columns["DeviceTypeEnum"].Caption = "設備類型";
     gridView1.Columns["CaseNo"].Caption         = "案場名稱";
     gridView1.Columns["ReceiveNo"].Caption      = "Receive編號";
     gridView1.Columns["ReceiveName"].Caption    = "Receive名稱";
     gridView1.Columns["NotifyFlag"].Visible     = false;
     gridView1.Columns["HTimeoutSpan"].Visible   = false;
     gridView1.Columns["MTimeoutSpan"].Visible   = false;
     gridView1.Columns["SendTime"].Visible       = false;
     gridView1.Columns["ConnectionFlag"].Caption = "連線狀態";
     #region 案場名稱顯示功能
     gridView1.CustomColumnDisplayText += (s, e) =>
     {
         if (e.Column.FieldName.ToString() == "CaseNo")
         {
             string cellValue = e.Value.ToString();
             var    data      = CaseSettings.SingleOrDefault(g => g.CaseNo == cellValue);
             if (data != null)
             {
                 e.DisplayText = data.TitleName;
             }
         }
         else if (e.Column.FieldName.ToString() == "DeviceTypeEnum")
         {
             int cellValue = Convert.ToInt32(e.Value);
             var data      = DeviceConfigs.SingleOrDefault(g => g.DeviceTypeEnum == cellValue);
             if (data != null)
             {
                 e.DisplayText = data.DeviceName;
             }
         }
     };
     #endregion
     #region 斷線燈號顯示功能
     gridView1.CustomDrawCell += (s, e) =>
     {
         e.Appearance.TextOptions.HAlignment = HorzAlignment.Center;
         e.Appearance.Options.UseTextOptions = true;
         e.DefaultDraw();
         if (e.Column.FieldName == "ConnectionFlag")
         {
             Color  color;
             string cellValue = e.CellValue.ToString();
             if (cellValue == "不使用")
             {
                 color = normalPriority;
             }
             else if (cellValue == "斷線")
             {
                 color = highPriority;
             }
             else
             {
                 color = lowPriority;
             }
             e.Cache.FillEllipse(e.Bounds.X + 150, e.Bounds.Y + 1, markWidth, markWidth, color);
         }
     };
     #endregion
     #endregion
 }