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
);
43 this->AddOthersToAnchor();
45 m_PathList
.SortByPathname(true);
46 m_cList
.SetExtendedStyle( m_cList
.GetExtendedStyle()| LVS_EX_CHECKBOXES
);
48 for(int i
=0;i
<m_PathList
.GetCount();i
++)
50 m_cList
.InsertItem(0,m_PathList
[i
].GetWinPath());
51 m_cList
.SetCheck(0,true);
56 //CAppUtils::SetListCtrlBackgroundImage(m_cList.GetSafeHwnd(), nID);
59 this->GetWindowText(title
);
60 this->SetWindowText(title
+_T(" - ")+g_Git
.m_CurrentDir
);
61 EnableSaveRestore(_T("ImportDlg"));
66 BEGIN_MESSAGE_MAP(CImportPatchDlg
, CResizableStandAloneDialog
)
67 ON_LBN_SELCHANGE(IDC_LIST_PATCH
, &CImportPatchDlg::OnLbnSelchangeListPatch
)
68 ON_BN_CLICKED(IDC_BUTTON_ADD
, &CImportPatchDlg::OnBnClickedButtonAdd
)
69 ON_BN_CLICKED(IDC_BUTTON_UP
, &CImportPatchDlg::OnBnClickedButtonUp
)
70 ON_BN_CLICKED(IDC_BUTTON_DOWN
, &CImportPatchDlg::OnBnClickedButtonDown
)
71 ON_BN_CLICKED(IDC_BUTTON_REMOVE
, &CImportPatchDlg::OnBnClickedButtonRemove
)
72 ON_BN_CLICKED(IDOK
, &CImportPatchDlg::OnBnClickedOk
)
76 // CImportPatchDlg message handlers
78 void CImportPatchDlg::OnLbnSelchangeListPatch()
80 // TODO: Add your control notification handler code here
81 if(m_cList
.GetSelectedCount() == 0)
83 this->GetDlgItem(IDC_BUTTON_UP
)->EnableWindow(FALSE
);
84 this->GetDlgItem(IDC_BUTTON_DOWN
)->EnableWindow(FALSE
);
85 this->GetDlgItem(IDC_BUTTON_REMOVE
)->EnableWindow(FALSE
);
88 this->GetDlgItem(IDC_BUTTON_UP
)->EnableWindow(TRUE
);
89 this->GetDlgItem(IDC_BUTTON_DOWN
)->EnableWindow(TRUE
);
90 this->GetDlgItem(IDC_BUTTON_REMOVE
)->EnableWindow(TRUE
);
96 void CImportPatchDlg::OnBnClickedButtonAdd()
99 CFileDialog
dlg(TRUE
,NULL
,
101 OFN_HIDEREADONLY
| OFN_OVERWRITEPROMPT
|OFN_ALLOWMULTISELECT
,
102 _T("Patch Files(*.patch)|*.patch|Diff Files(*.diff)|*.diff|All Files(*.*)|*.*||"));
103 if(dlg
.DoModal()==IDOK
)
106 pos
=dlg
.GetStartPosition();
109 CString file
=dlg
.GetNextPathName(pos
);
113 m_cList
.InsertItem(0,file
);
114 m_cList
.SetCheck(0,true);
119 // TODO: Add your control notification handler code here
122 void CImportPatchDlg::OnBnClickedButtonUp()
124 // TODO: Add your control notification handler code here
126 pos
=m_cList
.GetFirstSelectedItemPosition();
129 int index
=m_cList
.GetNextSelectedItem(pos
);
132 CString old
=m_cList
.GetItemText(index
,0);
133 m_cList
.DeleteItem(index
);
135 m_cList
.InsertItem(index
-1,old
);
141 void CImportPatchDlg::OnBnClickedButtonDown()
143 // TODO: Add your control notification handler code here
145 pos
=m_cList
.GetFirstSelectedItemPosition();
148 int index
=m_cList
.GetNextSelectedItem(pos
);
150 CString old
=m_cList
.GetItemText(index
,0);
151 m_cList
.DeleteItem(index
);
153 m_cList
.InsertItem(index
+1,old
);
158 void CImportPatchDlg::OnBnClickedButtonRemove()
160 // TODO: Add your control notification handler code here
162 pos
=m_cList
.GetFirstSelectedItemPosition();
165 int index
=m_cList
.GetNextSelectedItem(pos
);
166 m_cList
.DeleteItem(index
);
167 pos
=m_cList
.GetFirstSelectedItemPosition();
171 void CImportPatchDlg::OnBnClickedOk()
175 for(int i
=0;i
<m_cList
.GetItemCount();i
++)
177 if(m_cList
.GetCheck(i
))
180 path
.SetFromWin(m_cList
.GetItemText(i
,0));
181 m_PathList
.AddPath(path
);