|
|
#include "StdAfx.h"
|
|
|
#include "SigmaDoc.h"
|
|
|
#include "ItemCopyAsImage.h"
|
|
|
#include "HSimpleTracker.h"
|
|
|
#include "ItemExportFile.H"
|
|
|
#include "DCHelp.h"
|
|
|
namespace NItem
|
|
|
{
|
|
|
CItemCopyAsImage::CItemCopyAsImage(CSigmaDoc* ppDoc)
|
|
|
:CItem(ppDoc)
|
|
|
{
|
|
|
m_pTracker = new CHSimpleTracker();
|
|
|
this->SetType(ITEM_COPY_AS_IMAGE);
|
|
|
}
|
|
|
|
|
|
CItemCopyAsImage::~CItemCopyAsImage()
|
|
|
{
|
|
|
m_pTracker->Reset();
|
|
|
delete m_pTracker;
|
|
|
m_pTracker = NULL;
|
|
|
}
|
|
|
|
|
|
int CItemCopyAsImage::SetRange(CRect rect)
|
|
|
{
|
|
|
GetDoc()->SetCapturedScreenStatus(false);
|
|
|
if (rect.IsRectEmpty())
|
|
|
{
|
|
|
m_range.SetRectEmpty();
|
|
|
m_pTracker->Reset();
|
|
|
return -1;
|
|
|
}
|
|
|
|
|
|
m_range = rect;
|
|
|
m_pTracker->Create(m_pDoc, m_range);
|
|
|
CopySelectedToClipboard();
|
|
|
GetDoc()->SetCapturedScreenStatus(true);
|
|
|
return 1;
|
|
|
}
|
|
|
|
|
|
CHSimpleTracker * CItemCopyAsImage::GetTracker()
|
|
|
{
|
|
|
return m_pTracker;
|
|
|
}
|
|
|
|
|
|
void CItemCopyAsImage::OnLButtonDown(CDC *pDC, UINT nFlags, CPoint point, int vk)
|
|
|
{
|
|
|
if (m_range.IsRectEmpty())
|
|
|
return;
|
|
|
|
|
|
m_pTracker->LButtonDown(point.x, point.y);
|
|
|
}
|
|
|
|
|
|
void CItemCopyAsImage::OnLButtonUp(CDC *pDC, UINT nFlags, CPoint point, int vk)
|
|
|
{
|
|
|
if (m_range.IsRectEmpty())
|
|
|
return;
|
|
|
|
|
|
m_pTracker->LButtonUp(point.x, point.y, pDC);
|
|
|
|
|
|
if (m_range.IsRectEmpty() == false)
|
|
|
CopySelectedToClipboard();
|
|
|
}
|
|
|
|
|
|
int CItemCopyAsImage::OnMouseMove(CDC *pDC, UINT nFlags, CPoint point)
|
|
|
{
|
|
|
if (m_range.IsRectEmpty())
|
|
|
return 1;
|
|
|
CDC * pScreenDC = pDC;
|
|
|
DCHelp::ClearDC(pScreenDC, m_BackColor);
|
|
|
pScreenDC->BitBlt(0, 0, m_client.Width(), m_client.Height(), m_pBackGroundDC, 0, 0, SRCCOPY);
|
|
|
m_pTracker->MouseMove(pDC, point.x, point.y);
|
|
|
return 1;
|
|
|
}
|
|
|
|
|
|
void CItemCopyAsImage::OnDraw(CXyDC* pDC)
|
|
|
{
|
|
|
if (m_range.IsRectEmpty())
|
|
|
return;
|
|
|
|
|
|
m_pTracker->Draw(pDC->GetDC());
|
|
|
CopySelectedToClipboard();
|
|
|
GetDoc()->SetCapturedScreenStatus(true);
|
|
|
}
|
|
|
|
|
|
void CItemCopyAsImage::DrawAssistant(CDC * pDC, int mouseX, int mouseY)
|
|
|
{
|
|
|
m_pTracker->Draw(pDC);
|
|
|
}
|
|
|
|
|
|
bool CItemCopyAsImage::CopySelectedToClipboard()
|
|
|
{
|
|
|
CRect rect = m_pTracker->GetBoundRect();
|
|
|
if (rect.IsRectEmpty())
|
|
|
return false;
|
|
|
|
|
|
CRect8 realRect = GetDC()->GetReal(rect);
|
|
|
CopyToClipboard(realRect);
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
void CItemCopyAsImage::CopyToClipboard(CRect8 & rect)
|
|
|
{
|
|
|
CRect rt = GetDC()->GetScreen(rect);
|
|
|
if (rt.IsRectEmpty()) return;
|
|
|
|
|
|
double dx = rect.left - GetDC()->left;
|
|
|
double dy = rect.top - GetDC()->top;
|
|
|
GetDC()->OffsetRect(dx, dy);
|
|
|
|
|
|
CItemExportFile ef(GetDoc());
|
|
|
CMemoryDC* pmdc = ef.ExportImage(rt.Size(), 24);
|
|
|
if (pmdc)
|
|
|
{
|
|
|
pmdc->CopyToClipboard();
|
|
|
delete pmdc;
|
|
|
}
|
|
|
|
|
|
GetDC()->OffsetRect(-dx, -dy);
|
|
|
}
|
|
|
|
|
|
//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͼ<EFBFBD><CDBC><EFBFBD><EFBFBD>
|
|
|
void NItem::CItemCopyAsImage::CopyWindowToClipboard(CRect windowRect)
|
|
|
{
|
|
|
CRect8 rect = GetDC()->GetReal(windowRect);
|
|
|
CopyToClipboard(rect);
|
|
|
}
|
|
|
|
|
|
//<2F><>ȡȫͼ.<2E>൱<EFBFBD><E0B5B1><EFBFBD><EFBFBD>ȫͼ<C8AB><CDBC><EFBFBD><EFBFBD>.<2E>ڽ<EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͼ<EFBFBD><CDBC><EFBFBD><EFBFBD>
|
|
|
void NItem::CItemCopyAsImage::CopyAllToClipboard(void)
|
|
|
{
|
|
|
//<2F><><EFBFBD>õ<EFBFBD><C3B5><EFBFBD>ͼ<EFBFBD><CDBC><EFBFBD>Ĵ<EFBFBD>С
|
|
|
CRect8 rect(1e100, -1e100, -1e100, 1e100);
|
|
|
GetDoc()->GetDrawRange(rect);
|
|
|
|
|
|
double dx = rect.Width();
|
|
|
double dy = rect.Height();
|
|
|
CSize sz(GetDC()->GetScreenWidth(dx), abs(GetDC()->GetScreenHeight(dy)));
|
|
|
if (dx < -1e20 || dy < -1e20)
|
|
|
{
|
|
|
AfxMessageBox("Map Range Error");
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
CopyToClipboard(rect);
|
|
|
}
|
|
|
} //end namespace
|