00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include "StdAfx.h"
00023 #include "Shareaza.h"
00024 #include "Settings.h"
00025 #include "Library.h"
00026 #include "SharedFile.h"
00027 #include "DlgExistingFile.h"
00028 #include "TigerTree.h"
00029 #include "SHA.h"
00030
00031 #ifdef _DEBUG
00032 #define new DEBUG_NEW
00033 #undef THIS_FILE
00034 static char THIS_FILE[] = __FILE__;
00035 #endif
00036
00037 IMPLEMENT_DYNAMIC(CExistingFileDlg, CSkinDialog)
00038
00039 BEGIN_MESSAGE_MAP(CExistingFileDlg, CSkinDialog)
00040
00041 ON_WM_CTLCOLOR()
00042 ON_BN_CLICKED(IDC_ACTION_0, OnAction0)
00043 ON_BN_CLICKED(IDC_ACTION_1, OnAction1)
00044 ON_BN_CLICKED(IDC_ACTION_2, OnAction2)
00045
00046 END_MESSAGE_MAP()
00047
00048
00050
00051
00052 CExistingFileDlg::CExistingFileDlg(CLibraryFile* pFile, CWnd* pParent) : CSkinDialog( CExistingFileDlg::IDD, pParent )
00053 {
00054
00055 m_sName = _T("");
00056 m_sURN = _T("");
00057 m_nAction = 0;
00058
00059
00060 m_sName = pFile->m_sName;
00061
00062 if ( pFile->m_bSHA1 && pFile->m_bTiger )
00063 {
00064 m_sURN = _T("bitprint:") + CSHA::HashToString( &pFile->m_pSHA1 )
00065 + '.' + CTigerNode::HashToString( &pFile->m_pTiger );
00066 }
00067 else if ( pFile->m_bSHA1 )
00068 {
00069 m_sURN = CSHA::HashToString( &pFile->m_pSHA1, TRUE );
00070 }
00071 else if ( pFile->m_bTiger )
00072 {
00073 m_sURN = CTigerNode::HashToString( &pFile->m_pTiger, TRUE );
00074 }
00075
00076 m_bAvailable = pFile->IsAvailable();
00077 m_sComments = pFile->m_sComments;
00078 }
00079
00080 void CExistingFileDlg::DoDataExchange(CDataExchange* pDX)
00081 {
00082 CSkinDialog::DoDataExchange(pDX);
00083
00084 DDX_Control(pDX, IDOK, m_wndOK);
00085 DDX_Control(pDX, IDC_FILE_NAME, m_wndName);
00086 DDX_Text(pDX, IDC_FILE_NAME, m_sName);
00087 DDX_Text(pDX, IDC_FILE_URN, m_sURN);
00088 DDX_Radio(pDX, IDC_ACTION_0, m_nAction);
00089
00090 DDX_Control(pDX, IDC_FILE_COMMENTS, m_wndComments);
00091 DDX_Control(pDX, IDC_MESSAGE_AVAILABLE, m_wndMessageAvailable);
00092 DDX_Control(pDX, IDC_MESSAGE_DELETED, m_wndMessageDeleted);
00093 DDX_Control(pDX, IDC_ACTION_0, m_wndLocate);
00094 DDX_Text(pDX, IDC_FILE_COMMENTS, m_sComments);
00095 }
00096
00098
00099
00100 BOOL CExistingFileDlg::OnInitDialog()
00101 {
00102 CSkinDialog::OnInitDialog();
00103
00104 SkinMe( NULL, IDR_DOWNLOADSFRAME );
00105
00106 if ( ! m_bAvailable ) m_nAction = 1;
00107 UpdateData( FALSE );
00108
00109 m_wndComments.ShowWindow( m_sComments.GetLength() > 0 ? SW_SHOW : SW_HIDE );
00110 m_wndMessageAvailable.ShowWindow( m_bAvailable ? SW_SHOW : SW_HIDE );
00111 m_wndMessageDeleted.ShowWindow( m_bAvailable ? SW_HIDE : SW_SHOW );
00112 m_wndLocate.EnableWindow( m_bAvailable );
00113
00114 return TRUE;
00115 }
00116
00117 HBRUSH CExistingFileDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
00118 {
00119 HBRUSH hbr = CSkinDialog::OnCtlColor( pDC, pWnd, nCtlColor );
00120
00121 if ( pWnd == &m_wndName || pWnd == &m_wndMessageAvailable || pWnd == &m_wndMessageDeleted )
00122 pDC->SelectObject( &theApp.m_gdiFontBold );
00123 if ( pWnd == &m_wndComments && ! m_bAvailable )
00124 pDC->SetTextColor( RGB( 255, 0, 0 ) );
00125
00126 return hbr;
00127 }
00128
00129 void CExistingFileDlg::OnAction0()
00130 {
00131 if ( m_wndLocate.IsWindowEnabled() ) m_wndOK.EnableWindow( TRUE );
00132 }
00133
00134 void CExistingFileDlg::OnAction1()
00135 {
00136 m_wndOK.EnableWindow( TRUE );
00137 }
00138
00139 void CExistingFileDlg::OnAction2()
00140 {
00141 m_wndOK.EnableWindow( TRUE );
00142 }
00143
00144 void CExistingFileDlg::OnOK()
00145 {
00146 UpdateData();
00147 if ( ! m_bAvailable && m_nAction == 0 ) return;
00148 CSkinDialog::OnOK();
00149 }