// 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());
|
}
|
}
|