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 "PageSettingsMedia.h"
00026 #include "DlgMediaVis.h"
00027
00028 #ifdef _DEBUG
00029 #define new DEBUG_NEW
00030 #undef THIS_FILE
00031 static char THIS_FILE[] = __FILE__;
00032 #endif
00033
00034 IMPLEMENT_DYNCREATE(CMediaSettingsPage, CSettingsPage)
00035
00036 BEGIN_MESSAGE_MAP(CMediaSettingsPage, CSettingsPage)
00037
00038 ON_BN_CLICKED(IDC_MEDIA_PLAY, OnMediaPlay)
00039 ON_BN_CLICKED(IDC_MEDIA_ENQUEUE, OnMediaEnqueue)
00040 ON_CBN_SELCHANGE(IDC_MEDIA_TYPES, OnSelChangeMediaTypes)
00041 ON_CBN_EDITCHANGE(IDC_MEDIA_TYPES, OnEditChangeMediaTypes)
00042 ON_BN_CLICKED(IDC_MEDIA_ADD, OnMediaAdd)
00043 ON_BN_CLICKED(IDC_MEDIA_REMOVE, OnMediaRemove)
00044 ON_BN_CLICKED(IDC_MEDIA_VIS, OnMediaVis)
00045
00046 END_MESSAGE_MAP()
00047
00048
00050
00051
00052 CMediaSettingsPage::CMediaSettingsPage() : CSettingsPage(CMediaSettingsPage::IDD)
00053 {
00054
00055 m_sType = _T("");
00056 m_bEnablePlay = FALSE;
00057 m_bEnableEnqueue = FALSE;
00058
00059 }
00060
00061 CMediaSettingsPage::~CMediaSettingsPage()
00062 {
00063 }
00064
00065 void CMediaSettingsPage::DoDataExchange(CDataExchange* pDX)
00066 {
00067 CSettingsPage::DoDataExchange(pDX);
00068
00069 DDX_Control(pDX, IDC_MEDIA_REMOVE, m_wndRemove);
00070 DDX_Control(pDX, IDC_MEDIA_ADD, m_wndAdd);
00071 DDX_Control(pDX, IDC_MEDIA_TYPES, m_wndList);
00072 DDX_CBString(pDX, IDC_MEDIA_TYPES, m_sType);
00073 DDX_Check(pDX, IDC_MEDIA_PLAY, m_bEnablePlay);
00074 DDX_Check(pDX, IDC_MEDIA_ENQUEUE, m_bEnableEnqueue);
00075
00076 }
00077
00079
00080
00081 BOOL CMediaSettingsPage::OnInitDialog()
00082 {
00083 CSettingsPage::OnInitDialog();
00084
00085 m_bEnablePlay = Settings.MediaPlayer.EnablePlay;
00086 m_bEnableEnqueue = Settings.MediaPlayer.EnableEnqueue;
00087
00088 for ( CString strList = Settings.MediaPlayer.FileTypes + '|' ; strList.GetLength() ; )
00089 {
00090 CString strType = strList.SpanExcluding( _T(" |") );
00091 strList = strList.Mid( strType.GetLength() + 1 );
00092 strType.TrimLeft();
00093 strType.TrimRight();
00094 if ( strType.GetLength() ) m_wndList.AddString( strType );
00095 }
00096
00097 UpdateData( FALSE );
00098
00099 m_wndList.EnableWindow( m_bEnablePlay || m_bEnableEnqueue );
00100 m_wndAdd.EnableWindow( ( m_bEnablePlay || m_bEnableEnqueue ) && m_wndList.GetWindowTextLength() > 0 );
00101 m_wndRemove.EnableWindow( ( m_bEnablePlay || m_bEnableEnqueue ) && m_wndList.GetCurSel() >= 0 );
00102
00103 return TRUE;
00104 }
00105
00106 void CMediaSettingsPage::OnMediaPlay()
00107 {
00108 UpdateData();
00109 m_wndList.EnableWindow( m_bEnablePlay || m_bEnableEnqueue );
00110 m_wndAdd.EnableWindow( ( m_bEnablePlay || m_bEnableEnqueue ) && m_wndList.GetWindowTextLength() > 0 );
00111 m_wndRemove.EnableWindow( ( m_bEnablePlay || m_bEnableEnqueue ) && m_wndList.GetCurSel() >= 0 );
00112 }
00113
00114 void CMediaSettingsPage::OnMediaEnqueue()
00115 {
00116 UpdateData();
00117 m_wndList.EnableWindow( m_bEnablePlay || m_bEnableEnqueue );
00118 m_wndAdd.EnableWindow( ( m_bEnablePlay || m_bEnableEnqueue ) && m_wndList.GetWindowTextLength() > 0 );
00119 m_wndRemove.EnableWindow( ( m_bEnablePlay || m_bEnableEnqueue ) && m_wndList.GetCurSel() >= 0 );
00120 }
00121
00122 void CMediaSettingsPage::OnSelChangeMediaTypes()
00123 {
00124 m_wndRemove.EnableWindow( ( m_bEnablePlay || m_bEnableEnqueue ) && m_wndList.GetCurSel() >= 0 );
00125 }
00126
00127 void CMediaSettingsPage::OnEditChangeMediaTypes()
00128 {
00129 m_wndAdd.EnableWindow( ( m_bEnablePlay || m_bEnableEnqueue ) && m_wndList.GetWindowTextLength() > 0 );
00130 }
00131
00132 void CMediaSettingsPage::OnMediaAdd()
00133 {
00134 UpdateData();
00135
00136 CharLower( m_sType.GetBuffer() );
00137 m_sType.ReleaseBuffer();
00138 m_sType.TrimLeft();
00139 m_sType.TrimRight();
00140 if ( m_sType.IsEmpty() ) return;
00141
00142 if ( m_wndList.FindStringExact( -1, m_sType ) >= 0 ) return;
00143
00144 m_wndList.AddString( m_sType );
00145 m_sType.Empty();
00146 UpdateData( FALSE );
00147 }
00148
00149 void CMediaSettingsPage::OnMediaRemove()
00150 {
00151 int nItem = m_wndList.GetCurSel();
00152 if ( nItem >= 0 ) m_wndList.DeleteString( nItem );
00153 m_wndRemove.EnableWindow( FALSE );
00154 }
00155
00156 void CMediaSettingsPage::OnMediaVis()
00157 {
00158 CMediaVisDlg dlg( NULL );
00159 dlg.DoModal();
00160 }
00161
00162 void CMediaSettingsPage::OnOK()
00163 {
00164 UpdateData();
00165
00166 Settings.MediaPlayer.EnablePlay = m_bEnablePlay;
00167 Settings.MediaPlayer.EnableEnqueue = m_bEnableEnqueue;
00168
00169 Settings.MediaPlayer.FileTypes.Empty();
00170
00171 for ( int nItem = 0 ; nItem < m_wndList.GetCount() ; nItem++ )
00172 {
00173 CString str;
00174 m_wndList.GetLBText( nItem, str );
00175
00176 if ( str.GetLength() )
00177 {
00178 if ( Settings.MediaPlayer.FileTypes.IsEmpty() )
00179 Settings.MediaPlayer.FileTypes += '|';
00180 Settings.MediaPlayer.FileTypes += str;
00181 Settings.MediaPlayer.FileTypes += '|';
00182 }
00183 }
00184
00185 CSettingsPage::OnOK();
00186 }