1 // ImportPatchDlg.cpp : implementation file
\r
5 #include "TortoiseProc.h"
\r
6 #include "ImportPatchDlg.h"
\r
9 // CImportPatchDlg dialog
\r
11 IMPLEMENT_DYNAMIC(CImportPatchDlg, CResizableStandAloneDialog)
\r
13 CImportPatchDlg::CImportPatchDlg(CWnd* pParent /*=NULL*/)
\r
14 : CResizableStandAloneDialog(CImportPatchDlg::IDD, pParent)
\r
16 m_cList.m_ContextMenuMask &=~ m_cList.GetMenuMask(CPatchListCtrl::MENU_APPLY);
\r
19 CImportPatchDlg::~CImportPatchDlg()
\r
24 void CImportPatchDlg::DoDataExchange(CDataExchange* pDX)
\r
26 CDialog::DoDataExchange(pDX);
\r
27 DDX_Control(pDX, IDC_LIST_PATCH,m_cList);
\r
30 BOOL CImportPatchDlg::OnInitDialog()
\r
32 CResizableStandAloneDialog::OnInitDialog();
\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
40 AddAnchor(IDOK,BOTTOM_RIGHT);
\r
41 AddAnchor(IDCANCEL,BOTTOM_RIGHT);
\r
43 this->AddOthersToAnchor();
\r
45 m_PathList.SortByPathname(true);
\r
46 m_cList.SetExtendedStyle( m_cList.GetExtendedStyle()| LVS_EX_CHECKBOXES );
\r
48 for(int i=0;i<m_PathList.GetCount();i++)
\r
50 m_cList.InsertItem(0,m_PathList[i].GetWinPath());
\r
51 m_cList.SetCheck(0,true);
\r
56 //CAppUtils::SetListCtrlBackgroundImage(m_cList.GetSafeHwnd(), nID);
\r
59 this->GetWindowText(title);
\r
60 this->SetWindowText(title+_T(" - ")+g_Git.m_CurrentDir);
\r
61 EnableSaveRestore(_T("ImportDlg"));
\r
66 BEGIN_MESSAGE_MAP(CImportPatchDlg, CResizableStandAloneDialog)
\r
67 ON_LBN_SELCHANGE(IDC_LIST_PATCH, &CImportPatchDlg::OnLbnSelchangeListPatch)
\r
68 ON_BN_CLICKED(IDC_BUTTON_ADD, &CImportPatchDlg::OnBnClickedButtonAdd)
\r
69 ON_BN_CLICKED(IDC_BUTTON_UP, &CImportPatchDlg::OnBnClickedButtonUp)
\r
70 ON_BN_CLICKED(IDC_BUTTON_DOWN, &CImportPatchDlg::OnBnClickedButtonDown)
\r
71 ON_BN_CLICKED(IDC_BUTTON_REMOVE, &CImportPatchDlg::OnBnClickedButtonRemove)
\r
72 ON_BN_CLICKED(IDOK, &CImportPatchDlg::OnBnClickedOk)
\r
76 // CImportPatchDlg message handlers
\r
78 void CImportPatchDlg::OnLbnSelchangeListPatch()
\r
80 // TODO: Add your control notification handler code here
\r
81 if(m_cList.GetSelectedCount() == 0)
\r
83 this->GetDlgItem(IDC_BUTTON_UP)->EnableWindow(FALSE);
\r
84 this->GetDlgItem(IDC_BUTTON_DOWN)->EnableWindow(FALSE);
\r
85 this->GetDlgItem(IDC_BUTTON_REMOVE)->EnableWindow(FALSE);
\r
88 this->GetDlgItem(IDC_BUTTON_UP)->EnableWindow(TRUE);
\r
89 this->GetDlgItem(IDC_BUTTON_DOWN)->EnableWindow(TRUE);
\r
90 this->GetDlgItem(IDC_BUTTON_REMOVE)->EnableWindow(TRUE);
\r
96 void CImportPatchDlg::OnBnClickedButtonAdd()
\r
99 CFileDialog dlg(TRUE,NULL,
\r
101 OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT|OFN_ALLOWMULTISELECT,
\r
102 _T("Patch Files(*.patch)|*.patch|Diff Files(*.diff)|*.diff|All Files(*.*)|*.*||"));
\r
103 if(dlg.DoModal()==IDOK)
\r
106 pos=dlg.GetStartPosition();
\r
109 CString file=dlg.GetNextPathName(pos);
\r
111 if(!file.IsEmpty())
\r
113 m_cList.InsertItem(0,file);
\r
114 m_cList.SetCheck(0,true);
\r
119 // TODO: Add your control notification handler code here
\r
122 void CImportPatchDlg::OnBnClickedButtonUp()
\r
124 // TODO: Add your control notification handler code here
\r
126 pos=m_cList.GetFirstSelectedItemPosition();
\r
129 int index=m_cList.GetNextSelectedItem(pos);
\r
132 CString old=m_cList.GetItemText(index,0);
\r
133 m_cList.DeleteItem(index);
\r
135 m_cList.InsertItem(index-1,old);
\r
141 void CImportPatchDlg::OnBnClickedButtonDown()
\r
143 // TODO: Add your control notification handler code here
\r
145 pos=m_cList.GetFirstSelectedItemPosition();
\r
148 int index=m_cList.GetNextSelectedItem(pos);
\r
150 CString old=m_cList.GetItemText(index,0);
\r
151 m_cList.DeleteItem(index);
\r
153 m_cList.InsertItem(index+1,old);
\r
158 void CImportPatchDlg::OnBnClickedButtonRemove()
\r
160 // TODO: Add your control notification handler code here
\r
162 pos=m_cList.GetFirstSelectedItemPosition();
\r
165 int index=m_cList.GetNextSelectedItem(pos);
\r
166 m_cList.DeleteItem(index);
\r
167 pos=m_cList.GetFirstSelectedItemPosition();
\r
171 void CImportPatchDlg::OnBnClickedOk()
\r
173 m_PathList.Clear();
\r
175 for(int i=0;i<m_cList.GetItemCount();i++)
\r
178 path.SetFromWin(m_cList.GetItemText(i,0));
\r
179 m_PathList.AddPath(path);
\r