From 23c351be52a0567ac089b28e8f534c3ebf08b9a9 Mon Sep 17 00:00:00 2001
From: chenluhua1980 <Chenluhua@qq.com>
Date: 星期四, 13 十一月 2025 16:33:57 +0800
Subject: [PATCH] 1.机器状态图由单个指示修改为多个指示器,代表是否有物料;

---
 SourceCode/Bond/Servo/EqsGraphWnd.cpp |  295 +++++++++++++++++++++++++++++++---------------------------
 1 files changed, 159 insertions(+), 136 deletions(-)

diff --git a/SourceCode/Bond/Servo/EqsGraphWnd.cpp b/SourceCode/Bond/Servo/EqsGraphWnd.cpp
index 9aa534d..fbdd34b 100644
--- a/SourceCode/Bond/Servo/EqsGraphWnd.cpp
+++ b/SourceCode/Bond/Servo/EqsGraphWnd.cpp
@@ -1,4 +1,4 @@
-#include "stdafx.h"
+锘�#include "stdafx.h"
 #include "EqsGraphWnd.h"
 #include "ColorTransfer.h"
 #include "MapPosWnd.h"
@@ -86,7 +86,7 @@
 	wc.cbClsExtra = 0;
 	wc.cbWndExtra = 0;
 
-	// 注册窗口类
+	// 娉ㄥ唽绐楀彛绫�
 	return (::RegisterClass(&wc) != 0);
 }
 
