You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
kev/Drawer/Module/GeoSigmaDraw/InterfaceCopyAsImage.cpp

166 lines
3.4 KiB
C++

1 month ago
#include "stdafx.h"
#include "SigmaView.h"
#include "SectionDoc.h"
#include "ItemCopyAsImage.h"
#include "HSimpleTracker.h"
static CItemCopyAsImage * getItemItemCopyAsImage(CSigmaView * pView)
{
CItem * pItem = pView->GetItem();
if (pItem == NULL)
return NULL;
CItemCopyAsImage * ciItem = dynamic_cast<CItemCopyAsImage *>(pItem);
return ciItem;
}
extern "C" __declspec(dllexport)
int CopyAsImage_SetRange(CSigmaView * pView, int left, int right, int top, int bottom, HDC hdc)
{
if (pView == NULL)
return -1;
CItemCopyAsImage * pItem = getItemItemCopyAsImage(pView);
if (pItem == NULL)
return -1;
CDC * pDC = CDC::FromHandle(hdc);
if (pDC == NULL)
return -1;
CRect rect;
rect.left = left;
rect.right = right;
rect.top = top;
rect.bottom = bottom;
if (pItem->SetRange(rect) == -1)
return -1;
CHSimpleTracker * tracker = pItem->GetTracker();
if (tracker)
{
tracker->Draw(pDC);
}
return 1;
}
extern "C" __declspec(dllexport)
void CopyAsImage_EraseTrackerForRange(CSigmaView * pView, HDC hdc)
{
if (pView == NULL)
return ;
CItemCopyAsImage * pItem = getItemItemCopyAsImage(pView);
if (pItem == NULL)
return ;
CDC * pDC = CDC::FromHandle(hdc);
if (pDC == NULL)
return ;
CHSimpleTracker * tracker = pItem->GetTracker();
if (tracker == NULL)
return;
tracker->Draw(pDC);
}
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7>ɹ<EFBFBD> <20>ɹ<EFBFBD><C9B9><EFBFBD><EFBFBD><EFBFBD>1 ʧ<>ܷ<EFBFBD><DCB7><EFBFBD>-1
extern "C" __declspec(dllexport)
int CopyAsImage_IsSuccess(CSigmaView * pView, HDC hdc)
{
if (pView == NULL)
return -1;
if (pView->m_pDoc == NULL)
return -1;
if (pView->m_pDoc->IsCapturedScreen())
return 1;
return -1;
}
//0--<2D><><EFBFBD>¼<EFBFBD>ͷ 1--<2D><>ֱ<EFBFBD><D6B1>ͷ 2--<2D><><EFBFBD>¼<EFBFBD>ͷ 3--ˮƽ<CBAE><C6BD>ͷ
//4--<2D><>ת<EFBFBD><D7AA>ͷ 5--ˮƽ<CBAE><C6BD><EFBFBD>м<EFBFBD>ͷ 6--<2D><>ֱ<EFBFBD><D6B1><EFBFBD>м<EFBFBD>ͷ 7--ƽ<>Ƽ<EFBFBD>ͷ
//-1 <20><><EFBFBD><EFBFBD>
extern "C" __declspec(dllexport)
int CopyAsImage_GetTrackerHandleCursorType(CSigmaView * pView, int mouseX, int mouseY)
{
if (pView == NULL)
return -1;
CItemCopyAsImage * pItem = getItemItemCopyAsImage(pView);
if (pItem == NULL)
return -1;
HTRACKER_HANDLE_KIND handleKind = pItem->GetTracker()->HitTest(mouseX, mouseY);
if (handleKind == HTRACKER_HANDLE_KIND_INVALID)
return -1;
if (handleKind == HTRACKER_HANDLE_KIND_CENTER)
return 7;
switch (handleKind)
{
case HTRACKER_HANDLE_KIND_TOP_LEFT:
case HTRACKER_HANDLE_KIND_BOTTOM_RIGHT:
return 0;
case HTRACKER_HANDLE_KIND_TOP_RIGHT:
case HTRACKER_HANDLE_KIND_BOTTOM_LEFT:
return 2;
case HTRACKER_HANDLE_KIND_TOP:
case HTRACKER_HANDLE_KIND_BOTTOM:
return 1;
case HTRACKER_HANDLE_KIND_RIGTH:
case HTRACKER_HANDLE_KIND_LEFT:
return 3;
}
return -1;
}
extern "C" __declspec(dllexport)
int CopyAsImage_CopyWindow(CSigmaView * pView, int left, int right, int top, int bottom)
{
if (pView == NULL)
return -1;
CRect rect;
rect.left = left;
rect.right = right;
rect.top = top;
rect.bottom = bottom;
CItemCopyAsImage * pItem = getItemItemCopyAsImage(pView);
if (pItem == NULL)
{
pItem = new CItemCopyAsImage(pView->m_pDoc);
pItem->CopyWindowToClipboard(rect);
delete pItem;
pItem = nullptr;
}
else {
pItem->CopyWindowToClipboard(rect);
}
return 1;
}
extern "C" __declspec(dllexport)
int CopyAsImage_CopyAll(CSigmaView * pView, int left, int right, int top, int bottom)
{
if (pView == NULL)
return -1;
CItemCopyAsImage * pItem = getItemItemCopyAsImage(pView);
if (pItem == NULL)
{
pItem = new CItemCopyAsImage(pView->m_pDoc);
pItem->CopyAllToClipboard();
delete pItem;
pItem = nullptr;
}
else
{
pItem->CopyAllToClipboard();
}
return 1;
}