-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathEditToolDialog.cpp
72 lines (58 loc) · 1.72 KB
/
EditToolDialog.cpp
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
////////////////////////////////////////////////////////////////////////////////
//! \file EditToolDialog.cpp
//! \brief The EditToolDialog class definition.
//! \author Chris Oldwood
#include "Common.hpp"
#include "EditToolDialog.hpp"
#include <Core/Algorithm.hpp>
////////////////////////////////////////////////////////////////////////////////
//! Default constructor.
EditToolDialog::EditToolDialog()
: CDialog(IDD_HOST_TOOL)
, m_tool()
{
DEFINE_CTRL_TABLE
CTRL(IDC_NAME, &m_nameEditor)
CTRL(IDC_CMD_LINE, &m_cmdLineEditor)
END_CTRL_TABLE
}
////////////////////////////////////////////////////////////////////////////////
//! Dialog initialisation handler.
void EditToolDialog::OnInitDialog()
{
m_cmdLineEditor.Add(TXT("mstsc /f /v ${HOSTNAME}"));
m_cmdLineEditor.Add(TXT("explorer \\\\${HOSTNAME}\\Share"));
m_nameEditor.Text(m_tool.m_name);
if (!m_tool.m_commandLine.empty())
{
if (!m_cmdLineEditor.Exists(m_tool.m_commandLine))
m_cmdLineEditor.Add(m_tool.m_commandLine);
m_cmdLineEditor.Select(m_tool.m_commandLine);
}
}
////////////////////////////////////////////////////////////////////////////////
//! OK button handler.
bool EditToolDialog::OnOk()
{
m_tool.m_name = m_nameEditor.Text();
m_tool.m_commandLine = m_cmdLineEditor.Text();
if (m_tool.m_name.empty())
{
AlertMsg(TXT("You must provide a title for the tool."));
m_nameEditor.Focus();
return false;
}
if (Core::exists(m_usedNames, m_tool.m_name))
{
AlertMsg(TXT("There is already a tool with that name defined."));
m_nameEditor.Focus();
return false;
}
if (m_tool.m_commandLine.empty())
{
AlertMsg(TXT("You must supply the command line used to execute the tool."));
m_cmdLineEditor.Focus();
return false;
}
return true;
}