Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
若汝棋茗
RRQMSocket
提交
6e1f0b23
RRQMSocket
项目概览
若汝棋茗
/
RRQMSocket
11 个月 前同步成功
通知
20
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
RRQMSocket
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
6e1f0b23
编写于
7月 28, 2022
作者:
R
renzaijianghu4
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
新增UDP屏幕获取demo
上级
a65dcd64
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
480 addition
and
0 deletion
+480
-0
examples/Udp简单示例/ScreenUdpReceiver/Form1.Designer.cs
examples/Udp简单示例/ScreenUdpReceiver/Form1.Designer.cs
+63
-0
examples/Udp简单示例/ScreenUdpReceiver/Form1.cs
examples/Udp简单示例/ScreenUdpReceiver/Form1.cs
+40
-0
examples/Udp简单示例/ScreenUdpReceiver/Form1.resx
examples/Udp简单示例/ScreenUdpReceiver/Form1.resx
+61
-0
examples/Udp简单示例/ScreenUdpReceiver/Program.cs
examples/Udp简单示例/ScreenUdpReceiver/Program.cs
+23
-0
examples/Udp简单示例/ScreenUdpReceiver/ScreenUdpReceiver.csproj
examples/Udp简单示例/ScreenUdpReceiver/ScreenUdpReceiver.csproj
+14
-0
examples/Udp简单示例/ScreenUdpSender/Form1.Designer.cs
examples/Udp简单示例/ScreenUdpSender/Form1.Designer.cs
+55
-0
examples/Udp简单示例/ScreenUdpSender/Form1.cs
examples/Udp简单示例/ScreenUdpSender/Form1.cs
+123
-0
examples/Udp简单示例/ScreenUdpSender/Form1.resx
examples/Udp简单示例/ScreenUdpSender/Form1.resx
+64
-0
examples/Udp简单示例/ScreenUdpSender/Program.cs
examples/Udp简单示例/ScreenUdpSender/Program.cs
+23
-0
examples/Udp简单示例/ScreenUdpSender/ScreenUdpSender.csproj
examples/Udp简单示例/ScreenUdpSender/ScreenUdpSender.csproj
+14
-0
未找到文件。
examples/Udp简单示例/ScreenUdpReceiver/Form1.Designer.cs
0 → 100644
浏览文件 @
6e1f0b23
namespace
ScreenUdpReceiver
{
partial
class
Form1
{
/// <summary>
/// Required designer variable.
/// </summary>
private
System
.
ComponentModel
.
IContainer
components
=
null
;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected
override
void
Dispose
(
bool
disposing
)
{
if
(
disposing
&&
(
components
!=
null
))
{
components
.
Dispose
();
}
base
.
Dispose
(
disposing
);
}
#
region
Windows
Form
Designer
generated
code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private
void
InitializeComponent
()
{
this
.
pictureBox1
=
new
System
.
Windows
.
Forms
.
PictureBox
();
((
System
.
ComponentModel
.
ISupportInitialize
)(
this
.
pictureBox1
)).
BeginInit
();
this
.
SuspendLayout
();
//
// pictureBox1
//
this
.
pictureBox1
.
Dock
=
System
.
Windows
.
Forms
.
DockStyle
.
Fill
;
this
.
pictureBox1
.
Location
=
new
System
.
Drawing
.
Point
(
0
,
0
);
this
.
pictureBox1
.
Name
=
"pictureBox1"
;
this
.
pictureBox1
.
Size
=
new
System
.
Drawing
.
Size
(
800
,
450
);
this
.
pictureBox1
.
SizeMode
=
System
.
Windows
.
Forms
.
PictureBoxSizeMode
.
StretchImage
;
this
.
pictureBox1
.
TabIndex
=
0
;
this
.
pictureBox1
.
TabStop
=
false
;
//
// Form1
//
this
.
AutoScaleDimensions
=
new
System
.
Drawing
.
SizeF
(
7F
,
17F
);
this
.
AutoScaleMode
=
System
.
Windows
.
Forms
.
AutoScaleMode
.
Font
;
this
.
ClientSize
=
new
System
.
Drawing
.
Size
(
800
,
450
);
this
.
Controls
.
Add
(
this
.
pictureBox1
);
this
.
Name
=
"Form1"
;
this
.
Text
=
"ScreenReceiver 感谢若汝棋茗大佬的无私奉献 -xfdl 监听地址127.0.0.1:7790"
;
this
.
Load
+=
new
System
.
EventHandler
(
this
.
Form1_Load
);
((
System
.
ComponentModel
.
ISupportInitialize
)(
this
.
pictureBox1
)).
EndInit
();
this
.
ResumeLayout
(
false
);
}
#
endregion
private
System
.
Windows
.
Forms
.
PictureBox
pictureBox1
;
}
}
examples/Udp简单示例/ScreenUdpReceiver/Form1.cs
0 → 100644
浏览文件 @
6e1f0b23
using
System
;
using
System.Drawing
;
using
System.Windows.Forms
;
using
TouchSocket.Core.Config
;
using
TouchSocket.Sockets
;
namespace
ScreenUdpReceiver
{
public
partial
class
Form1
:
Form
{
UdpSession
udpSession
;
public
Form1
()
{
InitializeComponent
();
}
private
void
Form1_Load
(
object
sender
,
EventArgs
e
)
{
try
{
udpSession
=
new
UdpSession
();
udpSession
.
Received
+=
(
endpoint
,
byteBlock
,
requestInfo
)
=>
{
pictureBox1
.
Image
=
Image
.
FromStream
(
byteBlock
);
};
udpSession
.
Setup
(
new
TouchSocketConfig
()
.
SetBindIPHost
(
new
IPHost
(
"127.0.0.1:7790"
))
.
SetBufferLength
(
1024
*
1024
)
.
SetUdpDataHandlingAdapter
(()
=>
{
return
new
UdpPackageAdapter
()
{
MaxPackageSize
=
1024
*
1024
};
})
).
Start
();
}
catch
(
Exception
ex
)
{
MessageBox
.
Show
(
$"错误:
{
ex
.
Message
}
,程序将退出"
);
Environment
.
Exit
(
0
);
}
}
}
}
examples/Udp简单示例/ScreenUdpReceiver/Form1.resx
0 → 100644
浏览文件 @
6e1f0b23
<root>
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>
\ No newline at end of file
examples/Udp简单示例/ScreenUdpReceiver/Program.cs
0 → 100644
浏览文件 @
6e1f0b23
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Threading.Tasks
;
using
System.Windows.Forms
;
namespace
ScreenUdpReceiver
{
internal
static
class
Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[
STAThread
]
static
void
Main
()
{
Application
.
SetHighDpiMode
(
HighDpiMode
.
SystemAware
);
Application
.
EnableVisualStyles
();
Application
.
SetCompatibleTextRenderingDefault
(
false
);
Application
.
Run
(
new
Form1
());
}
}
}
examples/Udp简单示例/ScreenUdpReceiver/ScreenUdpReceiver.csproj
0 → 100644
浏览文件 @
6e1f0b23
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<UseWindowsForms>true</UseWindowsForms>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="TouchSocket" Version="0.2.3" />
</ItemGroup>
</Project>
\ No newline at end of file
examples/Udp简单示例/ScreenUdpSender/Form1.Designer.cs
0 → 100644
浏览文件 @
6e1f0b23
namespace
ScreenUdpSender
{
partial
class
Form1
{
/// <summary>
/// Required designer variable.
/// </summary>
private
System
.
ComponentModel
.
IContainer
components
=
null
;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected
override
void
Dispose
(
bool
disposing
)
{
if
(
disposing
&&
(
components
!=
null
))
{
components
.
Dispose
();
}
base
.
Dispose
(
disposing
);
}
#
region
Windows
Form
Designer
generated
code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private
void
InitializeComponent
()
{
this
.
components
=
new
System
.
ComponentModel
.
Container
();
this
.
timer1
=
new
System
.
Windows
.
Forms
.
Timer
(
this
.
components
);
this
.
SuspendLayout
();
//
// timer1
//
this
.
timer1
.
Tick
+=
new
System
.
EventHandler
(
this
.
timer1_Tick
);
//
// Form1
//
this
.
AutoScaleDimensions
=
new
System
.
Drawing
.
SizeF
(
7F
,
17F
);
this
.
AutoScaleMode
=
System
.
Windows
.
Forms
.
AutoScaleMode
.
Font
;
this
.
ClientSize
=
new
System
.
Drawing
.
Size
(
800
,
450
);
this
.
Name
=
"Form1"
;
this
.
Text
=
"Sender 感谢若汝棋茗大佬的无私奉献 -xfdl 监听地址127.0.0.1:7789,发送地址127.0.0.1:7790"
;
this
.
Load
+=
new
System
.
EventHandler
(
this
.
Form1_Load
);
this
.
ResumeLayout
(
false
);
}
#
endregion
private
System
.
Windows
.
Forms
.
Timer
timer1
;
}
}
examples/Udp简单示例/ScreenUdpSender/Form1.cs
0 → 100644
浏览文件 @
6e1f0b23
using
System
;
using
System.Drawing
;
using
System.IO
;
using
System.Net
;
using
System.Runtime.InteropServices
;
using
System.Windows.Forms
;
using
TouchSocket.Core.ByteManager
;
using
TouchSocket.Core.Config
;
using
TouchSocket.Sockets
;
namespace
ScreenUdpSender
{
public
partial
class
Form1
:
Form
{
UdpSession
udpSession
;
public
Form1
()
{
InitializeComponent
();
}
private
void
Form1_Load
(
object
sender
,
EventArgs
e
)
{
timer1
.
Enabled
=
true
;
try
{
udpSession
=
new
UdpSession
();
udpSession
.
Setup
(
new
TouchSocketConfig
()
.
SetBindIPHost
(
new
IPHost
(
7789
))
.
SetBufferLength
(
1024
*
1024
)
.
SetUdpDataHandlingAdapter
(()
=>
{
return
new
UdpPackageAdapter
()
{
MaxPackageSize
=
1024
*
1024
};
})
).
Start
();
}
catch
(
Exception
ex
)
{
MessageBox
.
Show
(
$"错误:
{
ex
.
Message
}
,程序将退出"
);
Environment
.
Exit
(
0
);
}
}
private
void
timer1_Tick
(
object
sender
,
EventArgs
e
)
{
byte
[]
byteArray
=
ImageToByte
(
getScreen
());
ByteBlock
bb
=
new
ByteBlock
(
byteArray
);
udpSession
.
Send
(
new
IPEndPoint
(
IPAddress
.
Parse
(
"127.0.0.1"
),
7790
),
bb
);
}
#
region
屏幕和光标获取
[
DllImport
(
"user32.dll"
)]
static
extern
bool
GetCursorInfo
(
out
CURSORINFO
pci
);
private
const
Int32
CURSOR_SHOWING
=
0x00000001
;
[
StructLayout
(
LayoutKind
.
Sequential
)]
struct
POINT
{
public
Int32
x
;
public
Int32
y
;
}
[
StructLayout
(
LayoutKind
.
Sequential
)]
struct
CURSORINFO
{
public
Int32
cbSize
;
public
Int32
flags
;
public
IntPtr
hCursor
;
public
POINT
ptScreenPos
;
}
public
Image
getScreen
(
int
x
=
0
,
int
y
=
0
,
int
width
=
-
1
,
int
height
=
-
1
,
String
savePath
=
""
,
bool
haveCursor
=
true
)
{
if
(
width
==
-
1
)
width
=
SystemInformation
.
VirtualScreen
.
Width
;
if
(
height
==
-
1
)
height
=
SystemInformation
.
VirtualScreen
.
Height
;
Bitmap
tmp
=
new
Bitmap
(
width
,
height
);
//按指定大小创建位图
Graphics
g
=
Graphics
.
FromImage
(
tmp
);
//从位图创建Graphics对象
g
.
CopyFromScreen
(
x
,
y
,
0
,
0
,
new
Size
(
width
,
height
));
//绘制
// 绘制鼠标
if
(
haveCursor
)
{
try
{
CURSORINFO
pci
;
pci
.
cbSize
=
Marshal
.
SizeOf
(
typeof
(
CURSORINFO
));
GetCursorInfo
(
out
pci
);
System
.
Windows
.
Forms
.
Cursor
cur
=
new
System
.
Windows
.
Forms
.
Cursor
(
pci
.
hCursor
);
cur
.
Draw
(
g
,
new
Rectangle
(
pci
.
ptScreenPos
.
x
,
pci
.
ptScreenPos
.
y
,
cur
.
Size
.
Width
,
cur
.
Size
.
Height
));
}
catch
(
Exception
ex
)
{
}
// 若获取鼠标异常则不显示
}
//Size halfSize = new Size((int)(tmp.Size.Width * 0.8), (int)(tmp.Size.Height * 0.8)); // 按一半尺寸存储图像
//if (!savePath.Equals("")) saveImage(tmp, tmp.Size, savePath); // 保存到指定的路径下
return
tmp
;
//返回构建的新图像
}
#
endregion
#
region
格式转换
private
byte
[]
ImageToByte
(
Image
Picture
)
{
MemoryStream
ms
=
new
MemoryStream
();
if
(
Picture
==
null
)
return
new
byte
[
ms
.
Length
];
Picture
.
Save
(
ms
,
System
.
Drawing
.
Imaging
.
ImageFormat
.
Jpeg
);
byte
[]
BPicture
=
new
byte
[
ms
.
Length
];
BPicture
=
ms
.
GetBuffer
();
return
BPicture
;
}
private
Image
ByteToImage
(
byte
[]
btImage
)
{
if
(
btImage
.
Length
==
0
)
return
null
;
System
.
IO
.
MemoryStream
ms
=
new
System
.
IO
.
MemoryStream
(
btImage
);
System
.
Drawing
.
Image
image
=
System
.
Drawing
.
Image
.
FromStream
(
ms
);
return
image
;
}
#
endregion
}
}
examples/Udp简单示例/ScreenUdpSender/Form1.resx
0 → 100644
浏览文件 @
6e1f0b23
<root>
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="timer1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
</root>
\ No newline at end of file
examples/Udp简单示例/ScreenUdpSender/Program.cs
0 → 100644
浏览文件 @
6e1f0b23
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Threading.Tasks
;
using
System.Windows.Forms
;
namespace
ScreenUdpSender
{
internal
static
class
Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[
STAThread
]
static
void
Main
()
{
Application
.
SetHighDpiMode
(
HighDpiMode
.
SystemAware
);
Application
.
EnableVisualStyles
();
Application
.
SetCompatibleTextRenderingDefault
(
false
);
Application
.
Run
(
new
Form1
());
}
}
}
examples/Udp简单示例/ScreenUdpSender/ScreenUdpSender.csproj
0 → 100644
浏览文件 @
6e1f0b23
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<UseWindowsForms>true</UseWindowsForms>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="TouchSocket" Version="0.2.3" />
</ItemGroup>
</Project>
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录