@@ -235,7 +235,7 @@
 }
 
 /*
- * 计算磁力线位置
+ * 璁$畻纾佸姏绾夸綅缃�
  */
 void CEqsGraphWnd::CalculateMagneticLine(EQITEM* pItem, LPRECT lprcItemRect, int &hoz, int &ver)
 {
@@ -243,7 +243,7 @@
 	ver = 0;
 #define MAGNETIC_DIS		10
 
-	// 检测是否接近或对齐
+	// 妫�娴嬫槸鍚︽帴杩戞垨瀵归綈
 	for (int i = 0; i < m_arItem.GetSize(); i++) {
 		EQITEM *pTemp = (EQITEM*)m_arItem.GetAt(i);
 		if (pTemp != pItem) {
@@ -287,10 +287,10 @@
 }
 
 /*
- * 取得In Pin的区域
+ * 鍙栧緱In Pin鐨勫尯鍩�
  * pItem -- EQITEM
- * lpRect -- 得到的Rect
- * 返回是否成功
+ * lpRect -- 寰楀埌鐨凴ect
+ * 杩斿洖鏄惁鎴愬姛
  */
 BOOL CEqsGraphWnd::GetItemRect(EQITEM* pItem, LPRECT lpRect)
 {
@@ -321,11 +321,11 @@
 }
 
 /*
- * 取得In Pin的区域
+ * 鍙栧緱In Pin鐨勫尯鍩�
  * pItem -- EQITEM
- * nPinIndex -- in pin索引
- * lpRect -- 得到的Rect
- * 返回是否成功
+ * nPinIndex -- in pin绱㈠紩
+ * lpRect -- 寰楀埌鐨凴ect
+ * 杩斿洖鏄惁鎴愬姛
  */
 BOOL CEqsGraphWnd::GetInPinRect(EQITEM* pItem, int nPinIndex, LPRECT lpRect)
 {
@@ -345,11 +345,11 @@
 }
 
 /*
- * 取得Out Pin的区域
+ * 鍙栧緱Out Pin鐨勫尯鍩�
  * pItem -- EQITEM
- * nPinIndex -- in pin索引
- * lpRect -- 得到的Rect
- * 返回是否成功
+ * nPinIndex -- in pin绱㈠紩
+ * lpRect -- 寰楀埌鐨凴ect
+ * 杩斿洖鏄惁鎴愬姛
  */
 BOOL CEqsGraphWnd::GetOutPinRect(EQITEM* pItem, int nPinIndex, LPRECT lpRect)
 {
@@ -368,11 +368,11 @@
 }
 
 /*
- * 取得Pin的Point
+ * 鍙栧緱Pin鐨凱oint
  * pItem -- EQITEM
- * nPinIndex -- in pin索引
- * lpRect -- 得到的Rect
- * 返回是否成功
+ * nPinIndex -- in pin绱㈠紩
+ * lpRect -- 寰楀埌鐨凴ect
+ * 杩斿洖鏄惁鎴愬姛
  */
 BOOL CEqsGraphWnd::GetPinPoint(PIN *pPin, LPPOINT lpPoint)
 {
@@ -453,7 +453,7 @@
 }
 
 /*
- * 清空PIN连接线缓存点,以便重新计算和绘制
+ * 娓呯┖PIN杩炴帴绾跨紦瀛樼偣锛屼互渚块噸鏂拌绠楀拰缁樺埗
  */
 void CEqsGraphWnd::ClearConnectedLinePoint(EQITEM*& pItem)
 {
@@ -555,7 +555,7 @@
  */
 EQITEM* CEqsGraphWnd::AddItem(int id, CString strText, DWORD_PTR dwData, int nType/* = ITEM_NORMAL*/)
 {
-	// 需要计算一个新位置,不然全部重叠在一起
+	// 闇�瑕佽绠椾竴涓柊浣嶇疆锛屼笉鐒跺叏閮ㄩ噸鍙犲湪涓�璧�
 	int x, y;
 	x = (m_arItem.GetCount() % 4) * 218;
 	y = (m_arItem.GetCount() / 4) * 168;
@@ -755,7 +755,7 @@
 	return 0;
 }
 
-// 删除Item, 如果pin有连接,注意先断开
+// 鍒犻櫎Item, 濡傛灉pin鏈夎繛鎺ワ紝娉ㄦ剰鍏堟柇寮�
 int CEqsGraphWnd::DeleteItem(EQITEM* pItem)
 {
 	for (int i = 0; i < m_arItem.GetSize(); i++) {
@@ -795,7 +795,7 @@
 }
 
 /*
- * 设置子项的选中状态
+ * 璁剧疆瀛愰」鐨勯�変腑鐘舵��
  */
 void CEqsGraphWnd::SetItemSelectState(int nIndex, BOOL bSelect)
 {
@@ -828,14 +828,14 @@
 }
 
 /*
- * 检测坐标点所在的项
- * 返回项类型, 如HT_ITEM, HT_PIN, HT_LINE
- * pItem - 所在的EQITEM
- * pPin --所在的pin, 如果在连线上,表示所属pin, out pin;
+ * 妫�娴嬪潗鏍囩偣鎵�鍦ㄧ殑椤�
+ * 杩斿洖椤圭被鍨�, 濡侶T_ITEM, HT_PIN, HT_LINE
+ * pItem - 鎵�鍦ㄧ殑EQITEM
+ * pPin --鎵�鍦ㄧ殑pin, 濡傛灉鍦ㄨ繛绾夸笂锛岃〃绀烘墍灞瀙in, out pin锛�
  */
 int CEqsGraphWnd::HighTest(POINT pt, OUT EQITEM*& pItem, OUT PIN *& pPin)
 {
-	// 检测是否在某个子项
+	// 妫�娴嬫槸鍚﹀湪鏌愪釜瀛愰」
 	int nRet = HT_NOWHERE;
 	pItem = NULL;
 	pPin = NULL;
@@ -844,7 +844,7 @@
 		EQITEM *pTempItem = (EQITEM*)m_arItem.GetAt(i);
 		GetItemRect(pTempItem, &rcItem);
 		if (::PtInRect(&rcItem, pt)) {
-			// 在Item
+			// 鍦↖tem
 			pItem = pTempItem;
 			nRet = HT_ITEM;
 			break;
@@ -854,7 +854,7 @@
 			CPtrArray * pPins = (CPtrArray *)pTempItem->pInPins;
 			for (int j = 0; j < pPins->GetSize(); j++) {
 				if (GetInPinRect(pTempItem, j, &rcPin) && ::PtInRect(&rcPin, pt)) {
-					// 在in pin上
+					// 鍦╥n pin涓�
 					pPin = (PIN *)pPins->GetAt(j);
 					pItem = pTempItem;
 					nRet = HT_PIN;
@@ -866,15 +866,15 @@
 				pPins = (CPtrArray *)pTempItem->pOutPins;
 				for (int j = 0; j < pPins->GetSize(); j++) {
 					if (GetOutPinRect(pTempItem, j, &rcPin) && ::PtInRect(&rcPin, pt)) {
-						// 在out pin
+						// 鍦╫ut pin
 						pPin = (PIN *)pPins->GetAt(j);
 						pItem = pTempItem;
 						nRet = HT_PIN;
 						break;
 					}
 					else {
-						// 是否在pin连接线上,即判断点是否在线上
-						// 点到直线的距离公式(先通过p1,p2用两点式求出直线的表达式,再套距离公式);abs()为取绝对值函数,sqrt()为开根号函数
+						// 鏄惁鍦╬in杩炴帴绾夸笂,鍗冲垽鏂偣鏄惁鍦ㄧ嚎涓�
+						// 鐐瑰埌鐩寸嚎鐨勮窛绂诲叕寮忥紙鍏堥�氳繃p1,p2鐢ㄤ袱鐐瑰紡姹傚嚭鐩寸嚎鐨勮〃杈惧紡锛屽啀濂楄窛绂诲叕寮忥級锛沘bs()涓哄彇缁濆鍊煎嚱鏁帮紝sqrt()涓哄紑鏍瑰彿鍑芥暟
 						PIN *pTempPin = (PIN *)pPins->GetAt(j);
 						if (pTempPin->pConnectedPin != NULL && pTempPin->nLinePtCount > 1) {
 							for (int i = 0; i < pTempPin->nLinePtCount - 1; i++) {
@@ -907,7 +907,7 @@
 }
 
 /*
- * 绘制虚线框,代表正在拖动的item
+ * 缁樺埗铏氱嚎妗嗭紝浠h〃姝e湪鎷栧姩鐨刬tem
  */
 void CEqsGraphWnd::DrawDropItemRectangle(LPRECT lpRect1, LPRECT lpRect2)
 {
@@ -935,7 +935,7 @@
 }
 
 /*
- * 绘制磁吸线
+ * 缁樺埗纾佸惛绾�
  */
 void CEqsGraphWnd::DrawMagneticLine(LPRECT lprcClient, int nHozLine1, int nHozLine2, int nVerLine1, int nVerLine2)
 {
@@ -969,16 +969,16 @@
 }
 
 /*
- * 缓制Pin连接线
- * pBrush -- 画刷
- * pPen - 画笔
- * lpPt1, lpPt2 -- Pin脚的位置
- * lpRect1, lpRect2 -- 两个Item的Rect
+ * 缂撳埗Pin杩炴帴绾�
+ * pBrush -- 鐢诲埛
+ * pPen - 鐢荤瑪
+ * lpPt1, lpPt2 -- Pin鑴氱殑浣嶇疆
+ * lpRect1, lpRect2 -- 涓や釜Item鐨凴ect
  */
 void CEqsGraphWnd::DrawPinConnectedLine(Gdiplus::Graphics *pGraphics, Gdiplus::Brush *pBrush, Gdiplus::Pen *pPen, LPPOINT lpPt1, LPPOINT lpPt2,
 	LPRECT lpRect1, LPRECT lpRect2, PIN *pOwnerPin)
 {
-	// 如果没有缓存线条的POINT,则先计算并缓存
+	// 濡傛灉娌℃湁缂撳瓨绾挎潯鐨凱OINT锛屽垯鍏堣绠楀苟缂撳瓨
 	ASSERT(pOwnerPin);
 
 	int nPinCount = ((CPtrArray*)pOwnerPin->pItem->pOutPins)->GetSize();
@@ -987,10 +987,10 @@
 	int nMargin = 12;
 	int x1, x2, y1;
 
-	if (pOwnerPin->nLinePtCount == 0) {						// 第一个点的最小折线长
+	if (pOwnerPin->nLinePtCount == 0) {						// 绗竴涓偣鐨勬渶灏忔姌绾块暱
 		::OffsetRect(lpRect1, +m_nOffsetX, +m_nOffsetY);
 		::OffsetRect(lpRect2, +m_nOffsetX, +m_nOffsetY);
-		lpPt1->x += m_nOffsetX;				// 消除偏移
+		lpPt1->x += m_nOffsetX;				// 娑堥櫎鍋忕Щ
 		lpPt1->y += m_nOffsetY;
 		lpPt2->x += m_nOffsetX;
 		lpPt2->y += m_nOffsetY;
@@ -1099,7 +1099,7 @@
 }
 
 /*
- * WindowProc,窗口过程
+ * WindowProc锛岀獥鍙h繃绋�
  */
 LRESULT CALLBACK CEqsGraphWnd::WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
 {
@@ -1110,7 +1110,7 @@
 	}
 
 
-	// 处理窗口消息
+	// 澶勭悊绐楀彛娑堟伅
 	ASSERT(hWnd);
 	switch (uMsg)
 	{
@@ -1174,7 +1174,7 @@
 
 /*
  * WM_NCCREATE
- * 窗口创建
+ * 绐楀彛鍒涘缓
  */
 LRESULT CEqsGraphWnd::OnNcCreate(HWND hWnd, WPARAM wParam, LPARAM lParam)
 {
@@ -1187,7 +1187,7 @@
 
 /*
  * WM_DESTROY
- * 窗口销毁
+ * 绐楀彛閿�姣�
  */
 LRESULT CEqsGraphWnd::OnDestroy(WPARAM wParam, LPARAM lParam)
 {
@@ -1250,7 +1250,7 @@
 
 /*
  * WM_MOUSEMOVE
- * 鼠标滚动
+ * 榧犳爣婊氬姩
  */
 LRESULT CEqsGraphWnd::OnMouseMove(WPARAM wParam, LPARAM lParam)
 {
@@ -1259,7 +1259,7 @@
 
 /*
  * WM_LBUTTONDOWN
- * 鼠标左键按下
+ * 榧犳爣宸﹂敭鎸変笅
  */
 LRESULT CEqsGraphWnd::OnLButtonDown(WPARAM wParam, LPARAM lParam)
 {
@@ -1276,7 +1276,7 @@
 	int nLastVerLine = 0;
 
 
-	// 检测点击坐标是否在某一子项上,如是,则高亮显示
+	// 妫�娴嬬偣鍑诲潗鏍囨槸鍚﹀湪鏌愪竴瀛愰」涓婏紝濡傛槸锛屽垯楂樹寒鏄剧ず
 	EQITEM* pLastItem = m_pCurItem;
 	PIN *pLastPin = m_pCurPin;
 	PIN *pLastSelLineOutPin = m_pSelLineOutPin;
@@ -1323,14 +1323,14 @@
 	bChanged = pLastItem != m_pCurItem || pLastPin != m_pCurPin || pLastSelLineOutPin != m_pSelLineOutPin;
 
 
-	// 刷新
+	// 鍒锋柊
 	SetFocus(m_hWnd);
 	if (bChanged) {
 		::InvalidateRect(m_hWnd, &rcClient, TRUE);
 	}
 
 
-	// 捕捉鼠标消息,检测是否拖动
+	// 鎹曟崏榧犳爣娑堟伅锛屾娴嬫槸鍚︽嫋鍔�
 	if (nRet == HT_ITEM && m_pCurItem != NULL) {
 		GetItemRect(m_pCurItem, &rcItem);
 
@@ -1400,7 +1400,7 @@
 	}
 
 
-	// 捕捉鼠标消息,检测是否连接引脚
+	// 鎹曟崏榧犳爣娑堟伅锛屾娴嬫槸鍚﹁繛鎺ュ紩鑴�
 	else if (nRet == HT_PIN && m_pCurPin != NULL) {
 		if (::GetCapture() == NULL) {
 			BOOL bLast = FALSE;
@@ -1427,12 +1427,12 @@
 					ptNew = msg.pt;
 					::ScreenToClient(m_hWnd, &ptNew);
 
-					// 擦除上一次
+					// 鎿﹂櫎涓婁竴娆�
 					if (bLast) {
 						DrawPinWillConnectLine(lineColor, &ptPin, &ptLast);
 					}
 
-					// 检测是否可以连接
+					// 妫�娴嬫槸鍚﹀彲浠ヨ繛鎺�
 					bCanConnect = false;
 					nRet = HighTest(ptNew, pHitItem, pHitPin);
 					if (nRet == HT_PIN) {
@@ -1458,12 +1458,12 @@
 					ptNew = msg.pt;
 					::ScreenToClient(m_hWnd, &ptNew);
 
-					// 擦除上一次
+					// 鎿﹂櫎涓婁竴娆�
 					if (bLast) {
 						DrawPinWillConnectLine(lineColor, &ptPin, &ptLast);
 					}
 
-					// 检测是否可以连接
+					// 妫�娴嬫槸鍚﹀彲浠ヨ繛鎺�
 					bCanConnect = false;
 					nRet = HighTest(ptNew, pHitItem, pHitPin);
 					if (nRet == HT_PIN) {
@@ -1498,7 +1498,7 @@
 	}
 
 	
-	// 检测鼠标消息,检测是否移动画布
+	// 妫�娴嬮紶鏍囨秷鎭紝妫�娴嬫槸鍚︾Щ鍔ㄧ敾甯�
 	else if (nRet == HT_NOWHERE) {
 		if (::GetCapture() == NULL) {
 			int nLastOffsetX = m_nOffsetX;
@@ -1569,7 +1569,7 @@
 
 /*
  * WM_LBUTTONDBLCLK
- * 鼠标左键双击
+ * 榧犳爣宸﹂敭鍙屽嚮
  */
 LRESULT CEqsGraphWnd::OnLButtonDblclk(WPARAM wParam, LPARAM lParam)
 {
@@ -1581,7 +1581,7 @@
 	GetClientRect(m_hWnd, &rcClient);
 	rcLast = { 0, 0, 0, 0 };
 
-	// 检测点击坐标是否在某一子项上,如是,则高亮显示
+	// 妫�娴嬬偣鍑诲潗鏍囨槸鍚﹀湪鏌愪竴瀛愰」涓婏紝濡傛槸锛屽垯楂樹寒鏄剧ず
 	EQITEM* pLastItem = m_pCurItem;
 	BOOL bChanged = FALSE;
 	EQITEM* pHitItem = NULL;
@@ -1601,7 +1601,7 @@
 
 /*
  * WM_MOUSEWHEEL
- * 鼠标滚动
+ * 榧犳爣婊氬姩
  */
 LRESULT CEqsGraphWnd::OnMouseWheel(WPARAM wParam, LPARAM lParam)
 {
@@ -1628,7 +1628,7 @@
 
 /*
 * WM_MOUSEHWHEEL
-* 鼠标滚动
+* 榧犳爣婊氬姩
 */
 LRESULT CEqsGraphWnd::OnMouseHWheel(WPARAM wParam, LPARAM lParam)
 {
@@ -1655,7 +1655,7 @@
 
 /*
  * WM_RBUTTONDOWN
- * 鼠标左键按下
+ * 榧犳爣宸﹂敭鎸変笅
  */
 LRESULT CEqsGraphWnd::OnRButtonDown(WPARAM wParam, LPARAM lParam)
 {
@@ -1667,7 +1667,7 @@
 	GetClientRect(m_hWnd, &rcClient);
 	rcLast = { 0, 0, 0, 0 };
 
-	// 检测点击坐标是否在某一子项上,如是,则高亮显示
+	// 妫�娴嬬偣鍑诲潗鏍囨槸鍚﹀湪鏌愪竴瀛愰」涓婏紝濡傛槸锛屽垯楂樹寒鏄剧ず
 	EQITEM* pLastItem = m_pCurItem;
 	PIN *pLastPin = m_pCurPin;
 	PIN *pLastSelLineOutPin = m_pSelLineOutPin;
@@ -1710,14 +1710,14 @@
 	bChanged = pLastItem != m_pCurItem || pLastPin != m_pCurPin || pLastSelLineOutPin != m_pSelLineOutPin;
 
 
-	// 刷新
+	// 鍒锋柊
 	SetFocus(m_hWnd);
 	if (bChanged) {
 		::InvalidateRect(m_hWnd, &rcClient, TRUE);
 	}
 
 
-	// 捕捉鼠标消息,检测是否拖动
+	// 鎹曟崏榧犳爣娑堟伅锛屾娴嬫槸鍚︽嫋鍔�
 	if (nRet == HT_ITEM && m_pCurItem != NULL) {
 		CopyRect(&rcItem, &m_pCurItem->rect);
 
@@ -1770,13 +1770,13 @@
 
 /*
  * WM_KEYDOWN
- * 键盘消息,按下按键
+ * 閿洏娑堟伅锛屾寜涓嬫寜閿�
  */
 LRESULT CEqsGraphWnd::OnKeyDown(WPARAM wParam, LPARAM lParam)
 {
 	BOOL bChanged = FALSE;
 	if (wParam == VK_DELETE) {
-		// 如果当前选择为线,则断开连接
+		// 濡傛灉褰撳墠閫夋嫨涓虹嚎锛屽垯鏂紑杩炴帴
 		if (m_pSelLineOutPin != NULL) {
 			if (m_listener.onDisconnectPin != nullptr) {
 				if (m_listener.onDisconnectPin(m_pSelLineOutPin)) {
@@ -1866,7 +1866,6 @@
 	CString strText;
 	HBRUSH hBrushBK;
 
-
 	// BeginPaint
 	PAINTSTRUCT ps;
 	hDC = BeginPaint(m_hWnd, &ps);
@@ -1877,14 +1876,12 @@
 		rcClient.bottom - rcClient.top);
 	::SelectObject(hMemDC, hBitmap);
 
-
-	// 背景颜色
+	// 鑳屾櫙棰滆壊
 	hBrushBK = CreateSolidBrush(m_crBkgnd);
 	::FillRect(hMemDC, &rcClient, hBrushBK);
 	DeleteObject(hBrushBK);
 
-
-	// 标题
+	// 鏍囬瀛椾綋
 	if (m_hFontTitle == nullptr) {
 		LOGFONT lf;
 		HFONT hFontDefault = (HFONT)GetStockObject(DEFAULT_GUI_FONT);
@@ -1894,8 +1891,9 @@
 		m_hFontTitle = CreateFontIndirect(&lf);
 	}
 
+	// 缁樺埗鏍囬鏂囨湰
 	{
-		char szTitle[256];
+		char szTitle[256] = { 0 };
 		GetWindowText(m_hWnd, szTitle, 256);
 		RECT rcTitle;
 		rcTitle.left = rcClient.left + 5;
@@ -1906,21 +1904,23 @@
 		::DrawText(hMemDC, szTitle, (int)strlen(szTitle), &rcTitle, DT_LEFT | DT_TOP);
 	}
 
-
-	// 绘制子项
+	// 缁樺埗瀛愰」
 	HBRUSH hbrItemBackground[2];
 	HBRUSH hbrItemFrame[2];
 	HBRUSH hbrPinBackground[3];
 	HBRUSH hbrIndicator;
+	HBRUSH hbrIndicatorGray;
+
 	hbrItemBackground[0] = CreateSolidBrush(m_crItemBackground[0]);
 	hbrItemBackground[1] = CreateSolidBrush(m_crItemBackground[1]);
 	hbrItemFrame[0] = CreateSolidBrush(m_crItemFrame[0]);
 	hbrItemFrame[1] = CreateSolidBrush(m_crItemFrame[1]);
-	hbrIndicator = CreateSolidBrush(RGB(34, 177, 76));
+	hbrIndicator = CreateSolidBrush(RGB(34, 177, 76));    // 缁胯壊
+	hbrIndicatorGray = CreateSolidBrush(RGB(192, 192, 192));  // 鐏拌壊
+
 	for (int i = 0; i < 3; i++) {
 		hbrPinBackground[i] = CreateSolidBrush(m_crPinBkgnd[i]);
 	}
-
 
 	// gdi+
 	Gdiplus::Graphics graphics(hMemDC);
@@ -1931,21 +1931,22 @@
 		graphics.SetSmoothingMode(Gdiplus::SmoothingModeHighQuality);
 	}
 
-
 	SetBkMode(hMemDC, TRANSPARENT);
 	{
 		RECT rcItem;
 		int nPinState;
 		int nItemCount = (int)m_arItem.GetCount();
+
+		// 鍏堢敾 item銆佹枃鏈�乸in 鍜屾寚绀虹伅
 		for (int i = 0; i < nItemCount; i++) {
 			EQITEM* pItem = (EQITEM*)m_arItem.GetAt(i);
 			if (pItem->nFlashFlag == 1) {
 				continue;
 			}
+
 			GetItemRect(pItem, &rcItem);
 
-
-			// 子项背景和边框
+			// 瀛愰」鑳屾櫙鍜岃竟妗�
 			if (m_nItemRound == 0) {
 				::FillRect(hMemDC, &rcItem, pItem->bHighlight ? hbrItemBackground[1] : hbrItemBackground[0]);
 				::FrameRect(hMemDC, &rcItem, pItem->bHighlight ? hbrItemFrame[1] : hbrItemFrame[0]);
@@ -1957,27 +1958,42 @@
 				::DeleteObject(hRgn);
 			}
 
-
-			// name和id
+			// name
 			HFONT hFontOld = (HFONT)::SelectObject(hMemDC, m_hFontName);
 			::SetTextColor(hMemDC, pItem->bHighlight ? m_crItemNameText[1] : m_crItemNameText[0]);
-			::DrawText(hMemDC, pItem->text, (int)strlen(pItem->text), &rcItem, DT_CENTER | DT_VCENTER | DT_SINGLELINE | DT_END_ELLIPSIS);
+			::DrawText(hMemDC, pItem->text, (int)strlen(pItem->text), &rcItem,
+				DT_CENTER | DT_VCENTER | DT_SINGLELINE | DT_END_ELLIPSIS);
 
-			
-			// 添加一个小绿点指示器
-			if(pItem->bShowIndicator[0]){
+			// 澶氫釜鎸囩ず鐏細宸︿笂瑙掞紝鎸� 4 鍒� 脳 2 琛屾帓鍒�
+			const int indicatorSize = 10;
+			const int indicatorMargin = 3;
+			const int indicatorsPerRow = 4;
+
+			for (int k = 0; k < EQITEM_INDICATOR_COUNT; ++k) {
+				BYTE indicatorState = pItem->nIndicatorState[k];
+				if (indicatorState == INDICATOR_STATE_HIDDEN) {
+					continue;
+				}
+
+				int row = k / indicatorsPerRow;
+				int col = k % indicatorsPerRow;
+
 				RECT rcIndicator;
-				rcIndicator.left = rcItem.left + 5;
-				rcIndicator.top = rcItem.top + 5;
-				rcIndicator.right = rcIndicator.left + 12;
-				rcIndicator.bottom = rcIndicator.top + 12;
-				HRGN hRgn = CreateRoundRectRgn(rcIndicator.left, rcIndicator.top, rcIndicator.right, rcIndicator.bottom, 2, 2);
-				::FillRgn(hMemDC, hRgn, hbrIndicator);
-				::FrameRgn(hMemDC, hRgn, hbrItemFrame[0], 1, 1);
-				::DeleteObject(hRgn);
+				rcIndicator.left = rcItem.left + 5 + col * (indicatorSize + indicatorMargin);
+				rcIndicator.top = rcItem.top + 5 + row * (indicatorSize + indicatorMargin);
+				rcIndicator.right = rcIndicator.left + indicatorSize;
+				rcIndicator.bottom = rcIndicator.top + indicatorSize;
+
+
+				// 鐢婚珮浜�/鐏拌壊鏂瑰潡
+				RECT rcInner = rcIndicator;
+				::InflateRect(&rcInner, -1, -1);
+				::FillRect(hMemDC, &rcInner, indicatorState == INDICATOR_STATE_HIGHLIGHT
+					? hbrIndicator : hbrIndicatorGray);
+				::FrameRect(hMemDC, &rcIndicator, hbrItemFrame[0]);
 			}
 
-
+			// ID 鏂囨湰锛堥潪灏忓彿 item锛�
 			if (pItem->nShowType != ITEM_SMALL) {
 				RECT rcId = rcItem;
 				rcId.left += 5;
@@ -1986,29 +2002,28 @@
 				strId.Format(_T("ID:%d"), pItem->id);
 				::SelectObject(hMemDC, m_hFontId);
 				::SetTextColor(hMemDC, pItem->bHighlight ? m_crItemIdText[1] : m_crItemIdText[0]);
-				::DrawText(hMemDC, strId, (int)strId.GetLength(), &rcId, DT_LEFT | DT_BOTTOM | DT_SINGLELINE | DT_END_ELLIPSIS);
+				::DrawText(hMemDC, strId, (int)strId.GetLength(), &rcId,
+					DT_LEFT | DT_BOTTOM | DT_SINGLELINE | DT_END_ELLIPSIS);
 			}
 
-
-			// 动画效果不绘pin
+			// 鍔ㄧ敾鏁堟灉鏃朵笉缁樺埗 pin
 			if (m_pAnimationItem == pItem) {
+				::SelectObject(hMemDC, hFontOld);
 				continue;
 			}
 
-
-			// 绘制pin
+			// 缁樺埗 pin
 			RECT rcPin, rcPin2, rcPinText;
-			CPtrArray *pPins;
+			CPtrArray* pPins;
 			rcPinText.left = rcItem.left + 8;
 			rcPinText.right = rcItem.right - 8;
 
-
 			// in pins
-			PIN *pPin = NULL;
-			pPins = (CPtrArray *)pItem->pInPins;
+			PIN* pPin = NULL;
+			pPins = (CPtrArray*)pItem->pInPins;
 			for (int j = 0; j < pPins->GetSize(); j++) {
 				if (GetInPinRect(pItem, j, &rcPin)) {
-					pPin = (PIN *)pPins->GetAt(j);
+					pPin = (PIN*)pPins->GetAt(j);
 					::FrameRect(hMemDC, &rcPin, pItem->bHighlight ? hbrItemFrame[1] : hbrItemFrame[0]);
 
 					rcPin2.left = rcPin.left + 1;
@@ -2016,22 +2031,25 @@
 					rcPin2.top = rcPin.top + 1;
 					rcPin2.bottom = rcPin.bottom - 1;
 					nPinState = GetPinState(pPin);
-					::FillRect(hMemDC, &rcPin2, nPinState == 0 ? (pItem->bHighlight ? hbrItemBackground[1] : hbrItemBackground[0]) : hbrPinBackground[nPinState]);
+					::FillRect(hMemDC, &rcPin2,
+						nPinState == 0
+						? (pItem->bHighlight ? hbrItemBackground[1] : hbrItemBackground[0])
+						: hbrPinBackground[nPinState]);
 
 					if (pItem->nShowType != ITEM_SMALL) {
 						rcPinText.top = rcPin.top - 12;
 						rcPinText.bottom = rcPin.bottom + 12;
 						::SetTextColor(hMemDC, pItem->bHighlight ? m_crItemIdText[1] : m_crItemIdText[0]);
-						::DrawText(hMemDC, pPin->text, (int)strlen(pPin->text), &rcPinText, DT_LEFT | DT_VCENTER | DT_SINGLELINE | DT_END_ELLIPSIS);
+						::DrawText(hMemDC, pPin->text, (int)strlen(pPin->text), &rcPinText,
+							DT_LEFT | DT_VCENTER | DT_SINGLELINE | DT_END_ELLIPSIS);
 					}
 				}
 			}
 
-
 			// out pins
-			pPins = (CPtrArray *)pItem->pOutPins;
+			pPins = (CPtrArray*)pItem->pOutPins;
 			for (int j = 0; j < pPins->GetSize(); j++) {
-				pPin = (PIN *)pPins->GetAt(j);
+				pPin = (PIN*)pPins->GetAt(j);
 				if (GetOutPinRect(pItem, j, &rcPin)) {
 					::FrameRect(hMemDC, &rcPin, pItem->bHighlight ? hbrItemFrame[1] : hbrItemFrame[0]);
 
@@ -2040,50 +2058,53 @@
 					rcPin2.top = rcPin.top + 1;
 					rcPin2.bottom = rcPin.bottom - 1;
 					nPinState = GetPinState(pPin);
-					::FillRect(hMemDC, &rcPin2, nPinState == 0 ? (pItem->bHighlight ? hbrItemBackground[1] : hbrItemBackground[0]) : hbrPinBackground[nPinState]);
+					::FillRect(hMemDC, &rcPin2,
+						nPinState == 0
+						? (pItem->bHighlight ? hbrItemBackground[1] : hbrItemBackground[0])
+						: hbrPinBackground[nPinState]);
 
 					if (pItem->nShowType != ITEM_SMALL) {
 						rcPinText.top = rcPin.top - 12;
 						rcPinText.bottom = rcPin.bottom + 12;
 						::SetTextColor(hMemDC, pItem->bHighlight ? m_crItemIdText[1] : m_crItemIdText[0]);
-						::DrawText(hMemDC, pPin->text, (int)strlen(pPin->text), &rcPinText, DT_RIGHT | DT_VCENTER | DT_SINGLELINE | DT_END_ELLIPSIS);
+						::DrawText(hMemDC, pPin->text, (int)strlen(pPin->text), &rcPinText,
+							DT_RIGHT | DT_VCENTER | DT_SINGLELINE | DT_END_ELLIPSIS);
 					}
 				}
 			}
 
-			::DeleteObject(hbrItemFrame);
 			::SelectObject(hMemDC, hFontOld);
 		}
 
-
-		// 绘制连接线,保存线条在最后绘制
+		// 鍐嶇粯鍒惰繛鎺ョ嚎
 		for (int i = 0; i < nItemCount; i++) {
-			EQITEM *pItem = (EQITEM*)m_arItem.GetAt(i);
+			EQITEM* pItem = (EQITEM*)m_arItem.GetAt(i);
 			if (pItem->nFlashFlag == 1) {
 				continue;
 			}
 
-			PIN *pPin = NULL;
-			CPtrArray *pPins;
-
-			// out pins边线
+			PIN* pPin = NULL;
+			CPtrArray* pPins;
 			RECT rcItem1, rcItem2;
-			pPins = (CPtrArray *)pItem->pOutPins;
+
+			// out pins 杈圭嚎
+			pPins = (CPtrArray*)pItem->pOutPins;
 			for (int j = 0; j < pPins->GetSize(); j++) {
-				pPin = (PIN *)pPins->GetAt(j);
+				pPin = (PIN*)pPins->GetAt(j);
 				if (pPin->pConnectedPin != NULL) {
 					POINT pt1, pt2;
 					if (GetPinPoint(pPin, &pt1) && GetPinPoint(pPin->pConnectedPin, &pt2)) {
 						GetItemRect(pItem, &rcItem1);
 						GetItemRect(pPin->pConnectedPin->pItem, &rcItem2);
-						DrawPinConnectedLine(&graphics, &brush1, pPin == m_pSelLineOutPin ? &pen2 : &pen1,
+						DrawPinConnectedLine(&graphics, &brush1,
+							pPin == m_pSelLineOutPin ? &pen2 : &pen1,
 							&pt1, &pt2, &rcItem1, &rcItem2, pPin);
 					}
 				}
 			}
 		}
 
-
+		// 鍒犻櫎 brush
 		for (int i = 0; i < 3; i++) {
 			::DeleteObject(hbrPinBackground[i]);
 		}
@@ -2091,11 +2112,9 @@
 		::DeleteObject(hbrItemBackground[1]);
 		::DeleteObject(hbrItemFrame[0]);
 		::DeleteObject(hbrItemFrame[1]);
-		::DeleteObject(hbrIndicator);		
+		::DeleteObject(hbrIndicator);
+		::DeleteObject(hbrIndicatorGray);
 	}
-
-
-
 
 	// EndPaint
 	::BitBlt(hDC, 0, 0, rcClient.right - rcClient.left, rcClient.bottom - rcClient.top,
@@ -2104,9 +2123,9 @@
 	::DeleteObject(hBitmap);
 	::DeleteDC(hMemDC);
 
-
 	return 1;
 }
+
 
 /*
  * WM_SIZE
@@ -2354,8 +2373,8 @@
 
 
 /*
- * 设置背景颜色
- * color -- 背景色
+ * 璁剧疆鑳屾櫙棰滆壊
+ * color -- 鑳屾櫙鑹�
  */
 void CEqsGraphWnd::SetBkgndColor(COLORREF color)
 {
@@ -2363,8 +2382,8 @@
 }
 
 /*
- * 边框颜色
- * color -- 边框色
+ * 杈规棰滆壊
+ * color -- 杈规鑹�
  */
 void CEqsGraphWnd::SetFrameColor(COLORREF color)
 {
@@ -2408,11 +2427,15 @@
 	SetTimer(m_hWnd, TIMER_ANIMATION_RECT, uElpase, NULL);
 }
 
-void CEqsGraphWnd::ShowItemIndicator(DWORD_PTR dwItemData, BOOL bShow)
+void CEqsGraphWnd::ShowItemIndicator(DWORD_PTR dwItemData, int state, int nIndex)
 {
+	if (nIndex < 0 || nIndex >= EQITEM_INDICATOR_COUNT) {
+		return;
+	}
+
 	EQITEM* pItem = GetItem(dwItemData);
 	if (pItem != nullptr) {
-		pItem->bShowIndicator[0] = bShow;
+		pItem->nIndicatorState[nIndex] = (BYTE)state;
 		::InvalidateRect(m_hWnd, nullptr, TRUE);
 	}
 }

--
Gitblit v1.9.3