Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
V
VIZ.Package
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.Package
Commits
6135859d
Commit
6135859d
authored
Mar 31, 2023
by
wangonghui
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
设置字体颜色功能开发
parent
2ee39501
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
264 additions
and
65 deletions
+264
-65
VIZ.Package.Module/ControlObject/FieldEdit/Edit/ClockEdit/ClockEditPanelModel.cs
+14
-22
VIZ.Package.Module/ControlObject/FieldEdit/Edit/ColorEdit/ColorEditPanel.xaml
+13
-7
VIZ.Package.Module/ControlObject/FieldEdit/Edit/ColorEdit/ColorEditPanelModel.cs
+225
-34
VIZ.Package.Service/Viz/VizCommandControlObjectService.cs
+12
-2
No files found.
VIZ.Package.Module/ControlObject/FieldEdit/Edit/ClockEdit/ClockEditPanelModel.cs
View file @
6135859d
...
...
@@ -67,17 +67,8 @@ namespace VIZ.Package.Module
/// </summary>
private
void
Start
()
{
var
pageModel
=
ApplicationDomainEx
.
CurrentPage
as
PageModel
;
ConnGroupModel
group
=
ApplicationDomainEx
.
ConnGroups
.
FirstOrDefault
(
p
=>
p
.
GroupID
==
pageModel
.
ConnGroupID
);
foreach
(
var
item
in
group
.
Items
)
{
if
(!
item
.
IsEnabled
||
!
item
.
IsConnected
)
continue
;
item
.
EndpointManager
.
Send
(
"CLOCK0 START"
);
}
SendTakeCmd
(
"CLOCK0 START"
);
}
...
...
@@ -91,17 +82,8 @@ namespace VIZ.Package.Module
/// </summary>
private
void
Stop
()
{
var
pageModel
=
ApplicationDomainEx
.
CurrentPage
as
PageModel
;
ConnGroupModel
group
=
ApplicationDomainEx
.
ConnGroups
.
FirstOrDefault
(
p
=>
p
.
GroupID
==
pageModel
.
ConnGroupID
);
foreach
(
var
item
in
group
.
Items
)
{
if
(!
item
.
IsEnabled
||
!
item
.
IsConnected
)
continue
;
item
.
EndpointManager
.
Send
(
"CLOCK0 STOP"
);
}
SendTakeCmd
(
"CLOCK0 STOP"
);
}
...
...
@@ -115,6 +97,16 @@ namespace VIZ.Package.Module
/// </summary>
private
void
Cont
()
{
SendTakeCmd
(
"CLOCK0 CONT"
);
}
/// <summary>
/// Viz发送命令Take命令行
/// </summary>
/// <param name="cmd"></param>
private
void
SendTakeCmd
(
string
cmd
)
{
var
pageModel
=
ApplicationDomainEx
.
CurrentPage
as
PageModel
;
ConnGroupModel
group
=
ApplicationDomainEx
.
ConnGroups
.
FirstOrDefault
(
p
=>
p
.
GroupID
==
pageModel
.
ConnGroupID
);
...
...
@@ -124,7 +116,7 @@ namespace VIZ.Package.Module
if
(!
item
.
IsEnabled
||
!
item
.
IsConnected
)
continue
;
item
.
EndpointManager
.
Send
(
"CLOCK0 CONT"
);
item
.
EndpointManager
.
Send
(
cmd
);
}
}
/// <summary>
...
...
VIZ.Package.Module/ControlObject/FieldEdit/Edit/ColorEdit/ColorEditPanel.xaml
View file @
6135859d
...
...
@@ -7,7 +7,7 @@
xmlns:dx="http://schemas.devexpress.com/winfx/2008/xaml/core"
mc:Ignorable="d"
x:Name="colorEditControl"
d:DesignHeight="300" d:DesignWidth="
38
0">
d:DesignHeight="300" d:DesignWidth="
40
0">
<UserControl.Resources>
<dx:ColorToBrushConverter x:Key="ColorToBrushConverter" />
...
...
@@ -53,7 +53,7 @@
</DataTemplate>
</UserControl.Resources>
<Grid>
<Grid
VerticalAlignment="Top"
>
<Grid.RowDefinitions>
<RowDefinition Height="40"/>
<RowDefinition Height="40"/>
...
...
@@ -71,7 +71,7 @@
<ColumnDefinition Width="85"/>
<ColumnDefinition Width="85"/>-->
<ColumnDefinition Width="340"/>
<ColumnDefinition Width="
4
0"/>
<ColumnDefinition Width="
6
0"/>
</Grid.ColumnDefinitions>
<dxe:ButtonEdit ShowText="False" AllowDefaultButton="False" IsEnabled="{Binding BtnGroupEnable,Mode=TwoWay}">
...
...
@@ -82,7 +82,7 @@
</dxe:ButtonEdit>
<CheckBox Content="
E
" Margin="10,0,0,0"
<CheckBox Content="
启用
" Margin="10,0,0,0"
ToolTip="Title Safe"
IsChecked="{Binding Path=IsEnabledAll,Mode=TwoWay}" Grid.Column="4">
</CheckBox>
...
...
@@ -124,7 +124,11 @@
<ColumnDefinition Width="80"/>
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="0" Text="Shininess" VerticalAlignment="Center" HorizontalAlignment="Center"/>
<dxe:TextEdit Grid.Column="1" Text="{Binding Path=Shininess,Mode=TwoWay}" HorizontalAlignment="Left" Height="30" Width="80" VerticalAlignment="Center"/>
<dxe:TextEdit Grid.Column="1"
Text="{Binding Path=Shininess,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"
HorizontalAlignment="Left" Height="30" Width="80"
Mask="[0-9]\d?|100" MaskType="RegEx" MaskUseAsDisplayFormat="True" ShowError="False"
VerticalAlignment="Center"/>
</Grid>
</WrapPanel>
...
...
@@ -139,8 +143,10 @@
<ColumnDefinition Width="80"/>
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="0" Text="Alpha" VerticalAlignment="Center" HorizontalAlignment="Center"/>
<dxe:TextEdit Grid.Column="1" Text="{Binding Path=Alpha,Mode=TwoWay}" HorizontalAlignment="Left" Width="80" Height="30" VerticalAlignment="Center"/>
<dxe:TextEdit Grid.Column="1" Text="{Binding Path=Alpha,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" HorizontalAlignment="Left" Width="80" Height="30" ShowError="False"
VerticalAlignment="Center" Mask="[0-9]\d?|100" MaskType="RegEx"
MaskUseAsDisplayFormat="True"/>
</Grid>
</WrapPanel>
...
...
VIZ.Package.Module/ControlObject/FieldEdit/Edit/ColorEdit/ColorEditPanelModel.cs
View file @
6135859d
...
...
@@ -5,6 +5,7 @@ using System.Text;
using
System.Threading.Tasks
;
using
System.Windows.Media
;
using
VIZ.Framework.Core
;
using
VIZ.Package.Domain
;
namespace
VIZ.Package.Module
{
...
...
@@ -12,7 +13,7 @@ namespace VIZ.Package.Module
{
public
override
string
GetFieldValue
()
{
throw
new
NotImplementedException
()
;
return
fieldValue
;
}
public
ColorEditPanelModel
()
...
...
@@ -29,8 +30,6 @@ namespace VIZ.Package.Module
this
.
DiffCommand
=
new
VCommand
(
DiffCmd
);
this
.
SpecCommand
=
new
VCommand
(
SpecCmd
);
this
.
EmisCommand
=
new
VCommand
(
EmisCmd
);
}
/// <summary>
...
...
@@ -64,24 +63,45 @@ namespace VIZ.Package.Module
{
emissionColor
=
colorValue
;
}
SendColorValue
();
}
else
{
eColor
=
colorValue
;
SendIsEnbaleAll
();
}
}
}
/// <summary>
/// ambientColor 设置颜色缓存
/// </summary>
private
Color
ambientColor
;
/// <summary>
/// diffuseColor 设置颜色缓存
/// </summary>
private
Color
diffuseColor
;
/// <summary>
/// specularColor 设置颜色缓存
/// </summary>
private
Color
specularColor
;
/// <summary>
/// emissionColor 设置颜色缓存
/// </summary>
private
Color
emissionColor
;
/// <summary>
/// 按钮禁用后 设置Color颜色缓存
/// </summary>
private
Color
eColor
;
//设置字段后的字符串
private
string
fieldValue
=
""
;
/// <summary>
/// 是否Ambient是否被禁用
/// </summary>
...
...
@@ -164,7 +184,6 @@ namespace VIZ.Package.Module
}
/// <summary>
/// E 是否禁用
/// </summary>
...
...
@@ -180,7 +199,7 @@ namespace VIZ.Package.Module
isEnabledAll
=
value
;
this
.
RaisePropertyChanged
(
nameof
(
IsEnabledAll
));
if
(
isEnabledAll
)
if
(
isEnabledAll
)
{
BtnGroupEnable
=
true
;
...
...
@@ -204,11 +223,17 @@ namespace VIZ.Package.Module
{
ColorValue
=
eColor
;
}
SendColorValue
();
}
else
{
BtnGroupEnable
=
false
;
ColorValue
=
eColor
;
SendIsEnbaleAll
();
}
}
}
...
...
@@ -243,6 +268,16 @@ namespace VIZ.Package.Module
{
shininess
=
value
;
this
.
RaisePropertyChanged
(
nameof
(
Shininess
));
if
(
isEnabledAll
)
{
SendColorValue
();
}
else
{
SendIsEnbaleAll
();
}
}
}
...
...
@@ -257,13 +292,105 @@ namespace VIZ.Package.Module
set
{
alpha
=
value
;
this
.
RaisePropertyChanged
(
nameof
(
Alpha
));
if
(
isEnabledAll
)
{
SendColorValue
();
}
else
{
SendIsEnbaleAll
();
}
}
}
/// <summary>
/// AmbCommand 方法
///第一次保存以后,打开更新的值到对象里面
/// </summary>
/// <param name="controlObject"></param>
/// <param name="controlField"></param>
public
override
void
Update
(
ControlObjectModel
controlObject
,
ControlFieldNodeModel
controlField
)
{
base
.
Update
(
controlObject
,
controlField
);
//this.IsSendToPreview = false;
//this.IsSendToPreview = true;
if
(
string
.
IsNullOrEmpty
(
this
.
ControlField
.
Value
))
{
return
;
}
else
{
string
[]
strValue
=
controlField
.
Value
.
Split
(
';'
);
Shininess
=
Convert
.
ToDouble
(
strValue
[
1
]);
Alpha
=
Convert
.
ToDouble
(
strValue
[
2
]);
if
(
strValue
[
0
]==
"0"
)
{
string
[]
colorValue
=
strValue
[
3
].
Split
(
','
);
// Color 颜色 R,G,B,A
eColor
=
Color
.
FromArgb
(
Convert
.
ToByte
(
Convert
.
ToDouble
(
colorValue
[
3
])*
255
),
Convert
.
ToByte
(
Convert
.
ToDouble
(
colorValue
[
0
])*
255
),
Convert
.
ToByte
(
Convert
.
ToDouble
(
colorValue
[
1
])*
255
),
Convert
.
ToByte
(
Convert
.
ToDouble
(
colorValue
[
2
])*
255
));
ColorValue
=
eColor
;
IsEnabledAll
=
false
;
}
else
{
IsEnabledAll
=
true
;
//Ambient 返回数组R,G,B,A
string
[]
strAmbient
=
strValue
[
3
].
Split
(
','
);
ambientColor
=
Color
.
FromArgb
(
Convert
.
ToByte
(
Convert
.
ToDouble
(
strAmbient
[
3
])*
255
),
Convert
.
ToByte
(
Convert
.
ToDouble
(
strAmbient
[
0
])*
255
),
Convert
.
ToByte
(
Convert
.
ToDouble
(
strAmbient
[
1
])*
255
),
Convert
.
ToByte
(
Convert
.
ToDouble
(
strAmbient
[
2
])*
255
));
//Diffuse 返回数组R,G,B,A
string
[]
strDiffuse
=
strValue
[
4
].
Split
(
','
);
diffuseColor
=
Color
.
FromArgb
(
Convert
.
ToByte
(
Convert
.
ToDouble
(
strDiffuse
[
3
])*
255
),
Convert
.
ToByte
(
Convert
.
ToDouble
(
strDiffuse
[
0
])*
255
),
Convert
.
ToByte
(
Convert
.
ToDouble
(
strDiffuse
[
1
])*
255
),
Convert
.
ToByte
(
Convert
.
ToDouble
(
strDiffuse
[
2
])*
255
));
//Specular 返回数组R,G,B,A
string
[]
strSpecular
=
strValue
[
5
].
Split
(
','
);
specularColor
=
Color
.
FromArgb
(
Convert
.
ToByte
(
Convert
.
ToDouble
(
strSpecular
[
3
])*
255
),
Convert
.
ToByte
(
Convert
.
ToDouble
(
strSpecular
[
0
])*
255
),
Convert
.
ToByte
(
Convert
.
ToDouble
(
strSpecular
[
1
])*
255
),
Convert
.
ToByte
(
Convert
.
ToDouble
(
strSpecular
[
2
])*
255
));
//Emission 返回数组R,G,B,A
string
[]
strEmission
=
strValue
[
6
].
Split
(
','
);
emissionColor
=
Color
.
FromArgb
(
Convert
.
ToByte
(
Convert
.
ToDouble
(
strEmission
[
3
])*
255
),
Convert
.
ToByte
(
Convert
.
ToDouble
(
strEmission
[
0
])*
255
),
Convert
.
ToByte
(
Convert
.
ToDouble
(
strEmission
[
1
])*
255
),
Convert
.
ToByte
(
Convert
.
ToDouble
(
strEmission
[
2
])*
255
));
if
(
IsEnabledA
==
false
)
{
ColorValue
=
ambientColor
;
}
else
if
(
IsEnabledD
==
false
)
{
ColorValue
=
diffuseColor
;
}
else
if
(
IsEnabledS
==
false
)
{
ColorValue
=
specularColor
;
}
else
if
(
IsEnabledE
==
false
)
{
ColorValue
=
emissionColor
;
}
}
}
}
/// <summary>
/// 点击 AmbCommand 方法
/// </summary>
public
VCommand
AmbCommand
{
get
;
set
;
}
...
...
@@ -274,11 +401,89 @@ namespace VIZ.Package.Module
IsEnabledD
=
true
;
IsEnabledS
=
true
;
IsEnabledE
=
true
;
SendColorValue
();
}
/// <summary>
/// 发送ColorValue值
/// </summary>
private
void
SendColorValue
()
{
// 指的是Color.R的颜色,G的是Color.G的颜色,B的是Color.B的颜色,A的是指的Color.A的就是指的透明图
string
amb
=
string
.
Format
(
"{0},{1},{2},{3}"
,
Convert
.
ToDouble
((
double
)
ambientColor
.
R
/
255
).
ToString
(),
Convert
.
ToDouble
((
double
)
ambientColor
.
G
/
255
).
ToString
(),
Convert
.
ToDouble
((
double
)
ambientColor
.
B
/
255
).
ToString
(),
Convert
.
ToDouble
((
double
)
ambientColor
.
A
/
255
).
ToString
());
// 指的是Color.R的颜色,G的是Color.G的颜色,B的是Color.B的颜色,A的是指的Color.A的就是指的透明图
string
dff
=
string
.
Format
(
"{0},{1},{2},{3}"
,
Convert
.
ToDouble
((
double
)
diffuseColor
.
R
/
255
).
ToString
(),
Convert
.
ToDouble
(
(
double
)
diffuseColor
.
G
/
255
).
ToString
(),
Convert
.
ToDouble
((
double
)
diffuseColor
.
B
/
255
).
ToString
(),
Convert
.
ToDouble
((
double
)
diffuseColor
.
A
/
255
).
ToString
());
// 指的是Color.R的颜色,G的是Color.G的颜色,B的是Color.B的颜色,A的是指的Color.A的就是指的透明图
string
spec
=
string
.
Format
(
"{0},{1},{2},{3}"
,
Convert
.
ToDouble
((
double
)
specularColor
.
R
/
255
).
ToString
(),
Convert
.
ToDouble
((
double
)
specularColor
.
G
/
255
).
ToString
(),
Convert
.
ToDouble
((
double
)
specularColor
.
B
/
255
).
ToString
(),
Convert
.
ToDouble
((
double
)
specularColor
.
A
/
255
).
ToString
());
// 指的是Color.R的颜色,G的是Color.G的颜色,B的是Color.B的颜色,A的是指的Color.A的就是指的透明图
string
emission
=
string
.
Format
(
"{0},{1},{2},{3}"
,
Convert
.
ToDouble
((
double
)
emissionColor
.
R
/
255
).
ToString
(),
Convert
.
ToDouble
((
double
)
emissionColor
.
G
/
255
).
ToString
(),
Convert
.
ToDouble
((
double
)
emissionColor
.
B
/
255
).
ToString
(),
Convert
.
ToDouble
((
double
)
emissionColor
.
A
/
255
).
ToString
());
//组装字符串说明 Enable;Shiness;Alpha;Ambient;Diffuse;specular;emission
fieldValue
=
string
.
Format
(
"1;{0};{1};{2};{3};{4};{5}"
,
Shininess
,
Alpha
,
amb
,
dff
,
spec
,
emission
);
this
.
ControlField
.
Value
=
fieldValue
;
// 没有预览连接
//if (ApplicationDomainEx.PreviewConn == null)
// return;
//// 没有控制对象或控制字段
//if (this.ControlObject == null || this.ControlField == null)
// return;
//this.VizCommandControlObjectService.SetControlObjectValue(
// ApplicationDomainEx.PreviewConn,
// ApplicationDomainEx.CurrentPage.GetVizScene(),
// this.ControlObject.TreeNodePath,
// this.ControlField.FieldIdentifier,
// this.ControlField.Value);
}
/// <summary>
/// DiffCommand
/// 禁用全部发送Color的值
/// </summary>
private
void
SendIsEnbaleAll
()
{
//byte[] bytes = { eColor.R};
// double scr = BitConverter.ToDouble(bytes,1);
//Ambient 返回数组R,G,B,A
string
ecolor
=
string
.
Format
(
"{0},{1},{2},{3}"
,
Convert
.
ToDouble
((
double
)
eColor
.
R
/
255
).
ToString
(),
Convert
.
ToDouble
((
double
)
eColor
.
G
/
255
).
ToString
(),
Convert
.
ToDouble
((
double
)
eColor
.
B
/
255
).
ToString
(),
Convert
.
ToDouble
((
double
)
eColor
.
A
/
255
).
ToString
());
//组装字符串说明 Enable;Shiness;Alpha;Color颜色
fieldValue
=
string
.
Format
(
"0;{0};{1};{2}"
,
Shininess
,
Alpha
,
ecolor
);
this
.
ControlField
.
Value
=
fieldValue
;
//// 没有预览连接
//if (ApplicationDomainEx.PreviewConn == null)
// return;
//// 没有控制对象或控制字段
//if (this.ControlObject == null || this.ControlField == null)
// return;
//this.VizCommandControlObjectService.SetControlObjectValue(
// ApplicationDomainEx.PreviewConn,
// ApplicationDomainEx.CurrentPage.GetVizScene(),
// this.ControlObject.TreeNodePath,
// this.ControlField.FieldIdentifier,
// this.ControlField.Value);
}
/// <summary>
/// 点击 DiffCommand
/// </summary>
public
VCommand
DiffCommand
{
get
;
set
;
}
...
...
@@ -288,10 +493,12 @@ namespace VIZ.Package.Module
IsEnabledD
=
false
;
IsEnabledS
=
true
;
IsEnabledE
=
true
;
SendColorValue
();
}
/// <summary>
/// SpecCommand 方法
///
点击
SpecCommand 方法
/// </summary>
public
VCommand
SpecCommand
{
get
;
set
;
}
...
...
@@ -302,10 +509,13 @@ namespace VIZ.Package.Module
IsEnabledD
=
true
;
IsEnabledS
=
false
;
IsEnabledE
=
true
;
SendColorValue
();
}
/// <summary>
/// EmisCommand 方法
///
点击
EmisCommand 方法
/// </summary>
public
VCommand
EmisCommand
{
get
;
set
;
}
...
...
@@ -315,29 +525,10 @@ namespace VIZ.Package.Module
IsEnabledD
=
true
;
IsEnabledS
=
true
;
IsEnabledE
=
false
;
}
///// <summary>
///// EnableCommand 方法
///// </summary>
//public VCommand EnableCommand { get; set; }
//private void EnableCmd()
//{
// if (IsEnabledAll)
// {
// BtnGroupEnable = false;
// IsEnabledAll = true;
// }
// else
// {
// BtnGroupEnable = true;
// IsEnabledAll = false;
// }
//}
SendColorValue
();
}
}
}
VIZ.Package.Service/Viz/VizCommandControlObjectService.cs
View file @
6135859d
...
...
@@ -333,6 +333,16 @@ namespace VIZ.Package.Service
conn
.
EndpointManager
.
Send
(
str
);
}
/// <summary>
/// 设置时钟的发送命令字符串
/// </summary>
/// <param name="conn"></param>
/// <param name="scene"></param>
/// <param name="treeNodePath"></param>
/// <param name="fieldIdentifier"></param>
/// <param name="upValue"></param>
/// <param name="downValue"></param>
/// <param name="cmd"></param>
public
void
SetControlObjectClockCmd
(
ConnModel
conn
,
VizScene
scene
,
string
treeNodePath
,
string
fieldIdentifier
,
string
upValue
,
string
downValue
,
string
cmd
)
{
string
str
=
$"
{
scene
}
*TREE*
{
treeNodePath
}
*FUNCTION*ControlObject*in SET ON
{
fieldIdentifier
}
SET *TIME SET
{
upValue
}
,*LIMIT SET
{
downValue
}
,*DIRECTION SET
{
cmd
}
"
;
...
...
@@ -597,8 +607,8 @@ namespace VIZ.Package.Service
if
(
type
==
"clock"
)
return
VizControlFieldType
.
clock
;
//
if (type == "color")
//
return VizControlFieldType.color;
if
(
type
==
"color"
)
return
VizControlFieldType
.
color
;
return
VizControlFieldType
.
none
;
}
...
...
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