240705
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
using CapMachine.Core;
|
||||
using CapMachine.Model;
|
||||
using CapMachine.Wpf.Models;
|
||||
using CapMachine.Wpf.Services;
|
||||
using ImTools;
|
||||
using Prism.Commands;
|
||||
using Prism.Services.Dialogs;
|
||||
@@ -17,37 +18,13 @@ namespace CapMachine.Wpf.ViewModels
|
||||
{
|
||||
public class DialogChartRtConfigViewModel : DialogViewModel
|
||||
{
|
||||
public DialogChartRtConfigViewModel(IFreeSql freeSql, IMapper mapper)
|
||||
public DialogChartRtConfigViewModel(IFreeSql freeSql, IMapper mapper, MachineRtDataService machineRtDataService)
|
||||
{
|
||||
this.Title = "曲线编辑";
|
||||
|
||||
//加载曲线数据源
|
||||
ChartSrcDataListViewItems = new ObservableCollection<ChartSrcData>();
|
||||
ChartSrcDataListViewItems.Add(new ChartSrcData()
|
||||
{
|
||||
Index = 1,
|
||||
Name = "温度",
|
||||
Selected = true
|
||||
});
|
||||
ChartSrcDataListViewItems.Add(new ChartSrcData()
|
||||
{
|
||||
Index = 2,
|
||||
Name = "压力",
|
||||
Selected = true
|
||||
});
|
||||
ChartSrcDataListViewItems.Add(new ChartSrcData()
|
||||
{
|
||||
Index = 3,
|
||||
Name = "湿度",
|
||||
Selected = false
|
||||
});
|
||||
ChartSrcDataListViewItems.Add(new ChartSrcData()
|
||||
{
|
||||
Index = 4,
|
||||
Name = "过冷度",
|
||||
Selected = false
|
||||
});
|
||||
|
||||
|
||||
ChartYAxisDataListViewItems = new ObservableCollection<ChartYAxisDto>()
|
||||
{
|
||||
new ChartYAxisDto(){
|
||||
@@ -74,8 +51,8 @@ namespace CapMachine.Wpf.ViewModels
|
||||
};
|
||||
FreeSql = freeSql;
|
||||
this.Mapper = mapper;
|
||||
|
||||
RefreshChartSourceData();
|
||||
MachineRtDataService = machineRtDataService;
|
||||
LoadChartSourceData();
|
||||
RefreshChartSelectedData();
|
||||
RefreshChartYAxisData();
|
||||
}
|
||||
@@ -84,11 +61,36 @@ namespace CapMachine.Wpf.ViewModels
|
||||
/// FreeSql
|
||||
/// </summary>
|
||||
public IFreeSql FreeSql { get; }
|
||||
|
||||
/// <summary>
|
||||
/// AutoMap映射
|
||||
/// </summary>
|
||||
public IMapper Mapper { get; }
|
||||
|
||||
/// <summary>
|
||||
/// 数据服务
|
||||
/// </summary>
|
||||
public MachineRtDataService MachineRtDataService { get; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 加载ChartSourceData
|
||||
/// </summary>
|
||||
private void LoadChartSourceData()
|
||||
{
|
||||
foreach (var item in MachineRtDataService.ListMeterRtData)
|
||||
{
|
||||
ChartSrcDataListViewItems.Add(new ChartSrcData()
|
||||
{
|
||||
Index=1,
|
||||
Name=item.MeterName,
|
||||
Selected=false,
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 加载数据
|
||||
/// </summary>
|
||||
@@ -98,6 +100,7 @@ namespace CapMachine.Wpf.ViewModels
|
||||
//Mapper.Map<List<ChartSelectDto>>(data);
|
||||
//ChartSelectDataListViewItems = new ObservableCollection<ChartSelectDto>(Mapper.Map<List<ChartSelectDto>>(data));
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -105,13 +108,25 @@ namespace CapMachine.Wpf.ViewModels
|
||||
/// </summary>
|
||||
private void RefreshChartSelectedData()
|
||||
{
|
||||
var ChartSelectedData = FreeSql.Select<ConfigChartSelect>().Include(a=>a.ConfigChartYAxis).ToList();
|
||||
var ChartSelectedData = FreeSql.Select<ConfigChartSelect>().Include(a => a.ConfigChartYAxis).ToList();
|
||||
ChartSelectDataListViewItems.Clear();
|
||||
foreach (var item in ChartSelectedData)
|
||||
{
|
||||
ChartSelectDataListViewItems.Add(Mapper.Map<ChartSelectDto>(item));
|
||||
}
|
||||
|
||||
//选中后源数据状态被选中
|
||||
foreach (var item in ChartSelectedData)
|
||||
{
|
||||
var data = ChartSrcDataListViewItems.FindFirst(a => a.Name == item.Name);
|
||||
if (data != null)
|
||||
{
|
||||
//选中
|
||||
data.Selected = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//SelectedChartSelectData = null;
|
||||
|
||||
//Mapper.Map<List<ChartSelectDto>>(data);
|
||||
@@ -345,7 +360,7 @@ namespace CapMachine.Wpf.ViewModels
|
||||
//数据库保存
|
||||
FreeSql.Update<ConfigChartSelect>()
|
||||
.Where(a => a.Id == SelectedChartSelectData.Id)
|
||||
.Set(a=>a.ConfigChartYAxisId, SelectedChartYAxisData.Id)
|
||||
.Set(a => a.ConfigChartYAxisId, SelectedChartYAxisData.Id)
|
||||
.ExecuteAffrows();
|
||||
|
||||
//刷新图表
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
using CapMachine.Core;
|
||||
using CapMachine.Wpf.PrismEvent;
|
||||
using Prism.Commands;
|
||||
using Prism.Events;
|
||||
using Prism.Services.Dialogs;
|
||||
using SharpDX.Direct3D9;
|
||||
using System;
|
||||
@@ -12,10 +14,11 @@ namespace CapMachine.Wpf.ViewModels
|
||||
/// <summary>
|
||||
/// 实例化函数
|
||||
/// </summary>
|
||||
public RealTimeChartViewModel(IDialogService dialogService, IFreeSql freeSql)
|
||||
public RealTimeChartViewModel(IDialogService dialogService, IFreeSql freeSql, IEventAggregator eventAggregator)
|
||||
{
|
||||
DialogService = dialogService;
|
||||
FreeSql = freeSql;
|
||||
EventAggregator = eventAggregator;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -28,6 +31,11 @@ namespace CapMachine.Wpf.ViewModels
|
||||
/// </summary>
|
||||
public IFreeSql FreeSql { get; }
|
||||
|
||||
/// <summary>
|
||||
/// 事件聚合器
|
||||
/// </summary>
|
||||
public IEventAggregator EventAggregator { get; }
|
||||
|
||||
private DelegateCommand _ChartConfigCmd;
|
||||
/// <summary>
|
||||
/// 编辑曲线数据
|
||||
@@ -60,8 +68,8 @@ namespace CapMachine.Wpf.ViewModels
|
||||
{
|
||||
//程序名称
|
||||
var ReturnValue = par.Parameters.GetValue<string>("Name");
|
||||
|
||||
|
||||
//返回数据,刷新Chart
|
||||
EventAggregator.GetEvent<ChartRtActionEvent>().Publish(ChartActionType.ReLoadChart);
|
||||
}
|
||||
else if (par.Result == ButtonResult.Cancel)
|
||||
{
|
||||
@@ -72,7 +80,7 @@ namespace CapMachine.Wpf.ViewModels
|
||||
});
|
||||
}
|
||||
|
||||
//#region 曲线配置
|
||||
#region 曲线配置
|
||||
|
||||
//private LightningChart _LightningChartInstance;
|
||||
///// <summary>
|
||||
@@ -127,6 +135,6 @@ namespace CapMachine.Wpf.ViewModels
|
||||
//}
|
||||
|
||||
|
||||
//#endregion
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user