OSDN Git Service

fix some dialog can't show after resize and close and open again
[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         this->AddOthersToAnchor();\r
44 \r
45         EnableSaveRestore(_T("ImportDlg"));\r
46         return TRUE;\r
47 }\r
48 \r
49 BEGIN_MESSAGE_MAP(CImportPatchDlg, CResizableStandAloneDialog)\r
50         ON_LBN_SELCHANGE(IDC_LIST_PATCH, &CImportPatchDlg::OnLbnSelchangeListPatch)\r
51         ON_BN_CLICKED(IDC_BUTTON_ADD, &CImportPatchDlg::OnBnClickedButtonAdd)\r
52         ON_BN_CLICKED(IDC_BUTTON_UP, &CImportPatchDlg::OnBnClickedButtonUp)\r
53         ON_BN_CLICKED(IDC_BUTTON_DOWN, &CImportPatchDlg::OnBnClickedButtonDown)\r
54         ON_BN_CLICKED(IDC_BUTTON_REMOVE, &CImportPatchDlg::OnBnClickedButtonRemove)\r
55         ON_BN_CLICKED(IDOK, &CImportPatchDlg::OnBnClickedOk)\r
56 END_MESSAGE_MAP()\r
57 \r
58 \r
59 // CImportPatchDlg message handlers\r
60 \r
61 void CImportPatchDlg::OnLbnSelchangeListPatch()\r
62 {\r
63         // TODO: Add your control notification handler code here\r
64         if(m_cList.GetSelectedCount() == 0)\r
65         {\r
66                 this->GetDlgItem(IDC_BUTTON_UP)->EnableWindow(FALSE);\r
67                 this->GetDlgItem(IDC_BUTTON_DOWN)->EnableWindow(FALSE);\r
68                 this->GetDlgItem(IDC_BUTTON_REMOVE)->EnableWindow(FALSE);\r
69         }else\r
70         {\r
71                 this->GetDlgItem(IDC_BUTTON_UP)->EnableWindow(TRUE);\r
72                 this->GetDlgItem(IDC_BUTTON_DOWN)->EnableWindow(TRUE);\r
73                 this->GetDlgItem(IDC_BUTTON_REMOVE)->EnableWindow(TRUE);\r
74 \r
75         }\r
76 \r
77 }\r
78 \r
79 void CImportPatchDlg::OnBnClickedButtonAdd()\r
80 {\r
81         \r
82         CFileDialog dlg(TRUE,NULL,\r
83                                         NULL,\r
84                                         OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT|OFN_ALLOWMULTISELECT,\r
85                                         _T("Patch Files(*.patch)|*.patch|Diff Files(*.diff)|*.diff|All Files(*.*)|*.*||"));\r
86         if(dlg.DoModal()==IDOK)\r
87         {\r
88                 POSITION pos;\r
89                 pos=dlg.GetStartPosition();\r
90                 while(pos)\r
91                 {\r
92                         m_cList.InsertItem(0,dlg.GetNextPathName(pos));\r
93                 }\r
94         }\r
95 \r
96         // TODO: Add your control notification handler code here\r
97 }\r
98 \r
99 void CImportPatchDlg::OnBnClickedButtonUp()\r
100 {\r
101         // TODO: Add your control notification handler code here\r
102         POSITION pos;\r
103         pos=m_cList.GetFirstSelectedItemPosition();\r
104         while(pos)\r
105         {\r
106                 int index=m_cList.GetNextSelectedItem(pos);\r
107                 if(index>1)\r
108                 {\r
109                         CString old=m_cList.GetItemText(index,0);\r
110                         m_cList.DeleteItem(index);\r
111 \r
112                         m_cList.InsertItem(index-1,old);\r
113                 }\r
114         }\r
115 \r
116 }\r
117 \r
118 void CImportPatchDlg::OnBnClickedButtonDown()\r
119 {\r
120         // TODO: Add your control notification handler code here\r
121         POSITION pos;\r
122         pos=m_cList.GetFirstSelectedItemPosition();\r
123         while(pos)\r
124         {\r
125                 int index=m_cList.GetNextSelectedItem(pos);\r
126                 \r
127                 CString old=m_cList.GetItemText(index,0);\r
128                 m_cList.DeleteItem(index);\r
129 \r
130                 m_cList.InsertItem(index+1,old);\r
131                 \r
132         }\r
133 }\r
134 \r
135 void CImportPatchDlg::OnBnClickedButtonRemove()\r
136 {\r
137         // TODO: Add your control notification handler code here\r
138         POSITION pos;\r
139         pos=m_cList.GetFirstSelectedItemPosition();\r
140         while(pos)\r
141         {\r
142                 int index=m_cList.GetNextSelectedItem(pos);\r
143                 m_cList.DeleteItem(index);\r
144                 pos=m_cList.GetFirstSelectedItemPosition();\r
145         }\r
146 }\r
147 \r
148 void CImportPatchDlg::OnBnClickedOk()\r
149 {\r
150         for(int i=0;i<m_cList.GetItemCount();i++)\r
151         {\r
152                 CTGitPath path;\r
153                 path.SetFromWin(m_cList.GetItemText(i,0));\r
154                 m_PathList.AddPath(path);\r
155         }\r
156         OnOK();\r
157 }\r