admin
2024-05-17 495cd025f02ad9a0261cffdd10b01b7c558cd894
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
// CSettingDlg.cpp: 实现文件
//
 
#include "common/pch.h"
#include "FloatTrade.h"
#include "CSettingDlg.h"
#include "afxdialogex.h"
#include "../common/StringUtil.h"
#include "../common/NetworkApi.h"
#include "ConfigUtil.h"
#include <iostream>
#include <string>
#include <sstream>
using namespace std;
 
 
// CSettingDlg 对话框
 
IMPLEMENT_DYNAMIC(CSettingDlg, CDialogEx)
 
CSettingDlg::CSettingDlg(CWnd* pParent /*=nullptr*/)
    : CDialogEx(IDD_SETTINGS, pParent)
{
 
}
 
CSettingDlg::~CSettingDlg()
{
}
 
void CSettingDlg::DoDataExchange(CDataExchange* pDX)
{
    CDialogEx::DoDataExchange(pDX);
    DDX_Control(pDX, edit_trade_refresh_space_time, editRefreshSpaceTime);
    DDX_Control(pDX, edit_trade_group_space_time, editGroupSpaceTime);
    DDX_Control(pDX, edit_group_pos, editGroupPos);
    DDX_Control(pDX, edit_per_code_buy_money, editPerCodeBuyMoney);
}
 
 
BEGIN_MESSAGE_MAP(CSettingDlg, CDialogEx)
    ON_BN_CLICKED(btn_sure, &CSettingDlg::OnBnClickedsure)
    ON_BN_CLICKED(btn_sure_network, &CSettingDlg::OnBnClickedsurenetwork)
END_MESSAGE_MAP()
 
 
// CSettingDlg 消息处理程序
 
 
void CSettingDlg::OnBnClickedsure()
{
    CString refreshSpace;
    editRefreshSpaceTime.GetWindowTextW(refreshSpace);
 
    CString groupSpace;
    editGroupSpaceTime.GetWindowTextW(groupSpace);
 
 
    CString pos;
    editGroupPos.GetWindowTextW(pos);
 
    if (refreshSpace.GetLength() < 0) {
        AfxMessageBox(L"请填写交易刷新频率");
        return;
    }
 
    if (groupSpace.GetLength() < 0) {
        AfxMessageBox(L"请填写分组刷新频率");
        return;
    }
 
    list<POINT> posList;
 
    if (pos.GetLength() > 0) {
        string result = StringUtil::cstring2String(pos);
        istringstream iss(result);    // 输入流
        string token;            // 接收缓冲区
        while (getline(iss, token, '\n'))    // 以split为分隔符
        {
            cout << token.find(",") << endl; // 输出
            if (token.find(",")>0) {
                int x = stoi(token.substr(0, token.find(",")));
                int y = stoi(token.substr(token.find(",") + 1));
                posList.push_back(POINT({ x,y }));
            }
        }
    }
 
    ConfigUtil::setThsAutoClickTimeSpace(stoi(StringUtil::cstring2String(groupSpace)));
    ConfigUtil::setThsAutoRefreshTimeSpace(stoi(StringUtil::cstring2String(refreshSpace)));
    ConfigUtil::setThsAutoClickPositions(posList);
    AfxMessageBox(L"保存成功", MB_ICONINFORMATION);
}
 
 
BOOL CSettingDlg::OnInitDialog()
{
    CDialogEx::OnInitDialog();
 
    // TODO:  在此添加额外的初始化
    list<POINT> posList = ConfigUtil::getThsAutoClickPositions();
    string st;
    for (list<POINT>::iterator ele = posList.begin(); ele != posList.end(); ++ele) {
        POINT p = *ele;
        st.append(std::to_string(p.x));
        st.append(",");
        st.append(std::to_string(p.y));
        st.append("\r\n");
    }
    editGroupPos.SetWindowTextW(CString( st.c_str()));
 
 
    int ct = ConfigUtil::getThsAutoClickTimeSpace();
    editGroupSpaceTime.SetWindowTextW(CString(std::to_string(ct).c_str()));
 
    int rt = ConfigUtil::getThsAutoRefreshTimeSpace();
    editRefreshSpaceTime.SetWindowTextW(CString(std::to_string(rt).c_str()));
 
    try {
        int money = NetworkApi::get_per_code_buy_money();
        editPerCodeBuyMoney.SetWindowTextW(to_wstring(money).c_str());
    }
    catch (... ) {
    
    }
    
 
    return TRUE;  // return TRUE unless you set the focus to a control
                  // 异常: OCX 属性页应返回 FALSE
}
 
 
void CSettingDlg::OnBnClickedsurenetwork()
{
    CString cmoney;
    editPerCodeBuyMoney.GetWindowTextW(cmoney);
    string money = StringUtil::cstring2String(cmoney);
    if (!StringUtil::isNumber(money)) {
        AfxMessageBox(L"输入内容格式错误");
        return;
    }
    try {
         NetworkApi::set_per_code_buy_money(stoi(money.c_str()));
         MessageBox(L"设置成功",L"提示");
    }
    catch (wstring st) {
        AfxMessageBox(st.c_str());
    }
}