You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
132 lines
5.3 KiB
132 lines
5.3 KiB
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;
|
|
using System.ComponentModel;
|
|
using System.Runtime.CompilerServices;
|
|
using System.Windows;
|
|
using SunlightCentralizedControlManagement_SCCM_.View;
|
|
|
|
namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
|
|
{
|
|
public partial class CurveTempModel : ObservableObject//ViewModelBase
|
|
{
|
|
public static ISeries[] Series { get; set; }
|
|
public static ObservableCollection<ObservableValue> ObservableValues { get; set; }
|
|
//x轴时间格式
|
|
public Axis[] XAxes { get; set; } =
|
|
{
|
|
new DateTimeAxis(TimeSpan.FromSeconds(5) , date => date.ToString("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 =160,
|
|
Name = Properties.Resources.Temperature +" ( °C )",
|
|
NameTextSize = 15,
|
|
NamePaint = new SolidColorPaint(s_blue),
|
|
NamePadding = new LiveChartsCore.Drawing.Padding(0, 20),
|
|
Padding = new LiveChartsCore.Drawing.Padding(0, 0, 20, 0),
|
|
TextSize = 12,
|
|
LabelsPaint = new SolidColorPaint(s_blue),
|
|
TicksPaint = new SolidColorPaint(s_blue),
|
|
SubticksPaint = new SolidColorPaint(s_blue),
|
|
DrawTicksPath = true,
|
|
CrosshairSnapEnabled = true,
|
|
Position = LiveChartsCore.Measure.AxisPosition.Start
|
|
},//温度轴
|
|
|
|
};
|
|
|
|
private static Random _r = new Random();
|
|
private static ObservableCollection<DateTimePoint> MST_values;
|
|
static DataTable CDB = new DataTable();
|
|
private static int CDB_Count;//长度
|
|
|
|
public CurveTempModel()
|
|
{
|
|
CDB = View.CurveTemp.dataTable;
|
|
Curve();
|
|
}
|
|
public static void Curve()
|
|
{
|
|
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"));
|
|
MST_items.Add(new DateTimePoint(TIME, CDB.Rows[i].Field<double>("MST")));
|
|
}
|
|
|
|
MST_values = new ObservableCollection<DateTimePoint>(MST_items);
|
|
|
|
Series = new ISeries[]
|
|
{
|
|
|
|
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,
|
|
}, //目标温度
|
|
|
|
};
|
|
|
|
|
|
}
|
|
}
|
|
}
|
|
|