00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #include "stdafx.h"
00026 #include <afxpriv.h>
00027 #include "VSRip.h"
00028 #include "VSRipIndexingDlg.h"
00029
00030
00031
00032 IMPLEMENT_DYNAMIC(CVSRipIndexingDlg, CVSRipPage)
00033 CVSRipIndexingDlg::CVSRipIndexingDlg(IVSFRipper* pVSFRipper, CWnd* pParent )
00034 : CVSRipPage(pVSFRipper, CVSRipIndexingDlg::IDD, pParent)
00035 , m_bBeep(FALSE), m_bExit(FALSE)
00036 , m_fFinished(false)
00037 , m_fAuto(false)
00038 {
00039 }
00040
00041 CVSRipIndexingDlg::~CVSRipIndexingDlg()
00042 {
00043 }
00044
00045 void CVSRipIndexingDlg::DoDataExchange(CDataExchange* pDX)
00046 {
00047 CVSRipPage::DoDataExchange(pDX);
00048 DDX_Control(pDX, IDC_PROGRESS1, m_progress);
00049 DDX_Control(pDX, IDC_EDIT1, m_log);
00050 DDX_Check(pDX, IDC_CHECK1, m_bExit);
00051 DDX_Check(pDX, IDC_CHECK2, m_bBeep);
00052 }
00053
00054 STDMETHODIMP CVSRipIndexingDlg::OnMessage(LPCTSTR msg)
00055 {
00056 if(CEdit* pLog = (CEdit*)CEdit::FromHandle(m_log.m_hWnd))
00057 {
00058 CString str = msg;
00059 str += _T("\r\n");
00060 int len = pLog->GetWindowTextLength();
00061 pLog->SetSel(len, len);
00062 pLog->ReplaceSel(str);
00063 }
00064
00065 return S_OK;
00066 }
00067
00068 STDMETHODIMP CVSRipIndexingDlg::OnProgress(double progress)
00069 {
00070 if(CProgressCtrl* pProgress = (CProgressCtrl*)CProgressCtrl::FromHandle(m_progress.m_hWnd))
00071 {
00072 pProgress->SetPos((int)(progress * 100));
00073 }
00074
00075 return S_OK;
00076 }
00077
00078 STDMETHODIMP CVSRipIndexingDlg::OnFinished(bool fSucceeded)
00079 {
00080 m_fFinished = fSucceeded;
00081
00082 GetParent()->PostMessage(WM_KICKIDLE);
00083
00084 if(m_fFinished && m_bBeep) MessageBeep(-1);
00085 if(m_fFinished && m_bExit) GetParent()->PostMessage(WM_COMMAND, IDCANCEL);
00086
00087 if(!fSucceeded)
00088 {
00089 VSFRipperData rd;
00090 m_pVSFRipper->GetRipperData(rd);
00091 if(rd.fCloseIgnoreError) GetParent()->PostMessage(WM_COMMAND, IDCANCEL);
00092 }
00093
00094 return S_OK;
00095 }
00096
00097 BEGIN_MESSAGE_MAP(CVSRipIndexingDlg, CVSRipPage)
00098 ON_BN_CLICKED(IDC_BUTTON1, OnIndex)
00099 ON_UPDATE_COMMAND_UI(IDC_BUTTON1, OnUpdateIndex)
00100 ON_WM_SHOWWINDOW()
00101 ON_BN_CLICKED(IDC_CHECK2, OnBnClickedCheck2)
00102 ON_BN_CLICKED(IDC_CHECK1, OnBnClickedCheck1)
00103 END_MESSAGE_MAP()
00104
00105
00106
00107
00108 void CVSRipIndexingDlg::OnIndex()
00109 {
00110 if(S_OK == m_pVSFRipper->IsIndexing())
00111 {
00112 m_pVSFRipper->Abort(false);
00113 }
00114 else
00115 {
00116 m_progress.SetRange(0, 100);
00117 m_progress.SetPos(0);
00118 m_log.SetWindowText(_T(""));
00119 m_log.SetMargins(0, 0);
00120
00121 m_pVSFRipper->Index();
00122 }
00123
00124 GetParent()->PostMessage(WM_KICKIDLE);
00125 }
00126
00127 void CVSRipIndexingDlg::OnUpdateIndex(CCmdUI* pCmdUI)
00128 {
00129 pCmdUI->SetText(S_OK == m_pVSFRipper->IsIndexing() ? _T("&Stop") : _T("Re&start"));
00130 }
00131
00132 void CVSRipIndexingDlg::OnShowWindow(BOOL bShow, UINT nStatus)
00133 {
00134 __super::OnShowWindow(bShow, nStatus);
00135
00136 m_fFinished = false;
00137
00138 if(bShow)
00139 {
00140 VSFRipperData rd;
00141 m_pVSFRipper->GetRipperData(rd);
00142 m_bBeep = rd.fBeep;
00143 m_bExit = rd.fClose;
00144 m_fAuto = rd.fAuto;
00145 UpdateData(FALSE);
00146
00147 if(S_OK != m_pVSFRipper->IsIndexing())
00148 {
00149 if(!m_fAuto)
00150 {
00151 m_progress.SetRange(0, 100);
00152 m_progress.SetPos(0);
00153 m_log.SetWindowText(_T(""));
00154 m_log.SetMargins(0, 0);
00155 }
00156
00157 m_pVSFRipper->Index();
00158 }
00159 }
00160 else
00161 {
00162 VSFRipperData rd;
00163 m_pVSFRipper->GetRipperData(rd);
00164 UpdateData();
00165 rd.fBeep = !m_bBeep;
00166 rd.fClose = !!m_bExit;
00167 m_pVSFRipper->UpdateRipperData(rd);
00168 }
00169 }
00170
00171 void CVSRipIndexingDlg::OnBnClickedCheck2()
00172 {
00173 UpdateData();
00174 }
00175
00176 void CVSRipIndexingDlg::OnBnClickedCheck1()
00177 {
00178 UpdateData();
00179 }