Commit 70d4619c authored by 潘栩锋's avatar 潘栩锋 🚴

修改 机架调试界面,修复XY轴缩放到单位=1时,会异常崩溃。

parent e70a5725
...@@ -170,6 +170,9 @@ ...@@ -170,6 +170,9 @@
<Compile Include="PgGetSample.xaml.cs"> <Compile Include="PgGetSample.xaml.cs">
<DependentUpon>PgGetSample.xaml</DependentUpon> <DependentUpon>PgGetSample.xaml</DependentUpon>
</Compile> </Compile>
<Compile Include="PgGrid.xaml.cs">
<DependentUpon>PgGrid.xaml</DependentUpon>
</Compile>
<Compile Include="PgInitparam.xaml.cs"> <Compile Include="PgInitparam.xaml.cs">
<DependentUpon>PgInitparam.xaml</DependentUpon> <DependentUpon>PgInitparam.xaml</DependentUpon>
</Compile> </Compile>
...@@ -195,14 +198,6 @@ ...@@ -195,14 +198,6 @@
<Compile Include="PgError\WdIOTip.xaml.cs"> <Compile Include="PgError\WdIOTip.xaml.cs">
<DependentUpon>WdIOTip.xaml</DependentUpon> <DependentUpon>WdIOTip.xaml</DependentUpon>
</Compile> </Compile>
<Compile Include="PgGrid\IPgGridVm.cs" />
<Compile Include="PgGrid\PgGrid.xaml.cs">
<DependentUpon>PgGrid.xaml</DependentUpon>
</Compile>
<Compile Include="PgGrid\PgGridVm.cs" />
<Compile Include="PgGrid\PgGridVmUt.cs" />
<Compile Include="PgGrid\PgGridXlsxOutput.cs" />
<Compile Include="PgGrid\SeriesInfo.cs" />
<Compile Include="PgPwManager.xaml.cs"> <Compile Include="PgPwManager.xaml.cs">
<DependentUpon>PgPwManager.xaml</DependentUpon> <DependentUpon>PgPwManager.xaml</DependentUpon>
</Compile> </Compile>
...@@ -276,6 +271,7 @@ ...@@ -276,6 +271,7 @@
<Compile Include="WdThickScale.xaml.cs"> <Compile Include="WdThickScale.xaml.cs">
<DependentUpon>WdThickScale.xaml</DependentUpon> <DependentUpon>WdThickScale.xaml</DependentUpon>
</Compile> </Compile>
<Compile Include="XYRangeSlider.cs" />
<Page Include="App.xaml"> <Page Include="App.xaml">
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType> <SubType>Designer</SubType>
...@@ -348,6 +344,10 @@ ...@@ -348,6 +344,10 @@
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType> <SubType>Designer</SubType>
</Page> </Page>
<Page Include="PgGrid.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="PgInitparam.xaml"> <Page Include="PgInitparam.xaml">
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
...@@ -380,14 +380,6 @@ ...@@ -380,14 +380,6 @@
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType> <SubType>Designer</SubType>
</Page> </Page>
<Page Include="PgGrid\PgGrid.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="PgGrid\PgGridStyle.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="PgPwManager.xaml"> <Page Include="PgPwManager.xaml">
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
......
This diff is collapsed.
This diff is collapsed.
using CommunityToolkit.Mvvm.Input;
using LiveCharts;
using System;
using System.Collections.ObjectModel;
using System.ComponentModel;
namespace FLY.Thick.Base.UI
{
/// <summary>
///
/// </summary>
interface IPgGridVm : INotifyPropertyChanged
{
/// <summary>
/// 目标位置 单位:脉冲
/// </summary>
int TargetPos { get; set; }
/// <summary>
/// 目标位置 单位:mm
/// </summary>
double TargetMm { get; }
/// <summary>
/// AD值模式
/// </summary>
bool IsADMode { get; set; }
/// <summary>
/// 最多6条曲线
/// </summary>
ObservableCollection<SeriesInfo> SeriesInfos { get; }
#region 曲线
Func<double, string> XFormatter { get; }
Func<double, string> YFormatter { get; }
double XUpper { get; set; }
double XLower { get; set; }
double YUpper { get; set; }
double YLower { get; set; }
double XMax { get; }
double XMin { get; }
double YMax { get; }
double YMin { get; }
double SectionValue { get; }
double SectionWidth { get; }
SeriesCollection Series { get; }
#endregion
#region 测量
/// <summary>
/// 测量开始位置 单位:脉冲
/// </summary>
int MeasureValuePos { get; set; }
/// <summary>
/// 测量开始位置 单位:mm
/// </summary>
double MeasureValueMm { get; }
/// <summary>
/// 测量宽度 单位:脉冲
/// </summary>
int MeasureWidthPos { get; set; }
/// <summary>
/// 测量宽度 单位:mm
/// </summary>
double MeasureWidthMm { get; }
#endregion
#region command
RelayCommand RunToCmd { get; }
RelayCommand GetFDataCmd { get; }
RelayCommand GetBDataCmd { get; }
RelayCommand ClearCmd { get; }
RelayCommand MeasureCmd { get; }
RelayCommand SaveCmd { get; }
RelayCommand<SeriesInfo> SelectCmd { get; }
#endregion
#region 输出使用
int PosOfGrid { get; }
double Mmpp { get; }
#endregion
}
}
using FLY.Thick.Base.IService;
using LiveCharts;
using LiveCharts.Helpers;
using LiveCharts.Wpf;
using System;
using System.Linq;
using System.Windows.Controls;
using System.Windows.Input;
using Unity;
namespace FLY.Thick.Base.UI
{
/// <summary>
/// PgGrid.xaml 的交互逻辑
/// </summary>
public partial class PgGrid : Page
{
PgGridVm viewModel;
/// <summary>
///
/// </summary>
public PgGrid()
{
InitializeComponent();
InitializeChart();
}
void InitializeChart()
{
//写在xaml ,设计模式会引发 最大值最小值=0 异常, 所以用代码方式编写
//
//异常内容:
//LiveChartsException: One axis has an invalid range, it is or it tends to zero, please ensure your axis has a valid range
var axis = chart1.AxisX[0];
axis.SetBinding(LiveCharts.Wpf.Axis.LabelFormatterProperty, nameof(PgGridVm.XFormatter));
axis.SetBinding(LiveCharts.Wpf.Axis.MaxValueProperty, nameof(PgGridVm.XUpper));
axis.SetBinding(LiveCharts.Wpf.Axis.MinValueProperty, nameof(PgGridVm.XLower));
axis = chart1.AxisY[0];
axis.SetBinding(LiveCharts.Wpf.Axis.LabelFormatterProperty, nameof(PgGridVm.YFormatter));
axis.SetBinding(LiveCharts.Wpf.Axis.MaxValueProperty, nameof(PgGridVm.YUpper));
axis.SetBinding(LiveCharts.Wpf.Axis.MinValueProperty, nameof(PgGridVm.YLower));
}
/// <summary>
/// 初始化
/// </summary>
/// <param name="container"></param>
/// <param name="initParam"></param>
/// <param name="gageService"></param>
/// <param name="flyADService"></param>
[InjectionMethod]
public void Init(
IUnityContainer container,
IInitParamService initParam,
ITDGageService gageService,
IFlyADService flyADService
)
{
viewModel = new PgGridVm();
viewModel.Init(initParam, gageService, flyADService);
this.DataContext = viewModel;
container.BuildUp(mircoGage);
}
private void UIElement_OnMouseMove(object sender, MouseEventArgs e)
{
if (!isDown)
return;
var vm = viewModel;
var series = vm.SeriesInfos.First(info => info.IsSelected).Series;
var chart = (LiveCharts.Wpf.CartesianChart)sender;
//lets get where the mouse is at our chart
var mouseCoordinate = e.GetPosition(chart);
//now that we know where the mouse is, lets use
//ConverToChartValues extension
//it takes a point in pixes and scales it to our chart current scale/values
var p = chart.ConvertToChartValues(mouseCoordinate);
//var series = chart.Series[0];
var closetsPoint = series.ClosestPointTo(p.X, AxisOrientation.X);
if (closetsPoint == null)
return;
xEnd = closetsPoint.X;
vm.MeasureValuePos = (int)(Math.Min(xBegin, xEnd) * vm.PosOfGrid);
vm.MeasureWidthPos = (int)((Math.Abs(xEnd - xBegin) + 1) * vm.PosOfGrid);
}
private double xBegin;
private double xEnd;
private bool isDown = false;
private void UIElement_MouseDown(object sender, MouseButtonEventArgs e)
{
isDown = true;
var vm = viewModel;
var series = vm.SeriesInfos.First(info => info.IsSelected).Series;
var chart = (LiveCharts.Wpf.CartesianChart)sender;
var mouseCoordinate = e.GetPosition(chart);
var p = chart.ConvertToChartValues(mouseCoordinate);
//var series = chart.Series[0];
var closetsPoint = series.ClosestPointTo(p.X, AxisOrientation.X);
if (closetsPoint == null)
{
isDown = false;
return;
}
xBegin = closetsPoint.X;
vm.MeasureValuePos = (int)(xBegin * vm.PosOfGrid);
}
private void UIElement_MouseUp(object sender, MouseButtonEventArgs e)
{
isDown = false;
var vm = viewModel;
var series = vm.SeriesInfos.First(info => info.IsSelected).Series;
var chart = (LiveCharts.Wpf.CartesianChart)sender;
//lets get where the mouse is at our chart
var mouseCoordinate = e.GetPosition(chart);
//now that we know where the mouse is, lets use
//ConverToChartValues extension
//it takes a point in pixes and scales it to our chart current scale/values
var p = chart.ConvertToChartValues(mouseCoordinate);
//for X in this case we will only highlight the closest point.
//lets use the already defined ClosestPointTo extension
//it will return the closest ChartPoint to a value according to an axis.
//here we get the closest point to p.X according to the X axis
//var series = chart.Series[0];
var closetsPoint = series.ClosestPointTo(p.X, AxisOrientation.X);
if (closetsPoint == null)
return;
xEnd = closetsPoint.X;
vm.MeasureValuePos = (int)(Math.Min(xBegin, xEnd) * vm.PosOfGrid);
vm.MeasureWidthPos = (int)((Math.Abs(xEnd - xBegin) + 1) * vm.PosOfGrid);
}
}
}
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:lvc="clr-namespace:LiveCharts.Wpf;assembly=LiveCharts.Wpf"
xmlns:local="clr-namespace:FLY.Thick.Base.UI"
xmlns:iconPacks="http://metro.mahapps.com/winfx/xaml/iconpacks">
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/FLY.Thick.Base.UI;component/Themes/Styles.xaml"/>
<ResourceDictionary Source="pack://application:,,,/FLY.Thick.Base.UI;component/Converter/Dictionary_MyConv.xaml"/>
</ResourceDictionary.MergedDictionaries>
<!--<Style x:Key="Styles.Card.Title" TargetType="TextBlock">
<Setter Property="Background" Value="#FFC107"/>
<Setter Property="FontSize" Value="18"/>
<Setter Property="HorizontalAlignment" Value="Right"/>
<Setter Property="Padding" Value="20 5"/>
<Setter Property="FontWeight" Value="Bold"/>
</Style>
<Style x:Key="Styles.Card.Border" TargetType="Border">
<Setter Property="Margin" Value="5"/>
<Setter Property="Background" Value="{StaticResource MahApps.Brushes.ThemeBackground}"/>
<Setter Property="CornerRadius" Value="3"/>
<Setter Property="Padding" Value="8"/>
<Setter Property="BorderThickness" Value="1"/>
<Setter Property="BorderBrush" Value="{StaticResource MahApps.Brushes.Gray8}"/>
<Setter Property="Effect">
<Setter.Value>
<DropShadowEffect Color="{StaticResource MahApps.Brushes.Gray1}" Opacity=".25" BlurRadius="5" ShadowDepth="3"/>
</Setter.Value>
</Setter>
</Style>-->
<Style x:Key="Styles.Axis.Section" TargetType="lvc:AxisSection" >
<Setter Property="StrokeThickness" Value="1"/>
<Setter Property="DataLabel" Value="False"/>
<Setter Property="DisableAnimations" Value="True"/>
<Setter Property="DataLabelForeground" Value="White"/>
<Setter Property="Opacity" Value="0.1"/>
<Setter Property="Stroke" Value="#FFFDC8C8"/>
<Setter Property="Fill" Value="#59F7D8D8"/>
<!--<Setter Property="Fill" Value="Orange" />-->
</Style>
<Style TargetType="{x:Type ToggleButton}" x:Key="Styles.ToggleButton.Check" >
<Setter Property="HorizontalContentAlignment" Value="Center"/>
<Setter Property="VerticalContentAlignment" Value="Center"/>
<Setter Property="Padding" Value="1"/>
<Setter Property="Background" Value="Transparent"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ToggleButton}">
<Border Background="{TemplateBinding Background}" CornerRadius="2" >
<iconPacks:PackIconMaterial x:Name="icon" Kind="CheckboxBlankOutline" Height="{TemplateBinding Height}" Width="{TemplateBinding Width}" />
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsChecked" Value="True">
<Setter TargetName="icon" Property="Kind" Value="CheckboxMarkedOutline"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>
\ No newline at end of file
using CommunityToolkit.Mvvm.Input;
using LiveCharts;
using LiveCharts.Wpf;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;
using System.Windows.Media;
namespace FLY.Thick.Base.UI
{
class PgGridVmUt : IPgGridVm
{
public event PropertyChangedEventHandler PropertyChanged;
#region IPgGridVm Property
/// <summary>
/// 目标位置 单位:脉冲
/// </summary>
public int TargetPos { get; set; }
/// <summary>
/// 目标位置 单位:mm
/// </summary>
public double TargetMm => TargetPos * Mmpp;
/// <summary>
/// AD值模式
/// </summary>
public bool IsADMode { get; set; }
/// <summary>
/// 最多6条曲线
/// </summary>
public ObservableCollection<SeriesInfo> SeriesInfos { get; } = new ObservableCollection<SeriesInfo>();
#region 曲线
public Func<double, string> XFormatter { get; private set; }
public Func<double, string> YFormatter { get; private set; }
public double XUpper { get; set; } = 1024;
public double XLower { get; set; } = 0;
public double YUpper { get; set; } = double.NaN;
public double YLower { get; set; } = double.NaN;
public double XMax { get; private set; } = 1024;
public double XMin { get; private set; } = 0;
public double YMax { get; private set; } = double.NaN;
public double YMin { get; private set; } = double.NaN;
public double SectionValue => MeasureValuePos / PosOfGrid;
public double SectionWidth => MeasureWidthPos / PosOfGrid;
public SeriesCollection Series { get; } = new SeriesCollection();
#endregion
#region 测量
/// <summary>
/// 测量开始位置 单位:脉冲
/// </summary>
public int MeasureValuePos { get; set; }
/// <summary>
/// 测量开始位置 单位:mm
/// </summary>
public double MeasureValueMm => MeasureValuePos * Mmpp;
/// <summary>
/// 测量宽度 单位:脉冲
/// </summary>
public int MeasureWidthPos { get; set; }
/// <summary>
/// 测量宽度 单位:mm
/// </summary>
public double MeasureWidthMm => MeasureWidthPos * Mmpp;
#endregion
#endregion
#region command
public RelayCommand RunToCmd { get; }
public RelayCommand GetFDataCmd { get; }
public RelayCommand GetBDataCmd { get; }
public RelayCommand ClearCmd { get; }
public RelayCommand MeasureCmd { get; }
public RelayCommand SaveCmd { get; }
public RelayCommand<SeriesInfo> SelectCmd { get; }
#endregion
public int PosOfGrid { get; set; } = 10;
public double Mmpp { get; set; } = 0.1;
public PgGridVmUt()
{
#region 与数据无关界面参数
XFormatter = (x) =>
{
int index = (int)x;
int pos = index * PosOfGrid;
int mm = (int)(pos * Mmpp);
return $"{pos}\n{mm}mm";
};
YFormatter = (y) =>
{
if (IsADMode)
{
return $"{y}";
}
else
{
return $"{y:F1}";
}
};
for (int i = 0; i < 6; i++)
{
SeriesInfo info = new SeriesInfo()
{
Title = $"{i}",
Fill = FLY.ControlLibrary.Themes.Styles.GetForeground(i),
};
LineSeries lineSeries = new LineSeries
{
StrokeThickness = 2,
Fill = new SolidColorBrush(System.Windows.Media.Colors.Transparent),
PointGeometry = null
};
lineSeries.SetBinding(LineSeries.StrokeProperty, "Fill");
lineSeries.DataContext = info;
Series.Add(lineSeries);
info.Series = lineSeries;
SeriesInfos.Add(info);
}
#endregion
IsADMode = false;
UpdateADMode();
//-----------------------------------------------------------------
//虚拟数据
TargetPos = 800;
MeasureValuePos = 7000;
MeasureWidthPos = 500;
Random r = new Random();
for (int i = 0; i < 4; i++)
{
var info = SeriesInfos[i];
int period = r.Next(200, 600);
info.ADs.Clear();
info.Thicks.Clear();
info.ADs.AddRange(GetADs(period));
info.Thicks.AddRange(GetValues(info.ADs));
info.IsBackw = i % 2 == 0;
}
SeriesInfos[0].IsSelected = true;
UpdateMeasure();
}
void UpdateADMode()
{
if (IsADMode)
{
foreach (var info in SeriesInfos)
info.Series.SetBinding(LineSeries.ValuesProperty, "ADs");
}
else
{
foreach (var info in SeriesInfos)
info.Series.SetBinding(LineSeries.ValuesProperty, "Thicks");
}
}
void UpdateMeasure()
{
int begin_grid = MeasureValuePos / PosOfGrid;
int end_grid = (MeasureValuePos + MeasureWidthPos) / PosOfGrid;
foreach (var info in SeriesInfos)
{
if (IsADMode)
{
double sum = 0;
int cnt = 0;
for (int i = begin_grid; i <= end_grid && i < info.ADs.Count() && i >= 0; i++)
{
sum += info.ADs[i];
cnt++;
}
if (cnt == 0)
info.Avg = double.NaN;
else
info.Avg = sum / cnt;
}
else
{
double sum = 0;
int cnt = 0;
for (int i = begin_grid; i <= end_grid && i < info.Thicks.Count() && i >= 0; i++)
{
sum += info.Thicks[i];
cnt++;
}
if (cnt == 0)
info.Avg = double.NaN;
else
info.Avg = sum / cnt;
}
}
}
IEnumerable<double> GetADs(int period)
{
List<double> ads = new List<double>();
Random r = new Random();
for (int i = 0; i < 1000; i++)
{
if (i < 100 || i > 800)
{
ads.Add(double.NaN);
}
else
{
int ad = (int)(Math.Sin(Math.PI * 2 * i / period) * 2000) + r.Next(200) - 100 + 10000;
ads.Add(ad);
}
}
return ads;
}
IEnumerable<double> GetValues(IEnumerable<double> ADs)
{
return ADs.Select(ad =>
{
if (double.IsNaN(ad))
return double.NaN;
else
return ad / 100.0;
});
}
}
}
using MahApps.Metro.Controls;
using MahApps.Metro.Controls.Dialogs;
using OfficeOpenXml;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
namespace FLY.Thick.Base.UI
{
/// <summary>
///
/// </summary>
class PgGridOutput
{
IPgGridVm viewModel;
/// <summary>
///
/// </summary>
/// <param name="viewModel"></param>
public void Init(IPgGridVm viewModel)
{
this.viewModel = viewModel;
}
/// <summary>
///
/// </summary>
/// <param name="filepath"></param>
public async void SaveToXlsx(string filepath)
{
if (viewModel.SeriesInfos.All(s => s.ADs.Count() == 0))
{
FLY.ControlLibrary.Window_WarningTip.Show("输出失败", "没有任何数据", TimeSpan.FromSeconds(2));
return;
//await ((MetroWindow)Application.Current.MainWindow).ShowMessageAsync("输出失败",
// "没有任何数据");
//return;
}
FLY.ControlLibrary.Window_Tip.Show("请等待...", "开始导出");
//var controller = await ((MetroWindow)Application.Current.MainWindow).ShowProgressAsync("请等待...", "开始导出",
// settings: new MetroDialogSettings()
// {
// NegativeButtonText = "停止",
// AnimateShow = false,
// AnimateHide = false,
// });
////controller.SetCancelable(true);
//controller.SetIndeterminate();
await Task.Factory.StartNew(() =>
{
using (ExcelPackage p = new ExcelPackage(new FileInfo(filepath)))
{
SaveToXlsxThicks(p);
SaveToXlsxAD(p);
p.Save();
}
});
//await controller.CloseAsync();
//await ((MetroWindow)Application.Current.MainWindow).ShowMessageAsync("输出成功",
// filepath);
FLY.ControlLibrary.Window_Tip.ShowShortTime("输出成功", filepath);
}
void SaveToXlsxAD(ExcelPackage p)
{
var seriesInfos = viewModel.SeriesInfos;
int posOfGrid = viewModel.PosOfGrid;
double mmpp = viewModel.Mmpp;
var ws = p.Workbook.Worksheets.Add("AD数据");
ws.Cells[1, 1].Value = "脉冲";
ws.Cells[1, 2].Value = "mm";
int max_pos_count = 0;
for (int i = 0; i < seriesInfos.Count(); i++)
{
var info = seriesInfos[i];
var values = info.ADs;
int col = 3 + i;
ws.Cells[1, col].Value = $"{info.Header}";
for (int j = 0; j < values.Count(); j++)
{
if(!double.IsNaN(values[j]))
ws.Cells[2 + j, col].Value = (int)values[j];
}
if (values.Count() <= max_pos_count)
continue;
// 脉冲 & mm
for (int j = max_pos_count; j < values.Count(); j++)
{
ws.Cells[2 + j, 1].Value = j * posOfGrid;
ws.Cells[2 + j, 2].Value = j * posOfGrid * mmpp;
}
max_pos_count = values.Count();
}
//设置格式
//格式
ws.Column(1).Style.Numberformat.Format = "0";
ws.Column(2).Style.Numberformat.Format = "0";
for (int i = 0; i < seriesInfos.Count(); i++)
{
int col = 3 + i;
ws.Column(col).Style.Numberformat.Format = "0";
}
}
void SaveToXlsxThicks(ExcelPackage p)
{
var seriesInfos = viewModel.SeriesInfos;
int posOfGrid = viewModel.PosOfGrid;
double mmpp = viewModel.Mmpp;
var ws = p.Workbook.Worksheets.Add("Thick数据");
ws.Cells[1, 1].Value = "脉冲";
ws.Cells[1, 2].Value = "mm";
int max_pos_count = 0;
for (int i = 0; i < seriesInfos.Count(); i++)
{
var info = seriesInfos[i];
var values = info.Thicks;
int col = 3 + i;
ws.Cells[1, col].Value = $"{info.Header}";
for (int j = 0; j < values.Count(); j++)
{
if (!double.IsNaN(values[j]))
ws.Cells[2 + j, col].Value = values[j];
}
if (values.Count() <= max_pos_count)
continue;
// 脉冲 & mm
for (int j = max_pos_count; j < values.Count(); j++)
{
ws.Cells[2 + j, 1].Value = j * posOfGrid;
ws.Cells[2 + j, 2].Value = j * posOfGrid * mmpp;
}
max_pos_count = values.Count();
}
//设置格式
//格式
ws.Column(1).Style.Numberformat.Format = "0";
ws.Column(2).Style.Numberformat.Format = "0";
for (int i = 0; i < seriesInfos.Count(); i++)
{
int col = 3 + i;
ws.Column(col).Style.Numberformat.Format = "0.00";
}
}
}
}
using LiveCharts;
using LiveCharts.Wpf;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Media;
namespace FLY.Thick.Base.UI
{
class SeriesInfo : INotifyPropertyChanged
{
/// <summary>
/// 显示的标题,肯定是 0,1,2,3,4,5.。。。
/// </summary>
public string Title { get; set; }
/// <summary>
/// 是反向数据
/// </summary>
public bool? IsBackw { get; set; }
public string Header
{
get {
if (IsBackw == null)
return Title;
else
{
if (IsBackw == false)
return $"{Title} 正";
else
return $"{Title} 反";
}
}
}
/// <summary>
/// 颜色
/// </summary>
public Brush Fill { get; set; }
/// <summary>
/// 当前被选中
/// </summary>
public bool IsSelected { get; set; }
/// <summary>
/// 对应的曲线
/// </summary>
public LineSeries Series { get; set; }
/// <summary>
/// 测量区平均值
/// </summary>
public double Avg { get; set; } = double.NaN;
/// <summary>
/// 当非AD值模式时,显示的厚度值
/// </summary>
public ChartValues<double> Thicks { get; } = new ChartValues<double>();
/// <summary>
/// 当为AD值模式时,显示的AD值
/// </summary>
public ChartValues<double> ADs { get; } = new ChartValues<double>();
public void Clear()
{
Thicks.Clear();
ADs.Clear();
Avg = double.NaN;
IsBackw = null;
}
public event PropertyChangedEventHandler PropertyChanged;
}
}
...@@ -38,6 +38,7 @@ ...@@ -38,6 +38,7 @@
</Style> </Style>
<!--Axis.Section--> <!--Axis.Section-->
<!--图表中选择器-->
<Style x:Key="Styles.Axis.Section.Selected" TargetType="lvc:AxisSection" > <Style x:Key="Styles.Axis.Section.Selected" TargetType="lvc:AxisSection" >
<Setter Property="StrokeThickness" Value="1"/> <Setter Property="StrokeThickness" Value="1"/>
<Setter Property="DataLabel" Value="False"/> <Setter Property="DataLabel" Value="False"/>
...@@ -47,10 +48,18 @@ ...@@ -47,10 +48,18 @@
<Setter Property="Stroke" Value="#FFCA000C"/> <Setter Property="Stroke" Value="#FFCA000C"/>
<Setter Property="Fill" Value="#59CA000C"/> <Setter Property="Fill" Value="#59CA000C"/>
<!--<Setter Property="Stroke" Value="#FFFDC8C8"/>-->
<!--<Setter Property="Fill" Value="#59F7D8D8"/>-->
</Style> </Style>
<!--图表中放大用选择器-->
<Style x:Key="Styles.Axis.Section.Selected.ZoomIn" TargetType="lvc:AxisSection" >
<Setter Property="StrokeThickness" Value="1"/>
<Setter Property="DataLabel" Value="True"/>
<Setter Property="DisableAnimations" Value="True"/>
<Setter Property="DataLabelForeground" Value="White"/>
<Setter Property="Opacity" Value="0.5"/>
<Setter Property="Stroke" Value="{StaticResource MahApps.Brushes.Accent}"/>
</Style>
<!--扫描图,纵向趋势图Y轴 标签--> <!--扫描图,纵向趋势图Y轴 标签-->
<Style x:Key="AxisSectionStyle" TargetType="lvc:AxisSection" > <Style x:Key="AxisSectionStyle" TargetType="lvc:AxisSection" >
<Setter Property="StrokeThickness" Value="1"/> <Setter Property="StrokeThickness" Value="1"/>
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment