From fec3ff7b0bb0a4e53c2f9ff26cd06659a0c8aff9 Mon Sep 17 00:00:00 2001
From: LAPTOP-SNT8I5JK\Boounion <Chenluhua@qq.com>
Date: 星期二, 07 一月 2025 11:08:34 +0800
Subject: [PATCH] 1.工具条; 2.左侧PLC列表;
---
SourceCode/Bond/BoounionPLC/res/application.exe.manifest | 20 +
SourceCode/Bond/x64/Debug/res2/add_gray_32.ico | 0
SourceCode/Bond/BoounionPLC/BoounionPLC.rc | 0
SourceCode/Bond/BoounionPLC/Common.h | 2
SourceCode/Bond/BoounionPLC/ApredTreeCtrl.h | 66 ++++
SourceCode/Bond/BoounionPLC/Resource.h | 0
SourceCode/Bond/BoounionPLC/TopToolbar.cpp | 26 -
SourceCode/Bond/x64/BoounionPLC/Debug/Res/add_gray_32.ico | 0
SourceCode/Bond/BoounionPLC/PagePlcList.h | 40 ++
SourceCode/Bond/x64/BoounionPLC/Debug/Res/Settings_High_32.ico | 0
SourceCode/Bond/x64/BoounionPLC/Debug/Res/add_blue_32.ico | 0
SourceCode/Bond/x64/BoounionPLC/Debug/Res/Operator_High_32.ico | 0
SourceCode/Bond/BoounionPLC/BoounionPLCDlg.cpp | 46 ++-
SourceCode/Bond/BoounionPLC/BoounionPLCDlg.h | 3
SourceCode/Bond/x64/BoounionPLC/Debug/Res/Settings_Gray_32.ico | 0
SourceCode/Bond/BoounionPLC/TopToolbar.h | 4
SourceCode/Bond/BoounionPLC/ApredTreeCtrl.cpp | 466 +++++++++++++++++++++++++++++++++
SourceCode/Bond/BoounionPLC/BoounionPLC.vcxproj.filters | 15 +
SourceCode/Bond/x64/BoounionPLC/Debug/Res/Operator_Gray_32.ico | 0
SourceCode/Bond/x64/Debug/res2/add_blue_32.ico | 0
SourceCode/Bond/BoounionPLC/BoounionPLC.vcxproj | 8
SourceCode/Bond/BoounionPLC/PagePlcList.cpp | 97 ++++++
22 files changed, 754 insertions(+), 39 deletions(-)
diff --git a/SourceCode/Bond/BoounionPLC/ApredTreeCtrl.cpp b/SourceCode/Bond/BoounionPLC/ApredTreeCtrl.cpp
new file mode 100644
index 0000000..163b19e
--- /dev/null
+++ b/SourceCode/Bond/BoounionPLC/ApredTreeCtrl.cpp
@@ -0,0 +1,466 @@
+#include "stdafx.h"
+#include "ApredTreeCtrl.h"
+
+
+#define ROFFSET 7
+#define WIDE 10
+#define WIDE2 5
+#define EXPANDED_WIDE 8
+
+#define BADGE_HIDE 0
+#define BADGE_DOT 1
+#define BADGE_NUMBER 2
+#define BADGE_DOT_WIDTH 12
+#define BADGE_NUMBER_WIDTH 20
+
+
+IMPLEMENT_DYNAMIC(CApredTreeCtrl, CTreeCtrl)
+
+CApredTreeCtrl::CApredTreeCtrl()
+{
+ m_hBrushItem[0] = NULL;
+ m_hBrushItem[1] = NULL;
+ m_hBrushItem[2] = NULL;
+ m_hPenItem[0] = nullptr;
+ m_hPenItem[1] = nullptr;
+ m_hPenItem[2] = nullptr;
+ m_hBrushBtn[0] = nullptr;
+ m_hBrushBtn[1] = nullptr;
+ m_hBrushBtn[2] = nullptr;
+ m_crItemBk[0] = RGB(255,255,255);
+ m_crItemBk[1] = RGB(228, 229, 234);
+ m_crItemBk[2] = RGB(236, 237, 241);
+ m_crText[0] = RGB(28, 28, 28);
+ m_crText[1] = RGB(28, 28, 28);
+ m_crText[2] = RGB(28, 28, 28);
+ m_hHoverItem = nullptr;
+ m_bTracking = FALSE;
+}
+
+CApredTreeCtrl::~CApredTreeCtrl()
+{
+ if (m_hBrushItem[0] != NULL) {
+ ::DeleteObject(m_hBrushItem[0]);
+ }
+ if (m_hBrushItem[1] != NULL) {
+ ::DeleteObject(m_hBrushItem[1]);
+ }
+ if (m_hBrushItem[2] != NULL) {
+ ::DeleteObject(m_hBrushItem[2]);
+ }
+ if (m_hBrushBtn[0] != NULL) {
+ ::DeleteObject(m_hBrushBtn[0]);
+ }
+ if (m_hBrushBtn[1] != NULL) {
+ ::DeleteObject(m_hBrushBtn[1]);
+ }
+ if (m_hBrushBtn[2] != NULL) {
+ ::DeleteObject(m_hBrushBtn[2]);
+ }
+ if (m_hPenItem[0] != nullptr) {
+ ::DeleteObject(m_hPenItem[0]);
+ }
+ if (m_hPenItem[1] != nullptr) {
+ ::DeleteObject(m_hPenItem[1]);
+ }
+ if (m_hPenItem[2] != nullptr) {
+ ::DeleteObject(m_hPenItem[2]);
+ }
+}
+
+BEGIN_MESSAGE_MAP(CApredTreeCtrl, CTreeCtrl)
+ ON_WM_PAINT()
+ ON_WM_MOUSEMOVE()
+ ON_WM_MOUSEHOVER()
+ ON_WM_MOUSELEAVE()
+ ON_WM_TIMER()
+ ON_WM_LBUTTONDOWN()
+ ON_WM_CREATE()
+END_MESSAGE_MAP()
+
+void CApredTreeCtrl::DrawItemButton(HTREEITEM hItem, HDC hDC, CRect* pRect)
+{
+ // 按钮要刷一下
+ POINT pt[3];
+ if ((GetItemState(hItem, TVIS_EXPANDED) & TVIS_EXPANDED) == TVIS_EXPANDED) {
+ int nBottomOffset = (pRect->Height() - EXPANDED_WIDE) / 2;
+ pt[0].x = pRect->right - ROFFSET - EXPANDED_WIDE;
+ pt[0].y = pRect->bottom - nBottomOffset;
+ pt[1].x = pRect->right - ROFFSET;
+ pt[1].y = pRect->bottom - nBottomOffset;
+ pt[2].x = pRect->right - ROFFSET;
+ pt[2].y = pRect->bottom - nBottomOffset - EXPANDED_WIDE;
+ }
+ else {
+ int nBottomOffset = (pRect->Height() - WIDE) / 2;
+ pt[0].x = pRect->right - ROFFSET - WIDE2;
+ pt[0].y = pRect->bottom - nBottomOffset - WIDE;
+ pt[1].x = pRect->right - ROFFSET - WIDE2;
+ pt[1].y = pRect->bottom - nBottomOffset;
+ pt[2].x = pRect->right - ROFFSET;
+ pt[2].y = pRect->bottom - nBottomOffset - WIDE2;
+ }
+
+ ::Polygon(hDC, pt, 3);
+}
+
+void CApredTreeCtrl::OnPaint()
+{
+ HDC hDC, hMemDC;
+ HBITMAP hBitmap;
+ RECT rcClient;
+ CString strText;
+ HFONT hFont;
+ HBRUSH hBrushBK;
+
+
+ if (m_hBrushItem[0] == nullptr) {
+ m_hBrushItem[0] = CreateSolidBrush(m_crItemBk[0]);
+ }
+ if (m_hBrushItem[1] == nullptr) {
+ m_hBrushItem[1] = CreateSolidBrush(m_crItemBk[1]);
+ }
+ if (m_hBrushItem[2] == nullptr) {
+ m_hBrushItem[2] = CreateSolidBrush(m_crItemBk[2]);
+ }
+ if (m_hBrushBtn[0] == nullptr) {
+ m_hBrushBtn[0] = CreateSolidBrush(m_crText[0]);
+ }
+ if (m_hBrushBtn[1] == nullptr) {
+ m_hBrushBtn[1] = CreateSolidBrush(m_crText[1]);
+ }
+ if (m_hBrushBtn[2] == nullptr) {
+ m_hBrushBtn[2] = CreateSolidBrush(m_crText[2]);
+ }
+ if (m_hPenItem[0] == nullptr) {
+ m_hPenItem[0] = ::CreatePen(PS_SOLID, 1, m_crText[0]);
+ }
+ if (m_hPenItem[1] == nullptr) {
+ m_hPenItem[1] = ::CreatePen(PS_SOLID, 1, m_crText[1]);
+ }
+ if (m_hPenItem[2] == nullptr) {
+ m_hPenItem[2] = ::CreatePen(PS_SOLID, 1, m_crText[2]);
+ }
+
+ // BeginPaint
+ PAINTSTRUCT ps;
+ hDC = ::BeginPaint(m_hWnd, &ps);
+ GetClientRect(&rcClient);
+
+ hMemDC = ::CreateCompatibleDC(hDC);
+ hBitmap = ::CreateCompatibleBitmap(hDC, rcClient.right - rcClient.left,
+ rcClient.bottom - rcClient.top);
+ ::SelectObject(hMemDC, hBitmap);
+
+ hFont = (HFONT)GetStockObject(DEFAULT_GUI_FONT);
+ ::SelectObject(hMemDC, hFont);
+ ::SetBkMode(hMemDC, TRANSPARENT);
+
+
+ // 背景颜色
+ hBrushBK = CreateSolidBrush(GetBkColor());
+ ::FillRect(hMemDC, &rcClient, hBrushBK);
+ DeleteObject(hBrushBK);
+
+
+
+ // 绘制子项
+ DrawItems(hMemDC);
+
+
+ // EndPaint
+ ::BitBlt(hDC, 0, 0, rcClient.right - rcClient.left, rcClient.bottom - rcClient.top,
+ hMemDC, 0, 0, SRCCOPY);
+ ::EndPaint(m_hWnd, &ps);
+ ::DeleteObject(hBitmap);
+ ::DeleteDC(hMemDC);
+}
+
+void CApredTreeCtrl::DrawItems(HDC hDC)
+{
+ HTREEITEM hCurrentItem;
+ int itemState;
+ CRect rcClient, rcItem, rcText;
+ GetClientRect(&rcClient);
+ Gdiplus::Graphics graphics(hDC);
+ graphics.SetSmoothingMode(Gdiplus::SmoothingModeAntiAlias);
+
+
+ // 绘制可见的子项
+ hCurrentItem = GetFirstVisibleItem();//获取第一个课可见的项
+ do {
+ if (GetItemRect(hCurrentItem, &rcItem, FALSE) && GetItemRect(hCurrentItem, &rcText, TRUE)) {
+ rcText.right = rcItem.right - 8;
+ rcText.left += 8;
+ CRect fillRect(0, rcItem.top, rcClient.right, rcItem.bottom);
+ if (rcItem.top > rcClient.bottom) {
+ break;
+ }
+
+
+ // 绘制子项背景
+ itemState = GetItemState(hCurrentItem, TVIF_STATE);
+ COLORREF crText = m_crText[0];
+ if (itemState & TVIS_SELECTED) {
+ crText = m_crText[1];
+ HRGN hRgn = CreateRoundRectRgn(rcItem.left, rcItem.top, rcItem.right, rcItem.bottom, 4, 4);
+ ::FillRgn(hDC, hRgn, m_hBrushItem[1]);
+ ::DeleteObject(hRgn);
+ ::SelectObject(hDC, m_hBrushBtn[1]);
+ ::SelectObject(hDC, m_hPenItem[1]);
+ }
+ else if (hCurrentItem == m_hHoverItem) {
+ crText = m_crText[2];
+ HRGN hRgn = CreateRoundRectRgn(rcItem.left, rcItem.top, rcItem.right, rcItem.bottom, 4, 4);
+ ::FillRgn(hDC, hRgn, m_hBrushItem[2]);
+ ::DeleteObject(hRgn);
+ ::SelectObject(hDC, m_hBrushBtn[2]);
+ ::SelectObject(hDC, m_hPenItem[2]);
+ }
+ else {
+ crText = m_crText[0];
+ ::SelectObject(hDC, m_hBrushBtn[0]);
+ ::SelectObject(hDC, m_hPenItem[0]);
+ }
+
+
+ //绘制展开图片
+ if (ItemHasChildren(hCurrentItem)) {
+ CRect rcBtn = rcText;
+ rcBtn.right = rcText.left - 2;
+ rcBtn.left -= rcBtn.right - 30;
+ DrawItemButton(hCurrentItem, hDC, &rcBtn);
+ }
+
+ // 图标
+ if (m_icons.find(hCurrentItem) != m_icons.end()) {
+ HICON hIcon = m_icons[hCurrentItem];
+ DrawIconEx(hDC, 8, (rcItem.bottom - rcItem.top - 32) / 2,
+ hIcon, 32, 32, 0, 0, DI_NORMAL);
+ rcText.left += 32;
+ rcText.left += 8;
+ }
+
+
+ //绘制文字
+ HFONT hFont = (HFONT)GetStockObject(DEFAULT_GUI_FONT);
+ ::SelectObject(hDC, hFont);
+ LOGFONT lf;
+ ::GetObject(hFont, sizeof(LOGFONT), &lf);
+ lf.lfWeight = FW_BOLD;
+ HFONT hFontBold = CreateFontIndirect(&lf);
+
+ ::SetTextColor(hDC, crText);
+ CString strText = GetItemText(hCurrentItem);
+ if (FindBoldItem(hCurrentItem)) {
+ ::SelectObject(hDC, hFontBold);
+ }
+ else {
+ ::SelectObject(hDC, hFont);
+ }
+ DrawText(hDC, strText, strText.GetLength(), &rcText, DT_LEFT | DT_VCENTER | DT_SINGLELINE);
+ ::DeleteObject(hFontBold);
+
+
+ // 是否有小圆点
+ if (m_badges.find(hCurrentItem) != m_badges.end()) {
+ BADGE& badge = m_badges[hCurrentItem];
+ if (badge.type == BADGE_DOT) {
+ Gdiplus::SolidBrush brush(Gdiplus::Color(GetRValue(badge.badgeBackground), GetGValue(badge.badgeBackground), GetBValue(badge.badgeBackground)));
+ int x = rcItem.right - 18 - BADGE_DOT_WIDTH;
+ int y = rcItem.top + (rcItem.Height() - BADGE_DOT_WIDTH) / 2;
+ graphics.FillEllipse(&brush, x, y, BADGE_DOT_WIDTH, BADGE_DOT_WIDTH);
+ }
+ else if (badge.type == BADGE_NUMBER) {
+ Gdiplus::SolidBrush brush(Gdiplus::Color(GetRValue(badge.badgeBackground), GetGValue(badge.badgeBackground), GetBValue(badge.badgeBackground)));
+ int x = rcItem.right - 18 - BADGE_NUMBER_WIDTH;
+ int y = rcItem.top + (rcItem.Height() - BADGE_NUMBER_WIDTH) / 2;
+ graphics.FillEllipse(&brush, x, y, BADGE_NUMBER_WIDTH, BADGE_NUMBER_WIDTH);
+ RECT rcBadge;
+ rcBadge.left = x;
+ rcBadge.right = rcBadge.left + BADGE_NUMBER_WIDTH;
+ rcBadge.top = y;
+ rcBadge.bottom = rcBadge.top + BADGE_NUMBER_WIDTH;
+ ::SetTextColor(hDC, badge.badgeForeground);
+ char szBuffer[32];
+ sprintf_s(szBuffer, 32, "%d%s", min(badge.number, 9), badge.number > 9 ? "+" : "");
+ DrawText(hDC, szBuffer, (int)strlen(szBuffer), &rcBadge, DT_CENTER | DT_VCENTER | DT_SINGLELINE);
+ }
+ }
+ }
+ } while ((hCurrentItem = GetNextVisibleItem(hCurrentItem)) != NULL);
+}
+
+void CApredTreeCtrl::OnMouseMove(UINT nFlags, CPoint point)
+{
+ // 检测并记录热点项
+ HTREEITEM hHoverItem = HitTest(point);
+ if (m_hHoverItem != hHoverItem) {
+ m_hHoverItem = hHoverItem;
+ InvalidateRect(NULL);
+ }
+
+ if (!m_bTracking) {
+ TRACKMOUSEEVENT tme;
+ tme.cbSize = sizeof(tme);
+ tme.dwFlags = TME_HOVER | TME_LEAVE; // 发送WM_MOUSEHOVER和WM_MOUSELEAVE
+ tme.hwndTrack = m_hWnd; // 指定要追踪的窗口
+ tme.dwHoverTime = 10; // 鼠标在按钮上停留超过10ms,才认为状态为HOVER
+ m_bTracking = _TrackMouseEvent(&tme); // 开启Windows的WM_MOUSELEAVEWM_MOUSEHOVER事件支持
+ }
+
+ CTreeCtrl::OnMouseMove(nFlags, point);
+}
+
+void CApredTreeCtrl::OnTimer(UINT_PTR nIDEvent)
+{
+ if (1 == nIDEvent) {
+ BOOL bNeedInvalidate = FALSE;
+ for (auto& item : m_badges) {
+ if (item.second.showTime > 0) {
+ item.second.showTime--;
+ if (item.second.showTime == 0) {
+ item.second.type = BADGE_HIDE;
+ bNeedInvalidate = TRUE;
+ }
+ }
+ }
+ if(bNeedInvalidate)
+ InvalidateRect(NULL, TRUE);
+ }
+
+
+ CTreeCtrl::OnTimer(nIDEvent);
+}
+
+void CApredTreeCtrl::OnMouseHover(UINT nFlags, CPoint point)
+{
+
+}
+
+void CApredTreeCtrl::OnMouseLeave()
+{
+ m_hHoverItem = nullptr;
+ m_bTracking = FALSE; // 若已经离开,则停止追踪
+ InvalidateRect(NULL);
+
+ CTreeCtrl::OnMouseLeave();
+}
+
+void CApredTreeCtrl::OnLButtonDown(UINT nFlags, CPoint point)
+{
+ HTREEITEM hItem = HitTest(point);
+ if (hItem != nullptr) {
+ SelectItem(hItem);
+ GetParent()->SendMessage(ID_MSG_TREE_CLICK_ITEM, (WPARAM)hItem, 0);
+ }
+
+ CTreeCtrl::OnLButtonDown(nFlags, point);
+}
+
+void CApredTreeCtrl::SetItemBadge(HTREEITEM hItem, COLORREF badgeBackground, COLORREF badgeForeground)
+{
+ if (m_badges.find(hItem) == m_badges.end()) {
+ BADGE badge;
+ badge.badgeBackground = badgeBackground;
+ badge.badgeForeground = badgeForeground;
+ badge.type = BADGE_HIDE;
+ badge.showTime = 0;
+ m_badges[hItem] = badge;
+ }
+ else {
+ BADGE& badge = m_badges[hItem];
+ badge.badgeBackground = badgeBackground;
+ badge.badgeForeground = badgeForeground;
+ badge.type = BADGE_HIDE;
+ }
+}
+
+void CApredTreeCtrl::ShowItemBadgeNumber(HTREEITEM hItem, int number)
+{
+ if (m_badges.find(hItem) == m_badges.end()) {
+ return;
+ }
+
+ BADGE& badge = m_badges[hItem];
+ badge.type = BADGE_NUMBER;
+ badge.number = number;
+ InvalidateRect(NULL, TRUE);
+}
+
+void CApredTreeCtrl::ShowItemBadgeDotMode(HTREEITEM hItem, int nSecond/* = 0*/)
+{
+ if (m_badges.find(hItem) == m_badges.end()) {
+ return;
+ }
+
+ BADGE& badge = m_badges[hItem];
+ if (badge.type != BADGE_DOT) {
+ badge.type = BADGE_DOT;
+ badge.showTime = nSecond;
+ InvalidateRect(NULL, TRUE);
+ }
+}
+
+void CApredTreeCtrl::HideItemBadge(HTREEITEM hItem)
+{
+ BADGE& badge = m_badges[hItem];
+ if (badge.type != BADGE_HIDE) {
+ badge.type = BADGE_HIDE;
+ badge.showTime = 0;
+ InvalidateRect(NULL, TRUE);
+ }
+}
+
+void CApredTreeCtrl::SetItemBold(HTREEITEM item)
+{
+ if (!FindBoldItem(item)) {
+ m_itemBolds.push_back(item);
+ }
+}
+
+void CApredTreeCtrl::CancelItemBold(HTREEITEM item)
+{
+ for (auto iter = m_itemBolds.begin(); iter != m_itemBolds.end(); iter++) {
+ if (*iter == item) {
+ m_itemBolds.erase(iter);
+ break;
+ }
+ }
+
+ InvalidateRect(NULL, TRUE);
+}
+
+BOOL CApredTreeCtrl::FindBoldItem(HTREEITEM item)
+{
+ BOOL bFound = FALSE;
+ for (auto i : m_itemBolds) {
+ if (i == item) return TRUE;
+ }
+
+ return FALSE;
+}
+
+
+int CApredTreeCtrl::OnCreate(LPCREATESTRUCT lpCreateStruct)
+{
+ if (CTreeCtrl::OnCreate(lpCreateStruct) == -1)
+ return -1;
+
+ SetTimer(1, 1000, nullptr);
+
+ return 0;
+}
+
+
+void CApredTreeCtrl::PreSubclassWindow()
+{
+ SetTimer(1, 1000, nullptr);
+
+ CTreeCtrl::PreSubclassWindow();
+}
+
+void CApredTreeCtrl::SetItemIcon(HTREEITEM hItem, HICON hIcon)
+{
+ m_icons[hItem] = hIcon;
+}
diff --git a/SourceCode/Bond/BoounionPLC/ApredTreeCtrl.h b/SourceCode/Bond/BoounionPLC/ApredTreeCtrl.h
new file mode 100644
index 0000000..17e5f0a
--- /dev/null
+++ b/SourceCode/Bond/BoounionPLC/ApredTreeCtrl.h
@@ -0,0 +1,66 @@
+#pragma once
+#include <afxcmn.h>
+#include <map>
+#include <vector>
+
+#define ID_MSG_TREE_CLICK_ITEM WM_USER+2080
+
+class CApredTreeCtrl :
+ public CTreeCtrl
+{
+public:
+ typedef struct tagBADGE
+ {
+ HTREEITEM hTreeItem;
+ COLORREF badgeBackground;
+ COLORREF badgeForeground;
+ int type; /* 0: 无,不显示*/
+ int number;
+ int showTime; /* 显示时长,0:永远*/
+ } BADGE;
+
+ DECLARE_DYNAMIC(CApredTreeCtrl)
+
+public:
+ CApredTreeCtrl();
+ virtual ~CApredTreeCtrl();
+
+
+public:
+ void SetItemBadge(HTREEITEM hItem, COLORREF badgeBackground, COLORREF badgeForeground);
+ void ShowItemBadgeNumber(HTREEITEM hItem, int number);
+ void ShowItemBadgeDotMode(HTREEITEM hItem, int nSecond = 0);
+ void HideItemBadge(HTREEITEM hItem);
+ void SetItemBold(HTREEITEM item);
+ void CancelItemBold(HTREEITEM item);
+ BOOL FindBoldItem(HTREEITEM item);
+ void SetItemIcon(HTREEITEM hItem, HICON hIcon);
+
+private:
+ void DrawItemButton(HTREEITEM hItem, HDC hDC, CRect* pRect);
+ void DrawItems(HDC hDC);
+
+private:
+ std::map<HTREEITEM, BADGE> m_badges;
+ std::map<HTREEITEM, HICON> m_icons;
+ std::vector< HTREEITEM> m_itemBolds;
+ HBRUSH m_hBrushItem[3];
+ COLORREF m_crItemBk[3];
+ COLORREF m_crText[3];
+ HBRUSH m_hBrushBtn[3];
+ HPEN m_hPenItem[3];
+ HTREEITEM m_hHoverItem;
+ BOOL m_bTracking; // 跟踪
+
+public:
+ DECLARE_MESSAGE_MAP()
+ afx_msg void OnPaint();
+ afx_msg void OnMouseMove(UINT nFlags, CPoint point);
+ afx_msg void OnMouseHover(UINT nFlags, CPoint point);
+ afx_msg void OnMouseLeave();
+ afx_msg void OnTimer(UINT_PTR nIDEvent);
+ afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
+ afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
+ virtual void PreSubclassWindow();
+};
+
diff --git a/SourceCode/Bond/BoounionPLC/BoounionPLC.rc b/SourceCode/Bond/BoounionPLC/BoounionPLC.rc
index 0a1c8d5..c700a40 100644
--- a/SourceCode/Bond/BoounionPLC/BoounionPLC.rc
+++ b/SourceCode/Bond/BoounionPLC/BoounionPLC.rc
Binary files differ
diff --git a/SourceCode/Bond/BoounionPLC/BoounionPLC.vcxproj b/SourceCode/Bond/BoounionPLC/BoounionPLC.vcxproj
index fa0be85..1b7c789 100644
--- a/SourceCode/Bond/BoounionPLC/BoounionPLC.vcxproj
+++ b/SourceCode/Bond/BoounionPLC/BoounionPLC.vcxproj
@@ -78,6 +78,7 @@
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
+ <OutDir>$(SolutionDir)\$(Platform)\BoounionPLC\$(Configuration)\</OutDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
@@ -190,6 +191,7 @@
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\BondEq\HorizontalLine.h" />
+ <ClInclude Include="ApredTreeCtrl.h" />
<ClInclude Include="BlButton.h" />
<ClInclude Include="BoounionPLC.h" />
<ClInclude Include="BoounionPLCDlg.h" />
@@ -197,6 +199,7 @@
<ClInclude Include="Configuration.h" />
<ClInclude Include="Log.h" />
<ClInclude Include="Model.h" />
+ <ClInclude Include="PagePlcList.h" />
<ClInclude Include="Resource.h" />
<ClInclude Include="stdafx.h" />
<ClInclude Include="targetver.h" />
@@ -205,12 +208,14 @@
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\BondEq\HorizontalLine.cpp" />
+ <ClCompile Include="ApredTreeCtrl.cpp" />
<ClCompile Include="BlButton.cpp" />
<ClCompile Include="BoounionPLC.cpp" />
<ClCompile Include="BoounionPLCDlg.cpp" />
<ClCompile Include="Configuration.cpp" />
<ClCompile Include="Log.cpp" />
<ClCompile Include="Model.cpp" />
+ <ClCompile Include="PagePlcList.cpp" />
<ClCompile Include="stdafx.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
@@ -229,6 +234,9 @@
<ItemGroup>
<Image Include="res\BoounionPLC.ico" />
</ItemGroup>
+ <ItemGroup>
+ <Manifest Include="res\application.exe.manifest" />
+ </ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
diff --git a/SourceCode/Bond/BoounionPLC/BoounionPLC.vcxproj.filters b/SourceCode/Bond/BoounionPLC/BoounionPLC.vcxproj.filters
index 36108b3..3cad77d 100644
--- a/SourceCode/Bond/BoounionPLC/BoounionPLC.vcxproj.filters
+++ b/SourceCode/Bond/BoounionPLC/BoounionPLC.vcxproj.filters
@@ -57,6 +57,12 @@
<ClInclude Include="VerticalLine.h">
<Filter>澶存枃浠�</Filter>
</ClInclude>
+ <ClInclude Include="PagePlcList.h">
+ <Filter>澶存枃浠�</Filter>
+ </ClInclude>
+ <ClInclude Include="ApredTreeCtrl.h">
+ <Filter>澶存枃浠�</Filter>
+ </ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="BoounionPLC.cpp">
@@ -89,6 +95,12 @@
<ClCompile Include="VerticalLine.cpp">
<Filter>婧愭枃浠�</Filter>
</ClCompile>
+ <ClCompile Include="PagePlcList.cpp">
+ <Filter>婧愭枃浠�</Filter>
+ </ClCompile>
+ <ClCompile Include="ApredTreeCtrl.cpp">
+ <Filter>婧愭枃浠�</Filter>
+ </ClCompile>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="BoounionPLC.rc">
@@ -105,4 +117,7 @@
<Filter>璧勬簮鏂囦欢</Filter>
</Image>
</ItemGroup>
+ <ItemGroup>
+ <Manifest Include="res\application.exe.manifest" />
+ </ItemGroup>
</Project>
\ No newline at end of file
diff --git a/SourceCode/Bond/BoounionPLC/BoounionPLCDlg.cpp b/SourceCode/Bond/BoounionPLC/BoounionPLCDlg.cpp
index a7524f9..a0db823 100644
--- a/SourceCode/Bond/BoounionPLC/BoounionPLCDlg.cpp
+++ b/SourceCode/Bond/BoounionPLC/BoounionPLCDlg.cpp
@@ -6,6 +6,7 @@
#include "BoounionPLC.h"
#include "BoounionPLCDlg.h"
#include "afxdialogex.h"
+#include "Common.h"
#ifdef _DEBUG
#define new DEBUG_NEW
@@ -54,6 +55,8 @@
{
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
m_pTopToolbar = nullptr;
+ m_crBkgnd = APP_MAIN_DLG_BACKGROUND;
+ m_hbrBkgnd = nullptr;
}
void CBoounionPLCDlg::DoDataExchange(CDataExchange* pDX)
@@ -107,13 +110,18 @@
m_pTopToolbar = new CTopToolbar();
m_pTopToolbar->Create(IDD_TOP_TOOLBAR, this);
m_pTopToolbar->ShowWindow(SW_SHOW);
- m_pTopToolbar->GetBtn(IDC_BUTTON_STOP)->EnableWindow(FALSE);
- m_pTopToolbar->GetBtn(IDC_BUTTON_ALARM)->EnableWindow(FALSE);
HMENU hMenu = m_pTopToolbar->GetOperatorMenu();
ASSERT(hMenu);
::EnableMenuItem(hMenu, ID_OPEATOR_SWITCH, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
+ // page plc list
+ m_pPagePlcList = new CPagePlcList();
+ m_pPagePlcList->Create(IDD_PAGE_PLC_LIST, this);
+ m_pPagePlcList->ShowWindow(SW_SHOW);
+
+
+ ShowWindow(SW_MAXIMIZE);
Resize();
@@ -179,6 +187,17 @@
delete m_pTopToolbar;
m_pTopToolbar = nullptr;
}
+
+ if (m_pPagePlcList != nullptr) {
+ m_pPagePlcList->DestroyWindow();
+ delete m_pPagePlcList;
+ m_pPagePlcList = nullptr;
+ }
+
+ if (m_hbrBkgnd != nullptr) {
+ ::DeleteObject(m_hbrBkgnd);
+ m_hbrBkgnd = nullptr;
+ }
}
@@ -190,7 +209,8 @@
Resize();
}
-#define TOOLBAR_HEIGHT 78
+#define TOOLBAR_HEIGHT 78
+#define PAGE_PLC_LIST_WIDTH 218
void CBoounionPLCDlg::Resize()
{
CRect rcClient, rcItem;
@@ -200,14 +220,7 @@
m_pTopToolbar->MoveWindow(0, 0, rcClient.Width(), TOOLBAR_HEIGHT);
y += TOOLBAR_HEIGHT;
- /*
- ASSERT(m_pPanelProject);
- int nPanelEquipmentWidth = m_pPanelProject->GetPanelWidth();
- m_pPanelProject->MoveWindow(0, y, nPanelEquipmentWidth, rcClient.bottom - y);
-
- int x = nPanelEquipmentWidth;
- m_pMainContainer->MoveWindow(x + 1, y, rcClient.Width() - x - 0, rcClient.bottom - y - 2);
- */
+ m_pPagePlcList->MoveWindow(0, y, PAGE_PLC_LIST_WIDTH, rcClient.Height() - y - 2);
}
@@ -215,8 +228,13 @@
{
HBRUSH hbr = CDialogEx::OnCtlColor(pDC, pWnd, nCtlColor);
- // TODO: 在此更改 DC 的任何特性
+ if (nCtlColor == CTLCOLOR_STATIC) {
+ pDC->SetBkColor(m_crBkgnd);
+ }
- // TODO: 如果默认的不是所需画笔,则返回另一个画笔
- return hbr;
+ if (m_hbrBkgnd == nullptr) {
+ m_hbrBkgnd = CreateSolidBrush(m_crBkgnd);
+ }
+
+ return m_hbrBkgnd;
}
diff --git a/SourceCode/Bond/BoounionPLC/BoounionPLCDlg.h b/SourceCode/Bond/BoounionPLC/BoounionPLCDlg.h
index e2a2da9..9edd29c 100644
--- a/SourceCode/Bond/BoounionPLC/BoounionPLCDlg.h
+++ b/SourceCode/Bond/BoounionPLC/BoounionPLCDlg.h
@@ -4,7 +4,7 @@
#pragma once
#include "TopToolbar.h"
-
+#include "PagePlcList.h"
// CBoounionPLCDlg 对话框
class CBoounionPLCDlg : public CDialogEx
@@ -22,6 +22,7 @@
HBRUSH m_hbrBkgnd;
IObserver* m_pObserver;
CTopToolbar* m_pTopToolbar;
+ CPagePlcList* m_pPagePlcList;
// 对话框数据
diff --git a/SourceCode/Bond/BoounionPLC/Common.h b/SourceCode/Bond/BoounionPLC/Common.h
index 861ec49..f3816ef 100644
--- a/SourceCode/Bond/BoounionPLC/Common.h
+++ b/SourceCode/Bond/BoounionPLC/Common.h
@@ -6,4 +6,6 @@
#define RX_CODE_LOG 1000
/* 定制颜色 */
+#define APP_MAIN_DLG_BACKGROUND RGB(255, 255, 255)
#define TOP_TOOLBAR_BACKGROUND RGB(240, 240, 240)
+#define PAGE_PLC_LIST_BACKGROUND RGB(245, 245, 250)
\ No newline at end of file
diff --git a/SourceCode/Bond/BoounionPLC/PagePlcList.cpp b/SourceCode/Bond/BoounionPLC/PagePlcList.cpp
new file mode 100644
index 0000000..d883f2f
--- /dev/null
+++ b/SourceCode/Bond/BoounionPLC/PagePlcList.cpp
@@ -0,0 +1,97 @@
+// PagePlcList.cpp : 实现文件
+//
+
+#include "stdafx.h"
+#include "BoounionPLC.h"
+#include "PagePlcList.h"
+#include "afxdialogex.h"
+#include "Common.h"
+
+
+// CPagePlcList 对话框
+
+IMPLEMENT_DYNAMIC(CPagePlcList, CDialogEx)
+
+CPagePlcList::CPagePlcList(CWnd* pParent /*=NULL*/)
+ : CDialogEx(IDD_PAGE_PLC_LIST, pParent)
+{
+ m_crBkgnd = PAGE_PLC_LIST_BACKGROUND;
+ m_hbrBkgnd = nullptr;
+}
+
+CPagePlcList::~CPagePlcList()
+{
+}
+
+void CPagePlcList::DoDataExchange(CDataExchange* pDX)
+{
+ CDialogEx::DoDataExchange(pDX);
+ DDX_Control(pDX, IDC_TREE1, m_treeCtrl);
+}
+
+
+BEGIN_MESSAGE_MAP(CPagePlcList, CDialogEx)
+ ON_WM_CTLCOLOR()
+ ON_WM_DESTROY()
+ ON_WM_SIZE()
+END_MESSAGE_MAP()
+
+
+// CPagePlcList 消息处理程序
+
+
+BOOL CPagePlcList::OnInitDialog()
+{
+ CDialogEx::OnInitDialog();
+
+
+ m_treeCtrl.SetBkColor(PAGE_PLC_LIST_BACKGROUND);
+ m_treeCtrl.SetItemHeight(50);
+ ReadPLCList();
+
+ return TRUE; // return TRUE unless you set the focus to a control
+ // 异常: OCX 属性页应返回 FALSE
+}
+
+
+HBRUSH CPagePlcList::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
+{
+ HBRUSH hbr = CDialogEx::OnCtlColor(pDC, pWnd, nCtlColor);
+
+ if (nCtlColor == CTLCOLOR_STATIC) {
+ pDC->SetBkColor(m_crBkgnd);
+ }
+
+ if (m_hbrBkgnd == nullptr) {
+ m_hbrBkgnd = CreateSolidBrush(m_crBkgnd);
+ }
+
+ return m_hbrBkgnd;
+}
+
+
+void CPagePlcList::OnDestroy()
+{
+ CDialogEx::OnDestroy();
+
+ // TODO: 在此处添加消息处理程序代码
+}
+
+void CPagePlcList::OnSize(UINT nType, int cx, int cy)
+{
+ CDialogEx::OnSize(nType, cx, cy);
+ if (GetDlgItem(IDC_TREE1) == nullptr) return;
+
+ CRect rcClient;
+ GetClientRect(&rcClient);
+ GetDlgItem(IDC_TREE1)->MoveWindow(12, 12, rcClient.Width() - 24, rcClient.Height() - 24);
+ GetDlgItem(IDC_TOOLBAR_LINE1)->MoveWindow(rcClient.right - 3, 0,
+ 2, rcClient.Height());
+ GetDlgItem(IDC_TOOLBAR_LINE1)->Invalidate();
+}
+
+void CPagePlcList::ReadPLCList()
+{
+ m_treeCtrl.InsertItem("PLC1", nullptr, nullptr);
+ m_treeCtrl.InsertItem("PLC2", nullptr, nullptr);
+}
\ No newline at end of file
diff --git a/SourceCode/Bond/BoounionPLC/PagePlcList.h b/SourceCode/Bond/BoounionPLC/PagePlcList.h
new file mode 100644
index 0000000..9098887
--- /dev/null
+++ b/SourceCode/Bond/BoounionPLC/PagePlcList.h
@@ -0,0 +1,40 @@
+#pragma once
+#include "ApredTreeCtrl.h"
+
+
+// CPagePlcList 对话框
+
+class CPagePlcList : public CDialogEx
+{
+ DECLARE_DYNAMIC(CPagePlcList)
+
+public:
+ CPagePlcList(CWnd* pParent = NULL); // 标准构造函数
+ virtual ~CPagePlcList();
+
+
+private:
+ void ReadPLCList();
+
+
+private:
+ CApredTreeCtrl m_treeCtrl;
+ COLORREF m_crBkgnd;
+ HBRUSH m_hbrBkgnd;
+
+
+// 对话框数据
+#ifdef AFX_DESIGN_TIME
+ enum { IDD = IDD_PAGE_PLC_LIST };
+#endif
+
+protected:
+ virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持
+
+ DECLARE_MESSAGE_MAP()
+public:
+ virtual BOOL OnInitDialog();
+ afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor);
+ afx_msg void OnDestroy();
+ afx_msg void OnSize(UINT nType, int cx, int cy);
+};
diff --git a/SourceCode/Bond/BoounionPLC/Resource.h b/SourceCode/Bond/BoounionPLC/Resource.h
index 1315a8c..c17f449 100644
--- a/SourceCode/Bond/BoounionPLC/Resource.h
+++ b/SourceCode/Bond/BoounionPLC/Resource.h
Binary files differ
diff --git a/SourceCode/Bond/BoounionPLC/TopToolbar.cpp b/SourceCode/Bond/BoounionPLC/TopToolbar.cpp
index 56f41a9..5cd0f56 100644
--- a/SourceCode/Bond/BoounionPLC/TopToolbar.cpp
+++ b/SourceCode/Bond/BoounionPLC/TopToolbar.cpp
@@ -26,9 +26,7 @@
void CTopToolbar::DoDataExchange(CDataExchange* pDX)
{
CDialogEx::DoDataExchange(pDX);
- DDX_Control(pDX, IDC_BUTTON_RUN, m_btnRun);
- DDX_Control(pDX, IDC_BUTTON_STOP, m_btnStop);
- DDX_Control(pDX, IDC_BUTTON_ALARM, m_btnAlarm);
+ DDX_Control(pDX, IDC_BUTTON_ADD, m_btnAdd);
DDX_Control(pDX, IDC_BUTTON_SETTINGS, m_btnSettings);
DDX_Control(pDX, IDC_BUTTON_OPERATOR, m_btnOperator);
}
@@ -49,9 +47,7 @@
{
CDialogEx::OnInitDialog();
- InitBtn(m_btnRun, "Run_High_32.ico", "Run_Gray_32.ico");
- InitBtn(m_btnStop, "Stop_High_32.ico", "Stop_Gray_32.ico");
- InitBtn(m_btnAlarm, "Alarm_o_32.ico", "Alarm_gray_32.ico");
+ InitBtn(m_btnAdd, "Add_blue_32.ico", "Add_Gray_32.ico");
InitBtn(m_btnSettings, "Settings_High_32.ico", "Settings_Gray_32.ico");
InitBtn(m_btnOperator, "Operator_High_32.ico", "Operator_Gray_32.ico");
HMENU hMenu = LoadMenu(AfxGetInstanceHandle(), MAKEINTRESOURCEA(IDR_MENU_OPEATOR));
@@ -92,7 +88,7 @@
void CTopToolbar::OnSize(UINT nType, int cx, int cy)
{
CDialogEx::OnSize(nType, cx, cy);
- if (GetDlgItem(IDC_BUTTON_RUN) == nullptr) return;
+ if (GetDlgItem(IDC_BUTTON_ADD) == nullptr) return;
Resize();
}
@@ -106,17 +102,7 @@
int nBthHeight = (rcClient.Height() - 10);
int x = 2, y = 3;
- pItem = GetDlgItem(IDC_BUTTON_RUN);
- pItem->MoveWindow(x, y, BTN_WIDTH, nBthHeight);
- x += BTN_WIDTH;
- x += 2;
-
- pItem = GetDlgItem(IDC_BUTTON_STOP);
- pItem->MoveWindow(x, y, BTN_WIDTH, nBthHeight);
- x += BTN_WIDTH;
- x += 2;
-
- pItem = GetDlgItem(IDC_BUTTON_ALARM);
+ pItem = GetDlgItem(IDC_BUTTON_ADD);
pItem->MoveWindow(x, y, BTN_WIDTH, nBthHeight);
x += BTN_WIDTH;
x += 2;
@@ -174,9 +160,7 @@
BOOL CTopToolbar::OnCommand(WPARAM wParam, LPARAM lParam)
{
switch (LOWORD(wParam)) {
- case IDC_BUTTON_RUN:
- case IDC_BUTTON_STOP:
- case IDC_BUTTON_ALARM:
+ case IDC_BUTTON_ADD:
case IDC_BUTTON_SETTINGS:
GetParent()->SendMessage(ID_MSG_TOOLBAR_BTN_CLICKED, 0, LOWORD(wParam));
break;
diff --git a/SourceCode/Bond/BoounionPLC/TopToolbar.h b/SourceCode/Bond/BoounionPLC/TopToolbar.h
index 1228bbb..58005b4 100644
--- a/SourceCode/Bond/BoounionPLC/TopToolbar.h
+++ b/SourceCode/Bond/BoounionPLC/TopToolbar.h
@@ -30,9 +30,7 @@
private:
- CBlButton m_btnRun;
- CBlButton m_btnStop;
- CBlButton m_btnAlarm;
+ CBlButton m_btnAdd;
CBlButton m_btnSettings;
CBlButton m_btnOperator;
diff --git a/SourceCode/Bond/BoounionPLC/res/application.exe.manifest b/SourceCode/Bond/BoounionPLC/res/application.exe.manifest
new file mode 100644
index 0000000..b96c40d
--- /dev/null
+++ b/SourceCode/Bond/BoounionPLC/res/application.exe.manifest
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
+ <assemblyIdentity
+ name="XP style manifest"
+ processorArchitecture="amd64"
+ version="1.0.0.0"
+ type="win32"/>
+ <dependency>
+ <dependentAssembly>
+ <assemblyIdentity
+ type="win32"
+ name="Microsoft.Windows.Common-Controls"
+ version="6.0.0.0"
+ processorArchitecture="amd64"
+ publicKeyToken="6595b64144ccf1df"
+ language="*"
+ />
+ </dependentAssembly>
+ </dependency>
+</assembly>
\ No newline at end of file
diff --git a/SourceCode/Bond/x64/BoounionPLC/Debug/Res/Operator_Gray_32.ico b/SourceCode/Bond/x64/BoounionPLC/Debug/Res/Operator_Gray_32.ico
new file mode 100644
index 0000000..b5a51f7
--- /dev/null
+++ b/SourceCode/Bond/x64/BoounionPLC/Debug/Res/Operator_Gray_32.ico
Binary files differ
diff --git a/SourceCode/Bond/x64/BoounionPLC/Debug/Res/Operator_High_32.ico b/SourceCode/Bond/x64/BoounionPLC/Debug/Res/Operator_High_32.ico
new file mode 100644
index 0000000..f57d0f0
--- /dev/null
+++ b/SourceCode/Bond/x64/BoounionPLC/Debug/Res/Operator_High_32.ico
Binary files differ
diff --git a/SourceCode/Bond/x64/BoounionPLC/Debug/Res/Settings_Gray_32.ico b/SourceCode/Bond/x64/BoounionPLC/Debug/Res/Settings_Gray_32.ico
new file mode 100644
index 0000000..4b6512c
--- /dev/null
+++ b/SourceCode/Bond/x64/BoounionPLC/Debug/Res/Settings_Gray_32.ico
Binary files differ
diff --git a/SourceCode/Bond/x64/BoounionPLC/Debug/Res/Settings_High_32.ico b/SourceCode/Bond/x64/BoounionPLC/Debug/Res/Settings_High_32.ico
new file mode 100644
index 0000000..3ce66d2
--- /dev/null
+++ b/SourceCode/Bond/x64/BoounionPLC/Debug/Res/Settings_High_32.ico
Binary files differ
diff --git a/SourceCode/Bond/x64/BoounionPLC/Debug/Res/add_blue_32.ico b/SourceCode/Bond/x64/BoounionPLC/Debug/Res/add_blue_32.ico
new file mode 100644
index 0000000..6ad7455
--- /dev/null
+++ b/SourceCode/Bond/x64/BoounionPLC/Debug/Res/add_blue_32.ico
Binary files differ
diff --git a/SourceCode/Bond/x64/BoounionPLC/Debug/Res/add_gray_32.ico b/SourceCode/Bond/x64/BoounionPLC/Debug/Res/add_gray_32.ico
new file mode 100644
index 0000000..a727e6c
--- /dev/null
+++ b/SourceCode/Bond/x64/BoounionPLC/Debug/Res/add_gray_32.ico
Binary files differ
diff --git a/SourceCode/Bond/x64/Debug/res2/add_blue_32.ico b/SourceCode/Bond/x64/Debug/res2/add_blue_32.ico
new file mode 100644
index 0000000..6ad7455
--- /dev/null
+++ b/SourceCode/Bond/x64/Debug/res2/add_blue_32.ico
Binary files differ
diff --git a/SourceCode/Bond/x64/Debug/res2/add_gray_32.ico b/SourceCode/Bond/x64/Debug/res2/add_gray_32.ico
new file mode 100644
index 0000000..a727e6c
--- /dev/null
+++ b/SourceCode/Bond/x64/Debug/res2/add_gray_32.ico
Binary files differ
--
Gitblit v1.9.3