/
PageProfilePlay.cpp
168 lines (134 loc) · 4.27 KB
/
PageProfilePlay.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
//
// PageProfilePlay.cpp
//
#include "stdafx.h"
#include "Xcenter.h"
#include "PageProfilePlay.h"
#include "CoolInterface.h"
#include "XML.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
IMPLEMENT_DYNCREATE(CPlayProfilePage, CSettingsPage)
BEGIN_MESSAGE_MAP(CPlayProfilePage, CSettingsPage)
//{{AFX_MSG_MAP(CPlayProfilePage)
ON_BN_CLICKED(IDC_ADD, OnAdd)
ON_BN_CLICKED(IDC_DELETE, OnDelete)
ON_NOTIFY(LVN_ITEMCHANGED, IDC_LIST, OnItemChangedList)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CPlayProfilePage property page
CPlayProfilePage::CPlayProfilePage(CXMLElement* pXML)
: CSettingsPage( CPlayProfilePage::IDD ), m_pXML( pXML )
{
//{{AFX_DATA_INIT(CPlayProfilePage)
//}}AFX_DATA_INIT
}
CPlayProfilePage::~CPlayProfilePage()
{
}
void CPlayProfilePage::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CPlayProfilePage)
DDX_Control(pDX, IDC_DELETE, m_wndDelete);
DDX_Control(pDX, IDC_PLAY_NAME, m_wndName);
DDX_Control(pDX, IDC_PLAY_INDEX, m_wndIndex);
DDX_Control(pDX, IDC_LIST, m_wndList);
//}}AFX_DATA_MAP
}
/////////////////////////////////////////////////////////////////////////////
// CPlayProfilePage message handlers
BOOL CPlayProfilePage::OnInitDialog()
{
CSettingsPage::OnInitDialog();
m_wndList.InsertColumn( 0, _T("°´¼ü´úÂë"), LVCFMT_LEFT, 80, -1 );
m_wndList.InsertColumn( 1, _T("½ÚÄ¿Ãû³Æ"), LVCFMT_LEFT, 220, 0 );
m_wndList.SetImageList( &CoolInterface.m_pImages, LVSIL_SMALL );
m_wndList.SetExtendedStyle( LVS_EX_FULLROWSELECT );
if ( m_pXML ) LoadXML();
m_wndDelete.EnableWindow( FALSE );
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CPlayProfilePage::OnOK()
{
// if ( m_pXML ) EditXML();
CSettingsPage::OnOK();
}
BOOL CPlayProfilePage::LoadXML()
{
CString strValue;
CXMLAttribute* pAttri = NULL;
for ( POSITION pos = m_pXML->GetElementIterator() ; pos ; )
{
CXMLElement* pMap = m_pXML->GetNextElement( pos );
if ( ! pMap->IsNamed( _T("Map") ) ) continue;
if ( pAttri = pMap->GetAttribute( _T("ID") ) )
{
strValue = pAttri->GetValue();
int nItem = m_wndList.InsertItem(
LVIF_TEXT|LVIF_IMAGE|LVIF_PARAM,
m_wndList.GetItemCount(), strValue, 0, 0,
CoolInterface.ImageForID(ID_REPORT_MUSIC), (LPARAM)pMap );
if ( pAttri = pMap->GetAttribute( _T("Play") ) )
{
m_wndList.SetItemText( nItem, 1, pAttri->GetValue() );
}
}
}
return TRUE;
}
void CPlayProfilePage::OnItemChangedList(NMHDR* pNMHDR, LRESULT* pResult)
{
NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR;
*pResult = 0;
if ( pNMListView->iItem >= 0 )
{
if ( ( pNMListView->uOldState & LVIS_SELECTED ) != ( pNMListView->uNewState & LVIS_SELECTED ) )
{
if ( pNMListView->uNewState & LVIS_SELECTED )
{
CXMLElement* pMap = (CXMLElement*)m_wndList.GetItemData( pNMListView->iItem );
if ( pMap != NULL )
{
CString strValue;
strValue = pMap->GetAttributeValue( _T("ID") );
m_wndIndex.SetWindowText( (LPCTSTR)strValue );
strValue = pMap->GetAttributeValue( _T("Play") );
m_wndName.SetWindowText( (LPCTSTR)strValue );
m_wndDelete.EnableWindow( TRUE );
}
}
}
}
}
void CPlayProfilePage::OnAdd()
{
CString strValue;
CXMLAttribute* pAttri = NULL;
if ( CXMLElement* pMap = m_pXML->AddElement( _T("Map") ) )
{
m_wndIndex.GetWindowText( strValue );
pMap->AddAttribute( _T("ID"), strValue );
int nItem = m_wndList.InsertItem(
LVIF_TEXT|LVIF_IMAGE|LVIF_PARAM,
m_wndList.GetItemCount(), strValue, 0, 0,
CoolInterface.ImageForID(ID_REPORT_MUSIC), (LPARAM)pMap );
m_wndName.GetWindowText( strValue );
pMap->AddAttribute( _T("Play"), strValue );
m_wndList.SetItemText( nItem, 1, strValue );
}
}
void CPlayProfilePage::OnDelete()
{
int nItem = m_wndList.GetNextItem( -1, LVNI_SELECTED );
if ( nItem == -1 ) return;
CXMLElement* pMap = (CXMLElement*)m_wndList.GetItemData( nItem );
m_wndList.DeleteItem( nItem );
if ( pMap ) pMap->Delete();
m_wndDelete.EnableWindow( FALSE );
}