示例#1
0
xpr_bool_t Thumbnail::getImageId(const xpr_tchar_t *aPath, xpr_uint_t &aThumbImageId)
{
    aThumbImageId = InvalidThumbImageId;

    if (XPR_IS_NULL(aPath))
        return XPR_FALSE;

    ThumbImgList::ThumbElement *sThumbElement = mThumbImgList->getImage(aPath);
    if (XPR_IS_NULL(sThumbElement))
        return XPR_FALSE;

    aThumbImageId = sThumbElement->mThumbImageId;

    xpr_bool_t sMatched = XPR_TRUE;

    FILETIME sModifiedFileTime = {0};
    if (GetFileLastWriteTime(aPath, &sModifiedFileTime) == XPR_FALSE)
        sMatched = XPR_FALSE;
    else
    {
        xpr_sint_t sCompare = mThumbImgList->compareTime(sThumbElement->mImageIndex, &sModifiedFileTime);
        if (sCompare == -1 || sCompare == 1)
            sMatched = XPR_FALSE;
    }

    if (sMatched == XPR_FALSE)
    {
        removeImageId(aThumbImageId);
        aThumbImageId = InvalidThumbImageId;
    }

    return XPR_TRUE;
}
示例#2
0
 // if 
 void FileWatchImpl::OnDirectoryChangeNotification()
 {
     FILETIME fileLastWriteTime =  GetFileLastWriteTime(m_filename.GetString());
     if (fileLastWriteTime.dwHighDateTime != m_fileLastWriteTime.dwHighDateTime ||
         fileLastWriteTime.dwLowDateTime  != m_fileLastWriteTime.dwLowDateTime)
     {
         InvokeCallback();
         m_fileLastWriteTime = fileLastWriteTime;
     }
 }
示例#3
0
void FileProperties::Load()
{
	if(!loaded)
	{
		loaded=true;
		smallIcon=GetFileIcon(fullPath, SHGFI_SMALLICON | SHGFI_ICON);
		bigIcon=GetFileIcon(fullPath, SHGFI_LARGEICON | SHGFI_ICON);
		displayName=GetFileDisplayName(fullPath);
		typeName=GetFileTypeName(fullPath);
		lastWriteTime=GetFileLastWriteTime(fullPath);
		size=GetFileSize(fullPath);
	}
	}
示例#4
0
文件: Main.cpp 项目: DaZhu/gac
	// Fill all information about a directory or a file.
	FOREACH(WString, file, files)
	{
		Ptr<list::ListViewItem> item=new list::ListViewItem;
		WString fullPath=path+L"\\"+file;

		// Get large icon.
		item->largeImage=GetFileIcon(fullPath, SHGFI_LARGEICON | SHGFI_ICON);
		// Get small icon.
		item->smallImage=GetFileIcon(fullPath, SHGFI_SMALLICON | SHGFI_ICON);
		// Get display name
		item->text=GetFileDisplayName(fullPath);
		// Get type name
		item->subItems.Add(GetFileTypeName(fullPath));
		// Get last write time
		item->subItems.Add(FileTimeToString(GetFileLastWriteTime(fullPath)));
		// Get file size
		item->subItems.Add(FileSizeToString(GetFileSize(fullPath)));

		listView->GetItems().Add(item);
	}
示例#5
0
 FileWatchImpl(const Luc::Common::HashedString& filename, FCNCallback callback) :
     m_filename(filename), m_callback(callback), m_activated(true)
 {
     m_fileLastWriteTime = GetFileLastWriteTime(filename.GetString());
 }
示例#6
0
 FileWatchImpl(const std::string& filename, FCNCallback callback) : 
     m_filename(filename), m_callback(callback), m_activated(true) 
 {
     m_fileLastWriteTime = GetFileLastWriteTime(filename);
 }
