forked from xaozai/DS-Helper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEditPathesDlg.cpp
168 lines (147 loc) · 5.1 KB
/
EditPathesDlg.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
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
/*
// Synology DownloadStation Helper
//
// The application is designed to simplify adding your download tasks to DownloadStation on your Synology DiskStation.
//
// MIT License
//
// Copyright (c) 2017 xaozai
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
*/
#include "stdafx.h"//precompiled headers
#include "DS Helper.h"
#include "EditPathesDlg.h"
#include "InputBox.h"
#include "DS SynoFSDlg.h"
CEditPathesDlg::CEditPathesDlg() : CDialogEx(CEditPathesDlg::IDD)
{
}
void CEditPathesDlg::DoDataExchange(CDataExchange* pDX)
{
CDialogEx::DoDataExchange(pDX);
DDX_Control(pDX, IDC_LIST_PATHES, m_ListPathes);
DDX_Control(pDX, IDC_BUTTON_ADD_PATH, m_ButtonAddPath);
DDX_Control(pDX, IDC_BUTTON_REMOVE_PATH, m_ButtonRemovePath);
DDX_Control(pDX, IDC_BUTTON_MOVE_UP, m_ButtonMoveUp);
DDX_Control(pDX, IDC_BUTTON_MOVE_DOWN, m_ButtonMoveDown);
DDX_Control(pDX, IDOK, m_ButtonOK);
}
BEGIN_MESSAGE_MAP(CEditPathesDlg, CDialogEx)
ON_BN_CLICKED(IDC_BUTTON_ADD_PATH, &CEditPathesDlg::OnBnClickedButtonAddPath)
ON_BN_CLICKED(IDC_BUTTON_REMOVE_PATH, &CEditPathesDlg::OnBnClickedButtonRemovePath)
ON_BN_CLICKED(IDC_BUTTON_MOVE_UP, &CEditPathesDlg::OnBnClickedButtonMoveUp)
ON_BN_CLICKED(IDC_BUTTON_MOVE_DOWN, &CEditPathesDlg::OnBnClickedButtonMoveDown)
ON_BN_CLICKED(IDOK, &CEditPathesDlg::OnBnClickedOk)
ON_BN_CLICKED(IDC_BUTTON_VIEW_EDIT_ON_SYNO, &CEditPathesDlg::OnBnClickedButtonViewEditOnSyno)
END_MESSAGE_MAP()
BOOL CEditPathesDlg::OnInitDialog()
{
CDialogEx::OnInitDialog();
//Create the ToolTip control
if (!m_ToolTip.Create(this))
{
TRACE0("Unable to create the ToolTip!");
}
else
{
m_ToolTip.AddTool(&m_ButtonAddPath, _T("Add a path"));
m_ToolTip.AddTool(&m_ButtonRemovePath, _T("Remove a path"));
m_ToolTip.AddTool(&m_ButtonMoveUp, _T("Move Up"));
m_ToolTip.AddTool(&m_ButtonMoveDown, _T("Move Down"));
m_ToolTip.AddTool(&m_ButtonOK, _T("Save"));
m_ToolTip.Activate(TRUE);
}
m_ButtonMoveUp.SetIcon((HICON)LoadImage(AfxGetApp()->m_hInstance, MAKEINTRESOURCE(IDI_ICON_UP), IMAGE_ICON, 0, 0, LR_DEFAULTCOLOR));
m_ButtonMoveDown.SetIcon((HICON)LoadImage(AfxGetApp()->m_hInstance, MAKEINTRESOURCE(IDI_ICON_DOWN), IMAGE_ICON, 0, 0, LR_DEFAULTCOLOR));
for (byte i = 0; i < m_pParentDlg->m_ComboPath.GetCount(); i++)
{
m_pParentDlg->m_ComboPath.GetLBText(i, str_Tmp);
m_ListPathes.AddString(str_Tmp);
}
return TRUE;
}
void CEditPathesDlg::OnBnClickedButtonAddPath()
{
CInputBox dialog(&CString("Type a path:"), &str_Tmp, this);
if (dialog.DoModal() == IDOK)
{
m_ListPathes.AddString(str_Tmp);
m_ListPathes.SetCurSel(m_ListPathes.GetCount() - 1);
}
}
void CEditPathesDlg::OnBnClickedButtonRemovePath()
{
byte ind = m_ListPathes.GetCurSel();
m_ListPathes.DeleteString(ind);
byte count = m_ListPathes.GetCount();
if (count == 1)
m_ListPathes.SetCurSel(0);
else if((count - 1) < ind)
m_ListPathes.SetCurSel(ind - 1);
else
m_ListPathes.SetCurSel(ind);
}
void CEditPathesDlg::OnBnClickedButtonMoveUp()
{
byte ind = m_ListPathes.GetCurSel();
if (ind)
{
m_ListPathes.GetText(ind, str_Tmp);
m_ListPathes.DeleteString(ind);
m_ListPathes.InsertString(ind - 1, str_Tmp);
m_ListPathes.SetCurSel(ind - 1);
}
}
void CEditPathesDlg::OnBnClickedButtonMoveDown()
{
byte ind = m_ListPathes.GetCurSel();
if (ind < (m_ListPathes.GetCount() - 1))
{
m_ListPathes.GetText(ind, str_Tmp);
m_ListPathes.DeleteString(ind);
m_ListPathes.InsertString(ind + 1, str_Tmp);
m_ListPathes.SetCurSel(ind + 1);
}
}
void CEditPathesDlg::OnBnClickedOk()
{
for (byte i = 0; i < m_ListPathes.GetCount(); i++)
{
m_ListPathes.GetText(i, str_Tmp);
m_RetArr.Add(str_Tmp);
}
CDialogEx::OnOK();
}
BOOL CEditPathesDlg::PreTranslateMessage(MSG* pMsg)
{
m_ToolTip.RelayEvent(pMsg);
return CDialogEx::PreTranslateMessage(pMsg);
}
void CEditPathesDlg::OnBnClickedButtonViewEditOnSyno()
{
CString RV;
CDSSynoFSDlg dlgSynoFS(&RV, this);
dlgSynoFS.DoModal();
if (!RV.IsEmpty())
{
m_ListPathes.AddString(RV);
m_ListPathes.SetCurSel(m_ListPathes.GetCount() - 1);
}
}