sc 12 months ago
parent
commit
d580a70503
  1. 18
      App.xaml
  2. 22
      App.xaml.cs
  3. 175
      MainWindow.xaml
  4. 27
      Properties/Resources.Designer.cs
  5. 9
      Properties/Resources.en-US.resx
  6. 9
      Properties/Resources.resx
  7. 9
      Properties/Resources.zh-CN.resx
  8. 9
      Properties/Resources.zh-TW.resx
  9. 6
      SunlightCentralizedControlManagement_SCCM_.csproj
  10. 54
      View/CurveView.xaml
  11. 11
      View/CurveView.xaml.cs
  12. 7
      View/MonitorView.xaml
  13. 320
      ViewModel/CurveDiagramViewModel.cs
  14. 7
      ViewModel/MainWindowViewModel.cs
  15. 8
      ViewModel/ViewModelLocator.cs

18
App.xaml

@ -4,13 +4,13 @@
xmlns:local="clr-namespace:SunlightCentralizedControlManagement_SCCM_"
StartupUri="MainWindow.xaml">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Light.xaml" />
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesign3.Defaults.xaml" />
<ResourceDictionary Source="pack://application:,,,/MaterialDesignColors;component/Themes/Recommended/Primary/MaterialDesignColor.DeepPurple.xaml" />
<ResourceDictionary Source="pack://application:,,,/MaterialDesignColors;component/Themes/Recommended/Secondary/MaterialDesignColor.Lime.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Light.xaml" />
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesign3.Defaults.xaml" />
<ResourceDictionary Source="pack://application:,,,/MaterialDesignColors;component/Themes/Recommended/Primary/MaterialDesignColor.DeepPurple.xaml" />
<ResourceDictionary Source="pack://application:,,,/MaterialDesignColors;component/Themes/Recommended/Secondary/MaterialDesignColor.Lime.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
</Application>

22
App.xaml.cs

@ -1,4 +1,7 @@
using System;
using LiveChartsCore;
using LiveChartsCore.SkiaSharpView;
using SkiaSharp;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
@ -9,6 +12,7 @@ using System.Reflection;
using System.Runtime.InteropServices;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Markup;
namespace SunlightCentralizedControlManagement_SCCM_
{
@ -47,6 +51,22 @@ namespace SunlightCentralizedControlManagement_SCCM_
return Assembly.Load(assemblyRawBytes);
}
}
protected override void OnStartup(StartupEventArgs e)
{
base.OnStartup(e);
AppDomain.CurrentDomain.AssemblyResolve += OnResolveAssembly;
this.DispatcherUnhandledException += App_DispatcherUnhandledException;
LiveCharts.Configure(config => config.HasGlobalSKTypeface(SKFontManager.Default.MatchCharacter('温')));
LiveCharts.Configure(config => config.HasGlobalSKTypeface(SKFontManager.Default.MatchCharacter('度')));
LiveCharts.Configure(config => config.HasGlobalSKTypeface(SKFontManager.Default.MatchCharacter('水')));
LiveCharts.Configure(config => config.HasGlobalSKTypeface(SKFontManager.Default.MatchCharacter('位')));
LiveCharts.Configure(config => config.HasGlobalSKTypeface(SKFontManager.Default.MatchCharacter('主')));
LiveCharts.Configure(config => config.HasGlobalSKTypeface(SKFontManager.Default.MatchCharacter('附')));
LiveCharts.Configure(config => config.HasGlobalSKTypeface(SKFontManager.Default.MatchCharacter('料')));
LiveCharts.Configure(config => config.HasGlobalSKTypeface(SKFontManager.Default.MatchCharacter('药')));
LiveCharts.Configure(config => config.HasGlobalSKTypeface(SKFontManager.Default.MatchCharacter('缸')));
}
private UserClass.IniFile.IniFiles Configini = new UserClass.IniFile.IniFiles(Convert.ToString(System.AppDomain.CurrentDomain.BaseDirectory) + "SCCM.ini");
public App()

175
MainWindow.xaml

@ -117,180 +117,5 @@
<ContentControl x:Name="Picture"/>
</Grid>
<Grid Background="White" Margin="60,50,0,0" Visibility="Hidden">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<GroupBox>
<GroupBox.Header>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center" >
<materialDesign:PackIcon Kind="Billboard" HorizontalAlignment="Center" VerticalAlignment="Center" Width="18" Height="18" Foreground="White"/>
<TextBlock Text="控件效果1" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="White"/>
</StackPanel>
</GroupBox.Header>
<TabControl>
<TabItem>
<TabItem.Header>
<StackPanel Orientation="Horizontal">
<materialDesign:PackIcon Kind="Tab"/>
<TextBlock Text="选项卡1"/>
</StackPanel>
</TabItem.Header>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="50"/>
<RowDefinition Height="50"/>
<RowDefinition Height="50"/>
<RowDefinition Height="50"/>
<RowDefinition Height="50"/>
<RowDefinition Height="50"/>
<RowDefinition Height="50"/>
<RowDefinition Height="50"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Button HorizontalAlignment="Center" VerticalAlignment="Center" Grid.Row="0" Grid.Column="0">
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center">
<materialDesign:PackIcon Kind="GestureTapButton" HorizontalAlignment="Center" VerticalAlignment="Center" Width="18" Height="18"/>
<TextBlock Text="按钮控件" HorizontalAlignment="Center" VerticalAlignment="Center"/>
</StackPanel>
</Button>
<Button HorizontalAlignment="Center" VerticalAlignment="Center" Grid.Row="0" Grid.Column="1" Background="#FFB821F3" BorderBrush="#FFB821F3">
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center">
<materialDesign:PackIcon Kind="GestureTapButton" HorizontalAlignment="Center" VerticalAlignment="Center" Width="18" Height="18"/>
<TextBlock Text="按钮控件" HorizontalAlignment="Center" VerticalAlignment="Center"/>
</StackPanel>
</Button>
<Button HorizontalAlignment="Center" VerticalAlignment="Center" Grid.Row="0" Grid.Column="2" Background="#FFF39421" BorderBrush="#FFF39421">
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center">
<materialDesign:PackIcon Kind="GestureTapButton" HorizontalAlignment="Center" VerticalAlignment="Center" Width="18" Height="18"/>
<TextBlock Text="按钮控件" HorizontalAlignment="Center" VerticalAlignment="Center"/>
</StackPanel>
</Button>
<Button HorizontalAlignment="Center" VerticalAlignment="Center" Grid.Row="1" Grid.Column="0" Background="{x:Null}" Foreground="#2196F3">
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center">
<materialDesign:PackIcon Kind="GestureTapButton" HorizontalAlignment="Center" VerticalAlignment="Center" Width="18" Height="18"/>
<TextBlock Text="按钮控件" HorizontalAlignment="Center" VerticalAlignment="Center"/>
</StackPanel>
</Button>
<Button HorizontalAlignment="Center" VerticalAlignment="Center" Grid.Row="1" Grid.Column="1" BorderBrush="#FFB821F3" Background="{x:Null}" Foreground="#FFB821F3">
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center">
<materialDesign:PackIcon Kind="GestureTapButton" HorizontalAlignment="Center" VerticalAlignment="Center" Width="18" Height="18"/>
<TextBlock Text="按钮控件" HorizontalAlignment="Center" VerticalAlignment="Center"/>
</StackPanel>
</Button>
<Button HorizontalAlignment="Center" VerticalAlignment="Center" Grid.Row="1" Grid.Column="2" Background="{x:Null}" BorderBrush="#FFF39421" Foreground="#FFF39421">
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center">
<materialDesign:PackIcon Kind="GestureTapButton" HorizontalAlignment="Center" VerticalAlignment="Center" Width="18" Height="18"/>
<TextBlock Text="按钮控件" HorizontalAlignment="Center" VerticalAlignment="Center"/>
</StackPanel>
</Button>
<CheckBox Content="复选框1" Grid.Row="2" Grid.Column="0" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="#2196F3"/>
<CheckBox Content="复选框2" Grid.Row="2" Grid.Column="1" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="#FFB821F3"/>
<CheckBox Content="复选框3" Grid.Row="2" Grid.Column="2" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="#FFF39421"/>
<RadioButton Content="单选框1" Grid.Row="3" Grid.Column="0" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="#2196F3" Cursor=""/>
<RadioButton Content="单选框2" Grid.Row="3" Grid.Column="1" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="#FFB821F3"/>
<RadioButton Content="单选框3" Grid.Row="3" Grid.Column="2" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="#FFF39421"/>
<ComboBox Grid.Row="4" Grid.Column="0" Margin="10,0,10,0" SelectedIndex="0" Foreground="Black" HorizontalContentAlignment="Center" >
<ComboBoxItem Content="下拉选项1"/>
<ComboBoxItem Content="下拉选项2"/>
<ComboBoxItem Content="下拉选项3"/>
<ComboBoxItem Content="下拉选项4"/>
<ComboBoxItem Content="下拉选项5"/>
</ComboBox>
<materialDesign:TimePicker Grid.Row="4" Grid.Column="1" VerticalAlignment="Center" HorizontalAlignment="Center" Width="120" SelectedTime="12:30:30" SelectedTimeFormat="Long" Cursor="" />
<materialDesign:ColorPicker Grid.Row="8" Grid.ColumnSpan="3"/>
<materialDesign:RatingBar Grid.Row="4" Grid.Column="2" HorizontalAlignment="Center" VerticalAlignment="Center" Max="8" Value="5"/>
<materialDesign:Card Grid.Row="5" Background="#2196F3" Foreground="White">
<TextBlock HorizontalAlignment="Center" VerticalAlignment="Center" Text="Card" />
</materialDesign:Card>
<materialDesign:Card Grid.Row="5" Grid.Column="1" Background="#FFB821F3" Foreground="White">
<TextBlock HorizontalAlignment="Center" VerticalAlignment="Center" Text="Card" />
</materialDesign:Card>
<materialDesign:Card Grid.Row="5" Grid.Column="2" Background="#FFF39421" Foreground="White">
<TextBlock HorizontalAlignment="Center" VerticalAlignment="Center" Text="Card" />
</materialDesign:Card>
<Slider Grid.Row="6" VerticalAlignment="Center" Maximum="100" Value="60"/>
<ProgressBar Grid.Row="6" Grid.Column="1" VerticalAlignment="Center" Maximum="100" Value="60" Height="12"/>
<PasswordBox Grid.Row="6" Grid.Column="2" Password="123456" VerticalAlignment="Center" HorizontalContentAlignment="Center" />
<TextBox Grid.Row="7" Grid.Column="0" Text="文本框" VerticalAlignment="Center" HorizontalContentAlignment="Center"/>
<TextBox Grid.Row="7" Grid.Column="1" Text="文本框" VerticalAlignment="Center" HorizontalContentAlignment="Center" IsEnabled="False"/>
<TextBox Grid.Row="7" Grid.Column="3" Text="文本框" VerticalAlignment="Center" HorizontalContentAlignment="Center" MaxLength="36"/>
</Grid>
</TabItem>
<TabItem>
<TabItem.Header>
<StackPanel Orientation="Horizontal">
<materialDesign:PackIcon Kind="Tab"/>
<TextBlock Text="选项卡2"/>
</StackPanel>
</TabItem.Header>
<Grid>
<TextBlock Text="选项卡2" HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Grid>
</TabItem>
</TabControl>
</GroupBox>
<GroupBox Grid.Column="1">
<GroupBox.Header>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center" >
<materialDesign:PackIcon Kind="Billboard" HorizontalAlignment="Center" VerticalAlignment="Center" Width="18" Height="18" Foreground="White"/>
<TextBlock Text="控件效果2" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="White"/>
</StackPanel>
</GroupBox.Header>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="460"/>
<RowDefinition Height="31*"/>
</Grid.RowDefinitions>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Calendar Margin="0,0,0,0" Grid.RowSpan="1" VerticalAlignment="Center" HorizontalAlignment="Center"/>
<materialDesign:Clock Grid.Row="0" Grid.Column="1" HorizontalAlignment="Center" VerticalAlignment="Center" />
<Grid Grid.Column="1">
<Grid.RowDefinitions>
<RowDefinition Height="50"/>
<RowDefinition Height="50"/>
<RowDefinition Height="50"/>
<RowDefinition Height="50"/>
<RowDefinition Height="159*"/>
</Grid.RowDefinitions>
</Grid>
<!--<materialDesign:DialogHost Grid.Column="1" />-->
</Grid>
<DataGrid Grid.Row="1" CanUserAddRows="True">
<DataGrid.Columns>
<materialDesign:DataGridTextColumn Header="编号" Width="*"/>
<DataGridTextColumn Header="姓名" Width="*"/>
<materialDesign:DataGridComboBoxColumn Header="性别" Width="*"/>
<materialDesign:DataGridTextColumn Header="年龄" Width="*"/>
</DataGrid.Columns>
</DataGrid>
</Grid>
</GroupBox>
</Grid>
</Grid>
</Window>

27
Properties/Resources.Designer.cs

@ -501,6 +501,15 @@ namespace SunlightCentralizedControlManagement_SCCM_.Properties {
}
}
/// <summary>
/// 查找类似 Date 的本地化字符串。
/// </summary>
public static string Date {
get {
return ResourceManager.GetString("Date", resourceCulture);
}
}
/// <summary>
/// 查找类似 Delete 的本地化字符串。
/// </summary>
@ -663,6 +672,15 @@ namespace SunlightCentralizedControlManagement_SCCM_.Properties {
}
}
/// <summary>
/// 查找类似 EndDate 的本地化字符串。
/// </summary>
public static string Enddate {
get {
return ResourceManager.GetString("Enddate", resourceCulture);
}
}
/// <summary>
/// 查找类似 EndTime 的本地化字符串。
/// </summary>
@ -2013,6 +2031,15 @@ namespace SunlightCentralizedControlManagement_SCCM_.Properties {
}
}
/// <summary>
/// 查找类似 StartDate 的本地化字符串。
/// </summary>
public static string Startdate {
get {
return ResourceManager.GetString("Startdate", resourceCulture);
}
}
/// <summary>
/// 查找类似 StartTime 的本地化字符串。
/// </summary>

9
Properties/Resources.en-US.resx

@ -897,4 +897,13 @@
<data name="Conveyor" xml:space="preserve">
<value>Conveyor</value>
</data>
<data name="Date" xml:space="preserve">
<value>Date</value>
</data>
<data name="Startdate" xml:space="preserve">
<value>Start Date</value>
</data>
<data name="Enddate" xml:space="preserve">
<value>End Date</value>
</data>
</root>

9
Properties/Resources.resx

@ -897,4 +897,13 @@
<data name="Conveyor" xml:space="preserve">
<value>Conveyor</value>
</data>
<data name="Date" xml:space="preserve">
<value>Date</value>
</data>
<data name="Startdate" xml:space="preserve">
<value>StartDate</value>
</data>
<data name="Enddate" xml:space="preserve">
<value>EndDate</value>
</data>
</root>

9
Properties/Resources.zh-CN.resx

@ -897,4 +897,13 @@
<data name="Conveyor" xml:space="preserve">
<value>输送</value>
</data>
<data name="Date" xml:space="preserve">
<value>日期</value>
</data>
<data name="Startdate" xml:space="preserve">
<value>开始日期</value>
</data>
<data name="Enddate" xml:space="preserve">
<value>结束日期</value>
</data>
</root>

9
Properties/Resources.zh-TW.resx

@ -897,4 +897,13 @@
<data name="Receipt" xml:space="preserve">
<value>單據</value>
</data>
<data name="Date" xml:space="preserve">
<value>日期</value>
</data>
<data name="Startdate" xml:space="preserve">
<value>開始日期</value>
</data>
<data name="Enddate" xml:space="preserve">
<value>結束日期</value>
</data>
</root>

6
SunlightCentralizedControlManagement_SCCM_.csproj

@ -95,6 +95,7 @@
<Compile Include="UserClass\StrToInt.cs" />
<Compile Include="UserClass\SubItem.cs" />
<Compile Include="UserClass\UserControlMenuItem.cs" />
<Compile Include="ViewModel\CurveDiagramViewModel.cs" />
<Compile Include="ViewModel\MainWindowViewModel.cs" />
<Compile Include="ViewModel\ViewModelLocator.cs" />
<Compile Include="View\CurveView.xaml.cs">
@ -236,7 +237,10 @@
<PackageReference Include="CommunityToolkit.Mvvm">
<Version>8.3.2</Version>
</PackageReference>
<PackageReference Include="LiveChartsCore">
<PackageReference Include="LiveChartsCore.SkiaSharpView">
<Version>2.0.0-rc4.5</Version>
</PackageReference>
<PackageReference Include="LiveChartsCore.SkiaSharpView.WPF">
<Version>2.0.0-rc4.5</Version>
</PackageReference>
<PackageReference Include="MaterialDesignThemes">

54
View/CurveView.xaml

@ -3,10 +3,13 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:lvc="clr-namespace:LiveChartsCore.SkiaSharpView.WPF;assembly=LiveChartsCore.SkiaSharpView.WPF"
xmlns:viewmodel="clr-namespace:SunlightCentralizedControlManagement_SCCM_.ViewModel"
xmlns:local="clr-namespace:SunlightCentralizedControlManagement_SCCM_.View"
xmlns:lang="clr-namespace:SunlightCentralizedControlManagement_SCCM_.Properties"
xmlns:lang="clr-namespace:SunlightCentralizedControlManagement_SCCM_.Properties"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
mc:Ignorable="d"
d:DataContext="{d:DesignInstance Type=viewmodel:CurveDiagramViewModel}"
d:DesignHeight="900" d:DesignWidth="1800">
<Grid>
<DataGrid x:Name="Griddata" AlternationCount="2" IsReadOnly="True" SelectionChanged="Griddata_SelectionChanged"
@ -49,5 +52,54 @@
<DataGridTextColumn Header="{x:Static lang:Resources.Machine}" Binding="{Binding Name}" Width="auto" IsReadOnly="True"/>
</DataGrid.Columns>
</DataGrid>
<lvc:CartesianChart x:Name="OscChart" MinWidth="1280" MinHeight="600" EasingFunction="{x:Null}"
Series="{Binding Series}" YAxes="{Binding YAxes}" XAxes="{Binding XAxes}" Margin="300,0,0,50"/>
<StackPanel x:Name="s1cr" VerticalAlignment="Bottom" Height="50" Background="#FF00204E" Orientation="Horizontal" Margin="0,0,0,0">
<materialDesign:PackIcon Kind="DateRange" Width="25" Height="40" Margin="10" VerticalAlignment="Center" Foreground="#FF1368BD"/>
<DatePicker Width="200" Foreground="#FF1368BD" FontSize="20" Height="30" FontWeight="Bold" Padding="1,1,0,1"
>
<DatePicker.Resources>
<Style TargetType="{x:Type DatePickerTextBox}">
<Setter Property="IsReadOnly" Value="True"/>
</Style>
</DatePicker.Resources>
</DatePicker>
<DatePicker Width="200" Foreground="#FF1368BD" FontSize="20"
VerticalAlignment="Center" Height="30" FontWeight="Bold" />
<ListViewItem Height="50" x:Name="Resume">
<StackPanel Orientation="Horizontal" >
<materialDesign:PackIcon Kind="DateRange" Width="25" Height="40" Margin="10" VerticalAlignment="Center" Foreground="#FF1368BD"/>
<TextBlock Text="{x:Static lang:Resources.YES}" VerticalAlignment="Center" Margin="20 10" Foreground="White"/>
</StackPanel>
</ListViewItem>
<ListViewItem Width="150" Height="50" MouseLeftButtonUp="Paused_MouseLeftButtonUp" IsEnabled="False" x:Name="Paused">
<StackPanel Orientation="Horizontal">
<materialDesign:PackIcon Kind="Pause" Width="25" Height="25" Margin="10" VerticalAlignment="Center" Foreground="#FF1368BD"/>
<TextBlock Text="{x:Static lang:Resources.Paused}" VerticalAlignment="Center" Margin="20 10" Foreground="White"/>
</StackPanel>
</ListViewItem>
</StackPanel>
</Grid>
</UserControl>

11
View/CurveView.xaml.cs

@ -24,6 +24,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
public CurveView()
{
InitializeComponent();
DataContext = new CurveDiagramViewModel();
Griddata.ItemsSource = MainWindowViewModel.Machines.DefaultView;
}
@ -32,5 +33,15 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
{
}
private void Resume_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
{
}
private void Paused_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
{
}
}
}

7
View/MonitorView.xaml

@ -3,9 +3,9 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:SunlightCentralizedControlManagement_SCCM_.View"
xmlns:lang="clr-namespace:SunlightCentralizedControlManagement_SCCM_.Properties"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
xmlns:local="clr-namespace:SunlightCentralizedControlManagement_SCCM_.View"
xmlns:lang="clr-namespace:SunlightCentralizedControlManagement_SCCM_.Properties"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
mc:Ignorable="d"
d:DesignHeight="1000" d:DesignWidth="1900">
<Grid>
@ -132,7 +132,6 @@
</StackPanel>
</ListViewItem>
</StackPanel>
<StackPanel x:Name="scr" VerticalAlignment="Bottom" Height="50" Background="#FF00204E" Orientation="Horizontal" Margin="700,0,0,0">
<ListViewItem Width="150" Height="50" MouseLeftButtonUp="ListViewItem_Resume" IsEnabled="False" x:Name="Resume">
<StackPanel Orientation="Horizontal" >

320
ViewModel/CurveDiagramViewModel.cs

@ -0,0 +1,320 @@
using LiveChartsCore.SkiaSharpView;
using LiveChartsCore;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using CommunityToolkit.Mvvm.ComponentModel;
using LiveChartsCore.Kernel.Sketches;
using LiveChartsCore.SkiaSharpView.Painting;
using ScottPlot.Colormaps;
using System.Drawing;
using System.Windows.Media.TextFormatting;
using System.Xml.Linq;
using SkiaSharp;
using LiveChartsCore.Defaults;
using static System.Net.WebRequestMethods;
using System.Collections.ObjectModel;
using DyeingComputer.Properties;
using LiveChartsCore.Measure;
using LiveChartsCore.Motion;
using SunlightCentralizedControlManagement_SCCM_.Properties;
using static SunlightCentralizedControlManagement_SCCM_.UserClass.SqliteHelper;
using TouchSocket.Core;
namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
{
public partial class CurveDiagramViewModel : ObservableObject//ViewModelBase
{
public ISeries[] Series { get; set; }
//x轴时间格式
public Axis[] XAxes { get; set; } =
{
new DateTimeAxis(TimeSpan.FromSeconds(5) , date => date.ToString("yyyy-MM-dd HH:mm"))
{
CrosshairLabelsBackground = SKColors.DarkGray.AsLvcColor(),
CrosshairLabelsPaint = new SolidColorPaint(SKColors.DarkSlateBlue, 1),
CrosshairPaint = new SolidColorPaint(SKColors.DarkSlateGray, 1),
},
};
//颜色
private static readonly SKColor s_blue = new SKColor(25, 118, 210);
private static readonly SKColor s_blue_0 = new SKColor(25, 18, 210);
private static readonly SKColor s_blue_1 = new SKColor(25, 118, 170);
private static readonly SKColor s_blue_2 = new SKColor(25, 118, 130);
private static readonly SKColor s_blue_3 = new SKColor(25, 118, 90);
private static readonly SKColor s_blue_4 = new SKColor(25, 118, 50);
private static readonly SKColor s_red = new SKColor(229, 57, 53);
private static readonly SKColor s_red_1 = new SKColor(189, 57, 53);
private static readonly SKColor s_red_2 = new SKColor(149, 57, 53);
private static readonly SKColor s_red_3 = new SKColor(109, 57, 53);
private static readonly SKColor s_yellow = new SKColor(198, 167, 0);
public ICartesianAxis[] YAxes { get; set; } ={
new Axis //y在此轴上缩放
{
MinLimit =0,
MaxLimit =150,
Name = Properties.Resources.Temperature +" ( °C )",
NameTextSize = 24,
NamePaint = new SolidColorPaint(s_blue),
NamePadding = new LiveChartsCore.Drawing.Padding(0, 20),
Padding = new LiveChartsCore.Drawing.Padding(0, 0, 20, 0),
TextSize = 16,
LabelsPaint = new SolidColorPaint(s_blue),
TicksPaint = new SolidColorPaint(s_blue),
SubticksPaint = new SolidColorPaint(s_blue),
DrawTicksPath = true,
CrosshairSnapEnabled = true,
Position = LiveChartsCore.Measure.AxisPosition.Start
},//温度轴
new Axis // the "hundreds" series will be scaled on this axis
{
MinLimit =0,
Name = Properties.Resources.WaterLevel +" ( L )",
NameTextSize = 24,
NamePaint = new SolidColorPaint(s_red),
NamePadding = new LiveChartsCore.Drawing.Padding(0, 20),
Padding = new LiveChartsCore.Drawing.Padding(20, 0, 0, 0),
TextSize = 16,
LabelsPaint = new SolidColorPaint(s_red),
TicksPaint = new SolidColorPaint(s_red),
SubticksPaint = new SolidColorPaint(s_red),
DrawTicksPath = true,
CrosshairSnapEnabled = true,
Position = LiveChartsCore.Measure.AxisPosition.End
}, //液位轴
new Axis //
{
MinLimit =0,
MaxLimit =14,
Name = "PH ( pH )",
NameTextSize = 16,
NamePaint = new SolidColorPaint(s_yellow),
NamePadding = new LiveChartsCore.Drawing.Padding(0, 20),
Padding = new LiveChartsCore.Drawing.Padding(20, 0, 0, 0),
TextSize = 16,
LabelsPaint = new SolidColorPaint(s_yellow),
TicksPaint = new SolidColorPaint(s_yellow),
SubticksPaint = new SolidColorPaint(s_yellow),
DrawTicksPath = true,
CrosshairSnapEnabled = true,
Position = LiveChartsCore.Measure.AxisPosition.End
}, //PH轴
//new AnimatableAxisBounds
};
private readonly Random _r = new Random();
private readonly ObservableCollection<DateTimePoint> MTT_values;
private readonly ObservableCollection<DateTimePoint> MTL_values;
private readonly ObservableCollection<DateTimePoint> MTH_values;
private readonly ObservableCollection<DateTimePoint> MST_values;
private readonly ObservableCollection<DateTimePoint> MUT_values;
private readonly ObservableCollection<DateTimePoint> STTA_values;
private readonly ObservableCollection<DateTimePoint> STLA_values;
private readonly ObservableCollection<DateTimePoint> STTB_values;
private readonly ObservableCollection<DateTimePoint> STLB_values;
private readonly ObservableCollection<DateTimePoint> STTC_values;
private readonly ObservableCollection<DateTimePoint> STLC_values;
private SQLiteHelper SQLiteHelpers = null; //定义数据库
private readonly string ChartAdress = Environment.CurrentDirectory + "\\DataBase\\Chart.db"; //数据库路径
DataTable CDB = new DataTable();
private int CDB_Count;//长度
public CurveDiagramViewModel()
{
if (!string.IsNullOrEmpty(MainWindowViewModel.SYS_WorkNumder))
{
SQLiteHelpers = new SQLiteHelper(ChartAdress); //数据库连接路径
SQLiteHelpers.Open(); //打开数据库
CDB = SQLiteHelpers.ExecuteDataSet("select * from Chart where DYELOT = '" + MainWindowViewModel.SYS_WorkNumder + "'order by Time", null).Tables[0];
SQLiteHelpers.Close();
CDB_Count = CDB.Rows.Count;
var MTT_items = new List<DateTimePoint>();
var MTL_items = new List<DateTimePoint>();
var MTH_items = new List<DateTimePoint>();
var MST_items = new List<DateTimePoint>();
var MUT_items = new List<DateTimePoint>();
var STTA_items = new List<DateTimePoint>();
var STLA_items = new List<DateTimePoint>();
var STTB_items = new List<DateTimePoint>();
var STLB_items = new List<DateTimePoint>();
var STTC_items = new List<DateTimePoint>();
var STLC_items = new List<DateTimePoint>();
for (var i = 0; i < CDB_Count; i++)
{
DateTime TIME = Convert.ToDateTime(CDB.Rows[i].Field<string>("Time"));
MTT_items.Add(new DateTimePoint(TIME, CDB.Rows[i].Field<double>("MTT")));
MTL_items.Add(new DateTimePoint(TIME, CDB.Rows[i].Field<double>("MTL")));
MTH_items.Add(new DateTimePoint(TIME, CDB.Rows[i].Field<double>("MTH")));
MST_items.Add(new DateTimePoint(TIME, CDB.Rows[i].Field<double>("MST")));
MUT_items.Add(new DateTimePoint(TIME, CDB.Rows[i].Field<double>("MUT")));
if (MainWindowViewModel.SYS_AT1 == 1)
{
STTA_items.Add(new DateTimePoint(TIME, CDB.Rows[i].Field<double>("STTA")));
STLA_items.Add(new DateTimePoint(TIME, CDB.Rows[i].Field<double>("STLA")));
}
if (MainWindowViewModel.SYS_AT2 == 1)
{
STTB_items.Add(new DateTimePoint(TIME, CDB.Rows[i].Field<double>("STTB")));
STLB_items.Add(new DateTimePoint(TIME, CDB.Rows[i].Field<double>("STLB")));
}
if (MainWindowViewModel.SYS_AT3 == 1)
{
STTC_items.Add(new DateTimePoint(TIME, CDB.Rows[i].Field<double>("STTC")));
STLC_items.Add(new DateTimePoint(TIME, CDB.Rows[i].Field<double>("STLC")));
}
}
MTT_values = new ObservableCollection<DateTimePoint>(MTT_items);
MTL_values = new ObservableCollection<DateTimePoint>(MTL_items);
MTH_values = new ObservableCollection<DateTimePoint>(MTH_items);
MST_values = new ObservableCollection<DateTimePoint>(MST_items);
MUT_values = new ObservableCollection<DateTimePoint>(MUT_items);
if (MainWindowViewModel.SYS_AT1 == 1)
{
STTA_values = new ObservableCollection<DateTimePoint>(STTA_items);
STLA_values = new ObservableCollection<DateTimePoint>(STLA_items);
}
if (MainWindowViewModel.SYS_AT2 == 1)
{
STTB_values = new ObservableCollection<DateTimePoint>(STTB_items);
STLB_values = new ObservableCollection<DateTimePoint>(STLB_items);
}
if (MainWindowViewModel.SYS_AT3 == 1)
{
STTC_values = new ObservableCollection<DateTimePoint>(STTC_items);
STLC_values = new ObservableCollection<DateTimePoint>(STLC_items);
}
Series = new ISeries[]
{
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>
{
Name = Resources.Target + Resources.Temperature,
Values = MST_values,
Stroke = new SolidColorPaint(s_blue_0, 2),
GeometrySize = 0,
GeometryStroke = new SolidColorPaint(s_blue_0, 2),
Fill = null,
LineSmoothness = 0,
ScalesYAt = 0,
}, //目标温度
new LineSeries<DateTimePoint>
{
Name = Properties.Resources.Temperature +"1("+Properties.Resources.MasterCylinder+")",
Values = MTT_values,
Stroke = new SolidColorPaint(s_blue, 2),
GeometrySize = 0,
GeometryStroke = new SolidColorPaint(s_blue, 2),
Fill = null,
LineSmoothness = 0,
ScalesYAt = 0,
}, //主缸
new LineSeries<DateTimePoint>
{
Name = Properties.Resources.Temperature +"2("+Properties.Resources.MasterCylinder+Properties.Resources.Bottom+")",
Values = MUT_values,
Stroke = new SolidColorPaint(s_blue_4, 2),
GeometrySize = 0,
GeometryStroke = new SolidColorPaint(s_blue_4, 2),
Fill = null,
LineSmoothness = 0,
ScalesYAt = 0,
}, //缸底
new LineSeries<DateTimePoint>
{
Name = Properties.Resources.Temperature +"3("+Resources.Medicine + Resources.Tank +"1)",
Values = STTA_values,
Stroke = new SolidColorPaint(s_blue_1, 2),
GeometrySize = 0,
GeometryStroke = new SolidColorPaint(s_blue_1, 2),
Fill = null,
LineSmoothness = 0,
ScalesYAt = 0,
}, //附缸1
new LineSeries<DateTimePoint>
{
Name = Properties.Resources.Temperature +"4("+Resources.Medicine + Resources.Tank +"2)",
Values = STTB_values,
Stroke = new SolidColorPaint(s_blue_2, 2),
GeometrySize = 0,
GeometryStroke = new SolidColorPaint(s_blue_2, 2),
Fill = null,
LineSmoothness = 0,
ScalesYAt = 0,
}, //附缸2
new LineSeries<DateTimePoint>
{
Name = Properties.Resources.Temperature +"5("+Resources.Medicine + Resources.Tank +"3)",
Values = STTC_values,
Stroke = new SolidColorPaint(s_blue_3, 2),
GeometrySize = 0,
GeometryStroke = new SolidColorPaint(s_blue_3, 2),
Fill = null,
LineSmoothness = 0,
ScalesYAt = 0,
}, //附缸3
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)",
Values = STLA_values,
Stroke = new SolidColorPaint(s_red_1, 2),
GeometrySize = 0,
GeometryStroke = new SolidColorPaint(s_red_1, 2),
Fill = null,
LineSmoothness = 0,
ScalesYAt = 1,
}, //附缸1液位
new LineSeries<DateTimePoint>
{
Name = Properties.Resources.WaterLevel +"("+Resources.Medicine + Resources.Tank +"2)",
Values = STLB_values,
Stroke = new SolidColorPaint(s_red_2, 2),
GeometrySize = 0,
GeometryStroke = new SolidColorPaint(s_red_2, 2),
Fill = null,
LineSmoothness = 0,
ScalesYAt = 1,
}, //附缸2液位
new LineSeries<DateTimePoint>
{
Name = Properties.Resources.WaterLevel +"("+Resources.Medicine + Resources.Tank +"3)",
Values = STLC_values,
Stroke = new SolidColorPaint(s_red_3, 2),
GeometrySize = 0,
GeometryStroke = new SolidColorPaint(s_red_3, 2),
Fill = null,
LineSmoothness = 0,
ScalesYAt = 1,
}, //附缸3 液位
};
}
}
}
}

7
ViewModel/MainWindowViewModel.cs

@ -77,7 +77,6 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
{
}
private SQLiteHelper SQLiteHelpers = null; //定义数据库
private readonly string DBAddress = Environment.CurrentDirectory + "\\DataBase\\SCCM.db"; //数据库路径
public static DataTable Machines = new DataTable(); //设备表缓存
@ -92,8 +91,10 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
CountDown();
}
public static string SYS_WorkNumder = "738891980000"; //工单号
public static int SYS_AT1; //附缸1-3
public static int SYS_AT2;
public static int SYS_AT3;

8
ViewModel/ViewModelLocator.cs

@ -23,5 +23,13 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
return ServiceLocator.Current.GetInstance<MainWindowViewModel>();
}
}
public CurveDiagramViewModel Curve
{
get
{
return ServiceLocator.Current.GetInstance<CurveDiagramViewModel>();
}
}
}
}

Loading…
Cancel
Save