1 // ImportPatchDlg.cpp : implementation file
5 #include "TortoiseProc.h"
6 #include "ImportPatchDlg.h"
9 // CImportPatchDlg dialog
11 IMPLEMENT_DYNAMIC(CImportPatchDlg
, CResizableStandAloneDialog
)
13 CImportPatchDlg::CImportPatchDlg(CWnd
* pParent
/*=NULL*/)
14 : CResizableStandAloneDialog(CImportPatchDlg::IDD
, pParent
)
16 m_cList
.m_ContextMenuMask
&=~ m_cList
.GetMenuMask(CPatchListCtrl::MENU_APPLY
);
19 CImportPatchDlg::~CImportPatchDlg()
24 void CImportPatchDlg::DoDataExchange(CDataExchange
* pDX
)
26 CDialog::DoDataExchange(pDX
);
27 DDX_Control(pDX
, IDC_LIST_PATCH
,m_cList
);
30 BOOL
CImportPatchDlg::OnInitDialog()
32 CResizableStandAloneDialog::OnInitDialog();
34 AddAnchor(IDC_LIST_PATCH
, TOP_LEFT
, BOTTOM_RIGHT
);
35 AddAnchor(IDC_BUTTON_ADD
, TOP_RIGHT
);
36 AddAnchor(IDC_BUTTON_UP
, TOP_RIGHT
);
37 AddAnchor(IDC_BUTTON_DOWN
, TOP_RIGHT
);
38 AddAnchor(IDC_BUTTON_REMOVE
, TOP_RIGHT
);
40 AddAnchor(IDOK
,BOTTOM_RIGHT
);
41 AddAnchor(IDCANCEL
,BOTTOM_RIGHT
);
42 AddAnchor(IDHELP
, BOTTOM_RIGHT
);
44 this->AddOthersToAnchor();
46 m_PathList
.SortByPathname(true);
47 m_cList
.SetExtendedStyle( m_cList
.GetExtendedStyle()| LVS_EX_CHECKBOXES
);
49 for(int i
=0;i
<m_PathList
.GetCount();i
++)
51 m_cList
.InsertItem(0,m_PathList
[i
].GetWinPath());
52 m_cList
.SetCheck(0,true);
57 //CAppUtils::SetListCtrlBackgroundImage(m_cList.GetSafeHwnd(), nID);
60 this->GetWindowText(title
);
61 this->SetWindowText(title
+_T(" - ")+g_Git
.m_CurrentDir
);
62 EnableSaveRestore(_T("ImportDlg"));
67 BEGIN_MESSAGE_MAP(CImportPatchDlg
, CResizableStandAloneDialog
)
68 ON_LBN_SELCHANGE(IDC_LIST_PATCH
, &CImportPatchDlg::OnLbnSelchangeListPatch
)
69 ON_BN_CLICKED(IDC_BUTTON_ADD
, &CImportPatchDlg::OnBnClickedButtonAdd
)
70 ON_BN_CLICKED(IDC_BUTTON_UP
, &CImportPatchDlg::OnBnClickedButtonUp
)
71 ON_BN_CLICKED(IDC_BUTTON_DOWN
, &CImportPatchDlg::OnBnClickedButtonDown
)
72 ON_BN_CLICKED(IDC_BUTTON_REMOVE
, &CImportPatchDlg::OnBnClickedButtonRemove
)
73 ON_BN_CLICKED(IDOK
, &CImportPatchDlg::OnBnClickedOk
)
77 // CImportPatchDlg message handlers
79 void CImportPatchDlg::OnLbnSelchangeListPatch()
81 // TODO: Add your control notification handler code here
82 if(m_cList
.GetSelectedCount() == 0)
84 this->GetDlgItem(IDC_BUTTON_UP
)->EnableWindow(FALSE
);
85 this->GetDlgItem(IDC_BUTTON_DOWN
)->EnableWindow(FALSE
);
86 this->GetDlgItem(IDC_BUTTON_REMOVE
)->EnableWindow(FALSE
);
89 this->GetDlgItem(IDC_BUTTON_UP
)->EnableWindow(TRUE
);
90 this->GetDlgItem(IDC_BUTTON_DOWN
)->EnableWindow(TRUE
);
91 this->GetDlgItem(IDC_BUTTON_REMOVE
)->EnableWindow(TRUE
);
97 void CImportPatchDlg::OnBnClickedButtonAdd()
100 CFileDialog
dlg(TRUE
,NULL
,
102 OFN_HIDEREADONLY
| OFN_OVERWRITEPROMPT
|OFN_ALLOWMULTISELECT
,
103 _T("Patch Files(*.patch)|*.patch|Diff Files(*.diff)|*.diff|All Files(*.*)|*.*||"));
104 if(dlg
.DoModal()==IDOK
)
107 pos
=dlg
.GetStartPosition();
110 CString file
=dlg
.GetNextPathName(pos
);
114 m_cList
.InsertItem(0,file
);
115 m_cList
.SetCheck(0,true);
120 // TODO: Add your control notification handler code here
123 void CImportPatchDlg::OnBnClickedButtonUp()
125 // TODO: Add your control notification handler code here
127 pos
=m_cList
.GetFirstSelectedItemPosition();
130 int index
=m_cList
.GetNextSelectedItem(pos
);
133 CString old
=m_cList
.GetItemText(index
,0);
134 m_cList
.DeleteItem(index
);
136 m_cList
.InsertItem(index
-1,old
);
142 void CImportPatchDlg::OnBnClickedButtonDown()
144 // TODO: Add your control notification handler code here
146 pos
=m_cList
.GetFirstSelectedItemPosition();
149 int index
=m_cList
.GetNextSelectedItem(pos
);
151 CString old
=m_cList
.GetItemText(index
,0);
152 m_cList
.DeleteItem(index
);
154 m_cList
.InsertItem(index
+1,old
);
159 void CImportPatchDlg::OnBnClickedButtonRemove()
161 // TODO: Add your control notification handler code here
163 pos
=m_cList
.GetFirstSelectedItemPosition();
166 int index
=m_cList
.GetNextSelectedItem(pos
);
167 m_cList
.DeleteItem(index
);
168 pos
=m_cList
.GetFirstSelectedItemPosition();
172 void CImportPatchDlg::OnBnClickedOk()
176 for(int i
=0;i
<m_cList
.GetItemCount();i
++)
178 if(m_cList
.GetCheck(i
))
181 path
.SetFromWin(m_cList
.GetItemText(i
,0));
182 m_PathList
.AddPath(path
);