#145 Support remote drawing board
This commit is contained in:
Binary file not shown.
@@ -38,6 +38,7 @@
|
||||
#include "adapter.h"
|
||||
#include "client/MemoryModule.h"
|
||||
#include <file/CFileManagerDlg.h>
|
||||
#include "CDrawingBoard.h"
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define new DEBUG_NEW
|
||||
@@ -385,6 +386,7 @@ BEGIN_MESSAGE_MAP(CMy2015RemoteDlg, CDialogEx)
|
||||
ON_MESSAGE(WM_OPENCHATDIALOG, OnOpenChatDialog)
|
||||
ON_MESSAGE(WM_OPENDECRYPTDIALOG, OnOpenDecryptDialog)
|
||||
ON_MESSAGE(WM_OPENFILEMGRDIALOG, OnOpenFileMgrDialog)
|
||||
ON_MESSAGE(WM_OPENDRAWINGBOARD, OnOpenDrawingBoard)
|
||||
ON_MESSAGE(WM_UPXTASKRESULT, UPXProcResult)
|
||||
ON_WM_HELPINFO()
|
||||
ON_COMMAND(ID_ONLINE_SHARE, &CMy2015RemoteDlg::OnOnlineShare)
|
||||
@@ -1811,6 +1813,11 @@ VOID CMy2015RemoteDlg::MessageHandle(CONTEXT_OBJECT* ContextObject)
|
||||
ContextObject->Destroy();
|
||||
break;
|
||||
}
|
||||
case TOKEN_DRAWING_BOARD:
|
||||
{
|
||||
g_2015RemoteDlg->SendMessage(WM_OPENDRAWINGBOARD, 0, (LPARAM)ContextObject);
|
||||
break;
|
||||
}
|
||||
case TOKEN_DRIVE_LIST_PLUGIN: // 文件管理
|
||||
{
|
||||
g_2015RemoteDlg->SendMessage(WM_OPENFILEMGRDIALOG, 0, (LPARAM)ContextObject);
|
||||
@@ -2135,6 +2142,11 @@ LRESULT CMy2015RemoteDlg::OnOpenFileMgrDialog(WPARAM wParam, LPARAM lParam)
|
||||
return OpenDialog<file::CFileManagerDlg, IDD_FILE_WINOS>(wParam, lParam);
|
||||
}
|
||||
|
||||
LRESULT CMy2015RemoteDlg::OnOpenDrawingBoard(WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
return OpenDialog<CDrawingBoard, IDD_DRAWING_BOARD>(wParam, lParam);
|
||||
}
|
||||
|
||||
BOOL CMy2015RemoteDlg::OnHelpInfo(HELPINFO* pHelpInfo)
|
||||
{
|
||||
MessageBox("Copyleft (c) FTU 2025", "关于");
|
||||
|
||||
@@ -242,6 +242,7 @@ public:
|
||||
afx_msg LRESULT OnOpenChatDialog(WPARAM wParam, LPARAM lParam);
|
||||
afx_msg LRESULT OnOpenDecryptDialog(WPARAM wParam, LPARAM lParam);
|
||||
afx_msg LRESULT OnOpenFileMgrDialog(WPARAM wParam, LPARAM lParam);
|
||||
afx_msg LRESULT OnOpenDrawingBoard(WPARAM wParam, LPARAM lParam);
|
||||
afx_msg LRESULT UPXProcResult(WPARAM wParam, LPARAM lParam);
|
||||
afx_msg BOOL OnHelpInfo(HELPINFO* pHelpInfo);
|
||||
virtual BOOL PreTranslateMessage(MSG* pMsg);
|
||||
|
||||
@@ -260,6 +260,7 @@
|
||||
<ClInclude Include="AudioDlg.h" />
|
||||
<ClInclude Include="Buffer.h" />
|
||||
<ClInclude Include="BuildDlg.h" />
|
||||
<ClInclude Include="CDrawingBoard.h" />
|
||||
<ClInclude Include="Chat.h" />
|
||||
<ClInclude Include="CPasswordDlg.h" />
|
||||
<ClInclude Include="CTextDlg.h" />
|
||||
@@ -322,6 +323,7 @@
|
||||
<ClCompile Include="AudioDlg.cpp" />
|
||||
<ClCompile Include="Buffer.cpp" />
|
||||
<ClCompile Include="BuildDlg.cpp" />
|
||||
<ClCompile Include="CDrawingBoard.cpp" />
|
||||
<ClCompile Include="Chat.cpp" />
|
||||
<ClCompile Include="CPasswordDlg.cpp" />
|
||||
<ClCompile Include="CTextDlg.cpp" />
|
||||
@@ -380,6 +382,7 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Image Include="res\Bitmap\authorize.bmp" />
|
||||
<Image Include="res\Bitmap\DrawingBoard.bmp" />
|
||||
<Image Include="res\Bitmap\DxgiDesktop.bmp" />
|
||||
<Image Include="res\Bitmap\GrayDesktop.bmp" />
|
||||
<Image Include="res\Bitmap\note.bmp" />
|
||||
@@ -393,6 +396,7 @@
|
||||
<Image Include="res\chat.ico" />
|
||||
<Image Include="res\decrypt.ico" />
|
||||
<Image Include="res\delete.bmp" />
|
||||
<Image Include="res\DrawingBoard.ico" />
|
||||
<Image Include="res\file\FILE.ico" />
|
||||
<Image Include="res\file\Icon_A.ico" />
|
||||
<Image Include="res\file\Icon_C.ico" />
|
||||
|
||||
@@ -49,6 +49,7 @@
|
||||
<Filter>file</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="IOCPUDPServer.cpp" />
|
||||
<ClCompile Include="CDrawingBoard.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\..\client\Audio.h" />
|
||||
@@ -110,6 +111,7 @@
|
||||
</ClInclude>
|
||||
<ClInclude Include="IOCPUDPServer.h" />
|
||||
<ClInclude Include="Server.h" />
|
||||
<ClInclude Include="CDrawingBoard.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="2015Remote.rc" />
|
||||
@@ -148,6 +150,8 @@
|
||||
<Image Include="res\file\Icon_E.ico" />
|
||||
<Image Include="res\file\Icon_F.ico" />
|
||||
<Image Include="res\file\Icon_G.ico" />
|
||||
<Image Include="res\Bitmap\DrawingBoard.bmp" />
|
||||
<Image Include="res\DrawingBoard.ico" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="..\..\Release\ghost.exe" />
|
||||
|
||||
218
server/2015Remote/CDrawingBoard.cpp
Normal file
218
server/2015Remote/CDrawingBoard.cpp
Normal file
@@ -0,0 +1,218 @@
|
||||
#include "stdafx.h"
|
||||
#include "CDrawingBoard.h"
|
||||
#include "afxdialogex.h"
|
||||
#include "Resource.h"
|
||||
|
||||
IMPLEMENT_DYNAMIC(CDrawingBoard, CDialog)
|
||||
|
||||
CDrawingBoard::CDrawingBoard(CWnd* pParent, Server* IOCPServer, CONTEXT_OBJECT* ContextObject)
|
||||
: DialogBase(IDD_DRAWING_BOARD, pParent, IOCPServer, ContextObject, IDI_ICON_DRAWING),
|
||||
m_bDrawing(false)
|
||||
{
|
||||
m_bTopMost = true;
|
||||
m_bTransport = true;
|
||||
m_bMoving = false;
|
||||
m_bSizing = false;
|
||||
}
|
||||
|
||||
CDrawingBoard::~CDrawingBoard()
|
||||
{
|
||||
}
|
||||
|
||||
void CDrawingBoard::DoDataExchange(CDataExchange* pDX)
|
||||
{
|
||||
CDialog::DoDataExchange(pDX);
|
||||
}
|
||||
|
||||
BEGIN_MESSAGE_MAP(CDrawingBoard, CDialog)
|
||||
ON_WM_CLOSE()
|
||||
ON_WM_SIZE()
|
||||
ON_WM_PAINT()
|
||||
ON_WM_LBUTTONDOWN()
|
||||
ON_WM_MOUSEMOVE()
|
||||
ON_WM_LBUTTONUP()
|
||||
ON_WM_WINDOWPOSCHANGED()
|
||||
ON_COMMAND(ID_DRAWING_TOPMOST, &CDrawingBoard::OnDrawingTopmost)
|
||||
ON_COMMAND(ID_DRAWING_TRANSPORT, &CDrawingBoard::OnDrawingTransport)
|
||||
ON_COMMAND(ID_DRAWING_MOVE, &CDrawingBoard::OnDrawingMove)
|
||||
ON_COMMAND(ID_DRAWING_SIZE, &CDrawingBoard::OnDrawingSize)
|
||||
ON_COMMAND(ID_DRAWING_CLEAR, &CDrawingBoard::OnDrawingClear)
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
void CDrawingBoard::OnReceiveComplete()
|
||||
{
|
||||
// 接收时处理逻辑(暂空)
|
||||
}
|
||||
|
||||
void CDrawingBoard::OnClose()
|
||||
{
|
||||
CancelIO();
|
||||
if (IsProcessing()) {
|
||||
ShowWindow(SW_HIDE);
|
||||
return;
|
||||
}
|
||||
DialogBase::OnClose();
|
||||
}
|
||||
|
||||
void CDrawingBoard::OnPaint()
|
||||
{
|
||||
CPaintDC dc(this);
|
||||
|
||||
CPen pen(PS_SOLID, 2, RGB(0, 0, 0));
|
||||
CPen* pOldPen = dc.SelectObject(&pen);
|
||||
|
||||
for (const auto& path : m_paths)
|
||||
{
|
||||
if (path.size() < 2) continue;
|
||||
|
||||
dc.MoveTo(path[0]);
|
||||
for (size_t i = 1; i < path.size(); ++i)
|
||||
dc.LineTo(path[i]);
|
||||
}
|
||||
|
||||
if (m_bDrawing && m_currentPath.size() >= 2)
|
||||
{
|
||||
dc.MoveTo(m_currentPath[0]);
|
||||
for (size_t i = 1; i < m_currentPath.size(); ++i)
|
||||
dc.LineTo(m_currentPath[i]);
|
||||
}
|
||||
|
||||
dc.SelectObject(pOldPen);
|
||||
}
|
||||
|
||||
void CDrawingBoard::OnLButtonDown(UINT nFlags, CPoint point)
|
||||
{
|
||||
m_bDrawing = true;
|
||||
m_currentPath.clear();
|
||||
m_currentPath.push_back(point);
|
||||
|
||||
SetCapture();
|
||||
}
|
||||
|
||||
void CDrawingBoard::OnMouseMove(UINT nFlags, CPoint point)
|
||||
{
|
||||
if (m_bDrawing)
|
||||
{
|
||||
m_currentPath.push_back(point);
|
||||
Invalidate(FALSE);
|
||||
|
||||
// 发送当前点
|
||||
BYTE pkg[1 + sizeof(POINT)] = { CMD_DRAW_POINT };
|
||||
memcpy(pkg + 1, &point, sizeof(POINT));
|
||||
m_ContextObject->Send2Client((BYTE*)pkg, sizeof(pkg));
|
||||
}
|
||||
}
|
||||
|
||||
void CDrawingBoard::OnLButtonUp(UINT nFlags, CPoint point)
|
||||
{
|
||||
if (m_bDrawing)
|
||||
{
|
||||
m_bDrawing = false;
|
||||
m_currentPath.push_back(point);
|
||||
ReleaseCapture();
|
||||
|
||||
m_paths.push_back(m_currentPath);
|
||||
Invalidate();
|
||||
|
||||
// 发送结束命令,表示当前路径完成
|
||||
BYTE endCmd = CMD_DRAW_END;
|
||||
m_ContextObject->Send2Client(&endCmd, 1);
|
||||
}
|
||||
}
|
||||
|
||||
void CDrawingBoard::OnWindowPosChanged(WINDOWPOS* lpwndpos)
|
||||
{
|
||||
CDialog::OnWindowPosChanged(lpwndpos);
|
||||
if (!m_bMoving) return;
|
||||
|
||||
CRect rect;
|
||||
GetWindowRect(&rect); // 获取当前窗口屏幕位置
|
||||
BYTE pkg[1 + sizeof(CRect)] = { CMD_MOVEWINDOW };
|
||||
if (!m_bSizing) {
|
||||
rect.right = rect.left;
|
||||
rect.bottom = rect.top;
|
||||
}
|
||||
memcpy(pkg + 1, &rect, sizeof(CRect));
|
||||
m_ContextObject->Send2Client((BYTE*)pkg, sizeof(pkg));
|
||||
}
|
||||
|
||||
void CDrawingBoard::OnSize(UINT nType, int cx, int cy)
|
||||
{
|
||||
CDialog::OnSize(nType, cx, cy);
|
||||
if (!m_bSizing) return;
|
||||
|
||||
// 发送新的窗口尺寸到客户端
|
||||
int sizeData[2] = { cx, cy };
|
||||
BYTE pkg[sizeof(sizeData) + 1] = { CMD_SET_SIZE };
|
||||
memcpy(pkg + 1, &sizeData, sizeof(sizeData));
|
||||
m_ContextObject->Send2Client((PBYTE)pkg, sizeof(pkg));
|
||||
}
|
||||
|
||||
void CDrawingBoard::OnDrawingTopmost()
|
||||
{
|
||||
m_bTopMost = !m_bTopMost;
|
||||
BYTE cmd[2] = { CMD_TOPMOST, m_bTopMost };
|
||||
m_ContextObject->Send2Client((PBYTE)cmd, sizeof(cmd));
|
||||
HMENU hMenu = ::GetMenu(this->GetSafeHwnd());
|
||||
int n = m_bTopMost ? MF_CHECKED : MF_UNCHECKED;
|
||||
::CheckMenuItem(hMenu, ID_DRAWING_TOPMOST, MF_BYCOMMAND | n);
|
||||
}
|
||||
|
||||
|
||||
void CDrawingBoard::OnDrawingTransport()
|
||||
{
|
||||
m_bTransport = !m_bTransport;
|
||||
BYTE cmd[2] = { CMD_TRANSPORT, m_bTransport };
|
||||
m_ContextObject->Send2Client((PBYTE)cmd, sizeof(cmd));
|
||||
HMENU hMenu = ::GetMenu(this->GetSafeHwnd());
|
||||
int n = m_bTransport ? MF_CHECKED : MF_UNCHECKED;
|
||||
::CheckMenuItem(hMenu, ID_DRAWING_TRANSPORT, MF_BYCOMMAND | n);
|
||||
}
|
||||
|
||||
|
||||
void CDrawingBoard::OnDrawingMove()
|
||||
{
|
||||
m_bMoving = !m_bMoving;
|
||||
HMENU hMenu = ::GetMenu(this->GetSafeHwnd());
|
||||
int cmd = m_bMoving ? MF_CHECKED : MF_UNCHECKED;
|
||||
::CheckMenuItem(hMenu, ID_DRAWING_MOVE, MF_BYCOMMAND | cmd);
|
||||
}
|
||||
|
||||
|
||||
void CDrawingBoard::OnDrawingSize()
|
||||
{
|
||||
m_bSizing = !m_bSizing;
|
||||
HMENU hMenu = ::GetMenu(this->GetSafeHwnd());
|
||||
int cmd = m_bSizing ? MF_CHECKED : MF_UNCHECKED;
|
||||
::CheckMenuItem(hMenu, ID_DRAWING_SIZE, MF_BYCOMMAND | cmd);
|
||||
}
|
||||
|
||||
|
||||
BOOL CDrawingBoard::OnInitDialog()
|
||||
{
|
||||
DialogBase::OnInitDialog();
|
||||
|
||||
SetIcon(m_hIcon, TRUE);
|
||||
SetIcon(m_hIcon, FALSE);
|
||||
|
||||
CString str;
|
||||
str.Format("%s - 画板演示", m_IPAddress);
|
||||
SetWindowText(str);
|
||||
|
||||
HMENU hMenu = ::GetMenu(this->GetSafeHwnd());
|
||||
::CheckMenuItem(hMenu, ID_DRAWING_TOPMOST, MF_BYCOMMAND | MF_CHECKED);
|
||||
::CheckMenuItem(hMenu, ID_DRAWING_TRANSPORT, MF_BYCOMMAND | MF_CHECKED);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
void CDrawingBoard::OnDrawingClear()
|
||||
{
|
||||
m_paths.clear();
|
||||
m_currentPath.clear();
|
||||
BYTE cmd[2] = { CMD_DRAW_CLEAR, 0 };
|
||||
m_ContextObject->Send2Client((PBYTE)cmd, sizeof(cmd));
|
||||
if (m_hWnd && IsWindow(m_hWnd))
|
||||
::InvalidateRect(m_hWnd, NULL, TRUE); // 重绘整个窗口,清除痕迹
|
||||
}
|
||||
50
server/2015Remote/CDrawingBoard.h
Normal file
50
server/2015Remote/CDrawingBoard.h
Normal file
@@ -0,0 +1,50 @@
|
||||
#pragma once
|
||||
#include "IOCPServer.h"
|
||||
#include "afxwin.h"
|
||||
|
||||
// CDrawingBoard 对话框
|
||||
|
||||
class CDrawingBoard : public DialogBase
|
||||
{
|
||||
DECLARE_DYNAMIC(CDrawingBoard)
|
||||
|
||||
public:
|
||||
CDrawingBoard(CWnd* pParent = nullptr, Server* IOCPServer = NULL, CONTEXT_OBJECT* ContextObject = NULL);
|
||||
virtual ~CDrawingBoard();
|
||||
|
||||
#ifdef AFX_DESIGN_TIME
|
||||
enum { IDD = IDD_DRAWING_BOARD };
|
||||
#endif
|
||||
|
||||
VOID OnReceiveComplete();
|
||||
|
||||
afx_msg void OnPaint();
|
||||
afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
|
||||
afx_msg void OnMouseMove(UINT nFlags, CPoint point);
|
||||
afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
|
||||
afx_msg void OnWindowPosChanged(WINDOWPOS* lpwndpos);
|
||||
afx_msg void OnSize(UINT nType, int cx, int cy);
|
||||
|
||||
protected:
|
||||
virtual void DoDataExchange(CDataExchange* pDX);
|
||||
|
||||
void OnClose();
|
||||
|
||||
DECLARE_MESSAGE_MAP()
|
||||
|
||||
private:
|
||||
bool m_bTopMost; // 置顶
|
||||
bool m_bTransport; // 半透明
|
||||
bool m_bMoving; // 位置跟随
|
||||
bool m_bSizing; // 大小跟随
|
||||
bool m_bDrawing; // 是否正在绘图
|
||||
std::vector<CPoint> m_currentPath; // 当前路径点
|
||||
std::vector<std::vector<CPoint>> m_paths; // 所有路径
|
||||
public:
|
||||
afx_msg void OnDrawingTopmost();
|
||||
afx_msg void OnDrawingTransport();
|
||||
afx_msg void OnDrawingMove();
|
||||
afx_msg void OnDrawingSize();
|
||||
virtual BOOL OnInitDialog();
|
||||
afx_msg void OnDrawingClear();
|
||||
};
|
||||
@@ -566,10 +566,12 @@ BOOL IOCPServer::OnClientReceiving(PCONTEXT_OBJECT ContextObject, DWORD dwTrans
|
||||
BOOL WriteContextData(CONTEXT_OBJECT* ContextObject, PBYTE szBuffer, size_t ulOriginalLength) {
|
||||
assert(ContextObject);
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>͵<EFBFBD><CDB5><EFBFBD><EFBFBD><EFBFBD>
|
||||
if (ulOriginalLength < 100 && szBuffer[0] != COMMAND_SCREEN_CONTROL && szBuffer[0] != CMD_HEARTBEAT_ACK) {
|
||||
unsigned cmd = szBuffer[0];
|
||||
if (ulOriginalLength < 100 && cmd != COMMAND_SCREEN_CONTROL && cmd != CMD_HEARTBEAT_ACK &&
|
||||
cmd != CMD_DRAW_POINT && cmd != CMD_MOVEWINDOW && cmd != CMD_SET_SIZE) {
|
||||
char buf[100] = { 0 };
|
||||
if (ulOriginalLength == 1){
|
||||
sprintf_s(buf, "command %d", int(szBuffer[0]));
|
||||
sprintf_s(buf, "command %d", cmd);
|
||||
}
|
||||
else {
|
||||
memcpy(buf, szBuffer, ulOriginalLength);
|
||||
|
||||
BIN
server/2015Remote/res/DrawingBoard.ico
Normal file
BIN
server/2015Remote/res/DrawingBoard.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 894 B |
Binary file not shown.
@@ -80,6 +80,7 @@
|
||||
#define WM_OPENCHATDIALOG WM_USER+3017
|
||||
#define WM_OPENDECRYPTDIALOG WM_USER+3018
|
||||
#define WM_OPENFILEMGRDIALOG WM_USER+3019
|
||||
#define WM_OPENDRAWINGBOARD WM_USER+3020
|
||||
|
||||
#ifdef _UNICODE
|
||||
#if defined _M_IX86
|
||||
|
||||
Reference in New Issue
Block a user