private void InitScreen() { int nResult = BxDriver.Initialize(); if (0 != nResult) { BxDriver.GetErrorMessage("Initialize", nResult); return; } else { bScreenDllInit = true; } Thread thread = new Thread(ThreadMethod); thread.IsBackground = true; thread.Name = "AsyMonitor"; thread.Start(); Thread thread2 = new Thread(ThreadMethod2); thread2.IsBackground = true; thread2.Name = "ReflashScreen"; thread2.Start(); //Console.WriteLine("主线程:" + Thread.CurrentThread.ManagedThreadId + "运行"); //timer = new System.Threading.Timer( // new System.Threading.TimerCallback(ThreadMethod), null, 5, 5000); //timer2 = new System.Threading.Timer( // new System.Threading.TimerCallback(ThreadMethod2), null, 5, 10000); }
private void Button_Download_Click(object sender, RoutedEventArgs e) { string setResult = ""; double leftRatio = this.leftGrid.ActualWidth / this.mainGrid.ActualWidth; double titleRatio = this.rightTitle.ActualHeight / this.mainGrid.ActualHeight; if (!BxDriver.SetScreenPara(screenParamUse, leftRatio, titleRatio, out setResult)) { MessageBox.Show(setResult, "下载屏幕参数", MessageBoxButton.OK, MessageBoxImage.Warning); } }
public void ThreadMethod2(object sender) { while (true) { string strResult = ""; BxDriver.ReflashDynamicArea(myScreen1Param.ScreenParam, 0, out strResult); Thread.Sleep(500); BxDriver.ReflashDynamicArea(myScreen2Param.ScreenParam, 0, out strResult); Thread.Sleep(500); } }
private void Window_Loaded(object sender, RoutedEventArgs e) { string setResult = ""; double leftRatio = this.leftGrid.ActualWidth / this.mainGrid.ActualWidth; double titleRatio = this.rightTitle.ActualHeight / this.mainGrid.ActualHeight; if (!BxDriver.SetScreenPara(myScreen1Param.ScreenParam, leftRatio, titleRatio, out setResult)) { MessageBox.Show(setResult, "下载屏幕参数", MessageBoxButton.OK, MessageBoxImage.Warning); } if (!BxDriver.SetScreenPara(myScreen2Param.ScreenParam, leftRatio, titleRatio, out setResult)) { MessageBox.Show(setResult, "下载屏幕参数", MessageBoxButton.OK, MessageBoxImage.Warning); } }
private void Window_Close(object sender, System.ComponentModel.CancelEventArgs e) { MessageBoxResult message = MessageBox.Show("确定要退出本程序?", "温馨提示", MessageBoxButton.YesNo, MessageBoxImage.Information); if (message == MessageBoxResult.No) { e.Cancel = true; } else { if (bScreenDllInit) { int nResult = BxDriver.Uninitialize(); if (0 != nResult) { BxDriver.GetErrorMessage("Uninitialize", nResult); } else { bScreenDllInit = true; } } } }
public static bool SetScreenPara(ScreenParam screenParam, double leftRatio, double titleRatio, out string strResult) { int nResult = DeleteScreen_Dynamic(screenParam.Id); strResult = ""; if (0 != nResult) { strResult = BxDriver.GetErrorMessage("执行DeleteScreen函数,", nResult); } nResult = BxDriver.AddScreen_Dynamic(BxDriver.CONTROLLER_BX_5E1, screenParam.Id, SEND_MODE_NETWORK, screenParam.Width , screenParam.High, screenParam.Type, 1 , "COM1", 9600 , screenParam.IpAddr, Convert.ToInt32(screenParam.Port), 0, 0, "", "" , "", 0, "", "" , ""); if (0 != nResult) { strResult = GetErrorMessage("执行AddScreen函数,", nResult); return(false); } int leftWidth = (int)(screenParam.Width * leftRatio); int rightWidth = screenParam.Width - leftWidth; //左侧 nResult = AddScreenDynamicArea(screenParam.Id, 0, RUN_MODE_CYCLE_SHOW , 5, 0, "", 1 , 0, 0, leftWidth - 2, screenParam.High - 5 , 255, 0, 255 , 1, 0, 1); if (0 != nResult) { strResult = GetErrorMessage("执行AddScreenDynamicArea函数,", nResult); return(false); } if (System.IO.File.Exists(screenParam.Reader.MonitorText)) { Color color = ColorTranslator.FromHtml(screenParam.LeftContextFontColor); int colorValue = color.B << 16 | color.G << 8 | color.R; //int colorValue = Convert.ToInt32(screenParam.LeftContextFontColor); nResult = AddScreenDynamicAreaFile(screenParam.Id, 0 , screenParam.Reader.MonitorText, 0, 0, screenParam.LeftContextFontName, screenParam.LeftContextFontSize, 0, colorValue , 1, 2, 1); if (0 != nResult) { strResult = GetErrorMessage("执行AddScreenDynamicAreaFile函数, ", nResult); return(false); } } int titleHigh = (int)(screenParam.High * titleRatio); //右侧 nResult = AddScreenDynamicArea(screenParam.Id, 1, RUN_MODE_CYCLE_SHOW , 5, 0, "", 1 , leftWidth + 2, 0, rightWidth - 2, screenParam.High - (2 + titleHigh + 10) , 255, 0, 255 , 1, 0, 1); if (0 != nResult) { strResult = GetErrorMessage("执行AddScreenDynamicArea函数,", nResult); return(false); } if (System.IO.File.Exists(screenParam.Reader.NoteText)) { Color color = ColorTranslator.FromHtml(screenParam.RightContextFontColor); int colorValue = color.B << 16 | color.G << 8 | color.R; //int colorValue = Convert.ToInt32(screenParam.RightContextFontColor); nResult = AddScreenDynamicAreaFile(screenParam.Id, 1 , screenParam.Reader.NoteText, 0, 0, screenParam.RightContextFontName, screenParam.RightContextFontSize, 0, colorValue , 5, 10, 10); if (0 != nResult) { strResult = GetErrorMessage("执行AddScreenDynamicAreaFile函数, ", nResult); return(false); } } Thread.Sleep(100); return(true); }