#include "stdafx.h" #include "SigmaView.h" #include "SectionDoc.h" #include "ItemCurveEdit.h" extern "C" __declspec(dllexport) void ViewMouseDown(CSigmaView* pView, int mouseX, int mouseY) { CPoint pt; pt.x = mouseX; pt.y = mouseY; pView->ViewMouseDown(0, pt); } extern "C" __declspec(dllexport) void ViewMouseMove(CSigmaView* pView, HDC hdcMem, int mouseX, int mouseY) { //CDC *pDC = new CDC; //CDC *pDC = CDC::FromHandle(hdcMem); //pDC->Attach(hdcMem); //pView->SetDc(pDC); //CDC *pDC = CDC::FromHandle(hdcMem); //pView->SetDrawDC(pDC); CPoint pt; pt.x = mouseX; pt.y = mouseY; pView->ViewMouseMove(0, pt); //CDC::FromHandle(hdcMem)->DeleteDC(); } //extern "C" __declspec(dllexport) //void CanvasMouseMove(CSigmaView* pView, HDC hdc, int mouseX, int mouseY) //{ // if (pView == NULL) // return; // // CDC *pDC = CDC::FromHandle(hdc); // //pView->SetScreenDC(pDC); // // CPoint pt; // pt.x = mouseX; // pt.y = mouseY; // // //pView->DrawCrossLine(pDC, pt); // pView->UpdateCrossLine(pDC, pt); //} // //extern "C" __declspec(dllexport) //void CanvasDrawCrossLine(CSigmaView* pView, HDC hdc, int mouseX, int mouseY) //{ // if (pView == NULL) // return; // // CDC *pDC = CDC::FromHandle(hdc); // //pView->SetScreenDC(pDC); // // CPoint pt; // pt.x = mouseX; // pt.y = mouseY; // // pView->DrawCrossLine(pDC, pt); //} extern "C" __declspec(dllexport) void TestMouseMove(CSigmaView* pView, HDC hdcMem, int mouseX, int mouseY) { for (int i = 0; i < 1000; i++) { POINT ptOld; ::MoveToEx(hdcMem, mouseX + i, mouseY, &ptOld); ::LineTo(hdcMem, mouseX + i + 200, mouseY + 200); } /* if (pView == NULL) return; CPoint pt; pt.x = mouseX; pt.y = mouseY; CItem * pItem = pView->GetItem(); if (pItem) { pItem->SetHDC(hdcMem); pItem->OnMouseMove(0, pt, NULL); } */ } extern "C" __declspec(dllexport) void ViewMouseUp(CSigmaView* pView, int mouseX, int mouseY) { CPoint pt; pt.x = mouseX; pt.y = mouseY; pView->ViewMouseUp(0, pt); } extern "C" __declspec(dllexport) void OnLButtonDown(CSigmaView* pView, int mouseX, int mouseY, HDC hdc, int vk) { if (pView == NULL) return; CItem * pItem = pView->GetItem(); if (pItem == NULL) return; pItem->m_client = pView->m_client; CPoint pt; pt.x = mouseX; pt.y = mouseY; if (pView->HasEnableBKGrid()) pt = pView->GetGridPoint(pt); if (hdc != nullptr) { CDC *pDC = CDC::FromHandle(hdc); pItem->SetScreenDC(pDC); pItem->SetBackGroundDC(pView->m_pImgDC); pItem->OnLButtonDown(pDC, 0, pt, vk); } else { pItem->OnLButtonDown(nullptr, 0, pt, vk); } } //返回值:-1 出错 0 正在执行命名 1 未选中元素 2 选中了曲线 extern "C" __declspec(dllexport) int OnLButtonDoubleClick(CSigmaView* pView, int mouseX, int mouseY) //, HDC hdc) { if (pView == 0) return -1; if (pView->m_pDoc == 0) return -1; CPoint point(mouseX, mouseY); if (pView->HasEnableBKGrid()) point = pView->GetGridPoint(point); CSigmaDoc* pDoc = pView->m_pDoc; if (pDoc->GetItem()) { pDoc->GetItem()->OnLButtonDblClk(0, point); return 0; } else { CPoint2D pt = pDoc->GetDC().GetReal(point); POSITION p = pDoc->GetSelectedItem(pt); if (!p) return 1; int type = pDoc->GetDraw()->GetElementType(p); if (type == DOUBLEFOX_CURVE) { pDoc->ClearSelectionSet(); pDoc->AddToSelectionSet(p); return 2; } return -1; } return -1; } extern "C" __declspec(dllexport) void OnLButtonUp(CSigmaView* pView, int mouseX, int mouseY, HDC hdc, int vk) { if (pView == NULL) return; CItem * pItem = pView->GetItem(); if (pItem == NULL) return; CPoint pt; pt.x = mouseX; pt.y = mouseY; if (pView->HasEnableBKGrid()) pt = pView->GetGridPoint(pt); if (hdc != NULL) { CDC *pDC = CDC::FromHandle(hdc); //pView->SetScreenDC(pDC); pItem->SetScreenDC(pDC); pItem->SetBackGroundDC(pView->m_pImgDC); pItem->OnLButtonUp(pDC, 0, pt, vk); } else { pItem->OnLButtonUp(nullptr, 0, pt, vk); } } extern "C" __declspec(dllexport) void OnRButtonDown(CSigmaView* pView, int mouseX, int mouseY, HDC hdc, int vk) { if (pView == NULL) return; CItem * pItem = pView->GetItem(); if (pItem == NULL) return; pItem->m_client = pView->m_client; CPoint pt; pt.x = mouseX; pt.y = mouseY; if (pView->HasEnableBKGrid()) pt = pView->GetGridPoint(pt); if (hdc != nullptr) { CDC *pDC = CDC::FromHandle(hdc); pItem->SetScreenDC(pDC); pItem->SetBackGroundDC(pView->m_pImgDC); pItem->OnRButtonDown(0, pt); } else { pItem->OnRButtonDown(0, pt); } } extern "C" __declspec(dllexport) void OnRButtonUp(CSigmaView* pView, int mouseX, int mouseY, HDC hdc, int vk) { if (pView == NULL) return; pView->SetLastRightButtonPoint({ mouseX, mouseY }); CItem * pItem = pView->GetItem(); if (pItem == NULL) return; CPoint pt; pt.x = mouseX; pt.y = mouseY; if (pView->HasEnableBKGrid()) pt = pView->GetGridPoint(pt); if (hdc != NULL) { CDC *pDC = CDC::FromHandle(hdc); pItem->SetScreenDC(pDC); pItem->SetBackGroundDC(pView->m_pImgDC); pItem->OnRButtonUp(0, pt); } else { pItem->OnRButtonUp(0, pt); } } extern "C" __declspec(dllexport) void OnMouseWheel(CSigmaView* pView, uint32_t button, int32_t clicks, int32_t x, int32_t y, int32_t delta) { if (pView == NULL) return; CItem * pItem = pView->GetItem(); if (pItem == NULL) return; pItem->OnMouseWheel(button, clicks, x, y, delta); } extern "C" __declspec(dllexport) bool OnKeyDown(CSigmaView* pView, int keyValue, HDC hdc) //C#传入的keyValue 刚好等与VK_XXX 无需转换了 { if (pView == NULL) return false; CItem * pItem = pView->GetItem(); if (pItem == NULL) return false; CDC *pDC = CDC::FromHandle(hdc); pView->SetScreenDC(pDC); pItem->SetScreenDC(pDC); pItem->SetBackGroundDC(pView->m_pImgDC); return pItem->OnKeyDown(keyValue, 0, 0); } extern "C" __declspec(dllexport) int OnKeyUp(CSigmaView* pView, int keyValue, HDC hdc) //C#传入的keyValue 刚好等与VK_XXX 无需转换了 { if (pView == NULL) return -1; CItem * pItem = pView->GetItem(); if (pItem == NULL) return -1; CDC *pDC = CDC::FromHandle(hdc); pView->SetScreenDC(pDC); pItem->SetScreenDC(pDC); pItem->SetBackGroundDC(pView->m_pImgDC); BOOL b = pItem->OnKeyUp(keyValue, 0, 0); if (b == TRUE) return 1; return 0; } //buttonStatus的第一位是鼠标左键的状态 第二位是中键的状态 第三位右键状态 extern "C" __declspec(dllexport) int ItemMouseMove(CSigmaView* pView, HDC hMemDC, int mouseX, int mouseY, int buttonStatus) { if (pView == NULL) return 0; CDC *pDC = CDC::FromHandle(hMemDC); pView->SetScreenDC(pDC); CPoint pt; pt.x = mouseX; pt.y = mouseY; if (pView->HasEnableBKGrid()) pt = pView->GetGridPoint(pt); //pView->DrawCrossLine(pDC, pt); CItem * pItem = pView->GetItem(); if (pItem) { pItem->SetScreenDC(pDC); return pItem->OnMouseMove(pDC, buttonStatus, pt); } //CDC::FromHandle(hMemDC)->DeleteDC(); return 1; } extern "C" __declspec(dllexport) void ItemMouseMoveStatus(CSigmaView* pView, HDC hMemDC, int mouseX, int mouseY, int buttonStatus, BYTE*& destBuffer, int& destLen) { if (pView == NULL) return; CDC *pDC = CDC::FromHandle(hMemDC); pView->SetScreenDC(pDC); CPoint pt; pt.x = mouseX; pt.y = mouseY; if (pView->HasEnableBKGrid()) pt = pView->GetGridPoint(pt); //pView->DrawCrossLine(pDC, pt); CItem * pItem = pView->GetItem(); if (pItem) { pItem->SetScreenDC(pDC); pItem->OnMouseMoveStatus(pDC, buttonStatus, pt, destBuffer, destLen); } //CDC::FromHandle(hMemDC)->DeleteDC(); }