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 }
public Form1() { Log.Logger = new LoggerConfiguration() .WriteTo.Console() .WriteTo.File($"{AppDomain.CurrentDomain.BaseDirectory}\\log\\log-.txt", rollingInterval: RollingInterval.Day, outputTemplate: "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level:u3}] {Message:lj}{NewLine}{Exception}") .CreateLogger(); //宣告Serilog初始化 MySqlSetting = InitialMethod.MySqlLoad(); ButtonSetting = InitialMethod.InitialButtonLoad(); InitializeComponent(); NavigationFrame = new NavigationFrame() { Dock = DockStyle.Fill }; NavigationFrame.Parent = DisPlaypanelControl; ButtonMethod = new ButtonMethod() { Form1 = this, navigationFrame = NavigationFrame }; ButtonMethod.AccordionLoad(accordionControl1, ButtonSetting); #region Ewatch平台 Ewatch_MySqlMethod = new Ewatch_MySqlMethod(MySqlSetting); Ewatch_MySqlComponent = new Ewatch_MySqlComponent(Ewatch_MySqlMethod); Ewatch_MySqlComponent.MyWorkState = true; Ewatch_Field4Component.Add(Ewatch_MySqlComponent); Ewatch_AlarmComponent = new Ewatch_AlarmComponent(Ewatch_MySqlMethod); Ewatch_AlarmComponent.MyWorkState = true; Ewatch_Field4Component.Add(Ewatch_AlarmComponent); EwatchConnectionUserControl ewatchConnectionUserControl = new EwatchConnectionUserControl(Ewatch_MySqlComponent) { Dock = DockStyle.Fill }; NavigationFrame.AddPage(ewatchConnectionUserControl); Ewatch_Field4UserControl.Add(ewatchConnectionUserControl); CaseUserControl caseUserControl = new CaseUserControl(Ewatch_MySqlMethod) { Form1 = this, Dock = DockStyle.Fill }; NavigationFrame.AddPage(caseUserControl); Ewatch_Field4UserControl.Add(caseUserControl); AiSettingUserControl aiSettingUserControl = new AiSettingUserControl(Ewatch_MySqlMethod) { Form1 = this, Dock = DockStyle.Fill }; NavigationFrame.AddPage(aiSettingUserControl); Ewatch_Field4UserControl.Add(aiSettingUserControl); AiConfigUserControl aiConfigUserControl = new AiConfigUserControl(Ewatch_MySqlMethod) { Form1 = this, Dock = DockStyle.Fill }; NavigationFrame.AddPage(aiConfigUserControl); Ewatch_Field4UserControl.Add(aiConfigUserControl); ElectricSettingUserControl electricSettingUserControl = new ElectricSettingUserControl(Ewatch_MySqlMethod) { Form1 = this, Dock = DockStyle.Fill }; NavigationFrame.AddPage(electricSettingUserControl); Ewatch_Field4UserControl.Add(electricSettingUserControl); StateSettingUserControl stateSettingUserControl = new StateSettingUserControl(Ewatch_MySqlMethod) { Form1 = this, Dock = DockStyle.Fill }; NavigationFrame.AddPage(stateSettingUserControl); Ewatch_Field4UserControl.Add(stateSettingUserControl); #endregion #region ChungHsin平台 ChungHsin_MySqlMethod = new ChungHsin_MySqlMethod(MySqlSetting); ChungHsin_MySqlComponent = new ChungHsin_MySqlComponent(ChungHsin_MySqlMethod); ChungHsin_MySqlComponent.MyWorkState = true; ChungHsin_Field4Component.Add(ChungHsin_MySqlComponent); ChumgHsinConnectionUserControl chumgHsinConnectionUserControl = new ChumgHsinConnectionUserControl(ChungHsin_MySqlComponent) { Dock = DockStyle.Fill }; NavigationFrame.AddPage(chumgHsinConnectionUserControl); ChungHsin_Field4UserControl.Add(chumgHsinConnectionUserControl); DeviceConfigUserControl deviceConfigUserControl = new DeviceConfigUserControl(ChungHsin_MySqlMethod) { Dock = DockStyle.Fill }; NavigationFrame.AddPage(deviceConfigUserControl); ChungHsin_Field4UserControl.Add(deviceConfigUserControl); CH_CaseSettingUserControl cH_CaseSettingUserControl = new CH_CaseSettingUserControl(ChungHsin_MySqlMethod) { Dock = DockStyle.Fill }; NavigationFrame.AddPage(cH_CaseSettingUserControl); ChungHsin_Field4UserControl.Add(cH_CaseSettingUserControl); ReceiveSettingUserControl receiveSettingUserControl = new ReceiveSettingUserControl(ChungHsin_MySqlMethod) { Dock = DockStyle.Fill }; NavigationFrame.AddPage(receiveSettingUserControl); ChungHsin_Field4UserControl.Add(receiveSettingUserControl); #endregion timer1.Interval = 1000; timer1.Enabled = true; }