Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
T
thick-casting
Project
Project
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
潘栩锋
thick-casting
Commits
62a3a827
Commit
62a3a827
authored
Jul 01, 2021
by
潘栩锋
🚴
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修复 livechart 有bug, 不显示出来,就无法读取binding 的值
parent
caa8b5e4
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
110 additions
and
48 deletions
+110
-48
PicHistory.cs
.../FLY.Thick.FilmCasting.UI.Server/PicHistory/PicHistory.cs
+34
-7
ScanGraph.xaml
...FLY.Thick.FilmCasting.UI.Server/PicHistory/ScanGraph.xaml
+6
-30
ScanGraph.xaml.cs
....Thick.FilmCasting.UI.Server/PicHistory/ScanGraph.xaml.cs
+28
-6
WdPicHistory.xaml
....Thick.FilmCasting.UI.Server/PicHistory/WdPicHistory.xaml
+10
-3
WdPicHistory.xaml.cs
...ick.FilmCasting.UI.Server/PicHistory/WdPicHistory.xaml.cs
+20
-2
WdSetup.xaml.cs
...lmCasting/FLY.Thick.FilmCasting.UI.Server/WdSetup.xaml.cs
+12
-0
No files found.
Project.FLY.Thick.FilmCasting/FLY.Thick.FilmCasting.UI.Server/PicHistory/PicHistory.cs
View file @
62a3a827
...
...
@@ -12,6 +12,7 @@ using System.IO;
using
System.Linq
;
using
System.Text.RegularExpressions
;
using
System.Threading.Tasks
;
using
System.Windows.Controls
;
using
System.Windows.Threading
;
namespace
FLY.Thick.FilmCasting.UI.Server
...
...
@@ -106,7 +107,7 @@ namespace FLY.Thick.FilmCasting.UI.Server
Load
();
InitKeepDay
();
lastScanDataId
=
bulkDb
.
Last
Profile
Id
;
lastScanDataId
=
bulkDb
.
Last
ScanData
Id
;
this
.
scanGraphVm
=
new
ScanGraphVm
();
...
...
@@ -150,8 +151,9 @@ namespace FLY.Thick.FilmCasting.UI.Server
//触发!!!
CounterSec
=
0
;
if
(
lastScanDataId
!=
bulkDb
.
Last
Profile
Id
)
if
(
lastScanDataId
!=
bulkDb
.
Last
ScanData
Id
)
{
lastScanDataId
=
bulkDb
.
LastScanDataId
;
GetFrame
();
}
}
...
...
@@ -188,7 +190,36 @@ namespace FLY.Thick.FilmCasting.UI.Server
Directory
.
CreateDirectory
(
dirpath
);
return
$@"
{
dirpath
}
\
{
dt
:
HH_mm_ss
}
.jpg"
;
}
public
async
void
SavePic
(
string
path
)
{
//一定要把 scangraph 放入容器, 且scangraph Left,Top 对齐,margin=0
//不然有黑框
//整个scangraph 的尺寸是 Margin+(Width,Height)
//Margin 是透明,也就是黑色
var
viewbox
=
new
Viewbox
();
ScanGraph
scanGraph
=
new
ScanGraph
{
Width
=
PicWidth
,
Height
=
PicHeight
,
//HorizontalAlignment = System.Windows.HorizontalAlignment.Left,
//VerticalAlignment = System.Windows.VerticalAlignment.Top,
//Margin = new System.Windows.Thickness()
};
scanGraph
.
Init
(
scanGraphVm
);
viewbox
.
Child
=
scanGraph
;
viewbox
.
Measure
(
scanGraph
.
RenderSize
);
viewbox
.
Arrange
(
new
System
.
Windows
.
Rect
(
new
System
.
Windows
.
Point
(
0
,
0
),
scanGraph
.
RenderSize
));
scanGraph
.
ChartUpdate
();
//强制使 livechart 刷新
viewbox
.
UpdateLayout
();
ChartToImage
.
SaveToJpeg
(
scanGraph
,
path
);
}
public
async
Task
Add
(
Pack_GetFrameReponse
reponse
)
{
if
(
reponse
.
scanData
==
null
)
...
...
@@ -209,11 +240,7 @@ namespace FLY.Thick.FilmCasting.UI.Server
{
scanGraphVm
.
UpdateValue
(
reponse
,
isWarning
);
ScanGraph
scanGraph
=
new
ScanGraph
();
scanGraph
.
Init
(
scanGraphVm
);
scanGraph
.
Update
(
PicWidth
,
PicHeight
);
ChartToImage
.
SaveToJpeg
(
scanGraph
,
path
);
SavePic
(
path
);
});
await
Task
.
Factory
.
StartNew
(()
=>
...
...
Project.FLY.Thick.FilmCasting/FLY.Thick.FilmCasting.UI.Server/PicHistory/ScanGraph.xaml
View file @
62a3a827
...
...
@@ -52,7 +52,7 @@
<lvc:CartesianChart x:Name="chart" Grid.Row="1"
Hoverable="False" DisableAnimations="True" DataTooltip="{x:Null}" Margin="{StaticResource ControlMargin}">
<lvc:CartesianChart.AxisX>
<lvc:Axis LabelFormatter="{Binding XFormatter}"
<lvc:Axis
x:Name="axisX_0"
LabelFormatter="{Binding XFormatter}"
Foreground="{StaticResource Brushes.ChartAxisLabel}"
MaxValue="{Binding XMax}" MinValue="{Binding XMin}"
>
...
...
@@ -62,7 +62,7 @@
</lvc:Axis>
</lvc:CartesianChart.AxisX>
<lvc:CartesianChart.AxisY>
<lvc:Axis LabelFormatter="{Binding YFormatter}" MaxValue="{Binding YMax}" MinValue="{Binding YMin}" Panel.ZIndex="0" Foreground="Transparent" FontFamily="Courier New">
<lvc:Axis
x:Name="axisY_0"
LabelFormatter="{Binding YFormatter}" MaxValue="{Binding YMax}" MinValue="{Binding YMin}" Panel.ZIndex="0" Foreground="Transparent" FontFamily="Courier New">
<lvc:Axis.Sections>
<lvc:AxisSection Style="{StaticResource AxisSectionStyle}"
Value="{Binding YMax}"
...
...
@@ -101,7 +101,7 @@
</lvc:CartesianChart.AxisY>
<lvc:CartesianChart.Series>
<lvc2:Column2Series
<lvc2:Column2Series
x:Name="series_0"
YAxisCrossing="{Binding Target}"
Values="{Binding Values}"
Stroke = "Black"
...
...
@@ -109,21 +109,9 @@
PointGeometry = "{x:Null}"
Configuration = "{Binding Mapper}"
>
</lvc2:Column2Series>
</lvc:CartesianChart.Series>
<!--Series = new SeriesCollection
{
new Column2Series
{
Values = Values,
Stroke = new SolidColorBrush(Colors.Black),
StrokeThickness = 1,
PointGeometry = null,
Configuration = Mapper
}
};
((Series)Series[0]).SetBinding(Column2Series.YAxisCrossingProperty, new Binding(nameof(Target)) { Source = this });-->
</lvc:CartesianChart>
</Grid>
<Grid>
...
...
@@ -135,25 +123,13 @@
<Viewbox MaxHeight="75">
<StackPanel Orientation="Horizontal">
<StackPanel>
<Grid >
<Grid.Style>
<Style TargetType="Grid">
<Style.Setters>
<Setter Property="Background" Value="{StaticResource MahApps.Brushes.Gray10}"/>
</Style.Setters>
<Style.Triggers>
<DataTrigger Binding="{Binding IsWarning}" Value="true">
<Setter Property="Background" Value="{StaticResource MahApps.Brushes.Validation5}"/>
</DataTrigger>
</Style.Triggers>
</Style>
</Grid.Style>
<Grid Background="{StaticResource MahApps.Brushes.Gray10}">
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition Width="auto"/>
</Grid.ColumnDefinitions>
<TextBlock Style="{StaticResource ValueStyle}" Text="{Binding Title}" />
<TextBlock Grid.Column="1" Text="厚度报警" FontSize="20" Foreground="{StaticResource MahApps.Brushes.
Text.Validation
}" Margin="10,1"
<TextBlock Grid.Column="1" Text="厚度报警" FontSize="20" Foreground="{StaticResource MahApps.Brushes.
Validation5
}" Margin="10,1"
Visibility="{Binding IsWarning,Converter={StaticResource visbilityconv}}"/>
</Grid>
<StackPanel Orientation="Horizontal" >
...
...
Project.FLY.Thick.FilmCasting/FLY.Thick.FilmCasting.UI.Server/PicHistory/ScanGraph.xaml.cs
View file @
62a3a827
...
...
@@ -2,6 +2,7 @@
using
Misc
;
using
System.Windows
;
using
System.Windows.Controls
;
using
System.Windows.Data
;
namespace
FLY.Thick.FilmCasting.UI.Server
{
...
...
@@ -20,15 +21,36 @@ namespace FLY.Thick.FilmCasting.UI.Server
{
this
.
DataContext
=
viewModel
;
//下面是 livechart 的 bug
//没有 触发 ChartUpdater.Timer 的事件前,就算 axisX.DataContext 有值, binding 也无效, 无法获取数据
axisX_0
.
SetBinding
(
LiveCharts
.
Wpf
.
Axis
.
LabelFormatterProperty
,
new
Binding
(
nameof
(
viewModel
.
XFormatter
))
{
Source
=
viewModel
});
axisX_0
.
SetBinding
(
LiveCharts
.
Wpf
.
Axis
.
MinValueProperty
,
new
Binding
(
nameof
(
viewModel
.
XMin
))
{
Source
=
viewModel
});
axisX_0
.
SetBinding
(
LiveCharts
.
Wpf
.
Axis
.
MaxValueProperty
,
new
Binding
(
nameof
(
viewModel
.
XMax
))
{
Source
=
viewModel
});
axisX_0
.
Separator
.
SetBinding
(
LiveCharts
.
Wpf
.
Separator
.
StepProperty
,
new
Binding
(
nameof
(
viewModel
.
XStep
))
{
Source
=
viewModel
});
axisY_0
.
SetBinding
(
LiveCharts
.
Wpf
.
Axis
.
LabelFormatterProperty
,
new
Binding
(
nameof
(
viewModel
.
YFormatter
))
{
Source
=
viewModel
});
axisY_0
.
SetBinding
(
LiveCharts
.
Wpf
.
Axis
.
MinValueProperty
,
new
Binding
(
nameof
(
viewModel
.
YMin
))
{
Source
=
viewModel
});
axisY_0
.
SetBinding
(
LiveCharts
.
Wpf
.
Axis
.
MaxValueProperty
,
new
Binding
(
nameof
(
viewModel
.
YMax
))
{
Source
=
viewModel
});
axisY_0
.
Sections
[
0
].
SetBinding
(
LiveCharts
.
Wpf
.
AxisSection
.
ValueProperty
,
new
Binding
(
nameof
(
viewModel
.
YMax
))
{
Source
=
viewModel
});
axisY_0
.
Sections
[
1
].
SetBinding
(
LiveCharts
.
Wpf
.
AxisSection
.
ValueProperty
,
new
Binding
(
nameof
(
viewModel
.
YMin
))
{
Source
=
viewModel
});
axisY_0
.
Sections
[
2
].
SetBinding
(
LiveCharts
.
Wpf
.
AxisSection
.
ValueProperty
,
new
Binding
(
nameof
(
viewModel
.
Tolerance2YMax
))
{
Source
=
viewModel
});
axisY_0
.
Sections
[
3
].
SetBinding
(
LiveCharts
.
Wpf
.
AxisSection
.
ValueProperty
,
new
Binding
(
nameof
(
viewModel
.
Tolerance2YMin
))
{
Source
=
viewModel
});
axisY_0
.
Sections
[
4
].
SetBinding
(
LiveCharts
.
Wpf
.
AxisSection
.
ValueProperty
,
new
Binding
(
nameof
(
viewModel
.
ToleranceYMax
))
{
Source
=
viewModel
});
axisY_0
.
Sections
[
5
].
SetBinding
(
LiveCharts
.
Wpf
.
AxisSection
.
ValueProperty
,
new
Binding
(
nameof
(
viewModel
.
ToleranceYMin
))
{
Source
=
viewModel
});
axisY_0
.
Sections
[
6
].
SetBinding
(
LiveCharts
.
Wpf
.
AxisSection
.
ValueProperty
,
new
Binding
(
nameof
(
viewModel
.
Target
))
{
Source
=
viewModel
});
series_0
.
SetBinding
(
LiveCharts
.
Wpf
.
Column2Series
.
YAxisCrossingProperty
,
new
Binding
(
nameof
(
viewModel
.
Target
))
{
Source
=
viewModel
});
series_0
.
SetBinding
(
LiveCharts
.
Wpf
.
Column2Series
.
ValuesProperty
,
new
Binding
(
nameof
(
viewModel
.
Values
))
{
Source
=
viewModel
});
series_0
.
SetBinding
(
LiveCharts
.
Wpf
.
Column2Series
.
ConfigurationProperty
,
new
Binding
(
nameof
(
viewModel
.
Mapper
))
{
Source
=
viewModel
});
}
public
void
Update
(
int
width
,
int
height
)
public
void
ChartUpdate
()
{
Width
=
width
;
Height
=
height
;
Measure
(
RenderSize
);
Arrange
(
new
System
.
Windows
.
Rect
(
new
System
.
Windows
.
Point
(
0
,
0
),
RenderSize
));
chart
.
Update
(
true
,
true
);
//force chart redraw
UpdateLayout
();
}
}
}
Project.FLY.Thick.FilmCasting/FLY.Thick.FilmCasting.UI.Server/PicHistory/WdPicHistory.xaml
View file @
62a3a827
...
...
@@ -15,10 +15,13 @@
</Window.Resources>
<Grid>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition
/>
<RowDefinition Height="auto"/>
</Grid.RowDefinitions>
<local:ScanGraph x:Name="scanGraph" Margin="{StaticResource ControlMargin}"/>
<Grid x:Name="grid_root"/>
<Grid Margin="{StaticResource ControlMargin}" >
<local:ScanGraph x:Name="scanGraph" />
</Grid>
<StackPanel Margin="{StaticResource ControlMargin}" Grid.Row="1" >
<StackPanel Orientation="Horizontal">
<StackPanel Margin="{StaticResource ControlMargin}">
...
...
@@ -89,7 +92,11 @@
<CheckBox IsChecked="{Binding IsPercent}"/>
</StackPanel>
</StackPanel>
<Button Style="{StaticResource Styles.Button.Square.Accent2}" HorizontalAlignment="Right" Content="确定" Command="{Binding OkCmd}" />
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right" >
<Button Style="{StaticResource Styles.Button.Square.Accent2}" Content="图片保存" Click="btnSavePicClick" Width="auto"/>
<Button Style="{StaticResource Styles.Button.Square.Accent2}" Content="确定" Command="{Binding OkCmd}" />
</StackPanel>
</StackPanel>
</Grid>
...
...
Project.FLY.Thick.FilmCasting/FLY.Thick.FilmCasting.UI.Server/PicHistory/WdPicHistory.xaml.cs
View file @
62a3a827
using
GalaSoft.MvvmLight.Command
;
using
Microsoft.Win32
;
using
System
;
using
System.Collections.Generic
;
using
System.ComponentModel
;
...
...
@@ -22,17 +23,35 @@ namespace FLY.Thick.FilmCasting.UI.Server
public
partial
class
WdPicHistory
:
Window
{
WdPicHistoryVm
viewModel
;
PicHistory
picHistory
;
public
WdPicHistory
()
{
InitializeComponent
();
}
public
void
Init
(
PicHistory
picHistory
)
{
this
.
picHistory
=
picHistory
;
viewModel
=
new
WdPicHistoryVm
();
this
.
viewModel
.
Init
(
picHistory
);
this
.
DataContext
=
viewModel
;
scanGraph
.
DataContext
=
picHistory
.
scanGraphVm
;
scanGraph
.
Init
(
picHistory
.
scanGraphVm
);
}
private
void
btnSavePicClick
(
object
sender
,
RoutedEventArgs
e
)
{
string
strDesktopPath
=
Environment
.
GetFolderPath
(
Environment
.
SpecialFolder
.
DesktopDirectory
);
SaveFileDialog
sfd
=
new
SaveFileDialog
();
sfd
.
InitialDirectory
=
strDesktopPath
;
sfd
.
Filter
=
"jpg|*.jpg"
;
sfd
.
FileName
=
System
.
IO
.
Path
.
ChangeExtension
(
System
.
IO
.
Path
.
GetRandomFileName
(),
".jpg"
);
if
(
sfd
.
ShowDialog
()
==
true
)
{
//ChartToImage.SaveToJpeg(scanGraph, sfd.FileName);
picHistory
.
SavePic
(
sfd
.
FileName
);
}
}
}
...
...
@@ -82,7 +101,6 @@ namespace FLY.Thick.FilmCasting.UI.Server
public
bool
IsPercent
{
get
;
set
;
}
=
true
;
public
RelayCommand
OkCmd
{
get
;
private
set
;
}
private
PicHistory
picHistory
;
public
PicHistory
PicHistory
=>
picHistory
;
public
WdPicHistoryVm
()
...
...
Project.FLY.Thick.FilmCasting/FLY.Thick.FilmCasting.UI.Server/WdSetup.xaml.cs
View file @
62a3a827
...
...
@@ -66,12 +66,24 @@ namespace FLY.Thick.FilmCasting.UI.Server
FlyAdAddr
=
flyAd
.
Addr
;
DbKeepMonth
=
initParam
.
DBKeepMonth
;
if
(
DbKeepMonth
>
0
&&
DbKeepMonth
<
12
)
DbKeepMonth
=
12
;
DbDirPath
=
initParam
.
DbDirPath
;
}
private
void
Ok
()
{
if
(
DbKeepMonth
>
0
&&
DbKeepMonth
<
12
)
{
if
(
MessageBox
.
Show
(
$"数据库容量 最小值为12个月"
,
"提示"
)
==
MessageBoxResult
.
No
)
{
DbKeepMonth
=
12
;
return
;
}
}
if
(
MessageBox
.
Show
(
$"程序必须重启才能执行新的参数, 是否重启?"
,
"提示"
,
MessageBoxButton
.
YesNo
,
MessageBoxImage
.
Question
)
==
MessageBoxResult
.
No
)
{
return
;
...
...
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