UI: explain dangerous operations, screen modes and host filtering
Four items from a user-side review of the master. The common thread: the UI
now says what it is about to do instead of leaving the user to guess.
Confirm boxes. Logout, restart, shutdown, delete host and uninstall client
all asked "are you sure" without naming the action or the hosts, so a
multi-selection could not be checked. DescribeTargetHosts() lists
"note (or computer name) (ip)" capped at five lines, and the default button
is No. The preview is dropped before the modal box and targets are
re-resolved after it, since the list can reshuffle in between.
Screen modes. High Speed / Ultra Speed became High Quality (DXGI +
differential: lossless, bandwidth hungry) and Smooth (GDI + H264: lossy,
cheap). TranslateMenu looks menus up by displayed text, so the .rc entries,
the FeatureLimitsDlg item names and the language pack keys changed together.
Host filter. The Ctrl+F bar was find-next; it now filters as you type over
IP, location, note, OS and version, and Esc clears the filter. The status
line reads "filtered: N / M total" while active. Commands still resolve by
clientID and m_FilteredIndices still maps row to m_HostList index, so no
command path changes. SearchBarDlg drops from 446 to 312 lines.
Quality changes. The adaptive level now shows its reason for twenty seconds
("Good (high latency)") instead of silently changing. The full-screen info
bar was a fixed 170px, so that reason was clipped; the width is now measured
from the text with the same font that paints it, 170 becoming the floor and
16px quantisation so changing digits do not jitter the window. Cosmetic
only: no threshold, hysteresis, cooldown or lock-out logic is touched.
Verified: debug server build, 0 errors; new strings present in .res and in
the exe. UI not exercised - the debug master would fight the running release
master for the listening port in Bin/settings.ini.
This commit is contained in:
1 parent
a190c21217
commit
6b87a31c6f
12 files changed
+364
-220
No files matched your search
@@ -5577,7 +5577,21 @@ std::string floatToString(float f)
|
||||
void CMy2015RemoteDlg::OnOnlineDelete()
|
||||
{
|
||||
// TODO: 在此添加命令处理程序代码
|
||||
if (IDYES != MessageBoxL(_T("确定删除选定的被控计算机吗?"), _T("提示"), MB_ICONQUESTION | MB_YESNO))
|
||||
// 确认框里带上是哪几台主机:原来只说“选定的被控计算机”,多选时无从核对。
|
||||
EnterCriticalSection(&m_cs);
|
||||
std::vector<context*> preview = ResolveCommandTargets();
|
||||
const int targetCount = (int)preview.size();
|
||||
CString targetList = DescribeTargetHosts(preview, 5);
|
||||
LeaveCriticalSection(&m_cs);
|
||||
|
||||
if (targetCount == 0) return; // 没选中主机时不弹空确认框
|
||||
|
||||
CString msg;
|
||||
msg.Format(_TRF("确定要断开并删除以下 %d 台主机吗?"), targetCount);
|
||||
msg += _T("\r\n\r\n");
|
||||
msg += targetList;
|
||||
|
||||
if (MessageBox(msg, _TR("提示"), MB_ICONWARNING | MB_YESNO | MB_DEFBUTTON2) != IDYES)
|
||||
return;
|
||||
|
||||
// 确认框是模态的,期间列表可能已经重排;目标在锁内一次性锁定,后面发指令和
|
||||
@@ -8023,6 +8037,37 @@ std::vector<context*> CMy2015RemoteDlg::ResolveCommandTargets()
|
||||
return targets;
|
||||
}
|
||||
|
||||
// 危险操作确认框里的目标清单。原来关机/重启/注销/删除/卸载的确认框只说“选定的主机”,
|
||||
// 用户既看不出要点的是哪个操作,也看不出会作用在哪几台机器上 —— 多选时尤其危险。
|
||||
// 这里统一把「备注(没有则计算机名)(IP)」拼出来,超过 maxShow 台只列前几台,总数由
|
||||
// 调用方的正文交代,末尾补一行省略号避免让人误以为只影响列出的这几台。
|
||||
CString CMy2015RemoteDlg::DescribeTargetHosts(const std::vector<context*>& targets, int maxShow)
|
||||
{
|
||||
CString list;
|
||||
const int total = (int)targets.size();
|
||||
const int show = (total < maxShow) ? total : maxShow;
|
||||
for (int i = 0; i < show; i++) {
|
||||
context* ctx = targets[i];
|
||||
if (!ctx) continue;
|
||||
CString name = m_ClientMap->GetClientMapData(ctx->GetClientID(), MAP_NOTE);
|
||||
if (name.IsEmpty()) name = ctx->GetClientData(ONLINELIST_COMPUTER_NAME);
|
||||
CString ip = ctx->GetClientData(ONLINELIST_IP);
|
||||
if (name.IsEmpty()) name = ip;
|
||||
CString line;
|
||||
if (ip.IsEmpty() || name == ip) {
|
||||
line = name;
|
||||
} else {
|
||||
line.Format(_T("%s (%s)"), name.GetString(), ip.GetString());
|
||||
}
|
||||
if (!list.IsEmpty()) list += _T("\r\n");
|
||||
list += _T(" ") + line;
|
||||
}
|
||||
if (total > show) {
|
||||
list += _T("\r\n ...");
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
// 从 m_HostList 中移除 context 并更新索引映射。
|
||||
//
|
||||
// 重要:MarkDeviceOffline / m_ActiveWndW.erase 等"主机下线"副作用必须**只在
|
||||
@@ -12315,7 +12360,21 @@ void CMy2015RemoteDlg::OnToolRcedit()
|
||||
|
||||
void CMy2015RemoteDlg::OnOnlineUninstall()
|
||||
{
|
||||
if (IDYES != MessageBoxL(_T("确定卸载选定的被控程序吗?"), _T("提示"), MB_ICONQUESTION | MB_YESNO))
|
||||
// 确认框里带上是哪几台主机:原来只说“选定的被控程序”,多选时无从核对。
|
||||
EnterCriticalSection(&m_cs);
|
||||
std::vector<context*> preview = ResolveCommandTargets();
|
||||
const int targetCount = (int)preview.size();
|
||||
CString targetList = DescribeTargetHosts(preview, 5);
|
||||
LeaveCriticalSection(&m_cs);
|
||||
|
||||
if (targetCount == 0) return; // 没选中主机时不弹空确认框
|
||||
|
||||
CString msg;
|
||||
msg.Format(_TRF("确定要卸载以下 %d 台主机上的被控程序吗?"), targetCount);
|
||||
msg += _T("\r\n\r\n");
|
||||
msg += targetList;
|
||||
|
||||
if (MessageBox(msg, _TR("提示"), MB_ICONWARNING | MB_YESNO | MB_DEFBUTTON2) != IDYES)
|
||||
return;
|
||||
|
||||
// 确认框是模态的,期间列表可能已经重排;目标在锁内一次性锁定,后面发指令和
|
||||
@@ -12394,9 +12453,55 @@ void CMy2015RemoteDlg::OnOnlinePrivateScreen()
|
||||
SendSelectedCommand(buffer.data(), (ULONG)buffer.size());
|
||||
}
|
||||
|
||||
// 主机是否命中筛选关键字。匹配的列与原来搜索栏“查找”用的列保持一致:
|
||||
// IP / 地理位置 / 计算机名或备注 / 操作系统 / 版本。改这里要同步改 UI 提示。
|
||||
bool CMy2015RemoteDlg::HostMatchesFilter(context* ctx, const CString& lowerKey)
|
||||
{
|
||||
if (!ctx) return false;
|
||||
static const int cols[] = {
|
||||
ONLINELIST_IP, ONLINELIST_LOCATION, ONLINELIST_COMPUTER_NAME,
|
||||
ONLINELIST_OS, ONLINELIST_VERSION
|
||||
};
|
||||
for (int col : cols) {
|
||||
CString text;
|
||||
if (col == ONLINELIST_COMPUTER_NAME) {
|
||||
// 备注优先、没备注用计算机名 —— 与列表该列显示的口径一致
|
||||
text = m_ClientMap->GetClientMapData(ctx->GetClientID(), MAP_NOTE);
|
||||
if (text.IsEmpty()) text = ctx->GetClientData(col);
|
||||
} else {
|
||||
text = ctx->GetClientData(col);
|
||||
}
|
||||
// 地理位置列统一按 UTF-8 存储(见 AddList),而输入是 CP_ACP,
|
||||
// 转回 CP_ACP 再比对,否则按中文位置筛选会因编码不一致而失配。
|
||||
if (col == ONLINELIST_LOCATION) {
|
||||
text = CString(Utf8ToAnsi(std::string(text.GetString())).c_str());
|
||||
}
|
||||
text.MakeLower();
|
||||
if (text.Find(lowerKey) >= 0) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void CMy2015RemoteDlg::SetHostFilter(const CString& text)
|
||||
{
|
||||
CString key = text;
|
||||
key.Trim();
|
||||
if (key == m_strHostFilter) return; // 没变化就不重排列表,避免闪一下
|
||||
m_strHostFilter = key;
|
||||
|
||||
EnterCriticalSection(&m_cs);
|
||||
LoadListData(m_selectedGroup);
|
||||
LeaveCriticalSection(&m_cs);
|
||||
}
|
||||
|
||||
void CMy2015RemoteDlg::RebuildFilteredIndices()
|
||||
{
|
||||
m_FilteredIndices.clear();
|
||||
|
||||
CString key = m_strHostFilter;
|
||||
key.MakeLower();
|
||||
const bool filtering = !key.IsEmpty();
|
||||
|
||||
for (size_t i = 0; i < m_HostList.size(); ++i) {
|
||||
context* ctx = m_HostList[i];
|
||||
if (!ctx) continue;
|
||||
@@ -12404,6 +12509,8 @@ void CMy2015RemoteDlg::RebuildFilteredIndices()
|
||||
// 匹配当前分组:空分组视为 "default"
|
||||
if (groupName == m_selectedGroup ||
|
||||
(groupName.empty() && m_selectedGroup == "default")) {
|
||||
// 文本筛选叠加在分组之上:先按分组,再按关键字
|
||||
if (filtering && !HostMatchesFilter(ctx, key)) continue;
|
||||
m_FilteredIndices.push_back(i);
|
||||
}
|
||||
}
|
||||
@@ -12426,8 +12533,14 @@ void CMy2015RemoteDlg::LoadListData(const std::string& group)
|
||||
m_CList_Online.RedrawWindow(NULL, NULL, RDW_ERASE | RDW_INVALIDATE | RDW_UPDATENOW);
|
||||
}
|
||||
CString strStatusMsg;
|
||||
strStatusMsg.FormatL("有%d个主机在线", (int)m_FilteredIndices.size());
|
||||
strStatusMsg += CString("[Total: ") + std::to_string(m_HostList.size()).c_str() + "]";
|
||||
if (m_strHostFilter.IsEmpty()) {
|
||||
strStatusMsg.FormatL("有%d个主机在线", (int)m_FilteredIndices.size());
|
||||
strStatusMsg += CString("[Total: ") + std::to_string(m_HostList.size()).c_str() + "]";
|
||||
} else {
|
||||
// 筛选时换个说法,否则“有 12 个主机在线”会被读成“只有 12 台在线”
|
||||
strStatusMsg.FormatL("筛选结果:%d / 共 %d",
|
||||
(int)m_FilteredIndices.size(), (int)m_HostList.size());
|
||||
}
|
||||
m_StatusBar.SetPaneText(0, strStatusMsg);
|
||||
}
|
||||
|
||||
@@ -12511,7 +12624,37 @@ void CMy2015RemoteDlg::OnOnlineRegroup()
|
||||
|
||||
void CMy2015RemoteDlg::MachineManage(MachineCommand type)
|
||||
{
|
||||
if (MessageBoxL("此操作需客户端具有管理员权限,确定继续吗? ", "提示", MB_ICONQUESTION | MB_YESNO) == IDYES) {
|
||||
// 操作名直接复用「机器管理」菜单里的词条(注销/关机/重启),三种语言都已翻译,
|
||||
// 不新增词条。原来三个操作共用一句「此操作需客户端具有管理员权限,确定继续吗?」,
|
||||
// 用户看不出自己点的是关机还是重启、也看不出对哪台执行。
|
||||
CString action = type == MACHINE_LOGOUT ? _TR("注销")
|
||||
: type == MACHINE_SHUTDOWN ? _TR("关机")
|
||||
: _TR("重启");
|
||||
|
||||
// 目标清单只用于展示:确认框是模态的,期间列表可能重排或主机下线,所以这里读完
|
||||
// 就把指针丢掉,真正执行时再按 clientID 重新解析一次(见下面的 ResolveCommandTargets)。
|
||||
EnterCriticalSection(&m_cs);
|
||||
std::vector<context*> preview = ResolveCommandTargets();
|
||||
const int targetCount = (int)preview.size();
|
||||
CString targetList = DescribeTargetHosts(preview, 5);
|
||||
LeaveCriticalSection(&m_cs);
|
||||
|
||||
if (targetCount == 0) return; // 没选中主机时不弹空确认框
|
||||
|
||||
// 两行分开写:一行只有一个占位符,翻译成别的语序时不会把 %d 和 %s 对调。
|
||||
CString msg;
|
||||
msg.Format(_TRF("确定要执行「%s」吗?"), action.GetString());
|
||||
msg += _T("\r\n\r\n");
|
||||
CString head;
|
||||
head.Format(_TRF("目标主机(共 %d 台):"), targetCount);
|
||||
msg += head;
|
||||
msg += _T("\r\n");
|
||||
msg += targetList;
|
||||
msg += _T("\r\n\r\n");
|
||||
msg += _TR("此操作需要被控端具有管理员权限。");
|
||||
|
||||
// 默认按钮是「否」:这类操作不可撤销,回车不应直接确认
|
||||
if (MessageBox(msg, _TR("提示"), MB_ICONWARNING | MB_YESNO | MB_DEFBUTTON2) == IDYES) {
|
||||
EnterCriticalSection(&m_cs);
|
||||
// 确认框期间列表可能已重排,目标由 ResolveCommandTargets 按 clientID 还原
|
||||
for (context* ContextObject : ResolveCommandTargets()) {
|
||||
|
||||
Reference in new issue
Block a user