1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * @file CompareStatisticsDlg.cpp
5 * @brief Implementation file for CompareStatisticsDlg dialog
9 #include "CompareStatisticsDlg.h"
10 #include "CompareStats.h"
16 /////////////////////////////////////////////////////////////////////////////
17 // SaveClosingDlg dialog
19 IMPLEMENT_DYNAMIC(CompareStatisticsDlg, CTrDialog)
21 CompareStatisticsDlg::CompareStatisticsDlg(const CompareStats* pStats, CWnd* pParent /*= nullptr*/) :
22 m_pCompareStats(pStats),
23 CTrDialog(pStats->GetCompareDirs() < 3 ? IDD_COMPARE_STATISTICS : IDD_COMPARE_STATISTICS3, pParent)
25 //{{AFX_DATA_INIT(CompareStatisticsDlg)
29 BEGIN_MESSAGE_MAP(CompareStatisticsDlg, CTrDialog)
30 //{{AFX_MSG_MAP(SaveClosingDlg)
35 /////////////////////////////////////////////////////////////////////////////
36 // SaveClosingDlg message handlers
39 * @brief Initialize the dialog, set statistics and load icons.
41 BOOL CompareStatisticsDlg::OnInitDialog()
43 CTrDialog::OnInitDialog();
46 const int iconCX = []() {
47 const int cx = GetSystemMetrics(SM_CXSMICON);
56 const int iconCY = iconCX;
58 static const struct { int ctlID; CompareStats::RESULT resultType; bool isDir; } ctlResultTypeMap[] =
60 { IDC_STAT_IDENTICFOLDER, CompareStats::RESULT_DIRSAME, true },
61 { IDC_STAT_IDENTICFILE, CompareStats::RESULT_SAME, false },
62 { IDC_STAT_IDENTICBINARY, CompareStats::RESULT_BINSAME, false },
63 { IDC_STAT_DIFFFOLDER, CompareStats::RESULT_DIRDIFF, true },
64 { IDC_STAT_DIFFFILE, CompareStats::RESULT_DIFF, false },
65 { IDC_STAT_DIFFBINARY, CompareStats::RESULT_BINDIFF, false },
66 { IDC_STAT_LUNIQFOLDER, CompareStats::RESULT_LDIRUNIQUE, true },
67 { IDC_STAT_LUNIQFILE, CompareStats::RESULT_LUNIQUE, false },
68 { IDC_STAT_MUNIQFOLDER, CompareStats::RESULT_MDIRUNIQUE, true },
69 { IDC_STAT_MUNIQFILE, CompareStats::RESULT_MUNIQUE, false },
70 { IDC_STAT_RUNIQFOLDER, CompareStats::RESULT_RDIRUNIQUE, true },
71 { IDC_STAT_RUNIQFILE, CompareStats::RESULT_RUNIQUE, false },
72 { IDC_STAT_LMISSINGFOLDER, CompareStats::RESULT_LDIRMISSING, true },
73 { IDC_STAT_LMISSINGFILE, CompareStats::RESULT_LMISSING, false },
74 { IDC_STAT_MMISSINGFOLDER, CompareStats::RESULT_MDIRMISSING, true },
75 { IDC_STAT_MMISSINGFILE, CompareStats::RESULT_MMISSING, false },
76 { IDC_STAT_RMISSINGFOLDER, CompareStats::RESULT_RDIRMISSING, true },
77 { IDC_STAT_RMISSINGFILE, CompareStats::RESULT_RMISSING, false },
79 for (auto&& map : ctlResultTypeMap)
81 int count = m_pCompareStats->GetCount(map.resultType);
85 totalFolders += count;
86 SetDlgItemInt(map.ctlID, count);
90 SetDlgItemInt(IDC_STAT_TOTALFOLDER, totalFolders);
91 SetDlgItemInt(IDC_STAT_TOTALFILE, totalFiles);
93 // Load small folder icons
94 static const struct { int ctlID; int iconID; } ctlIconMap[] =
96 { IDC_STAT_ILUNIQFOLDER, IDI_LFOLDER },
97 { IDC_STAT_IMUNIQFOLDER, IDI_MFOLDER },
98 { IDC_STAT_IRUNIQFOLDER, IDI_RFOLDER },
99 { IDC_STAT_ILMISSINGFOLDER, IDI_MRFOLDER },
100 { IDC_STAT_IMMISSINGFOLDER, IDI_LRFOLDER },
101 { IDC_STAT_IRMISSINGFOLDER, IDI_LMFOLDER },
102 { IDC_STAT_INOTEQUALFOLDER, IDI_NOTEQUALFOLDER },
103 { IDC_STAT_INOTEQUAL, IDI_NOTEQUALFILE },
104 { IDC_STAT_IDIFFBINFILE, IDI_BINARYDIFF },
105 { IDC_STAT_ILUNIQFILE, IDI_LFILE },
106 { IDC_STAT_IMUNIQFILE, IDI_MFILE },
107 { IDC_STAT_IRUNIQFILE, IDI_RFILE },
108 { IDC_STAT_ILMISSINGFILE, IDI_MRFILE },
109 { IDC_STAT_IMMISSINGFILE, IDI_LRFILE },
110 { IDC_STAT_IRMISSINGFILE, IDI_LMFILE },
111 { IDC_STAT_IEQUALFILE, IDI_EQUALFILE },
112 { IDC_STAT_IEQUALBINFILE, IDI_EQUALBINARY },
113 { IDC_STAT_IIDENTICFOLDER, IDI_EQUALFOLDER },
116 for (auto&& map : ctlIconMap)
118 if (GetDlgItem(map.ctlID))
120 HICON hIcon = (HICON)LoadImage(AfxGetInstanceHandle(),
121 MAKEINTRESOURCE(map.iconID), IMAGE_ICON, iconCX, iconCY, LR_SHARED);
122 SendDlgItemMessage(map.ctlID, STM_SETICON, (WPARAM)hIcon, 0L);
126 return FALSE; // return TRUE unless you set the focus to a control
127 // EXCEPTION: OCX Property Pages should return FALSE