Browse Source

图表问题修改

master
sc 2 months ago
parent
commit
5798d8ba00
  1. 2
      View/CurveDiagramView.xaml
  2. 16
      View/CurveDiagramView.xaml.cs
  3. 8
      View/TechnologicalProcessView.xaml.cs
  4. 57
      ViewModel/CurveDiagramViewModel.cs
  5. 1
      ViewModel/MainWindowViewModel.cs
  6. 10
      Windows/ViewStep.xaml
  7. 61
      Windows/ViewStep.xaml.cs

2
View/CurveDiagramView.xaml

@ -5,11 +5,13 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:lvc="clr-namespace:LiveChartsCore.SkiaSharpView.WPF;assembly=LiveChartsCore.SkiaSharpView.WPF" xmlns:lvc="clr-namespace:LiveChartsCore.SkiaSharpView.WPF;assembly=LiveChartsCore.SkiaSharpView.WPF"
xmlns:viewmodel="clr-namespace:DyeingComputer.ViewModel" xmlns:viewmodel="clr-namespace:DyeingComputer.ViewModel"
xmlns:wpf="clr-namespace:ScottPlot.WPF;assembly=ScottPlot.WPF"
mc:Ignorable="d" Loaded="UserControl_Loaded" mc:Ignorable="d" Loaded="UserControl_Loaded"
d:DataContext="{d:DesignInstance Type=viewmodel:CurveDiagramViewModel}" d:DataContext="{d:DesignInstance Type=viewmodel:CurveDiagramViewModel}"
d:DesignHeight="630" d:DesignWidth="1280"> d:DesignHeight="630" d:DesignWidth="1280">
<Grid> <Grid>
<lvc:CartesianChart x:Name="OscChart" MinWidth="1280" MinHeight="600" EasingFunction="{x:Null}" <lvc:CartesianChart x:Name="OscChart" MinWidth="1280" MinHeight="600" EasingFunction="{x:Null}"
Series="{Binding Series}" YAxes="{Binding YAxes}" XAxes="{Binding XAxes}"/> Series="{Binding Series}" YAxes="{Binding YAxes}" XAxes="{Binding XAxes}"/>
</Grid> </Grid>
</UserControl> </UserControl>

16
View/CurveDiagramView.xaml.cs

@ -1,10 +1,16 @@
using DyeingComputer.ViewModel; using DyeingComputer.UserClass;
using LiveChartsCore.SkiaSharpView; using DyeingComputer.ViewModel;
using LiveChartsCore; using LiveChartsCore;
using LiveChartsCore.Kernel.Sketches;
using LiveChartsCore.Measure;
using LiveChartsCore.SkiaSharpView;
using ScottPlot;
using ScottPlot.Plottables;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Data; using System.Data;
using System.Linq; using System.Linq;
using System.Runtime.InteropServices;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows; using System.Windows;
@ -17,11 +23,6 @@ using System.Windows.Media.Imaging;
using System.Windows.Navigation; using System.Windows.Navigation;
using System.Windows.Shapes; using System.Windows.Shapes;
using static DyeingComputer.UserClass.SqliteHelper; using static DyeingComputer.UserClass.SqliteHelper;
using DyeingComputer.UserClass;
using LiveChartsCore.Kernel.Sketches;
using LiveChartsCore.Measure;
using ScottPlot.Plottables;
using System.Runtime.InteropServices;
namespace DyeingComputer.View namespace DyeingComputer.View
{ {
@ -38,6 +39,7 @@ namespace DyeingComputer.View
private void UserControl_Loaded(object sender, RoutedEventArgs e) private void UserControl_Loaded(object sender, RoutedEventArgs e)
{ {
} }
} }
} }

8
View/TechnologicalProcessView.xaml.cs

@ -348,10 +348,10 @@ namespace DyeingComputer.View
dr["StepName"] = e.StepNAME; dr["StepName"] = e.StepNAME;
dr["ParameterName"] = e.PNAME; dr["ParameterName"] = e.PNAME;
dr["Parameter1"] = e.Row_DAT.Field<double>("Parameter1"); dr["Parameter1"] = e.Row_DAT.Field<double>("Parameter1");
dr["Parameter2"] = e.Row_DAT.Field<double>("Parameter1"); dr["Parameter2"] = e.Row_DAT.Field<double>("Parameter2");
dr["Parameter3"] = e.Row_DAT.Field<double>("Parameter1"); dr["Parameter3"] = e.Row_DAT.Field<double>("Parameter3");
dr["Parameter4"] = e.Row_DAT.Field<double>("Parameter1"); dr["Parameter4"] = e.Row_DAT.Field<double>("Parameter4");
dr["Parameter5"] = e.Row_DAT.Field<double>("Parameter1"); dr["Parameter5"] = e.Row_DAT.Field<double>("Parameter5");
dr["Parameter1_S1"] = e.Row_DAT.Field<double>("Parameter1_S1"); dr["Parameter1_S1"] = e.Row_DAT.Field<double>("Parameter1_S1");
dr["Parameter2_S1"] = e.Row_DAT.Field<double>("Parameter2_S1"); dr["Parameter2_S1"] = e.Row_DAT.Field<double>("Parameter2_S1");
dr["Parameter3_S1"] = e.Row_DAT.Field<double>("Parameter3_S1"); dr["Parameter3_S1"] = e.Row_DAT.Field<double>("Parameter3_S1");

57
ViewModel/CurveDiagramViewModel.cs

@ -36,6 +36,7 @@ namespace DyeingComputer.ViewModel
CrosshairLabelsBackground = SKColors.DarkGray.AsLvcColor(), CrosshairLabelsBackground = SKColors.DarkGray.AsLvcColor(),
CrosshairLabelsPaint = new SolidColorPaint(SKColors.DarkSlateBlue, 1), CrosshairLabelsPaint = new SolidColorPaint(SKColors.DarkSlateBlue, 1),
CrosshairPaint = new SolidColorPaint(SKColors.DarkSlateGray, 1), CrosshairPaint = new SolidColorPaint(SKColors.DarkSlateGray, 1),
}, },
}; };
//颜色 //颜色
@ -101,11 +102,10 @@ namespace DyeingComputer.ViewModel
CrosshairSnapEnabled = true, CrosshairSnapEnabled = true,
Position = LiveChartsCore.Measure.AxisPosition.End Position = LiveChartsCore.Measure.AxisPosition.End
}, //PH轴 }, //PH轴
//new AnimatableAxisBounds //new AnimatableAxisBounds
}; };
private Random _r = new Random(); //private Random _r = new Random();
private List<DateTimePoint> MTT_values; private List<DateTimePoint> MTT_values;
private List<DateTimePoint> MTL_values; private List<DateTimePoint> MTL_values;
private List<DateTimePoint> MTH_values; private List<DateTimePoint> MTH_values;
@ -193,15 +193,15 @@ namespace DyeingComputer.ViewModel
{ {
new LineSeries<DateTimePoint> new LineSeries<DateTimePoint>
{ {
Name = Properties.Resources.MasterCylinder +"PH", Name = Properties.Resources.MasterCylinder+Properties.Resources.Temperature,
Values = MTH_values, Values = MTT_values,
Stroke = new SolidColorPaint(s_yellow, 2), Stroke = new SolidColorPaint(s_blue, 2),
GeometrySize = 0, GeometrySize = 0,
GeometryStroke = new SolidColorPaint(s_yellow, 2), GeometryStroke = new SolidColorPaint(s_blue, 2),
Fill = null, Fill = null,
LineSmoothness = 0, LineSmoothness = 0,
ScalesYAt = 2, ScalesYAt = 0,
}, //PH }, //主缸
new LineSeries<DateTimePoint> new LineSeries<DateTimePoint>
{ {
Name = Resources.Target + Resources.Temperature, Name = Resources.Target + Resources.Temperature,
@ -215,15 +215,26 @@ namespace DyeingComputer.ViewModel
}, //目标温度 }, //目标温度
new LineSeries<DateTimePoint> new LineSeries<DateTimePoint>
{ {
Name = Properties.Resources.Temperature +"1("+Properties.Resources.MasterCylinder+")", Name =Properties.Resources.MasterCylinder+Properties.Resources.WaterLevel,
Values = MTT_values, Values = MTL_values,
Stroke = new SolidColorPaint(s_blue, 2), Stroke = new SolidColorPaint(s_red, 2),
GeometrySize = 0, GeometrySize = 0,
GeometryStroke = new SolidColorPaint(s_blue, 2), GeometryStroke = new SolidColorPaint(s_red, 2),
Fill = null, Fill = null,
LineSmoothness = 0, LineSmoothness = 0,
ScalesYAt = 0, ScalesYAt = 1,
}, //主缸 }, //主缸液位
new LineSeries<DateTimePoint>
{
Name = Properties.Resources.MasterCylinder +"PH",
Values = MTH_values,
Stroke = new SolidColorPaint(s_yellow, 2),
GeometrySize = 0,
GeometryStroke = new SolidColorPaint(s_yellow, 2),
Fill = null,
LineSmoothness = 0,
ScalesYAt = 2,
}, //PH
/*new LineSeries<DateTimePoint> /*new LineSeries<DateTimePoint>
{ {
Name = Properties.Resources.Temperature +"2("+Properties.Resources.MasterCylinder+Properties.Resources.Bottom+")", Name = Properties.Resources.Temperature +"2("+Properties.Resources.MasterCylinder+Properties.Resources.Bottom+")",
@ -237,7 +248,7 @@ namespace DyeingComputer.ViewModel
}, */ //缸底 }, */ //缸底
new LineSeries<DateTimePoint> new LineSeries<DateTimePoint>
{ {
Name = Properties.Resources.Temperature +"3("+Resources.Medicine + Resources.Tank +"1)", Name = Properties.Resources.Temperature +"("+Resources.Medicine + Resources.Tank +"1)",
Values = STTA_values, Values = STTA_values,
Stroke = new SolidColorPaint(s_blue_1, 2), Stroke = new SolidColorPaint(s_blue_1, 2),
GeometrySize = 0, GeometrySize = 0,
@ -248,7 +259,7 @@ namespace DyeingComputer.ViewModel
}, //附缸1 }, //附缸1
new LineSeries<DateTimePoint> new LineSeries<DateTimePoint>
{ {
Name = Properties.Resources.Temperature +"4("+Resources.Medicine + Resources.Tank +"2)", Name = Properties.Resources.Temperature +"("+Resources.Medicine + Resources.Tank +"2)",
Values = STTB_values, Values = STTB_values,
Stroke = new SolidColorPaint(s_blue_2, 2), Stroke = new SolidColorPaint(s_blue_2, 2),
GeometrySize = 0, GeometrySize = 0,
@ -259,7 +270,7 @@ namespace DyeingComputer.ViewModel
}, //附缸2 }, //附缸2
new LineSeries<DateTimePoint> new LineSeries<DateTimePoint>
{ {
Name = Properties.Resources.Temperature +"5("+Resources.Medicine + Resources.Tank +"3)", Name = Properties.Resources.Temperature +"("+Resources.Medicine + Resources.Tank +"3)",
Values = STTC_values, Values = STTC_values,
Stroke = new SolidColorPaint(s_blue_3, 2), Stroke = new SolidColorPaint(s_blue_3, 2),
GeometrySize = 0, GeometrySize = 0,
@ -269,17 +280,6 @@ namespace DyeingComputer.ViewModel
ScalesYAt = 0, ScalesYAt = 0,
}, //附缸3 }, //附缸3
new LineSeries<DateTimePoint> new LineSeries<DateTimePoint>
{
Name = Properties.Resources.WaterLevel +"("+Properties.Resources.MasterCylinder+")",
Values = MTL_values,
Stroke = new SolidColorPaint(s_red, 2),
GeometrySize = 0,
GeometryStroke = new SolidColorPaint(s_red, 2),
Fill = null,
LineSmoothness = 0,
ScalesYAt = 1,
}, //主缸液位
new LineSeries<DateTimePoint>
{ {
Name = Properties.Resources.WaterLevel +"("+Resources.Medicine + Resources.Tank +"1)", Name = Properties.Resources.WaterLevel +"("+Resources.Medicine + Resources.Tank +"1)",
Values = STLA_values, Values = STLA_values,
@ -313,6 +313,7 @@ namespace DyeingComputer.ViewModel
ScalesYAt = 1, ScalesYAt = 1,
}, //附缸3液位 }, //附缸3液位
}; };
} }
} }
} }

1
ViewModel/MainWindowViewModel.cs

@ -506,7 +506,6 @@ namespace DyeingComputer.ViewModel
if(WORK_RUN !=0) Chart();//写入记录 if(WORK_RUN !=0) Chart();//写入记录
if(!UserButton) TechnologicalProcess_view();//刷新步骤页面 if(!UserButton) TechnologicalProcess_view();//刷新步骤页面
if ((Selet_dtm("1025") > 0) && (Selet_dtd("3021") || Selet_dtd("3022"))) if ((Selet_dtm("1025") > 0) && (Selet_dtd("3021") || Selet_dtd("3022")))
{ {
if (Selet_dtm("1030") == 0) if (Selet_dtm("1030") == 0)

10
Windows/ViewStep.xaml

@ -43,35 +43,35 @@
<TextBox x:Name="P1" HorizontalAlignment="Right" Height="30" Margin="0,120,10,0" <TextBox x:Name="P1" HorizontalAlignment="Right" Height="30" Margin="0,120,10,0"
TextWrapping="Wrap" VerticalAlignment="Top" Width="230" MaxLines="1" ClipToBounds="True" TextWrapping="Wrap" VerticalAlignment="Top" Width="230" MaxLines="1" ClipToBounds="True"
Text="0" PreviewTextInput="Tb_KeyP1" InputMethod.IsInputMethodEnabled="False" Text="0" PreviewTextInput="Tb_KeyP1" InputMethod.IsInputMethodEnabled="False"
FontSize="20" HorizontalContentAlignment="Right" Visibility="Hidden" /> FontSize="20" HorizontalContentAlignment="Right" Visibility="Hidden" TextChanged="P1_TextChanged"/>
<TextBlock x:Name="P2N" HorizontalAlignment="Left" Height="30" Margin="210,155,0,0" <TextBlock x:Name="P2N" HorizontalAlignment="Left" Height="30" Margin="210,155,0,0"
TextWrapping="Wrap" VerticalAlignment="Top" Width="150" FontSize="20" TextWrapping="Wrap" VerticalAlignment="Top" Width="150" FontSize="20"
Background="#FFEFEEEE" Visibility="Hidden"/> Background="#FFEFEEEE" Visibility="Hidden"/>
<TextBox x:Name="P2" HorizontalAlignment="Right" Height="30" Margin="0,155,10,0" <TextBox x:Name="P2" HorizontalAlignment="Right" Height="30" Margin="0,155,10,0"
TextWrapping="Wrap" VerticalAlignment="Top" Width="230" MaxLines="1" ClipToBounds="True" TextWrapping="Wrap" VerticalAlignment="Top" Width="230" MaxLines="1" ClipToBounds="True"
Text="0" PreviewTextInput="Tb_KeyP2" InputMethod.IsInputMethodEnabled="False" Text="0" PreviewTextInput="Tb_KeyP2" InputMethod.IsInputMethodEnabled="False"
FontSize="20" HorizontalContentAlignment="Right" Visibility="Hidden" /> FontSize="20" HorizontalContentAlignment="Right" Visibility="Hidden" TextChanged="P2_TextChanged"/>
<TextBlock x:Name="P3N" HorizontalAlignment="Left" Height="30" Margin="210,190,0,0" <TextBlock x:Name="P3N" HorizontalAlignment="Left" Height="30" Margin="210,190,0,0"
TextWrapping="Wrap" VerticalAlignment="Top" Width="150" FontSize="20" TextWrapping="Wrap" VerticalAlignment="Top" Width="150" FontSize="20"
Background="#FFEFEEEE" Visibility="Hidden"/> Background="#FFEFEEEE" Visibility="Hidden"/>
<TextBox x:Name="P3" HorizontalAlignment="Right" Height="30" Margin="0,190,10,0" <TextBox x:Name="P3" HorizontalAlignment="Right" Height="30" Margin="0,190,10,0"
TextWrapping="Wrap" VerticalAlignment="Top" Width="230" MaxLines="1" ClipToBounds="True" TextWrapping="Wrap" VerticalAlignment="Top" Width="230" MaxLines="1" ClipToBounds="True"
Text="0" PreviewTextInput="Tb_KeyP3" InputMethod.IsInputMethodEnabled="False" Text="0" PreviewTextInput="Tb_KeyP3" InputMethod.IsInputMethodEnabled="False"
FontSize="20" HorizontalContentAlignment="Right" Visibility="Hidden" /> FontSize="20" HorizontalContentAlignment="Right" Visibility="Hidden" TextChanged="P3_TextChanged"/>
<TextBlock x:Name="P4N" HorizontalAlignment="Left" Height="30" Margin="210,225,0,0" <TextBlock x:Name="P4N" HorizontalAlignment="Left" Height="30" Margin="210,225,0,0"
TextWrapping="Wrap" VerticalAlignment="Top" Width="150" FontSize="20" TextWrapping="Wrap" VerticalAlignment="Top" Width="150" FontSize="20"
Background="#FFEFEEEE" Visibility="Hidden"/> Background="#FFEFEEEE" Visibility="Hidden"/>
<TextBox x:Name="P4" HorizontalAlignment="Right" Height="30" Margin="0,225,10,0" <TextBox x:Name="P4" HorizontalAlignment="Right" Height="30" Margin="0,225,10,0"
TextWrapping="Wrap" VerticalAlignment="Top" Width="230" MaxLines="1" ClipToBounds="True" TextWrapping="Wrap" VerticalAlignment="Top" Width="230" MaxLines="1" ClipToBounds="True"
Text="0" PreviewTextInput="Tb_KeyP4" InputMethod.IsInputMethodEnabled="False" Text="0" PreviewTextInput="Tb_KeyP4" InputMethod.IsInputMethodEnabled="False"
FontSize="20" HorizontalContentAlignment="Right" Visibility="Hidden" /> FontSize="20" HorizontalContentAlignment="Right" Visibility="Hidden" TextChanged="P4_TextChanged"/>
<TextBlock x:Name="P5N" HorizontalAlignment="Left" Height="30" Margin="210,260,0,0" <TextBlock x:Name="P5N" HorizontalAlignment="Left" Height="30" Margin="210,260,0,0"
TextWrapping="Wrap" VerticalAlignment="Top" Width="150" FontSize="20" TextWrapping="Wrap" VerticalAlignment="Top" Width="150" FontSize="20"
Background="#FFEFEEEE" Visibility="Hidden"/> Background="#FFEFEEEE" Visibility="Hidden"/>
<TextBox x:Name="P5" HorizontalAlignment="Right" Height="30" Margin="0,260,10,0" <TextBox x:Name="P5" HorizontalAlignment="Right" Height="30" Margin="0,260,10,0"
TextWrapping="Wrap" VerticalAlignment="Top" Width="230" MaxLines="1" ClipToBounds="True" TextWrapping="Wrap" VerticalAlignment="Top" Width="230" MaxLines="1" ClipToBounds="True"
Text="0" PreviewTextInput="Tb_KeyP5" InputMethod.IsInputMethodEnabled="False" Text="0" PreviewTextInput="Tb_KeyP5" InputMethod.IsInputMethodEnabled="False"
FontSize="20" HorizontalContentAlignment="Right" Visibility="Hidden" /> FontSize="20" HorizontalContentAlignment="Right" Visibility="Hidden" TextChanged="P5_TextChanged"/>
</Grid> </Grid>
<Grid Grid.Row="1"> <Grid Grid.Row="1">

61
Windows/ViewStep.xaml.cs

@ -154,6 +154,56 @@ namespace DyeingComputer.Windows
P5P.SelectionStart, e.Text)); P5P.SelectionStart, e.Text));
P5P.Text = P5P.Text.Trim(); P5P.Text = P5P.Text.Trim();
} }
private void P1_TextChanged(object sender, TextChangedEventArgs e)
{
try
{
dat_D.BeginEdit();
dat_D["Parameter1"] = Convert.ToDouble(P1.Text);
dat_D.EndEdit();
}
catch (Exception) { }
}
private void P2_TextChanged(object sender, TextChangedEventArgs e)
{
try
{
dat_D.BeginEdit();
dat_D["Parameter2"] = Convert.ToDouble(P2.Text);
dat_D.EndEdit();
}
catch (Exception) { }
}
private void P3_TextChanged(object sender, TextChangedEventArgs e)
{
try
{
dat_D.BeginEdit();
dat_D["Parameter3"] = Convert.ToDouble(P3.Text);
dat_D.EndEdit();
}
catch (Exception) { }
}
private void P4_TextChanged(object sender, TextChangedEventArgs e)
{
try
{
dat_D.BeginEdit();
dat_D["Parameter4"] = Convert.ToDouble(P4.Text);
dat_D.EndEdit();
}
catch (Exception) { }
}
private void P5_TextChanged(object sender, TextChangedEventArgs e)
{
try
{
dat_D.BeginEdit();
dat_D["Parameter5"] = Convert.ToDouble(P5.Text);
dat_D.EndEdit();
}
catch (Exception) { }
}
private void P1P_TextChanged(object sender, TextChangedEventArgs e) private void P1P_TextChanged(object sender, TextChangedEventArgs e)
{ {
try try
@ -394,6 +444,11 @@ namespace DyeingComputer.Windows
int i = boxID.SelectedIndex; int i = boxID.SelectedIndex;
boxNAME.Text = id_dat.ElementAt(i); boxNAME.Text = id_dat.ElementAt(i);
Set(id_dat[i]); Set(id_dat[i]);
P1.Text.Remove(0);
P2.Text.Remove(0);
P3.Text.Remove(0);
P4.Text.Remove(0);
P5.Text.Remove(0);
} }
} }
private void boxIDp_SelectionChanged(object sender, SelectionChangedEventArgs e) private void boxIDp_SelectionChanged(object sender, SelectionChangedEventArgs e)
@ -422,6 +477,12 @@ namespace DyeingComputer.Windows
} }
dat_D.EndEdit(); dat_D.EndEdit();
} }
P1P.Text.Remove(0);
P2P.Text.Remove(0);
P3P.Text.Remove(0);
P4P.Text.Remove(0);
P5P.Text.Remove(0);
} }
private void YES_Click(object sender, RoutedEventArgs e)//确认 private void YES_Click(object sender, RoutedEventArgs e)//确认
{ {

Loading…
Cancel
Save