示例#7
0
xpr_sint_t Thumbnail::runThread(xpr::Thread &aThread)
{

    HWND sHwnd;
    xpr_uint_t sMsg;
    xpr_tchar_t sPath[XPR_MAX_PATH + 1];
    xpr_char_t sPathA[XPR_MAX_PATH + 1];
    xpr_size_t sInputBytes;
    xpr_size_t sOutputBytes;
    CSize sThumbSize;
    ThumbItem *sThumbItem = XPR_NULL;

    GFL_BITMAP *sGflBitmap = XPR_NULL;
    GFL_LOAD_PARAMS sGflLoadParams;
    xpr_uchar_t *sDibData = XPR_NULL;
    BITMAPINFOHEADER sBitmapInfoHeader;
    CBitmap *sBitmap, *sOldBitmap;
    ThumbImage *sThumbImage;

    CSize sPicSize;
    xpr_sint_t x, y, cx, cy;
    xpr_double_t sRatio;
    CRect sDestRect;

    DWORD sWait;

    while (true)
    {
        sWait = ::WaitForSingleObject(mEvent, INFINITE);

        if (mThread.isStop() == XPR_TRUE)
            break;

        if (sWait != WAIT_OBJECT_0)
            continue;

        {
            xpr::MutexGuard sLockGuard(mMutex);

            if (mThumbDeque.empty() == true)
            {
                ::ResetEvent(mEvent);
                continue;
            }

            sThumbItem = mThumbDeque.front();
            mThumbDeque.pop_front();

            if (XPR_IS_NULL(sThumbItem))
                continue;
        }

        sThumbImage = XPR_NULL;

        sHwnd = sThumbItem->mHwnd;
        sMsg = sThumbItem->mMsg;
        sThumbSize = sThumbItem->mThumbSize;

        _tcscpy(sPath, sThumbItem->mPath.c_str());
        sInputBytes = _tcslen(sPath) * sizeof(xpr_tchar_t);
        sOutputBytes = XPR_MAX_PATH * sizeof(xpr_tchar_t);
        XPR_TCS_TO_MBS(sPath, &sInputBytes, sPathA, &sOutputBytes);
        sPathA[sOutputBytes / sizeof(xpr_char_t)] = 0;

        XPR_TRACE(XPR_STRING_LITERAL("Thumbnail Thread, path=%s\n"), sPath);

        {
            gflGetDefaultPreviewParams(&sGflLoadParams); 
            sGflLoadParams.Flags      |= GFL_LOAD_SKIP_ALPHA | GFL_LOAD_PREVIEW_NO_CANVAS_RESIZE;
            sGflLoadParams.Origin      = GFL_BOTTOM_LEFT;
            sGflLoadParams.ColorModel  = GFL_BGR; 
            sGflLoadParams.LinePadding = 4;

            if (sThumbItem->mLoadByExt == XPR_TRUE)
                sGflLoadParams.Flags |= GFL_LOAD_BY_EXTENSION_ONLY;

            if (gflLoadPreview(sPathA, sThumbSize.cx, sThumbSize.cy, &sGflBitmap, &sGflLoadParams, XPR_NULL) == XPR_FALSE)
            {
                // image bilinear scale
                sPicSize.cx = sGflBitmap->Width;
                sPicSize.cy = sGflBitmap->Height;
                x = y = 0;
                cx = sThumbSize.cx;
                cy = sThumbSize.cy;
                sRatio = (xpr_double_t)sPicSize.cx / (xpr_double_t)sPicSize.cy;

                if (sPicSize.cx >= sThumbSize.cx || sPicSize.cy >= sThumbSize.cy)
                {
                    x = (sThumbSize.cx - sPicSize.cx) / 2;
                    y = (sThumbSize.cy - sPicSize.cy) / 2;
                    sDestRect = CRect(x, y, x+cx, y+cy);
                }
                else
                {
                    x = (sThumbSize.cx - sPicSize.cx) / 2;
                    y = (sThumbSize.cy - sPicSize.cy) / 2;
                    sDestRect = CRect(x, y, x+sPicSize.cx, y+sPicSize.cy);
                }

                CClientDC dc(CWnd::GetDesktopWindow());

                sBitmap = new CBitmap;
                sBitmap->CreateCompatibleBitmap(&dc, sThumbSize.cx, sThumbSize.cy);

                CDC sMemDC;
                sMemDC.CreateCompatibleDC(&dc);
                sOldBitmap = sMemDC.SelectObject(sBitmap);

                sDibData = XPR_NULL;
                GetDIBFromBitmap(sGflBitmap, &sBitmapInfoHeader, &sDibData);

                sMemDC.FillSolidRect(0, 0, sThumbSize.cx, sThumbSize.cy, RGB(255,255,255));
                ::StretchDIBits(
                    sMemDC.m_hDC,
                    x,
                    y,
                    sGflBitmap->Width,
                    sGflBitmap->Height,
                    0,
                    0,
                    sGflBitmap->Width,
                    sGflBitmap->Height,
                    (sDibData != XPR_NULL) ? sDibData : sGflBitmap->Data,
                    (BITMAPINFO *)&sBitmapInfoHeader,
                    DIB_RGB_COLORS,
                    SRCCOPY);

                sMemDC.SelectObject(sOldBitmap);

                sThumbImage = new ThumbImage;
                sThumbImage->mPath   = sThumbItem->mPath;
                sThumbImage->mImage  = sBitmap;
                sThumbImage->mWidth  = sGflBitmap->Width;
                sThumbImage->mHeight = sGflBitmap->Height;
                sThumbImage->mDepth  = sGflBitmap->BytesPerPixel * 8;
                GetFileLastWriteTime(sThumbItem->mPath.c_str(), &sThumbImage->mModifiedFileTime);

                if (XPR_IS_NOT_NULL(sDibData)) { free(sDibData); sDibData = XPR_NULL; }
                if (XPR_IS_NOT_NULL(sGflBitmap)) { gflFreeBitmap(sGflBitmap); sGflBitmap = XPR_NULL; }
            }
        }

        if (XPR_IS_NOT_NULL(sThumbImage))
        {
            if (::PostMessage(sHwnd, sMsg, (WPARAM)sThumbItem->mCode, (LPARAM)sThumbImage) == XPR_FALSE)
            {
                if (XPR_IS_NOT_NULL(sThumbImage) && XPR_IS_NOT_NULL(sThumbImage->mImage))
                {
                    sThumbImage->mImage->DeleteObject();
                    XPR_SAFE_DELETE(sThumbImage->mImage);
                }

                XPR_SAFE_DELETE(sThumbImage);
            }
        }

        XPR_SAFE_DELETE(sThumbItem);
    }

    return 0;
}