/*
* Copyright (C) 2001-2006 Jacek Sieka, arnetheduck on gmail point com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "stdafx.h"
#include "../client/DCPlusPlus.h"
#include "Resource.h"
#include "ADLSProperties.h"
#include "../client/ADLSearch.h"
#include "../client/FavoriteManager.h"
#include "WinUtil.h"
WinUtil::TextItem ADLSProperties::texts[] = {
{ IDD_ADLS_PROPERTIES, ResourceManager::ADLSEARCH_PROPERTIES },
{ IDC_ADLSEARCH_SEARCH_STRING, ResourceManager::ADLSEARCH_SEARCH_STRING },
{ IDC_ADLSEARCH_SOURCE_TYPE, ResourceManager::ADLSEARCH_SOURCE_TYPE },
{ IDC_ADLSEARCH_DESTINATION_DIRECTORY, ResourceManager::ADLSEARCH_DESTINATION_DIRECTORY },
{ IDC_ADLSEARCH_MIN_SIZE, ResourceManager::ADLSEARCH_MIN_SIZE },
{ IDC_ADLSEARCH_MAX_SIZE, ResourceManager::ADLSEARCH_MAX_SIZE },
{ IDC_IS_ACTIVE, ResourceManager::ADLSEARCH_ACTIVE_SEARCH },
{ IDC_ADLSEARCH_SIZE_TYPE, ResourceManager::ADLSEARCH_SIZE_TYPE },
{ IDOK, ResourceManager::OK },
{ IDCANCEL, ResourceManager::CANCEL },
{ 0, ResourceManager::SETTINGS_AUTO_AWAY }
};
// Initialize dialog
LRESULT ADLSProperties::OnInitDialog(UINT, WPARAM, LPARAM, BOOL&)
{
WinUtil::translate(*this, texts);
// Initialize combo boxes
#define SM_SOURCE(id, var) ::SendMessage(GetDlgItem(id), CB_ADDSTRING, 0, \
(LPARAM)search->SourceTypeToDisplayString(ADLSearch::var).c_str());
#define SM_SIZE(id, var) ::SendMessage(GetDlgItem(id), CB_ADDSTRING, 0, \
(LPARAM)search->SizeTypeToDisplayString(ADLSearch::var).c_str());
SM_SOURCE(IDC_SOURCE_TYPE, OnlyFile);
SM_SOURCE(IDC_SOURCE_TYPE, OnlyDirectory);
SM_SOURCE(IDC_SOURCE_TYPE, FullPath);
SM_SIZE(IDC_SIZE_TYPE, SizeBytes);
SM_SIZE(IDC_SIZE_TYPE, SizeKibiBytes);
SM_SIZE(IDC_SIZE_TYPE, SizeMebiBytes);
SM_SIZE(IDC_SIZE_TYPE, SizeGibiBytes);
// Load search data
SetDlgItemText(IDC_SEARCH_STRING, Text::toT(search->searchString).c_str());
SetDlgItemText(IDC_DEST_DIR, Text::toT(search->destDir).c_str());
SetDlgItemText(IDC_MIN_FILE_SIZE, Text::toT(search->minFileSize > 0 ? Util::toString(search->minFileSize) : "").c_str());
SetDlgItemText(IDC_MAX_FILE_SIZE, Text::toT(search->maxFileSize > 0 ? Util::toString(search->maxFileSize) : "").c_str());
#define SM_SEARCH(id, type, var) ::SendMessage(GetDlgItem(id), type, search->var, 0L);
SM_SEARCH(IDC_IS_ACTIVE, BM_SETCHECK, isActive ? 1 : 0);
SM_SEARCH(IDC_SOURCE_TYPE, CB_SETCURSEL, sourceType);
SM_SEARCH(IDC_SIZE_TYPE, CB_SETCURSEL, typeFileSize);
SM_SEARCH(IDC_AUTOQUEUE, BM_SETCHECK, isAutoQueue ? 1 : 0);
// Center dialog
CenterWindow(GetParent());
return FALSE;
}
// Exit dialog
LRESULT ADLSProperties::OnCloseCmd(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
{
if(wID == IDOK)
{
// Update search
TCHAR buf[256];
GetDlgItemText(IDC_SEARCH_STRING, buf, 256);
search->searchString = Text::fromT(buf);
GetDlgItemText(IDC_DEST_DIR, buf, 256);
search->destDir = Text::fromT(buf);
GetDlgItemText(IDC_MIN_FILE_SIZE, buf, 256);
search->minFileSize = (_tcslen(buf) == 0 ? -1 : Util::toInt64(Text::fromT(buf)));
GetDlgItemText(IDC_MAX_FILE_SIZE, buf, 256);
search->maxFileSize = (_tcslen(buf) == 0 ? -1 : Util::toInt64(Text::fromT(buf)));
search->sourceType = (ADLSearch::SourceType)::SendMessage(GetDlgItem(IDC_SOURCE_TYPE), CB_GETCURSEL, 0, 0L);
search->typeFileSize = (ADLSearch::SizeType)::SendMessage(GetDlgItem(IDC_SIZE_TYPE), CB_GETCURSEL, 0, 0L);
search->isActive = (::SendMessage(GetDlgItem(IDC_IS_ACTIVE), BM_GETCHECK, 0, 0L) != 0);
search->isAutoQueue = (::SendMessage(GetDlgItem(IDC_AUTOQUEUE), BM_GETCHECK, 0, 0L) != 0);
}
EndDialog(wID);
return 0;
}
/**
* @file
* $Id: ADLSProperties.cpp 109 2006-10-31 03:21:46Z crakter $
*/