Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
V
VIZ.Framework
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
刘龙飞
VIZ.Framework
Commits
99bd5ece
Commit
99bd5ece
authored
Dec 10, 2022
by
liulongfei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
viz 嵌入
parent
18f1ed6f
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
387 additions
and
0 deletions
+387
-0
VIZ.Framework.Common/VIZ.Framework.Common.csproj
+11
-0
VIZ.Framework.Common/Widgets/WindowHost/WindowHost.cs
+186
-0
VIZ.Framework.Common/Widgets/WindowHost/WindowHostForm.Designer.cs
+48
-0
VIZ.Framework.Common/Widgets/WindowHost/WindowHostForm.cs
+20
-0
VIZ.Framework.Common/Widgets/WindowHost/WindowHostForm.resx
+121
-0
VIZ.Framework.Core/VIZ.Framework.Core.csproj
+1
-0
No files found.
VIZ.Framework.Common/VIZ.Framework.Common.csproj
View file @
99bd5ece
...
...
@@ -119,6 +119,7 @@
<Reference Include="WindowsBase" />
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
<Reference Include="WindowsFormsIntegration" />
<Reference Include="Xceed.Wpf.AvalonDock, Version=4.4.0.0, Culture=neutral, PublicKeyToken=3e4669d2f30244f4, processorArchitecture=MSIL">
<HintPath>..\packages\Extended.Wpf.Toolkit.4.4.0\lib\net40\Xceed.Wpf.AvalonDock.dll</HintPath>
</Reference>
...
...
@@ -324,10 +325,20 @@
<Compile Include="Widgets\VideoTimeBar\EventArgs\VideoTimeBarValueChangedEventArgs.cs" />
<Compile Include="Widgets\VideoTimeBar\VideoTimeBar.cs" />
<Compile Include="Widgets\ViewLoader\ViewLoader.cs" />
<Compile Include="Widgets\WindowHost\WindowHost.cs" />
<Compile Include="Widgets\WindowHost\WindowHostForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Widgets\WindowHost\WindowHostForm.Designer.cs">
<DependentUpon>WindowHostForm.cs</DependentUpon>
</Compile>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
<EmbeddedResource Include="Widgets\WindowHost\WindowHostForm.resx">
<DependentUpon>WindowHostForm.cs</DependentUpon>
</EmbeddedResource>
<None Include="app.config" />
<None Include="packages.config" />
<None Include="Properties\Settings.settings">
...
...
VIZ.Framework.Common/Widgets/WindowHost/WindowHost.cs
0 → 100644
View file @
99bd5ece
using
log4net
;
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
using
System.Threading.Tasks
;
using
System.Windows
;
using
System.Windows.Forms.Integration
;
using
VIZ.Framework.Core
;
using
VIZ.Framework.Domain
;
namespace
VIZ.Framework.Common
{
/// <summary>
/// 窗口容器
/// </summary>
public
class
WindowHost
:
WindowsFormsHost
,
IDisposable
{
/// <summary>
/// 日志
/// </summary>
private
readonly
static
ILog
log
=
LogManager
.
GetLogger
(
typeof
(
WindowHost
));
/// <summary>
/// 窗口容器
/// </summary>
public
WindowHost
()
{
ApplicationDomain
.
ObjectPoolManager
.
Add
(
$"WindowHost_
{
Guid
.
NewGuid
()}
"
,
this
);
this
.
Loaded
+=
WindowHost_Loaded
;
}
#
region
PART
/// <summary>
/// 窗口停靠容器
/// </summary>
public
System
.
Windows
.
Forms
.
Panel
PART_Container
{
get
;
private
set
;
}
/// <summary>
/// 容器窗口
/// </summary>
public
WindowHostForm
PART_ContainerForm
{
get
;
protected
set
;
}
#
endregion
#
region
BackColor
--
背景色
/// <summary>
/// 背景色
/// </summary>
public
System
.
Drawing
.
Color
BackColor
{
get
{
return
(
System
.
Drawing
.
Color
)
GetValue
(
BackColorProperty
);
}
set
{
SetValue
(
BackColorProperty
,
value
);
}
}
/// <summary>
/// Using a DependencyProperty as the backing store for BackColor. This enables animation, styling, binding, etc...
/// </summary>
public
static
readonly
DependencyProperty
BackColorProperty
=
DependencyProperty
.
Register
(
"BackColor"
,
typeof
(
System
.
Drawing
.
Color
),
typeof
(
WindowHost
),
new
PropertyMetadata
(
System
.
Drawing
.
Color
.
White
));
#
endregion
/// <summary>
/// 容器窗口句柄
/// </summary>
public
IntPtr
ContainerFormHandle
{
get
;
private
set
;
}
/// <summary>
/// 目标窗口句柄
/// </summary>
public
IntPtr
TargetWindowHandle
{
get
;
private
set
;
}
/// <summary>
/// 更新任务信息
/// </summary>
private
TaskInfo
updateTaskInfo
;
/// <summary>
/// 更新任务
/// </summary>
private
Task
updateTask
;
/// <summary>
/// 销毁窗口
/// </summary>
/// <param name="disposing">是否正在销毁</param>
protected
override
void
Dispose
(
bool
disposing
)
{
base
.
Dispose
(
disposing
);
this
.
PART_ContainerForm
?.
Close
();
this
.
PART_ContainerForm
?.
Dispose
();
this
.
PART_ContainerForm
=
null
;
if
(
this
.
updateTaskInfo
!=
null
)
{
this
.
updateTaskInfo
.
IsCancel
=
true
;
}
this
.
updateTaskInfo
=
null
;
this
.
updateTask
=
null
;
}
/// <summary>
/// 加载完成时触发
/// </summary>
private
void
WindowHost_Loaded
(
object
sender
,
System
.
Windows
.
RoutedEventArgs
e
)
{
if
(
this
.
PART_Container
!=
null
)
return
;
this
.
PART_Container
=
new
System
.
Windows
.
Forms
.
Panel
();
this
.
PART_Container
.
BackColor
=
this
.
BackColor
;
this
.
Child
=
this
.
PART_Container
;
this
.
PART_ContainerForm
=
new
WindowHostForm
();
this
.
PART_ContainerForm
.
BackColor
=
this
.
BackColor
;
this
.
PART_ContainerForm
.
Show
();
this
.
ContainerFormHandle
=
this
.
PART_ContainerForm
.
Handle
;
// 设置窗口父子关系
if
(
Win32Helper
.
SetParent
(
this
.
PART_ContainerForm
.
Handle
,
this
.
PART_Container
.
Handle
).
ToInt32
()
<
+
0
)
{
log
.
Error
(
"set form parent error."
);
}
// 启动更新线程
this
.
updateTaskInfo
=
new
TaskInfo
();
this
.
updateTask
=
ThreadHelper
.
SafeRun
(
this
.
update
);
}
/// <summary>
/// 渲染大小改变时触发
/// </summary>
protected
override
void
OnRenderSizeChanged
(
SizeChangedInfo
sizeInfo
)
{
base
.
OnRenderSizeChanged
(
sizeInfo
);
if
(
this
.
PART_ContainerForm
==
null
)
return
;
int
width
=
(
int
)
sizeInfo
.
NewSize
.
Width
;
int
height
=
(
int
)
sizeInfo
.
NewSize
.
Height
;
// 改变宿主窗口大小
if
(!
Win32Helper
.
MoveWindow
(
this
.
PART_ContainerForm
.
Handle
,
0
,
0
,
width
,
height
,
false
))
{
log
.
Error
(
"resize form error."
);
}
}
/// <summary>
/// 更新
/// </summary>
private
void
update
()
{
TaskInfo
info
=
this
.
updateTaskInfo
;
if
(
info
==
null
)
return
;
while
(!
info
.
IsCancel
)
{
if
(
this
.
ContainerFormHandle
!=
IntPtr
.
Zero
)
{
IntPtr
target
=
Win32Helper
.
FindWindowEx
(
this
.
ContainerFormHandle
,
IntPtr
.
Zero
,
null
,
null
);
if
(
target
!=
IntPtr
.
Zero
)
{
this
.
TargetWindowHandle
=
target
;
}
if
(
target
==
IntPtr
.
Zero
&&
this
.
TargetWindowHandle
!=
IntPtr
.
Zero
)
{
Win32Helper
.
SetParent
(
this
.
TargetWindowHandle
,
this
.
ContainerFormHandle
);
}
}
System
.
Threading
.
Thread
.
Sleep
(
100
);
}
}
}
}
VIZ.Framework.Common/Widgets/WindowHost/WindowHostForm.Designer.cs
0 → 100644
View file @
99bd5ece
namespace
VIZ.Framework.Common
{
partial
class
WindowHostForm
{
/// <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
.
SuspendLayout
();
//
// WindowHostForm
//
this
.
AutoScaleDimensions
=
new
System
.
Drawing
.
SizeF
(
6F
,
12F
);
this
.
AutoScaleMode
=
System
.
Windows
.
Forms
.
AutoScaleMode
.
Font
;
this
.
ClientSize
=
new
System
.
Drawing
.
Size
(
800
,
450
);
this
.
FormBorderStyle
=
System
.
Windows
.
Forms
.
FormBorderStyle
.
None
;
this
.
Name
=
"WindowHostForm"
;
this
.
Text
=
"WindowHostForm"
;
this
.
ResumeLayout
(
false
);
}
#
endregion
}
}
\ No newline at end of file
VIZ.Framework.Common/Widgets/WindowHost/WindowHostForm.cs
0 → 100644
View file @
99bd5ece
using
System
;
using
System.Collections.Generic
;
using
System.ComponentModel
;
using
System.Data
;
using
System.Drawing
;
using
System.Linq
;
using
System.Text
;
using
System.Threading.Tasks
;
using
System.Windows.Forms
;
namespace
VIZ.Framework.Common
{
public
partial
class
WindowHostForm
:
Form
{
public
WindowHostForm
()
{
InitializeComponent
();
}
}
}
VIZ.Framework.Common/Widgets/WindowHost/WindowHostForm.resx
0 → 100644
View file @
99bd5ece
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<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
VIZ.Framework.Core/VIZ.Framework.Core.csproj
View file @
99bd5ece
...
...
@@ -145,6 +145,7 @@
<Compile Include="Core\VIZ\Engine\VizEngineConnectionItem.cs" />
<Compile Include="Core\VIZ\Engine\VizEngineModel.cs" />
<Compile Include="Core\VIZ\Engine\VizEngineModelCommandExpand.cs" />
<Compile Include="Core\Win32\Win32Helper.cs" />
<Compile Include="Expand\GPIO\Core\USB2GPIO.cs" />
<Compile Include="Expand\GPIO\Core\USBDevice.cs" />
<Compile Include="Expand\GPIO\Core\USBDeviceStruct.cs" />
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment