OSDN Git Service

Add EnableSaveRestore at some dialog.
[tortoisegit/TortoiseGitJp.git] / src / TortoiseProc / ImportPatchDlg.cpp
1 // ImportPatchDlg.cpp : implementation file\r
2 //\r
3 \r
4 #include "stdafx.h"\r
5 #include "TortoiseProc.h"\r
6 #include "ImportPatchDlg.h"\r
7 \r
8 \r
9 // CImportPatchDlg dialog\r
10 \r
11 IMPLEMENT_DYNAMIC(CImportPatchDlg, CResizableStandAloneDialog)\r
12 \r
13 CImportPatchDlg::CImportPatchDlg(CWnd* pParent /*=NULL*/)\r
14         : CResizableStandAloneDialog(CImportPatchDlg::IDD, pParent)\r
15 {\r
16 \r
17 }\r
18 \r
19 CImportPatchDlg::~CImportPatchDlg()\r
20 {\r
21 \r
22 }\r
23 \r
24 void CImportPatchDlg::DoDataExchange(CDataExchange* pDX)\r
25 {\r
26         CDialog::DoDataExchange(pDX);\r
27         DDX_Control(pDX, IDC_LIST_PATCH,m_cList);\r
28 }\r
29 \r
30 BOOL CImportPatchDlg::OnInitDialog()\r
31 {\r
32         CResizableStandAloneDialog::OnInitDialog();\r
33 \r
34         AddAnchor(IDC_LIST_PATCH, TOP_LEFT, BOTTOM_RIGHT);\r
35         AddAnchor(IDC_BUTTON_ADD, TOP_RIGHT);\r
36         AddAnchor(IDC_BUTTON_UP, TOP_RIGHT);\r
37         AddAnchor(IDC_BUTTON_DOWN, TOP_RIGHT);\r
38         AddAnchor(IDC_BUTTON_REMOVE, TOP_RIGHT);\r
39 \r
40         AddAnchor(IDOK,BOTTOM_RIGHT);\r
41         AddAnchor(IDCANCEL,BOTTOM_RIGHT);\r
42 \r
43         EnableSaveRestore(_T("ImportDlg"));\r
44         return TRUE;\r
45 }\r
46 \r
47 BEGIN_MESSAGE_MAP(CImportPatchDlg, CResizableStandAloneDialog)\r
48         ON_LBN_SELCHANGE(IDC_LIST_PATCH, &CImportPatchDlg::OnLbnSelchangeListPatch)\r
49         ON_BN_CLICKED(IDC_BUTTON_ADD, &CImportPatchDlg::OnBnClickedButtonAdd)\r
50         ON_BN_CLICKED(IDC_BUTTON_UP, &CImportPatchDlg::OnBnClickedButtonUp)\r
51         ON_BN_CLICKED(IDC_BUTTON_DOWN, &CImportPatchDlg::OnBnClickedButtonDown)\r
52         ON_BN_CLICKED(IDC_BUTTON_REMOVE, &CImportPatchDlg::OnBnClickedButtonRemove)\r
53         ON_BN_CLICKED(IDOK, &CImportPatchDlg::OnBnClickedOk)\r
54 END_MESSAGE_MAP()\r
55 \r
56 \r
57 // CImportPatchDlg message handlers\r
58 \r
59 void CImportPatchDlg::OnLbnSelchangeListPatch()\r
60 {\r
61         // TODO: Add your control notification handler code here\r
62         if(m_cList.GetSelectedCount() == 0)\r
63         {\r
64                 this->GetDlgItem(IDC_BUTTON_UP)->EnableWindow(FALSE);\r
65                 this->GetDlgItem(IDC_BUTTON_DOWN)->EnableWindow(FALSE);\r
66                 this->GetDlgItem(IDC_BUTTON_REMOVE)->EnableWindow(FALSE);\r
67         }else\r
68         {\r
69                 this->GetDlgItem(IDC_BUTTON_UP)->EnableWindow(TRUE);\r
70                 this->GetDlgItem(IDC_BUTTON_DOWN)->EnableWindow(TRUE);\r
71                 this->GetDlgItem(IDC_BUTTON_REMOVE)->EnableWindow(TRUE);\r
72 \r
73         }\r
74 \r
75 }\r
76 \r
77 void CImportPatchDlg::OnBnClickedButtonAdd()\r
78 {\r
79         \r
80         CFileDialog dlg(TRUE,NULL,\r
81                                         NULL,\r
82                                         OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT|OFN_ALLOWMULTISELECT,\r
83                                         _T("Patch Files(*.patch)|*.patch|Diff Files(*.diff)|*.diff|All Files(*.*)|*.*||"));\r
84         if(dlg.DoModal()==IDOK)\r
85         {\r
86                 POSITION pos;\r
87                 pos=dlg.GetStartPosition();\r
88                 while(pos)\r
89                 {\r
90                         m_cList.InsertItem(0,dlg.GetNextPathName(pos));\r
91                 }\r
92         }\r
93 \r
94         // TODO: Add your control notification handler code here\r
95 }\r
96 \r
97 void CImportPatchDlg::OnBnClickedButtonUp()\r
98 {\r
99         // TODO: Add your control notification handler code here\r
100         POSITION pos;\r
101         pos=m_cList.GetFirstSelectedItemPosition();\r
102         while(pos)\r
103         {\r
104                 int index=m_cList.GetNextSelectedItem(pos);\r
105                 if(index>1)\r
106                 {\r
107                         CString old=m_cList.GetItemText(index,0);\r
108                         m_cList.DeleteItem(index);\r
109 \r
110                         m_cList.InsertItem(index-1,old);\r
111                 }\r
112         }\r
113 \r
114 }\r
115 \r
116 void CImportPatchDlg::OnBnClickedButtonDown()\r
117 {\r
118         // TODO: Add your control notification handler code here\r
119         POSITION pos;\r
120         pos=m_cList.GetFirstSelectedItemPosition();\r
121         while(pos)\r
122         {\r
123                 int index=m_cList.GetNextSelectedItem(pos);\r
124                 \r
125                 CString old=m_cList.GetItemText(index,0);\r
126                 m_cList.DeleteItem(index);\r
127 \r
128                 m_cList.InsertItem(index+1,old);\r
129                 \r
130         }\r
131 }\r
132 \r
133 void CImportPatchDlg::OnBnClickedButtonRemove()\r
134 {\r
135         // TODO: Add your control notification handler code here\r
136         POSITION pos;\r
137         pos=m_cList.GetFirstSelectedItemPosition();\r
138         while(pos)\r
139         {\r
140                 int index=m_cList.GetNextSelectedItem(pos);\r
141                 m_cList.DeleteItem(index);\r
142                 pos=m_cList.GetFirstSelectedItemPosition();\r
143         }\r
144 }\r
145 \r
146 void CImportPatchDlg::OnBnClickedOk()\r
147 {\r
148         for(int i=0;i<m_cList.GetItemCount();i++)\r
149         {\r
150                 CTGitPath path;\r
151                 path.SetFromWin(m_cList.GetItemText(i,0));\r
152                 m_PathList.AddPath(path);\r
153         }\r
154         OnOK();\r
155 }\r