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
e3bab2c1
Commit
e3bab2c1
authored
Jul 19, 2022
by
liulongfei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1. 添加LabelValue 控件
2. 添加应用程序停止消息
parent
74205d8b
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
261 additions
and
2 deletions
+261
-2
VIZ.Framework.Common/Themes/Generic.xaml
+1
-0
VIZ.Framework.Common/VIZ.Framework.Common.csproj
+5
-0
VIZ.Framework.Common/Widgets/LabelValue/LabelValue.cs
+85
-0
VIZ.Framework.Common/Widgets/LabelValue/LabelValue.xaml
+29
-0
VIZ.Framework.Connection/ConnectionManager.cs
+5
-0
VIZ.Framework.Connection/Core/ConnBitLengthAttribute.cs
+30
-0
VIZ.Framework.Connection/Core/ConnMessageBase.cs
+5
-0
VIZ.Framework.Connection/Protocol/SerialPort/SerialPortConnection.cs
+50
-0
VIZ.Framework.Connection/Protocol/SerialPort/SerialPortEndpointManager.cs
+16
-1
VIZ.Framework.Connection/Provider/CommandLine/ConnCommandLinePackageProvider.cs
+2
-1
VIZ.Framework.Connection/Provider/FixedBuffer/ConnFixedBufferPackageProvider.cs
+2
-0
VIZ.Framework.Connection/Provider/SingleJson/ConnSingleJsonPackageProvider.cs
+2
-0
VIZ.Framework.Connection/VIZ.Framework.Connection.csproj
+1
-0
VIZ.Framework.Module/Setup/AppSetup.cs
+12
-0
VIZ.Framework.Module/Setup/Message/AppShutDownMessage.cs
+15
-0
VIZ.Framework.Module/VIZ.Framework.Module.csproj
+1
-0
No files found.
VIZ.Framework.Common/Themes/Generic.xaml
View file @
e3bab2c1
...
...
@@ -9,6 +9,7 @@
<ResourceDictionary Source="/VIZ.Framework.Common;component/Widgets/NavigationControl/NavigationControl.xaml"></ResourceDictionary>
<ResourceDictionary Source="/VIZ.Framework.Common;component/Widgets/NumberBox/NumberBox.xaml"></ResourceDictionary>
<ResourceDictionary Source="/VIZ.Framework.Common;component/Widgets/ColorPickButton/ColorPickButton.xaml"></ResourceDictionary>
<ResourceDictionary Source="/VIZ.Framework.Common;component/Widgets/LabelValue/LabelValue.xaml"></ResourceDictionary>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
VIZ.Framework.Common/VIZ.Framework.Common.csproj
View file @
e3bab2c1
...
...
@@ -138,6 +138,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Widgets\LabelValue\LabelValue.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Widgets\NavigationControl\NavigationControl.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
...
...
@@ -229,6 +233,7 @@
<Compile Include="Widgets\ColorPickButton\ColorPickButton.cs" />
<Compile Include="Widgets\DebugBorder\DebugBorder.cs" />
<Compile Include="Widgets\DragWindowBar\DragWindowBar.cs" />
<Compile Include="Widgets\LabelValue\LabelValue.cs" />
<Compile Include="Widgets\NavigationControl\NavigationConfig.cs" />
<Compile Include="Widgets\NavigationControl\NavigationControl.cs" />
<Compile Include="Widgets\NavigationControl\NavigationItemControl.cs" />
...
...
VIZ.Framework.Common/Widgets/LabelValue/LabelValue.cs
0 → 100644
View file @
e3bab2c1
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
using
System.Threading.Tasks
;
using
System.Windows
;
using
System.Windows.Controls
;
using
System.Windows.Data
;
using
System.Windows.Documents
;
using
System.Windows.Input
;
using
System.Windows.Media
;
using
System.Windows.Media.Imaging
;
using
System.Windows.Navigation
;
using
System.Windows.Shapes
;
namespace
VIZ.Framework.Common
{
/// <summary>
/// 标签和值
/// </summary>
public
class
LabelValue
:
Control
{
static
LabelValue
()
{
DefaultStyleKeyProperty
.
OverrideMetadata
(
typeof
(
LabelValue
),
new
FrameworkPropertyMetadata
(
typeof
(
LabelValue
)));
}
#
region
LabelWidth
--
标签宽度
/// <summary>
/// 标签宽度
/// </summary>
public
double
LabelWidth
{
get
{
return
(
double
)
GetValue
(
LabelWidthProperty
);
}
set
{
SetValue
(
LabelWidthProperty
,
value
);
}
}
/// <summary>
/// Using a DependencyProperty as the backing store for LabelWidth. This enables animation, styling, binding, etc...
/// </summary>
public
static
readonly
DependencyProperty
LabelWidthProperty
=
DependencyProperty
.
Register
(
"LabelWidth"
,
typeof
(
double
),
typeof
(
LabelValue
),
new
PropertyMetadata
(
120d
));
#
endregion
#
region
Label
--
标签
/// <summary>
/// 标签
/// </summary>
public
string
Label
{
get
{
return
(
string
)
GetValue
(
LabelProperty
);
}
set
{
SetValue
(
LabelProperty
,
value
);
}
}
/// <summary>
/// Using a DependencyProperty as the backing store for Label. This enables animation, styling, binding, etc...
/// </summary>
public
static
readonly
DependencyProperty
LabelProperty
=
DependencyProperty
.
Register
(
"Label"
,
typeof
(
string
),
typeof
(
LabelValue
),
new
PropertyMetadata
(
null
));
#
endregion
#
region
Text
--
文本
/// <summary>
/// 文本
/// </summary>
public
string
Text
{
get
{
return
(
string
)
GetValue
(
TextProperty
);
}
set
{
SetValue
(
TextProperty
,
value
);
}
}
/// <summary>
/// Using a DependencyProperty as the backing store for Text. This enables animation, styling, binding, etc...
/// </summary>
public
static
readonly
DependencyProperty
TextProperty
=
DependencyProperty
.
Register
(
"Text"
,
typeof
(
string
),
typeof
(
LabelValue
),
new
PropertyMetadata
(
null
));
#
endregion
}
}
VIZ.Framework.Common/Widgets/LabelValue/LabelValue.xaml
0 → 100644
View file @
e3bab2c1
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:VIZ.Framework.Common">
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/VIZ.Framework.Common.Resource;component/Style/TextBox/TextBox_None.xaml"></ResourceDictionary>
</ResourceDictionary.MergedDictionaries>
<Style TargetType="local:LabelValue">
<Setter Property="FocusVisualStyle" Value="{x:Null}"></Setter>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="local:LabelValue">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="auto"></ColumnDefinition>
<ColumnDefinition Width="*"></ColumnDefinition>
</Grid.ColumnDefinitions>
<TextBlock VerticalAlignment="Center" Foreground="#aa000000"
Text="{TemplateBinding Label}" Width="{TemplateBinding LabelWidth}"></TextBlock>
<TextBox Grid.Column="1" AcceptsReturn="False" IsReadOnly="True" TextWrapping="NoWrap"
Text="{TemplateBinding Text}" VerticalContentAlignment="Center" Style="{StaticResource TextBox_None}"></TextBox>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>
\ No newline at end of file
VIZ.Framework.Connection/ConnectionManager.cs
View file @
e3bab2c1
...
...
@@ -20,5 +20,10 @@ namespace VIZ.Framework.Connection
/// TCP连接
/// </summary>
public
static
TcpConnection
TcpConnection
{
get
;
set
;
}
/// <summary>
/// 串口连接
/// </summary>
public
static
SerialPortConnection
SerialPortConnection
{
get
;
set
;
}
}
}
VIZ.Framework.Connection/Core/ConnBitLengthAttribute.cs
0 → 100644
View file @
e3bab2c1
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
using
System.Threading.Tasks
;
namespace
VIZ.Framework.Connection
{
/// <summary>
/// 位长特性
/// </summary>
public
class
ConnBitLengthAttribute
:
Attribute
{
/// <summary>
/// 位长特性
/// </summary>
/// <param name="length">位长</param>
public
ConnBitLengthAttribute
(
int
length
)
{
this
.
Length
=
length
;
}
/// <summary>
/// 位长度
/// 1 Byte = 8bit
/// 1
/// </summary>
public
int
Length
{
get
;
set
;
}
}
}
VIZ.Framework.Connection/Core/ConnMessageBase.cs
View file @
e3bab2c1
...
...
@@ -35,5 +35,10 @@ namespace VIZ.Framework.Connection
/// 串口名称
/// </summary>
public
string
PortName
{
get
;
internal
set
;
}
/// <summary>
/// 处理器
/// </summary>
public
IConnPackageProvider
Provider
{
get
;
internal
set
;
}
}
}
VIZ.Framework.Connection/Protocol/SerialPort/SerialPortConnection.cs
View file @
e3bab2c1
...
...
@@ -17,14 +17,64 @@ namespace VIZ.Framework.Connection
/// </summary>
private
static
ILog
log
=
LogManager
.
GetLogger
(
typeof
(
SerialPortConnection
));
/// <summary>
/// 终结点管理器集合
/// </summary>
private
Dictionary
<
string
,
SerialPortEndpointManager
>
endpointManagers
=
new
Dictionary
<
string
,
SerialPortEndpointManager
>();
/// <summary>
/// 获取TCP终结点管理器
/// </summary>
/// <param name="key">终结点管理器键</param>
/// <returns>终结点管理器</returns>
public
SerialPortEndpointManager
GetEndpointManager
(
string
key
)
{
this
.
endpointManagers
.
TryGetValue
(
key
,
out
SerialPortEndpointManager
manager
);
return
manager
;
}
/// <summary>
/// 添加TCP终结点管理器
/// </summary>
/// <param name="manager">终结点管理器</param>
public
void
AddEndpointManager
(
SerialPortEndpointManager
manager
)
{
manager
.
SerialPortConnection
=
this
;
lock
(
this
.
endpointManagers
)
{
this
.
endpointManagers
.
Add
(
manager
.
Key
,
manager
);
}
}
/// <summary>
/// 移除UDP终结点管理器
/// </summary>
/// <param name="key">终结点管理器键</param>
public
void
RemoveEndpointManager
(
string
key
)
{
lock
(
this
.
endpointManagers
)
{
if
(
this
.
endpointManagers
.
ContainsKey
(
key
))
{
this
.
endpointManagers
.
Remove
(
key
);
}
}
}
/// <summary>
/// 销毁
/// </summary>
public
void
Dispose
()
{
lock
(
this
.
endpointManagers
)
{
foreach
(
SerialPortEndpointManager
manager
in
this
.
endpointManagers
.
Values
)
{
manager
.
Dispose
();
}
this
.
endpointManagers
.
Clear
();
}
}
}
}
VIZ.Framework.Connection/Protocol/SerialPort/SerialPortEndpointManager.cs
View file @
e3bab2c1
...
...
@@ -11,7 +11,7 @@ namespace VIZ.Framework.Connection
/// <summary>
/// 串口终结点管理器
/// </summary>
public
class
SerialPortEndpointManager
public
class
SerialPortEndpointManager
:
IDisposable
{
/// <summary>
/// 日志
...
...
@@ -55,6 +55,11 @@ namespace VIZ.Framework.Connection
public
IConnPackageProvider
PackageProvider
{
get
;
set
;
}
/// <summary>
/// 串口连接
/// </summary>
public
SerialPortConnection
SerialPortConnection
{
get
;
internal
set
;
}
/// <summary>
/// 打开串口
/// </summary>
public
void
Open
()
...
...
@@ -72,6 +77,16 @@ namespace VIZ.Framework.Connection
}
/// <summary>
/// 销毁
/// </summary>
public
void
Dispose
()
{
this
.
SerialPort
?.
Close
();
this
.
SerialPort
?.
Dispose
();
this
.
SerialPort
=
null
;
}
/// <summary>
/// 接收数据触发
/// </summary>
private
void
SerialPort_DataReceived
(
object
sender
,
SerialDataReceivedEventArgs
e
)
...
...
VIZ.Framework.Connection/Provider/CommandLine/ConnCommandLinePackageProvider.cs
View file @
e3bab2c1
...
...
@@ -77,9 +77,10 @@ namespace VIZ.Framework.Connection
msg
.
RemotePort
=
package
.
RemotePort
;
msg
.
LocalIP
=
package
.
LocalIP
;
msg
.
LocalPort
=
package
.
LocalPort
;
msg
.
PortName
=
package
.
PortName
;
msg
.
Provider
=
this
;
msg
.
Command
=
commands
[
i
];
try
{
ApplicationDomain
.
MessageManager
.
Send
(
msg
);
...
...
VIZ.Framework.Connection/Provider/FixedBuffer/ConnFixedBufferPackageProvider.cs
View file @
e3bab2c1
...
...
@@ -86,6 +86,8 @@ namespace VIZ.Framework.Connection
msg
.
LocalPort
=
package
.
LocalPort
;
msg
.
RemoteIP
=
package
.
RemoteIP
;
msg
.
RemotePort
=
package
.
RemotePort
;
msg
.
PortName
=
package
.
PortName
;
msg
.
Provider
=
this
;
msg
.
Buffer
=
this
.
buffer_cache
;
try
...
...
VIZ.Framework.Connection/Provider/SingleJson/ConnSingleJsonPackageProvider.cs
View file @
e3bab2c1
...
...
@@ -55,6 +55,8 @@ namespace VIZ.Framework.Connection
msg
.
LocalPort
=
package
.
LocalPort
;
msg
.
RemoteIP
=
package
.
RemoteIP
;
msg
.
RemotePort
=
package
.
RemotePort
;
msg
.
PortName
=
package
.
PortName
;
msg
.
Provider
=
this
;
msg
.
Json
=
json
;
try
...
...
VIZ.Framework.Connection/VIZ.Framework.Connection.csproj
View file @
e3bab2c1
...
...
@@ -68,6 +68,7 @@
</ItemGroup>
<ItemGroup>
<Compile Include="ConnectionManager.cs" />
<Compile Include="Core\ConnBitLengthAttribute.cs" />
<Compile Include="Core\ConnInfoBase.cs" />
<Compile Include="Core\ConnMessageBase.cs" />
<Compile Include="Core\ConnPackageInfo.cs" />
...
...
VIZ.Framework.Module/Setup/AppSetup.cs
View file @
e3bab2c1
...
...
@@ -6,6 +6,7 @@ using System.Text;
using
System.Threading.Tasks
;
using
System.Windows
;
using
log4net
;
using
VIZ.Framework.Domain
;
namespace
VIZ.Framework.Module
{
...
...
@@ -138,6 +139,17 @@ namespace VIZ.Framework.Module
if
(!
IsSetup
)
return
;
try
{
// 发送应用程序关闭消息
AppShutDownMessage
msg
=
new
AppShutDownMessage
();
ApplicationDomain
.
MessageManager
.
Send
(
msg
);
}
catch
(
Exception
ex
)
{
log
.
Error
(
ex
);
}
Stopwatch
stopwatch
=
Stopwatch
.
StartNew
();
AppSetupContext
context
=
new
AppSetupContext
();
...
...
VIZ.Framework.Module/Setup/Message/AppShutDownMessage.cs
0 → 100644
View file @
e3bab2c1
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
using
System.Threading.Tasks
;
namespace
VIZ.Framework.Module
{
/// <summary>
/// 应用程序关闭消息
/// </summary>
public
class
AppShutDownMessage
{
}
}
VIZ.Framework.Module/VIZ.Framework.Module.csproj
View file @
e3bab2c1
...
...
@@ -97,6 +97,7 @@
<Compile Include="Setup\AppSetupBase.cs" />
<Compile Include="Setup\AppSetupContext.cs" />
<Compile Include="Setup\IAppSetup.cs" />
<Compile Include="Setup\Message\AppShutDownMessage.cs" />
<Compile Include="Setup\Provider\Setup\AppSetup_CatchUnhandledException.cs" />
<Compile Include="Setup\Provider\Setup\AppSetup_Navigation3D.cs" />
<Compile Include="Setup\Provider\Setup\AppSetup_Loop.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