-
Notifications
You must be signed in to change notification settings - Fork 6
/
WinMTROptions.ixx
237 lines (190 loc) · 6.53 KB
/
WinMTROptions.ixx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
/*
WinMTR
Copyright (C) 2010-2019 Appnor MSP S.A. - http://www.appnor.com
Copyright (C) 2019-2021 Leetsoftwerx
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; version 2
of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
//*****************************************************************************
// FILE: WinMTROptions.cpp
//
//
//*****************************************************************************
module;
#pragma warning (disable : 4005)
#include "targetver.h"
#define WIN32_LEAN_AND_MEAN
#define VC_EXTRALEAN
#define NOMINMAX
#include <afxwin.h>
#include "resource.h"
export module WinMTR.Options;
//*****************************************************************************
// CLASS: WinMTROptions
//
//
//*****************************************************************************
export class WinMTROptions final : public CDialog
{
public:
WinMTROptions(CWnd* pParent = nullptr);
inline void SetUseDNS(bool udns) noexcept { useDNS = udns; };
inline void SetInterval(double i) noexcept { interval = i; };
inline void SetPingSize(int ps) noexcept { pingsize = ps; };
inline void SetMaxLRU(int mlru) noexcept { maxLRU = mlru; };
inline void SetUseIPv4(bool uip4) noexcept { useIPv4 = uip4; }
inline void SetUseIPv6(bool uip6) noexcept { useIPv6 = uip6; }
inline auto GetInterval() const noexcept { return interval; };
inline auto GetPingSize() const noexcept { return pingsize; };
inline auto GetMaxLRU() const noexcept { return maxLRU; };
inline auto GetUseDNS() const noexcept { return useDNS; }
inline auto GetUseIPv4() const noexcept { return useIPv4; }
inline auto GetUseIPv6() const noexcept { return useIPv6; }
enum { IDD = IDD_DIALOG_OPTIONS };
CEdit m_editSize;
CEdit m_editInterval;
CEdit m_editMaxLRU;
CButton m_checkDNS;
CButton m_useIPv4;
CButton m_useIPv6;
protected:
void DoDataExchange(CDataExchange* pDX) override;
BOOL OnInitDialog() override;
void OnOK() override;
afx_msg void OnLicense();
DECLARE_MESSAGE_MAP()
private:
double interval = 0.0;
unsigned pingsize = 0;
unsigned maxLRU = 0;
bool useDNS = false;
bool useIPv4 = true;
bool useIPv6 = true;
public:
afx_msg void OnBnClickedIpv4Check();
afx_msg void OnBnClickedUseipv6Check();
};
module : private;
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
import <format>;
import <iterator>;
import WinMTRUtils;
import WinMTR.License;
//*****************************************************************************
// BEGIN_MESSAGE_MAP
//
//
//*****************************************************************************
BEGIN_MESSAGE_MAP(WinMTROptions, CDialog)
ON_BN_CLICKED(ID_LICENSE, OnLicense)
ON_BN_CLICKED(IDC_IPV4_CHECK, &WinMTROptions::OnBnClickedIpv4Check)
ON_BN_CLICKED(IDC_USEIPV6_CHECK, &WinMTROptions::OnBnClickedUseipv6Check)
END_MESSAGE_MAP()
//*****************************************************************************
// WinMTROptions::WinMTROptions
//
//
//*****************************************************************************
WinMTROptions::WinMTROptions(CWnd* pParent) : CDialog(WinMTROptions::IDD, pParent)
{
}
//*****************************************************************************
// WinMTROptions::DoDataExchange
//
//
//*****************************************************************************
void WinMTROptions::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
DDX_Control(pDX, IDC_EDIT_SIZE, m_editSize);
DDV_MinMaxUInt(pDX, pingsize, WinMTRUtils::MIN_PING_SIZE, WinMTRUtils::MAX_PING_SIZE);
DDX_Control(pDX, IDC_EDIT_INTERVAL, m_editInterval);
DDV_MinMaxDouble(pDX, interval, WinMTRUtils::MIN_INTERVAL, WinMTRUtils::MAX_INTERVAL);
DDX_Control(pDX, IDC_EDIT_MAX_LRU, m_editMaxLRU);
DDV_MinMaxUInt(pDX, maxLRU, WinMTRUtils::MIN_MAX_LRU, WinMTRUtils::MAX_MAX_LRU);
DDX_Control(pDX, IDC_CHECK_DNS, m_checkDNS);
DDX_Control(pDX, IDC_USEIPV6_CHECK, m_useIPv6);
DDX_Control(pDX, IDC_IPV4_CHECK, m_useIPv4);
}
//*****************************************************************************
// WinMTROptions::OnInitDialog
//
//
//*****************************************************************************
BOOL WinMTROptions::OnInitDialog()
{
CDialog::OnInitDialog();
wchar_t strtmp[20] = {};
constexpr auto writable_size = std::size(strtmp) - 1;
auto result = std::format_to_n(std::begin(strtmp), writable_size, WinMTRUtils::float_number_format, interval);
*result.out = '\0';
m_editInterval.SetWindowText(strtmp);
result = std::format_to_n(std::begin(strtmp), writable_size, WinMTRUtils::int_number_format, pingsize);
*result.out = '\0';
m_editSize.SetWindowText(strtmp);
result = std::format_to_n(std::begin(strtmp), writable_size, WinMTRUtils::int_number_format, maxLRU);
*result.out = '\0';
m_editMaxLRU.SetWindowText(strtmp);
m_checkDNS.SetCheck(useDNS);
m_useIPv4.SetCheck(useIPv4);
m_useIPv6.SetCheck(useIPv6);
m_editInterval.SetFocus();
return FALSE;
}
//*****************************************************************************
// WinMTROptions::OnOK
//
//
//*****************************************************************************
void WinMTROptions::OnOK()
{
wchar_t tmpstr[20];
useDNS = m_checkDNS.GetCheck();
m_editInterval.GetWindowText(tmpstr, 20);
wchar_t* end = nullptr;
interval = wcstod(tmpstr, &end);
m_editSize.GetWindowText(tmpstr, 20);
end = nullptr;
pingsize = wcstoul(tmpstr, &end, 10);
m_editMaxLRU.GetWindowText(tmpstr, 20);
end = nullptr;
maxLRU = wcstoul(tmpstr, &end, 10);
useIPv4 = m_useIPv4.GetCheck();
useIPv6 = m_useIPv6.GetCheck();
CDialog::OnOK();
}
//*****************************************************************************
// WinMTROptions::OnLicense
//
//
//*****************************************************************************
void WinMTROptions::OnLicense()
{
WinMTRLicense mtrlicense;
mtrlicense.DoModal();
}
void WinMTROptions::OnBnClickedIpv4Check()
{
if (!m_useIPv4.GetCheck()) {
m_useIPv6.SetCheck(true);
}
}
void WinMTROptions::OnBnClickedUseipv6Check()
{
if (!m_useIPv6.GetCheck()) {
m_useIPv4.SetCheck(true);
}
}