protected override void DrawGrid(Graphics drawZoonGraphic, RectangularGridInfo curGird) { base.DrawGrid(drawZoonGraphic, curGird); _tempCustomInfo = new SetCustomObjInfo(); _tempCustomInfo = (SetCustomObjInfo)curGird.CustomObj; if (_tempCustomInfo == null) { return; } _oneHeight = curGird.DrawRegion.Height - this.DefaultStyle.BoardWidth; _strSizeF = GetStrSize(drawZoonGraphic, _tempCustomInfo.Count.ToString()); if (GetImageRectFAndDetectIsDrawStr(new RectangleF(curGird.DrawRegion.X, curGird.DrawRegion.Y, curGird.DrawRegion.Width - this.DefaultStyle.BoardWidth, curGird.DrawRegion.Height - this.DefaultStyle.BoardWidth), _strSizeF, out _imageRectF)) { _strRectF = new RectangleF(curGird.DrawRegion.X + _imageRectF.Width + ImageAndStrInterval * 2, curGird.DrawRegion.Y, curGird.DrawRegion.Width - _imageRectF.Width - ImageAndStrInterval * 2, _oneHeight); DrawStrForLeft(drawZoonGraphic, _tempCustomInfo.Count.ToString(), _strRectF); } if (_commonInfo.IconImage != null) { drawZoonGraphic.DrawImage(_commonInfo.IconImage, _imageRectF); } #region Bitmap -- Test //if (_isDrawBitMap) //{ // _tempBitMap1 = new Bitmap(_fanImage, (int)_imageRectF.Width, (int)_imageRectF.Height); // _bmpInf.bmiHeader.biHeight = -_tempBitMap1.Height; // _lineBytes = ((_tempBitMap1.Width * 24 + 32) >> 5) << 2; // _bmpInf.bmiHeader.biSizeImage = _lineBytes * _tempBitMap1.Height; // _bmpInf.bmiHeader.biWidth = _tempBitMap1.Width; // _tempBitMap = _tempBitMap1.Clone(new Rectangle(0, 0, _tempBitMap1.Width, _tempBitMap1.Height), // PixelFormat.Format32bppArgb); // _bmpData = _tempBitMap.LockBits(new Rectangle(0, 0, _tempBitMap.Width, _tempBitMap.Height), // ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb); // _hDrawPanel = drawZoonGraphic.GetHdc(); // SetDIBitsToDevice(_hDrawPanel, (int)_imageRectF.X, (int)_imageRectF.Y, (uint)_imageRectF.Width, // (uint)_imageRectF.Height, 0, 0, (uint)0, (uint)_tempBitMap.Height, _bmpData.Scan0, // ref _bmpInf, 0); // _tempBitMap.UnlockBits(_bmpData); // drawZoonGraphic.ReleaseHdc(_hDrawPanel); // _tempBitMap.Dispose(); // _tempBitMap1.Dispose(); //} //else //{ // drawZoonGraphic.DrawImage(_fanImage, _imageRectF); //} #endregion }
/// <summary> /// 鼠标移动事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void StandarAndSimpleLayout_GridMouseMove(object sender, RectangularGridMouseEventArgs e) { if (_customToolTip == null) { _customToolTip = new CustomToolTip(); _customToolTip.Owner = this.ParentForm; _customToolTip.TipContentFont = _customToolTipFont; } if (e.GridInfo == null) { //当前鼠标移动到的区域无矩形格子 _customToolTip.SetTipInfo(_standarAndSimpleLayout.DrawPanel, null); Debug.WriteLine("进入格子的GridMouseMove事件,并获取的格子信息为空"); return; } RectangularGridInfo scanBordGridInfo = _standarAndSimpleLayout[e.GridInfo.Key]; List <string> noticeStrList = null; if (scanBordGridInfo != null) { _tempCustomInfo = (SetCustomObjInfo)scanBordGridInfo.CustomObj; if (_tempCustomInfo == null) { _customToolTip.SetTipInfo(_standarAndSimpleLayout.DrawPanel, null); return; } noticeStrList = new List <string>(); _tempCnt = _tempCustomInfo.Count; noticeStrList.Add(StaticValue.SenderName + ":" + (_tempCustomInfo.ScanBordInfo.SenderIndex + 1)); noticeStrList.Add(StaticValue.PortName + ":" + (_tempCustomInfo.ScanBordInfo.PortIndex + 1)); noticeStrList.Add(StaticValue.ScanBoardName + ":" + (_tempCustomInfo.ScanBordInfo.ConnectIndex + 1)); noticeStrList.Add("(X, Y):(" + e.GridInfo.Region.X + "," + e.GridInfo.Region.Y + ")"); noticeStrList.Add("(W, H):(" + e.GridInfo.Region.Width + "," + e.GridInfo.Region.Height + ")"); noticeStrList.Add(StaticValue.CountStr + ":" + _tempCustomInfo.Count); } _customToolTip.SetTipInfo(_standarAndSimpleLayout.DrawPanel, noticeStrList); if (!_customToolTip.TopLevel) { _customToolTip.TopLevel = true; } }
protected override void DrawGrid(Graphics drawZoonGraphic, RectangularGridInfo curGird) { if (curGird == null) { return; } if (_isDisplayAll) { return; } IGridBiningObject customObj = (IGridBiningObject)curGird.CustomObj; Color backColor = Color.Gray; int nValue = 0; bool bTempOrHumiInvalid = false; if (customObj.Type == GridType.ScanBoardGird) { ScanBoardGridBindObj scanBoardGridObj = (ScanBoardGridBindObj)customObj; #region ��ȡ���ӱ�����ɫ if (customObj != null) { switch (_curType) { case MonitorDisplayType.SBStatus: GetMonitorColorAndValue.GetSBStatusColorAndStr(scanBoardGridObj.ScanBoardAndMonitorInfo.MonitorData, ref backColor); curGird.Style.BackColor = backColor; break; case MonitorDisplayType.MCStatus: GetMonitorColorAndValue.GetMCStatusColorAndStr(scanBoardGridObj.ScanBoardAndMonitorInfo.MonitorData, ref backColor); curGird.Style.BackColor = backColor; break; case MonitorDisplayType.Smoke: GetMonitorColorAndValue.GetSmokeColorAndStr(scanBoardGridObj.ScanBoardAndMonitorInfo.MonitorData, ref backColor); curGird.Style.BackColor = backColor; break; case MonitorDisplayType.Temperature: bTempOrHumiInvalid = !GetMonitorColorAndValue.DetectTempIsValidAndGetInfo(_clrGradePartition, _curMonitorConfigInfo.TempDisplayType, scanBoardGridObj.ScanBoardAndMonitorInfo.MonitorData, ref nValue, ref backColor); curGird.Style.BackColor = backColor; break; case MonitorDisplayType.Humidity: bTempOrHumiInvalid = !GetMonitorColorAndValue.DetectHumiValidAndGetInfo(_clrGradePartition, scanBoardGridObj.ScanBoardAndMonitorInfo.MonitorData, ref nValue, ref backColor); curGird.Style.BackColor = backColor; break; case MonitorDisplayType.Fan: curGird.Style.BackColor = Color.Gray; break; case MonitorDisplayType.Power: curGird.Style.BackColor = Color.Gray; break; case MonitorDisplayType.RowLine: GetMonitorColorAndValue.GetRowLineCorAndStr(scanBoardGridObj.ScanBoardAndMonitorInfo.MonitorData, scanBoardGridObj.ScanBoardAndMonitorInfo.RowLineStatus, ref backColor); curGird.Style.BackColor = backColor; break; case MonitorDisplayType.GeneralSwitch: GetMonitorColorAndValue.GetGeneralSwitchClr(scanBoardGridObj.ScanBoardAndMonitorInfo.MonitorData, scanBoardGridObj.ScanBoardAndMonitorInfo.GeneralSwitchList, ref backColor); curGird.Style.BackColor = backColor; break; } } #endregion base.DrawGrid(drawZoonGraphic, curGird); #region ���Ƹ����ϵ��ַ�����ͼ�� if (scanBoardGridObj.ScanBoardAndMonitorInfo.MonitorData == null) { return; } RectangleF drawRect = new RectangleF(curGird.DrawRegion.X + this.DefaultStyle.BoardWidth / 2, curGird.DrawRegion.Y + this.DefaultStyle.BoardWidth / 2, curGird.DrawRegion.Width - this.DefaultStyle.BoardWidth, curGird.DrawRegion.Height - this.DefaultStyle.BoardWidth); ScannerMonitorData monitorInfo = (ScannerMonitorData)scanBoardGridObj.ScanBoardAndMonitorInfo.MonitorData.Clone(); if (customObj != null && monitorInfo != null) { if (_curType == MonitorDisplayType.Temperature || _curType == MonitorDisplayType.Humidity) { #region ������ʪ���ַ��� if (bTempOrHumiInvalid) { return; } _strSize = GetStrSize(drawZoonGraphic, nValue.ToString()); if (_strSize.Width > drawRect.Width || _strSize.Height > drawRect.Height) { //���ܽ��ַ������Ƴ��� return; } DrawStrForCenter(drawZoonGraphic, nValue.ToString(), drawRect); #endregion } else if (_curType == MonitorDisplayType.Fan || _curType == MonitorDisplayType.Power) { ValueInfo valueInfo = new ValueInfo(); float fSwitchHeight = 0; Image drawImage = null; bool isDrawStr = false; float drawImageHeight = 0; float imageSize = 0; if (_curType == MonitorDisplayType.Fan) { #region ���Ʒ��ȷָ��� _curMCFanCnt = GetMonitorColorAndValue.GetMonitorFanCnt(_curMonitorConfigInfo.MCFanInfo, curGird.Key); if (_curMCFanCnt <= 0) { return; } if ((curGird.DrawRegion.Height - DrawOffset * 2) < _curMCFanCnt * _switchPen.Width || _curMCFanCnt <= 0) { //��ȡʵ�ʻ��Ƶķ��ȸ���ʧ�� return; } fSwitchHeight = (float)drawRect.Height / _curMCFanCnt; drawImageHeight = fSwitchHeight - ImageAndStrInterval * 2; for (int i = 0; i < _curMCFanCnt; i++) { isDrawStr = true; if (monitorInfo.FanSpeedOfMonitorCardCollection == null || i >= monitorInfo.FanSpeedOfMonitorCardCollection.Count) { valueInfo = new ValueInfo(); valueInfo.IsValid = false; } else { valueInfo = monitorInfo.FanSpeedOfMonitorCardCollection[i]; } //��ȡ���ȵ�ͼƬ���ַ������ƴ�С GetImageAndStrSize(drawZoonGraphic,drawRect, valueInfo, fSwitchHeight, drawImageHeight, out imageSize, out _strSize, out isDrawStr); //��ȡ���Ƶ�ͼƬ GetDrawImage(valueInfo, PicType.Fan, _curMonitorConfigInfo.MCFanInfo.AlarmThreshold, ref drawImage); //����ͼƬ���ַ��� DrawImageAndStr(drawZoonGraphic, drawImage, valueInfo, drawRect, fSwitchHeight, imageSize, _strSize, isDrawStr, i); #region �������� #region ��ȡ�ַ�����ͼƬ���ƵĴ�С //if (!valueInfo.IsValid) //{ // isDrawStr = false; // _strSize.Width = 0; //} //else //{ // _strSize = GetStrSize(drawZoonGraphic, valueInfo.Value.ToString()); //} //if (_strSize.Height > fSwitchHeight // || _strSize.Width + ImageAndStrInterval * 3 > drawRect.Width) //{ // isDrawStr = false; // _strSize.Width = 0; //} //imageWidth = drawRect.Width - _strSize.Width - ImageAndStrInterval * 3; //imageSize = Math.Min(imageWidth, drawImageHeight); //if (imageSize < MinImageSize) //{ // isDrawStr = false; // _strSize.Width = 0; // imageWidth = drawRect.Width - _strSize.Width - ImageAndStrInterval * 2; // imageSize = Math.Min(imageWidth, drawImageHeight); //} //if (imageSize < 0) //{ // imageSize = 0; //} #endregion #region �����ַ�����ͼƬ //imageRectF = new RectangleF(fRegionStartX + ImageAndStrInterval, // fRegionStartY + fSwitchHeight * i + (fSwitchHeight - imageSize) / 2, // imageSize, imageSize); //lineStartPoint = new PointF(fRegionStartX, fRegionStartY + fSwitchHeight * i); //lineEndPoint = new PointF(fRegionEndX, fRegionStartY + fSwitchHeight * i); ////���Ʊ��� //drawZoonGraphic.FillRectangle(_switchBrush, fRegionStartX, fRegionStartY + fSwitchHeight * i, // drawRect.Width - DrawOffset, fSwitchHeight); //drawZoonGraphic.DrawImage(drawImage, imageRectF); //if (i > 0) //{ // drawZoonGraphic.DrawLine(_switchPen, lineStartPoint, lineEndPoint); //} //if (isDrawStr) //{ // strRectF = new RectangleF(fRegionStartX + imageSize + ImageAndStrInterval * 2, // fRegionStartY + fSwitchHeight * i, // drawRect.Width - imageSize - ImageAndStrInterval * 2, // fSwitchHeight); // DrawStrForLeft(drawZoonGraphic, valueInfo.Value.ToString(), strRectF); //} #endregion #endregion } #endregion } else if (_curType == MonitorDisplayType.Power) { #region ���Ƶ�Դ�ָ��� _curMCPowerCnt = GetMonitorColorAndValue.GetMonitorPowerCnt(_curMonitorConfigInfo.MCPowerInfo, curGird.Key); if (_curMCPowerCnt <= 0) { return; } if ((drawRect.Height - DrawOffset * 2) < _curMCPowerCnt * _switchPen.Width) { return; } fSwitchHeight = (float)drawRect.Height / _curMCPowerCnt; drawImageHeight = fSwitchHeight - ImageAndStrInterval * 2; int powerIndexInList = 0; for (int i = 0; i < _curMCPowerCnt; i++) { powerIndexInList = i + 1; isDrawStr = true; if (monitorInfo.VoltageOfMonitorCardCollection == null || powerIndexInList >= monitorInfo.VoltageOfMonitorCardCollection.Count) { valueInfo = new ValueInfo(); valueInfo.IsValid = false; } else { valueInfo = monitorInfo.VoltageOfMonitorCardCollection[powerIndexInList]; } //��ȡ��Դ��ͼƬ���ַ������ƴ�С GetImageAndStrSize(drawZoonGraphic, drawRect, valueInfo, fSwitchHeight, drawImageHeight, out imageSize, out _strSize, out isDrawStr); //��ȡ���Ƶ�ͼƬ GetDrawImage(valueInfo, PicType.Power, _curMonitorConfigInfo.MCPowerInfo.AlarmThreshold, ref drawImage); //����ͼƬ���ַ��� DrawImageAndStr(drawZoonGraphic, drawImage, valueInfo, drawRect, fSwitchHeight, imageSize, _strSize, isDrawStr, i); #region �������� #region ��ȡ�ַ�����ͼƬ���ƵĴ�С //if (!valueInfo.IsValid) //{ // isDrawStr = false; // _strSize.Width = 0; //} //else //{ // _strSize = GetStrSize(drawZoonGraphic, valueInfo.Value.ToString("#0.00")); //} //if (_strSize.Height > fSwitchHeight // || _strSize.Width + ImageAndStrInterval * 3 > drawRect.Width) //{ // isDrawStr = false; // _strSize.Width = 0; //} //imageWidth = drawRect.Width - _strSize.Width - ImageAndStrInterval * 3; //imageSize = Math.Min(imageWidth, drawImageHeight); //if (imageSize < MinImageSize) //{ // isDrawStr = false; // _strSize.Width = 0; // imageWidth = drawRect.Width - _strSize.Width - ImageAndStrInterval * 2; // imageSize = Math.Min(imageWidth, drawImageHeight); //} //if (imageSize < 0) //{ // imageSize = 0; //} #endregion #region �����ַ�����ͼƬ //imageRectF = new RectangleF(fRegionStartX + ImageAndStrInterval, // fRegionStartY + fSwitchHeight * i + (fSwitchHeight - imageSize) / 2, // imageSize, imageSize); //lineStartPoint = new PointF(fRegionStartX, fRegionStartY + fSwitchHeight * i); //lineEndPoint = new PointF(fRegionEndX, fRegionStartY + fSwitchHeight * i); //GetDrawImage(valueInfo, PicType.Power, // _curMonitorConfigInfo.MCPowerInfo.AlarmThreshold, // ref drawImage); ////���Ʊ��� //drawZoonGraphic.FillRectangle(_switchBrush, fRegionStartX, fRegionStartY + fSwitchHeight * i, // drawRect.Width - DrawOffset, fSwitchHeight); //drawZoonGraphic.DrawImage(drawImage, imageRectF); //if (i > 0 && i < _curMCPowerCnt) //{ // drawZoonGraphic.DrawLine(_switchPen, lineStartPoint, lineEndPoint); //} //if (isDrawStr) //{ // strRectF = new RectangleF(fRegionStartX + imageSize + ImageAndStrInterval * 2, // fRegionStartY + fSwitchHeight * i, // drawRect.Width - imageSize - ImageAndStrInterval * 2, // fSwitchHeight); // DrawStrForLeft(drawZoonGraphic, valueInfo.Value.ToString("#0.00"), strRectF); //} #endregion #endregion } #endregion } } } #endregion } else if (customObj.Type == GridType.ComplexScreenGrid) { ComplexScreenGridBindObj complexScreenGridObj = (ComplexScreenGridBindObj)customObj; #region ��ȡ���ӱ�����ɫ backColor = Color.Gray; if (complexScreenGridObj.ComplexScreenLayout.IsAllMonitorDataIsValid) { switch (_curType) { case MonitorDisplayType.SBStatus: if (complexScreenGridObj.ComplexScreenLayout.FaultInfo.SBStatusErrCount > 0 || complexScreenGridObj.ComplexScreenLayout.AlarmInfo.SBStatusErrCount > 0) { backColor = Color.Red; } else { backColor = Color.Green; } break; case MonitorDisplayType.MCStatus: if (complexScreenGridObj.ComplexScreenLayout.FaultInfo.MCStatusErrCount > 0 || complexScreenGridObj.ComplexScreenLayout.AlarmInfo.MCStatusErrCount > 0) { backColor = Color.Red; } else { backColor = Color.Green; } break; case MonitorDisplayType.Smoke: if (complexScreenGridObj.ComplexScreenLayout.FaultInfo.SmokeAlarmCount > 0) { backColor = Color.Red; } else if (complexScreenGridObj.ComplexScreenLayout.AlarmInfo.SmokeAlarmCount > 0) { backColor = Color.Yellow; } else { backColor = Color.Green; } break; case MonitorDisplayType.Temperature: if (complexScreenGridObj.ComplexScreenLayout.FaultInfo.TemperatureAlarmCount > 0) { backColor = Color.Red; } else if (complexScreenGridObj.ComplexScreenLayout.AlarmInfo.TemperatureAlarmCount > 0) { backColor = Color.Yellow; } else { backColor = Color.Green; } break; case MonitorDisplayType.Humidity: if (complexScreenGridObj.ComplexScreenLayout.FaultInfo.HumidityAlarmCount > 0) { backColor = Color.Red; } else if (complexScreenGridObj.ComplexScreenLayout.AlarmInfo.HumidityAlarmCount > 0) { backColor = Color.Yellow; } else { backColor = Color.Green; } break; case MonitorDisplayType.Fan: if (complexScreenGridObj.ComplexScreenLayout.FaultInfo.FanAlarmSwitchCount > 0) { backColor = Color.Red; } else if (complexScreenGridObj.ComplexScreenLayout.AlarmInfo.FanAlarmSwitchCount > 0) { backColor = Color.Yellow; } else { backColor = Color.Green; } break; case MonitorDisplayType.Power: if (complexScreenGridObj.ComplexScreenLayout.FaultInfo.PowerAlarmSwitchCount > 0) { backColor = Color.Red; } else if (complexScreenGridObj.ComplexScreenLayout.AlarmInfo.PowerAlarmSwitchCount > 0) { backColor = Color.Yellow; } else { backColor = Color.Green; } break; case MonitorDisplayType.RowLine: if (complexScreenGridObj.ComplexScreenLayout.FaultInfo.SoketAlarmCount > 0) { backColor = Color.Red; } else if (complexScreenGridObj.ComplexScreenLayout.AlarmInfo.SoketAlarmCount > 0) { backColor = Color.Yellow; } else { backColor = Color.Green; } break; case MonitorDisplayType.GeneralSwitch: if (complexScreenGridObj.ComplexScreenLayout.FaultInfo.GeneralSwitchErrCount > 0) { backColor = Color.Red; } else if (complexScreenGridObj.ComplexScreenLayout.AlarmInfo.GeneralSwitchErrCount > 0) { backColor = Color.Yellow; } else { backColor = Color.Green; } break; } } curGird.Style.BackColor = backColor; #endregion base.DrawGrid(drawZoonGraphic, curGird); #region ���Ƹ������ı߽� //drawZoonGraphic.DrawRectangle(_screenBoarderPen, // curGird.DrawRegion.X + _screenBoarderPen.Width / 2, // curGird.DrawRegion.Y + _screenBoarderPen.Width / 2, // curGird.DrawRegion.Width - _screenBoarderPen.Width, // curGird.DrawRegion.Height - _screenBoarderPen.Width); #endregion } else if (customObj.Type == GridType.ScreenGrid) { ScreenGridBindObj screenGridObj = (ScreenGridBindObj)customObj; if (!screenGridObj.ScreenIsValid) { curGird.Style.BackColor = Color.Gray; base.DrawGrid(drawZoonGraphic, curGird); } #region ���Ƹ��ӱ߽� --- ��ʾ���߽� drawZoonGraphic.DrawRectangle(_screenBoarderPen, curGird.DrawRegion.X + _screenBoarderPen.Width / 2, curGird.DrawRegion.Y + _screenBoarderPen.Width / 2, curGird.DrawRegion.Width - _screenBoarderPen.Width, curGird.DrawRegion.Height - _screenBoarderPen.Width); #endregion } }
protected override void DrawGrid(Graphics drawZoonGraphic, RectangularGridInfo curGird) { if (curGird == null) { return; } if (_isDisplayAll) { return; } IGridBiningObject customObj = (IGridBiningObject)curGird.CustomObj; Color backColor = Color.Gray; int nValue = 0; bool bTempOrHumiInvalid = false; if (customObj.Type == GridType.ScanBoardGird) { ScanBoardGridBindObj scanBoardGridObj = (ScanBoardGridBindObj)customObj; #region 获取格子背景颜色 if (customObj != null) { switch (_curType) { case MonitorDisplayType.SBStatus: GetMonitorColorAndValue.GetSBStatusColorAndStr(scanBoardGridObj.ScanBoardAndMonitorInfo.MonitorData, ref backColor); curGird.Style.BackColor = backColor; break; case MonitorDisplayType.MCStatus: GetMonitorColorAndValue.GetMCStatusColorAndStr(scanBoardGridObj.ScanBoardAndMonitorInfo.MonitorData, ref backColor); curGird.Style.BackColor = backColor; break; case MonitorDisplayType.Smoke: GetMonitorColorAndValue.GetSmokeColorAndStr(scanBoardGridObj.ScanBoardAndMonitorInfo.MonitorData, ref backColor); curGird.Style.BackColor = backColor; break; case MonitorDisplayType.Temperature: bTempOrHumiInvalid = !GetMonitorColorAndValue.DetectTempIsValidAndGetInfo(_clrGradePartition, _curMonitorConfigInfo.TempDisplayType, scanBoardGridObj.ScanBoardAndMonitorInfo.MonitorData, ref nValue, ref backColor); curGird.Style.BackColor = backColor; break; case MonitorDisplayType.Humidity: bTempOrHumiInvalid = !GetMonitorColorAndValue.DetectHumiValidAndGetInfo(_clrGradePartition, scanBoardGridObj.ScanBoardAndMonitorInfo.MonitorData, ref nValue, ref backColor); curGird.Style.BackColor = backColor; break; case MonitorDisplayType.Fan: curGird.Style.BackColor = Color.Gray; break; case MonitorDisplayType.Power: curGird.Style.BackColor = Color.Gray; break; case MonitorDisplayType.RowLine: GetMonitorColorAndValue.GetRowLineCorAndStr(scanBoardGridObj.ScanBoardAndMonitorInfo.MonitorData, scanBoardGridObj.ScanBoardAndMonitorInfo.RowLineStatus, ref backColor); curGird.Style.BackColor = backColor; break; case MonitorDisplayType.GeneralSwitch: GetMonitorColorAndValue.GetGeneralSwitchClr(scanBoardGridObj.ScanBoardAndMonitorInfo.MonitorData, scanBoardGridObj.ScanBoardAndMonitorInfo.GeneralSwitchList, ref backColor); curGird.Style.BackColor = backColor; break; } } #endregion base.DrawGrid(drawZoonGraphic, curGird); #region 绘制格子上的字符串和图标 if (scanBoardGridObj.ScanBoardAndMonitorInfo.MonitorData == null) { return; } RectangleF drawRect = new RectangleF(curGird.DrawRegion.X + this.DefaultStyle.BoardWidth / 2, curGird.DrawRegion.Y + this.DefaultStyle.BoardWidth / 2, curGird.DrawRegion.Width - this.DefaultStyle.BoardWidth, curGird.DrawRegion.Height - this.DefaultStyle.BoardWidth); ScannerMonitorData monitorInfo = (ScannerMonitorData)scanBoardGridObj.ScanBoardAndMonitorInfo.MonitorData.Clone(); if (customObj != null && monitorInfo != null) { if (_curType == MonitorDisplayType.Temperature || _curType == MonitorDisplayType.Humidity) { #region 绘制温湿度字符串 if (bTempOrHumiInvalid) { return; } _strSize = GetStrSize(drawZoonGraphic, nValue.ToString()); if (_strSize.Width > drawRect.Width || _strSize.Height > drawRect.Height) { //不能将字符串绘制出来 return; } DrawStrForCenter(drawZoonGraphic, nValue.ToString(), drawRect); #endregion } else if (_curType == MonitorDisplayType.Fan || _curType == MonitorDisplayType.Power) { ValueInfo valueInfo = new ValueInfo(); float fSwitchHeight = 0; Image drawImage = null; bool isDrawStr = false; float drawImageHeight = 0; float imageSize = 0; if (_curType == MonitorDisplayType.Fan) { #region 绘制风扇分割线 _curMCFanCnt = GetMonitorColorAndValue.GetMonitorFanCnt(_curMonitorConfigInfo.MCFanInfo, curGird.Key); if (_curMCFanCnt <= 0) { return; } if ((curGird.DrawRegion.Height - DrawOffset * 2) < _curMCFanCnt * _switchPen.Width || _curMCFanCnt <= 0) { //获取实际绘制的风扇个数失败 return; } fSwitchHeight = (float)drawRect.Height / _curMCFanCnt; drawImageHeight = fSwitchHeight - ImageAndStrInterval * 2; for (int i = 0; i < _curMCFanCnt; i++) { isDrawStr = true; if (monitorInfo.FanSpeedOfMonitorCardCollection == null || i >= monitorInfo.FanSpeedOfMonitorCardCollection.Count) { valueInfo = new ValueInfo(); valueInfo.IsValid = false; } else { valueInfo = monitorInfo.FanSpeedOfMonitorCardCollection[i]; } //获取风扇的图片和字符串绘制大小 GetImageAndStrSize(drawZoonGraphic, drawRect, valueInfo, fSwitchHeight, drawImageHeight, out imageSize, out _strSize, out isDrawStr); //获取绘制的图片 GetDrawImage(valueInfo, PicType.Fan, _curMonitorConfigInfo.MCFanInfo.AlarmThreshold, ref drawImage); //绘制图片和字符串 DrawImageAndStr(drawZoonGraphic, drawImage, valueInfo, drawRect, fSwitchHeight, imageSize, _strSize, isDrawStr, i); #region 废弃代码 #region 获取字符串和图片绘制的大小 //if (!valueInfo.IsValid) //{ // isDrawStr = false; // _strSize.Width = 0; //} //else //{ // _strSize = GetStrSize(drawZoonGraphic, valueInfo.Value.ToString()); //} //if (_strSize.Height > fSwitchHeight // || _strSize.Width + ImageAndStrInterval * 3 > drawRect.Width) //{ // isDrawStr = false; // _strSize.Width = 0; //} //imageWidth = drawRect.Width - _strSize.Width - ImageAndStrInterval * 3; //imageSize = Math.Min(imageWidth, drawImageHeight); //if (imageSize < MinImageSize) //{ // isDrawStr = false; // _strSize.Width = 0; // imageWidth = drawRect.Width - _strSize.Width - ImageAndStrInterval * 2; // imageSize = Math.Min(imageWidth, drawImageHeight); //} //if (imageSize < 0) //{ // imageSize = 0; //} #endregion #region 绘制字符串和图片 //imageRectF = new RectangleF(fRegionStartX + ImageAndStrInterval, // fRegionStartY + fSwitchHeight * i + (fSwitchHeight - imageSize) / 2, // imageSize, imageSize); //lineStartPoint = new PointF(fRegionStartX, fRegionStartY + fSwitchHeight * i); //lineEndPoint = new PointF(fRegionEndX, fRegionStartY + fSwitchHeight * i); ////绘制背景 //drawZoonGraphic.FillRectangle(_switchBrush, fRegionStartX, fRegionStartY + fSwitchHeight * i, // drawRect.Width - DrawOffset, fSwitchHeight); //drawZoonGraphic.DrawImage(drawImage, imageRectF); //if (i > 0) //{ // drawZoonGraphic.DrawLine(_switchPen, lineStartPoint, lineEndPoint); //} //if (isDrawStr) //{ // strRectF = new RectangleF(fRegionStartX + imageSize + ImageAndStrInterval * 2, // fRegionStartY + fSwitchHeight * i, // drawRect.Width - imageSize - ImageAndStrInterval * 2, // fSwitchHeight); // DrawStrForLeft(drawZoonGraphic, valueInfo.Value.ToString(), strRectF); //} #endregion #endregion } #endregion } else if (_curType == MonitorDisplayType.Power) { #region 绘制电源分割线 _curMCPowerCnt = GetMonitorColorAndValue.GetMonitorPowerCnt(_curMonitorConfigInfo.MCPowerInfo, curGird.Key); if (_curMCPowerCnt <= 0) { return; } if ((drawRect.Height - DrawOffset * 2) < _curMCPowerCnt * _switchPen.Width) { return; } fSwitchHeight = (float)drawRect.Height / _curMCPowerCnt; drawImageHeight = fSwitchHeight - ImageAndStrInterval * 2; int powerIndexInList = 0; for (int i = 0; i < _curMCPowerCnt; i++) { powerIndexInList = i + 1; isDrawStr = true; if (monitorInfo.VoltageOfMonitorCardCollection == null || powerIndexInList >= monitorInfo.VoltageOfMonitorCardCollection.Count) { valueInfo = new ValueInfo(); valueInfo.IsValid = false; } else { valueInfo = monitorInfo.VoltageOfMonitorCardCollection[powerIndexInList]; } //获取电源的图片和字符串绘制大小 GetImageAndStrSize(drawZoonGraphic, drawRect, valueInfo, fSwitchHeight, drawImageHeight, out imageSize, out _strSize, out isDrawStr); //获取绘制的图片 GetDrawImage(valueInfo, PicType.Power, _curMonitorConfigInfo.MCPowerInfo.AlarmThreshold, ref drawImage); //绘制图片和字符串 DrawImageAndStr(drawZoonGraphic, drawImage, valueInfo, drawRect, fSwitchHeight, imageSize, _strSize, isDrawStr, i); #region 废弃代码 #region 获取字符串和图片绘制的大小 //if (!valueInfo.IsValid) //{ // isDrawStr = false; // _strSize.Width = 0; //} //else //{ // _strSize = GetStrSize(drawZoonGraphic, valueInfo.Value.ToString("#0.00")); //} //if (_strSize.Height > fSwitchHeight // || _strSize.Width + ImageAndStrInterval * 3 > drawRect.Width) //{ // isDrawStr = false; // _strSize.Width = 0; //} //imageWidth = drawRect.Width - _strSize.Width - ImageAndStrInterval * 3; //imageSize = Math.Min(imageWidth, drawImageHeight); //if (imageSize < MinImageSize) //{ // isDrawStr = false; // _strSize.Width = 0; // imageWidth = drawRect.Width - _strSize.Width - ImageAndStrInterval * 2; // imageSize = Math.Min(imageWidth, drawImageHeight); //} //if (imageSize < 0) //{ // imageSize = 0; //} #endregion #region 绘制字符串和图片 //imageRectF = new RectangleF(fRegionStartX + ImageAndStrInterval, // fRegionStartY + fSwitchHeight * i + (fSwitchHeight - imageSize) / 2, // imageSize, imageSize); //lineStartPoint = new PointF(fRegionStartX, fRegionStartY + fSwitchHeight * i); //lineEndPoint = new PointF(fRegionEndX, fRegionStartY + fSwitchHeight * i); //GetDrawImage(valueInfo, PicType.Power, // _curMonitorConfigInfo.MCPowerInfo.AlarmThreshold, // ref drawImage); ////绘制背景 //drawZoonGraphic.FillRectangle(_switchBrush, fRegionStartX, fRegionStartY + fSwitchHeight * i, // drawRect.Width - DrawOffset, fSwitchHeight); //drawZoonGraphic.DrawImage(drawImage, imageRectF); //if (i > 0 && i < _curMCPowerCnt) //{ // drawZoonGraphic.DrawLine(_switchPen, lineStartPoint, lineEndPoint); //} //if (isDrawStr) //{ // strRectF = new RectangleF(fRegionStartX + imageSize + ImageAndStrInterval * 2, // fRegionStartY + fSwitchHeight * i, // drawRect.Width - imageSize - ImageAndStrInterval * 2, // fSwitchHeight); // DrawStrForLeft(drawZoonGraphic, valueInfo.Value.ToString("#0.00"), strRectF); //} #endregion #endregion } #endregion } } } #endregion } else if (customObj.Type == GridType.ComplexScreenGrid) { ComplexScreenGridBindObj complexScreenGridObj = (ComplexScreenGridBindObj)customObj; #region 获取格子背景颜色 backColor = Color.Gray; if (complexScreenGridObj.ComplexScreenLayout.IsAllMonitorDataIsValid) { switch (_curType) { case MonitorDisplayType.SBStatus: if (complexScreenGridObj.ComplexScreenLayout.FaultInfo.SBStatusErrCount > 0 || complexScreenGridObj.ComplexScreenLayout.AlarmInfo.SBStatusErrCount > 0) { backColor = Color.Red; } else { backColor = Color.Green; } break; case MonitorDisplayType.MCStatus: if (complexScreenGridObj.ComplexScreenLayout.FaultInfo.MCStatusErrCount > 0 || complexScreenGridObj.ComplexScreenLayout.AlarmInfo.MCStatusErrCount > 0) { backColor = Color.Red; } else { backColor = Color.Green; } break; case MonitorDisplayType.Smoke: if (complexScreenGridObj.ComplexScreenLayout.FaultInfo.SmokeAlarmCount > 0) { backColor = Color.Red; } else if (complexScreenGridObj.ComplexScreenLayout.AlarmInfo.SmokeAlarmCount > 0) { backColor = Color.Yellow; } else { backColor = Color.Green; } break; case MonitorDisplayType.Temperature: if (complexScreenGridObj.ComplexScreenLayout.FaultInfo.TemperatureAlarmCount > 0) { backColor = Color.Red; } else if (complexScreenGridObj.ComplexScreenLayout.AlarmInfo.TemperatureAlarmCount > 0) { backColor = Color.Yellow; } else { backColor = Color.Green; } break; case MonitorDisplayType.Humidity: if (complexScreenGridObj.ComplexScreenLayout.FaultInfo.HumidityAlarmCount > 0) { backColor = Color.Red; } else if (complexScreenGridObj.ComplexScreenLayout.AlarmInfo.HumidityAlarmCount > 0) { backColor = Color.Yellow; } else { backColor = Color.Green; } break; case MonitorDisplayType.Fan: if (complexScreenGridObj.ComplexScreenLayout.FaultInfo.FanAlarmSwitchCount > 0) { backColor = Color.Red; } else if (complexScreenGridObj.ComplexScreenLayout.AlarmInfo.FanAlarmSwitchCount > 0) { backColor = Color.Yellow; } else { backColor = Color.Green; } break; case MonitorDisplayType.Power: if (complexScreenGridObj.ComplexScreenLayout.FaultInfo.PowerAlarmSwitchCount > 0) { backColor = Color.Red; } else if (complexScreenGridObj.ComplexScreenLayout.AlarmInfo.PowerAlarmSwitchCount > 0) { backColor = Color.Yellow; } else { backColor = Color.Green; } break; case MonitorDisplayType.RowLine: if (complexScreenGridObj.ComplexScreenLayout.FaultInfo.SoketAlarmCount > 0) { backColor = Color.Red; } else if (complexScreenGridObj.ComplexScreenLayout.AlarmInfo.SoketAlarmCount > 0) { backColor = Color.Yellow; } else { backColor = Color.Green; } break; case MonitorDisplayType.GeneralSwitch: if (complexScreenGridObj.ComplexScreenLayout.FaultInfo.GeneralSwitchErrCount > 0) { backColor = Color.Red; } else if (complexScreenGridObj.ComplexScreenLayout.AlarmInfo.GeneralSwitchErrCount > 0) { backColor = Color.Yellow; } else { backColor = Color.Green; } break; } } curGird.Style.BackColor = backColor; #endregion base.DrawGrid(drawZoonGraphic, curGird); #region 绘制复杂屏的边界 //drawZoonGraphic.DrawRectangle(_screenBoarderPen, // curGird.DrawRegion.X + _screenBoarderPen.Width / 2, // curGird.DrawRegion.Y + _screenBoarderPen.Width / 2, // curGird.DrawRegion.Width - _screenBoarderPen.Width, // curGird.DrawRegion.Height - _screenBoarderPen.Width); #endregion } else if (customObj.Type == GridType.ScreenGrid) { ScreenGridBindObj screenGridObj = (ScreenGridBindObj)customObj; if (!screenGridObj.ScreenIsValid) { curGird.Style.BackColor = Color.Gray; base.DrawGrid(drawZoonGraphic, curGird); } #region 绘制格子边界 --- 显示屏边界 drawZoonGraphic.DrawRectangle(_screenBoarderPen, curGird.DrawRegion.X + _screenBoarderPen.Width / 2, curGird.DrawRegion.Y + _screenBoarderPen.Width / 2, curGird.DrawRegion.Width - _screenBoarderPen.Width, curGird.DrawRegion.Height - _screenBoarderPen.Width); #endregion } }