修改多文件加载,增加排序,增加json文件解析;

增加时间轴间隔可设置
master
mzhifa 2 years ago
parent 5f42163a8c
commit 30a0338e14

@ -84,7 +84,7 @@ namespace mseedChart.MainModule.Models
}
public class JsonST
public class StationEventJson
{
public DateTime otime { get;set;}
public double lon { get; set; }

@ -12,7 +12,9 @@ namespace mseedChart.MainModule.Models
public StationModel()
{
Dzne.Add("dz", dz);
Dzne.Add("dn", dn);
Dzne.Add("de", de);
}
public double E;
@ -24,18 +26,21 @@ namespace mseedChart.MainModule.Models
public double NLat;
public DateTime BeginUseTime;
public int PointCount { get; set; }
public int SamplingFrequency { get; set; }
public DateTime StopUseTime;
public DateTime BeginTime;
public bool IsVisible = true;
public Dictionary<string, List<double>> dzne = new Dictionary<string, List<double>>();
public List<double> dz = new List<double>();
public Dictionary<string, List<double>> Dzne { get; } = new Dictionary<string, List<double>>();
public List<double> dz { get; } = new List<double>();
public List<double> dn = new List<double>();
public List<double> dn { get; } = new List<double>();
public List<double> de = new List<double>();
public List<double> de { get; } = new List<double>();
public string Name { get; set; }

@ -50,139 +50,84 @@ namespace mseedChart.MainModule.Models
}
return axisYList;
}
public List<SampleDataSeries> GetSampleDataSeriesPingPu(List<StationModel> stationModels, LightningChart curChart, AxisX xAxes, List<AxisY> axisY, double samplingFrequency)
{
List<SampleDataSeries> sampleList = new List<SampleDataSeries>();
for (int i = 0; i < stationModels.Count; i++)
public List<AxisY> CreateAxisYEventTime(StationEventJson stationEventJson, ViewXY chartV, List<StationModel> stationModels)
{
//Bug在波形数据少于台站数量时出现错误
if (i < axisY.Count)
for (int i = 0; i < stationEventJson.phases.Count; i++)
{
phases ph= stationEventJson.phases[i];
var index= stationModels.FindIndex(a =>ph.id.Contains(a.Name));
if(index == -1)
{
continue;
}
//Z
SampleDataSeries seriesZ = new SampleDataSeries(curChart.ViewXY, xAxes, axisY[i * 3]);
seriesZ.ShowInLegendBox = true;
seriesZ.Title.Text = axisY[i * 3].Title.Text;
seriesZ.SampleFormat = SampleFormat.DoubleFloat;
//series.LineStyle.Color = DefaultColors.SeriesForBlackBackgroundWpf[i % DefaultColors.SeriesForBlackBackgroundWpf.Length];
seriesZ.LineStyle.Color = System.Windows.Media.Colors.Blue;
seriesZ.SamplingFrequency = samplingFrequency;
seriesZ.FirstSampleTimeStamp = 1.0 / samplingFrequency;
seriesZ.LineStyle.Width = 0.5;
seriesZ.LineStyle.AntiAliasing = LineAntialias.None;
seriesZ.ScrollModePointsKeepLevel = 1;
seriesZ.ScrollingStabilizing = true;
seriesZ.AllowUserInteraction = false;
//Set custom colored palette
System.Windows.Media.Color colorEdge = ChartTools.CalcGradient(seriesZ.LineStyle.Color, System.Windows.Media.Colors.Gray, 50);
System.Windows.Media.Color colorCenter = seriesZ.LineStyle.Color;
//seriesZ.ValueRangePalette.Steps.Clear(); //Remove existing palette steps
//seriesZ.ValueRangePalette.Steps.Add(new PaletteStep(seriesZ.ValueRangePalette, colorEdge, -100));
//seriesZ.ValueRangePalette.Steps.Add(new PaletteStep(seriesZ.ValueRangePalette, colorCenter, 0));
//seriesZ.ValueRangePalette.Steps.Add(new PaletteStep(seriesZ.ValueRangePalette, colorEdge, 100));
sampleList.Add(seriesZ);
//E
SampleDataSeries seriesE = new SampleDataSeries(curChart.ViewXY, xAxes, axisY[i * 3 + 1]);
seriesE.ShowInLegendBox = true;
seriesE.Title.Text = axisY[i * 3+1].Title.Text;
seriesE.SampleFormat = SampleFormat.DoubleFloat;
//series.LineStyle.Color = DefaultColors.SeriesForBlackBackgroundWpf[i % DefaultColors.SeriesForBlackBackgroundWpf.Length];
seriesE.LineStyle.Color = System.Windows.Media.Colors.Red;
seriesE.SamplingFrequency = samplingFrequency;
seriesE.FirstSampleTimeStamp = 1.0 / samplingFrequency;
seriesE.LineStyle.Width = 0.5;
seriesE.LineStyle.AntiAliasing = LineAntialias.None;
seriesE.ScrollModePointsKeepLevel = 1;
seriesE.ScrollingStabilizing = true;
seriesE.AllowUserInteraction = false;
//Set custom colored palette
//System.Windows.Media.Color colorEdge = ChartTools.CalcGradient(series.LineStyle.Color, System.Windows.Media.Colors.Black, 50);
//System.Windows.Media.Color colorCenter = series.LineStyle.Color;
//seriesE.ValueRangePalette.Steps.Clear(); //Remove existing palette steps
//seriesE.ValueRangePalette.Steps.Add(new PaletteStep(seriesE.ValueRangePalette, colorEdge, -100));
//seriesE.ValueRangePalette.Steps.Add(new PaletteStep(seriesE.ValueRangePalette, colorCenter, 0));
//seriesE.ValueRangePalette.Steps.Add(new PaletteStep(seriesE.ValueRangePalette, colorEdge, 100));
sampleList.Add(seriesE);
//N
SampleDataSeries seriesN = new SampleDataSeries(curChart.ViewXY, xAxes, axisY[i * 3 + 2]);
seriesN.ShowInLegendBox = true;
seriesN.Title.Text = axisY[i * 3 + 2].Title.Text;
seriesN.SampleFormat = SampleFormat.DoubleFloat;
//series.LineStyle.Color = DefaultColors.SeriesForBlackBackgroundWpf[i % DefaultColors.SeriesForBlackBackgroundWpf.Length];
seriesN.LineStyle.Color = System.Windows.Media.Colors.Green;
seriesN.SamplingFrequency = samplingFrequency;
seriesN.FirstSampleTimeStamp = 1.0 / samplingFrequency;
seriesN.LineStyle.Width = 0.5;
seriesN.LineStyle.AntiAliasing = LineAntialias.None;
seriesN.ScrollModePointsKeepLevel = 1;
seriesN.ScrollingStabilizing = true;
seriesN.AllowUserInteraction = false;
//Set custom colored palette
//System.Windows.Media.Color colorEdge = ChartTools.CalcGradient(series.LineStyle.Color, System.Windows.Media.Colors.Black, 50);
//System.Windows.Media.Color colorCenter = series.LineStyle.Color;
int assignYAxisIndex = index * 3;
LineCollection lineCollection = new LineCollection()
{
AssignXAxisIndex = 0,
AssignYAxisIndex = assignYAxisIndex,
Tag=ph.id, //用于排序otime,只需要排更SHZ通道
Lines = new SegmentLine[] { new SegmentLine(chartV.XAxes[0].DateTimeToAxisValue(ph.atime), chartV.YAxes[assignYAxisIndex].Minimum, chartV.XAxes[0].DateTimeToAxisValue(ph.atime), chartV.YAxes[assignYAxisIndex].Maximum) },
ShowInLegendBox = false
//seriesN.ValueRangePalette.Steps.Clear(); //Remove existing palette steps
//seriesN.ValueRangePalette.Steps.Add(new PaletteStep(seriesN.ValueRangePalette, colorEdge, -100));
//seriesN.ValueRangePalette.Steps.Add(new PaletteStep(seriesN.ValueRangePalette, colorCenter, 0));
//seriesN.ValueRangePalette.Steps.Add(new PaletteStep(seriesN.ValueRangePalette, colorEdge, 100));
};
sampleList.Add(seriesN);
}
return sampleList;
lineCollection.LineStyle.Color = System.Windows.Media.Colors.Red;
lineCollection.Title.Text = ph.atime.ToString();
lineCollection.Title.Visible = true;
lineCollection.Title.Font.Size = 8;
lineCollection.Title.Shadow.DropColor = System.Windows.Media.Colors.Transparent;
lineCollection.Title.Shadow.ContrastColor = System.Windows.Media.Colors.Transparent;
lineCollection.Title.AutoPlacement = false;
lineCollection.Title.HorizontalAlign = AlignmentHorizontal.Left;
var b= (ph.atime- stationEventJson.otime).TotalSeconds*100;
lineCollection.Title.Offset= new PointIntXY((int)b, 0);
lineCollection.Title.Color = System.Windows.Media.Colors.Red;
lineCollection.Title.AutoPlacement = false;
chartV.LineCollections.Add(lineCollection);
}
public List<AxisY> CreateAxisYEventTime(MmEvent mmEvent, ViewXY chartV)
for (int i = 0; i < stationEventJson.amps.Count; i++)
{
for (int i = 0; i< chartV.YAxes.Count; i++)
amps am = stationEventJson.amps[i];
var index = stationModels.FindIndex(a => am.id.Contains(a.Name));
if (index == -1)
{
// lineCollection.Lines[i] = new SegmentLine(1+i, chartV.YAxes[0].Minimum, 1+i, chartV.YAxes[0].Maximum);
continue;
}
int assignYAxisIndex = index * 3;
assignYAxisIndex = am.id.Contains("SHE") ? assignYAxisIndex + 1 : assignYAxisIndex + 2;
LineCollection lineCollection = new LineCollection()
{
AssignXAxisIndex = 0,
AssignYAxisIndex = i,
Lines = new SegmentLine[] { new SegmentLine(0.5 * i, chartV.YAxes[i].Minimum, 0.5 * i, chartV.YAxes[i].Maximum) },
AssignYAxisIndex = assignYAxisIndex,
Lines = new SegmentLine[] { new SegmentLine(chartV.XAxes[0].DateTimeToAxisValue(am.atime), chartV.YAxes[assignYAxisIndex].Minimum, chartV.XAxes[0].DateTimeToAxisValue(am.atime), chartV.YAxes[assignYAxisIndex].Maximum) },
ShowInLegendBox = false
};
PointLineSeries pointLine = new PointLineSeries()
{
PointsVisible = true,
AssignXAxisIndex = 0,
AssignYAxisIndex = i,
ShowInLegendBox = false,
Points = new SeriesPoint[] { new SeriesPoint(0.5 * i, (chartV.YAxes[i].Minimum+ chartV.YAxes[i].Maximum)/2) },
};
// var value= chartV.YAxes[i].ValueToCoord(chartV.YAxes[i].Minimum);
chartV.PointLineSeries.Add(pointLine);
lineCollection.LineStyle.Color = System.Windows.Media.Colors.Red;
lineCollection.Title.Text = am.atime.ToString();
lineCollection.Title.Visible = true;
lineCollection.Title.Font.Size = 8;
lineCollection.Title.Shadow.DropColor = System.Windows.Media.Colors.Transparent;
lineCollection.Title.Shadow.ContrastColor = System.Windows.Media.Colors.Transparent;
lineCollection.Title.AutoPlacement = false;
lineCollection.Title.HorizontalAlign = AlignmentHorizontal.Left;
var b = (am.atime - stationEventJson.otime).TotalSeconds * 100;
lineCollection.Title.Offset = new PointIntXY((int)b, 0);
lineCollection.Title.Color = System.Windows.Media.Colors.Red;
// lineCollection.Title.AllowDragging = false;
chartV.LineCollections.Add(lineCollection);
}
return new List<AxisY>();
}
public JsonST mseedJsonResolve(string jsonFile)
public StationEventJson mseedJsonResolve(string jsonFile)
{
var str = File.ReadAllText(jsonFile);
var st = JsonConvert.DeserializeObject<JsonST[]>(str);
var st = JsonConvert.DeserializeObject<StationEventJson[]>(str);
JsonST jsonST = st[0];
StationEventJson jsonST = st[0];
return jsonST;
}
}

@ -11,10 +11,10 @@ namespace mseedChart.Core
{
public const string ContentRegion = "ContentRegion";
public static string MseedFilePath = @"D:\EwsCache\Mseed"; //AppDomain.CurrentDomain.BaseDirectory + "EwsCache\\Mseed";
public static string MseedFilePath = @"H:\EwsCache\Mseed"; //AppDomain.CurrentDomain.BaseDirectory + "EwsCache\\Mseed";
public static string TxtFilePath = @"D:\EwsCache\Txt";//;AppDomain.CurrentDomain.BaseDirectory + "EwsCache\\Txt";
public static string TxtFilePath = @"H:\EwsCache\Txt";//;AppDomain.CurrentDomain.BaseDirectory + "EwsCache\\Txt";
public static string DataTypeString = "A";
@ -22,30 +22,6 @@ namespace mseedChart.Core
public static Dictionary<string, StationModel> StationDic { get; set; }
public static Dictionary<string, StationModel> CreateStationFromCSV(string fn)
{
Dictionary<string, StationModel> stations = new Dictionary<string, StationModel>();
var datas= File.ReadLines(fn);
foreach (var item in datas)
{
if (item.Contains("net")) continue;
string[] row = item.Split(',');
StationModel model = new StationModel();
model.Name = row[1].ToString();
model.E = double.Parse(row[2].ToString());
model.N = double.Parse(row[3].ToString());
model.Z = double.Parse(row[4].ToString());
model.Sens = double.Parse(row[5].ToString());
model.BeginUseTime = DateTime.Parse(row[6].ToString());
model.StopUseTime = DateTime.Parse(row[7].ToString());
stations.Add(model.Name, model);
}
return stations;
}
}
}

@ -1,5 +1,6 @@
using Arction.Wpf.Charting;
using Arction.Wpf.Charting.Axes;
using Arction.Wpf.Charting.SeriesXY;
using Arction.Wpf.Charting.Views.ViewXY;
using Microsoft.Win32;
using mseedChart.Core;
@ -9,6 +10,7 @@ using Prism.Events;
using Prism.Mvvm;
using SharpDX.DirectWrite;
using System;
using System.Collections;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Collections.ObjectModel;
@ -17,6 +19,9 @@ using System.ComponentModel.Design.Serialization;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Net.Http.Headers;
using System.Reflection;
using System.Security.Cryptography;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
@ -38,9 +43,9 @@ namespace mseedChart.MainModule.ViewModels
CreateChart();
(Application.Current.MainWindow as System.Windows.Window).Closing += ApplicationClosingDispose;
string fileName = "2023-03-28T04:53:46.199584";
string fileName = "2023-03-28T05:14:59.108464";
// fileName = "2023-03-24T04:53:46.199584";
bool multFlies = true;
bool multFlies = false;
string eventTimeStr = fileName;
string datePath = eventTimeStr.Substring(0, 4) + eventTimeStr.Substring(5, 2) + eventTimeStr.Substring(8, 2);
string dataFilePath = RegionNames.MseedFilePath + "\\" + datePath + "\\";
@ -52,9 +57,13 @@ namespace mseedChart.MainModule.ViewModels
string asciiSavePath = RegionNames.TxtFilePath + "\\" + datePath + "\\";
if (!multFlies)
{
_wavesModel.mseedJsonResolve(dataFilePath + dataFileName + jsonStr);
CurrentEventTime = _wavesModel.mseedJsonResolve(dataFilePath + dataFileName + jsonStr);
}
ShowWave(dataFilePath + dataFileName + mseedStr, asciiSavePath + dataFileName + ".txt" , multFlies);
YaxisItems.Add("SHZ");
YaxisItems.Add("SHN");
YaxisItems.Add("SHE");
}
#region 字段
@ -63,14 +72,52 @@ namespace mseedChart.MainModule.ViewModels
int _channelCount = 0;
double _samplingFrequency = 500; // 采样频率 (Hz).
double _previousX = 0;
WavesModel _wavesModel;
private int _lChartCount = 1;
public ConcurrentQueue<StationModel> smList;
#endregion
#region 属性
private List<string> _yaxisItems=new List<string>();
public List<string> YaxisItems
{
get { return _yaxisItems; }
set { _yaxisItems = value; }
}
private int _selectIndex=1;
public int SelectIndex
{
get { return _selectIndex; }
set
{
SetProperty(ref _selectIndex, value);
}
}
private bool _isMultFiles;
public bool IsMultFiles
{
get { return _isMultFiles; }
set
{
SetProperty(ref _isMultFiles, value);
}
}
private int _xaisInterval;
public int XaisInterval
{
get { return _xaisInterval; }
set
{
SetProperty(ref _xaisInterval, value);
}
}
/// <summary>
/// 波形控件数量
/// </summary>
@ -103,12 +150,12 @@ namespace mseedChart.MainModule.ViewModels
get { return gridChart; }
set { gridChart = value; }
}
private MmEvent _eventTime;
private StationEventJson _currentEventTime;
public MmEvent EventTime
public StationEventJson CurrentEventTime
{
get { return _eventTime; }
set { _eventTime = value; }
get { return _currentEventTime; }
set { _currentEventTime = value; }
}
@ -119,6 +166,9 @@ namespace mseedChart.MainModule.ViewModels
#region 事件
public DelegateCommand<object> AxesYVisibleCommand => new DelegateCommand<object>(AxesYVisible);
public DelegateCommand FileSelectorCommand => new DelegateCommand(FileSelector);
public DelegateCommand<object> OtimeSortCommand => new DelegateCommand<object>(OtimeSort);
public DelegateCommand<object> YasixZENVisibleCommand => new DelegateCommand<object>(YasixZENVisible);
public DelegateCommand IntervalSureCommand => new DelegateCommand(IntervalSure);
private void AxesYVisible(object isCheck)
{
@ -165,13 +215,109 @@ namespace mseedChart.MainModule.ViewModels
OpenFileDialog openFileDialog = new OpenFileDialog
{
RestoreDirectory = true,
Filter = ".json|*.json|.mseed|*.mseed|.txt|*.txt",
Filter = ".mseed|*.mseed|.json|*.json|.txt|*.txt",
};
if (openFileDialog.ShowDialog() == true)
{
//ShowWave(openFileDialog.FileName);
string asciiSavePath = openFileDialog.FileName;
asciiSavePath = asciiSavePath.Replace("Mseed","Txt");
asciiSavePath= Path.ChangeExtension(asciiSavePath, ".txt");
ShowWave(openFileDialog.FileName, asciiSavePath, IsMultFiles);
}
}
private void OtimeSort(object isCheck)
{
if (_lChartAll != null)
{
LChartALL.BeginUpdate();
bool yAxesVisible = ((bool)isCheck == true);
ViewXY v= _lChartAll.ViewXY;
IOrderedEnumerable<LineCollection> lines;
if (yAxesVisible)
{
lines = v.LineCollections.Where(a => a.Tag != null && a.Tag.ToString().Contains("SHZ")).OrderBy(a => a.Lines[0].AX);
}
else
{
lines = v.LineCollections.Where(a => a.Tag != null && a.Tag.ToString().Contains("SHZ")).OrderByDescending(b => b.Lines[0].AX); ;
}
foreach (var item in lines)
{
var a= item.Tag.ToString().Contains("SHZ");
}
foreach (var item in lines.Reverse())
{
int index = item.AssignYAxisIndex;
for (int i = 0; i < 3; i++)
{
AxisY axisY = v.YAxes[index + i];
v.YAxes.RemoveAt(index + i);
v.YAxes.Insert(i, axisY);
}
}
LChartALL.EndUpdate();
}
}
private void YasixZENVisible(object isCheck)
{
if (_lChartAll != null)
{
_lChartAll.BeginUpdate();
bool yAxesVisible = ((bool)isCheck == true);
ViewXY v = _lChartAll.ViewXY;
List<bool> indexs = new List<bool>();
switch (SelectIndex)
{
case 0:
indexs = v.YAxes.Select(a => a.Title.Text.Contains(".Z")).ToList();
break;
case 1:
indexs = v.YAxes.Select(a => a.Title.Text.Contains(".N")).ToList();
break;
case 2:
indexs = v.YAxes.Select(a => a.Title.Text.Contains(".E")).ToList();
break;
default:
break;
}
for (int i = 0; i < indexs.Count; i++)
{
if (indexs[i] == true)
{
AxisY axisY = v.YAxes[i];
axisY.Visible = !yAxesVisible;
v.SampleDataSeries[i].Visible = !yAxesVisible;
int index = v.LineCollections.FindIndex(a => a.AssignYAxisIndex == i);
if (index != -1)
{
v.LineCollections[index].Visible = !yAxesVisible;
}
}
}
_lChartAll.EndUpdate();
}
}
private void IntervalSure()
{
if (_lChartAll != null)
{
_lChartAll.BeginUpdate();
if (XaisInterval >= 2)
{
_lChartAll.ViewXY.XAxes[0].MajorDivCount = XaisInterval;
}
_lChartAll.EndUpdate();
}
}
#endregion
public List<StationModel> UpdateWavesFromTxt(string fn)
{
@ -191,9 +337,6 @@ namespace mseedChart.MainModule.ViewModels
CurPoints = int.Parse(snStr[1].Trim().Split(' ')[0]);
StationModel station = new StationModel();
station.Name = tmpName;
station.dz = new List<double>();
station.dn = new List<double>();
station.de = new List<double>();
int channelFlag = 0;
@ -209,6 +352,9 @@ namespace mseedChart.MainModule.ViewModels
{
station = new StationModel();
station.Name = stationName;
station.BeginTime =Convert.ToDateTime(rowStr[3]);
station.PointCount = int.Parse(rowStr[1].Trim().Split(' ')[0]);
station.SamplingFrequency = int.Parse(rowStr[2].Trim().Split(' ')[0]);
temSM.Add(station);
}
if (chnStr1 == "SHZ")
@ -271,7 +417,6 @@ namespace mseedChart.MainModule.ViewModels
LChartALL.ChartRenderOptions.LineAAType2D = LineAntiAliasingType.QLAA;
LChartALL.Title.Text = "事件波形";
// LChartALL.Title.Color = Colors.Red;
LChartALL.Title.Font = new WpfFont("等线", 20);
//轴属性和布局
@ -286,28 +431,22 @@ namespace mseedChart.MainModule.ViewModels
LChartALL.ViewXY.ZoomPanOptions.DevicePrimaryButtonAction = UserInteractiveDeviceButtonAction.None;
LChartALL.ViewXY.ZoomPanOptions.DeviceSecondaryButtonAction = UserInteractiveDeviceButtonAction.None;
LChartALL.ViewXY.ZoomPanOptions.WheelZooming = WheelZooming.Off;
// 反锯齿系数。值0和1都不会应用反锯齿
LChartALL.ChartRenderOptions.AntiAliasLevel = 0;
//X轴设置
LChartALL.ViewXY.XAxes[0].AllowScrolling = false;
LChartALL.ViewXY.XAxes[0].PanningEnabled = false;
LChartALL.ViewXY.XAxes[0].SweepingGap = 0;
LChartALL.ViewXY.XAxes[0].ValueType = AxisValueType.DateTime;
LChartALL.ViewXY.XAxes[0].AutoFormatLabels = false;
// LChartALL.ViewXY.XAxes[0].LabelsNumberFormat = "N0";
// LChartALL.ViewXY.XAxes[0].MajorGrid.Pattern = LinePattern.Solid;
LChartALL.ViewXY.XAxes[0].MinorGrid.Visible = false;
LChartALL.ViewXY.XAxes[0].MajorGrid.Pattern = LinePattern.Solid;
//LChartALL.ViewXY.XAxes[0].MinimumDateTime=DateTime.Now;
LChartALL.ViewXY.XAxes[0].AutoDivSpacing = false;
LChartALL.ViewXY.XAxes[0].MinorDivTickStyle.Visible = true;
LChartALL.ViewXY.XAxes[0].ValueType = AxisValueType.DateTime;
LChartALL.ViewXY.XAxes[0].KeepDivCountOnRangeChange = true;
//LChartALL.ViewXY.XAxes[0].MajorDiv =6;
LChartALL.ViewXY.XAxes[0].LabelsColor = Colors.Black;
LChartALL.ViewXY.XAxes[0].AutoDivSpacing = false;
LChartALL.ViewXY.XAxes[0].MajorDivCount = 5;
LChartALL.ViewXY.XAxes[0].LabelsTimeFormat = "HH:mm.ss.ffff";
XaisInterval = 5;
//图表背景颜色
LChartALL.ViewXY.GraphBackground.Color = Colors.White;
//LChartALL.ViewXY.GraphBackground.GradientFill = GradientFill.Solid;
LChartALL.ViewXY.GraphBackground.GradientColor = Colors.White;
LChartALL.ChartBackground.GradientFill = GradientFill.Solid;
LChartALL.ChartBackground.Color = Color.FromArgb(0, 0, 0, 0);
@ -333,7 +472,6 @@ namespace mseedChart.MainModule.ViewModels
{
var filePath = new DirectoryInfo(Path.GetDirectoryName(dataFilePath));
FileInfo[] files = filePath.GetFiles();
//var dic = file.GetDirectories();
var mseedFiles = files.Where(i => i.Extension == ".mseed");
var asciiFiles = new DirectoryInfo(Path.GetDirectoryName(asciiSavePath));
@ -344,7 +482,7 @@ namespace mseedChart.MainModule.ViewModels
Stopwatch sw = Stopwatch.StartNew();
Parallel.ForEach(mseedFiles, (item) =>
{
MSeed2Asc(item.FullName, asciiSavePath + Path.GetFileNameWithoutExtension(item.Name));
MSeed2Asc(item.FullName, Path.Combine(Path.GetDirectoryName(asciiSavePath), Path.GetFileNameWithoutExtension(item.Name)));
});
sw.Stop();
Debug.WriteLine("MSeed2Asc解压时间" +sw.Elapsed.TotalSeconds);
@ -374,19 +512,44 @@ namespace mseedChart.MainModule.ViewModels
private void UpdateChart()
{
ViewXY v= LChartALL.ViewXY;
DisposeAllAndClear(v.YAxes);
DisposeAllAndClear(v.SampleDataSeries);
DisposeAllAndClear(v.LineCollections);
DisposeAllAndClear(LChartALL.ViewXY.YAxes);
DisposeAllAndClear(LChartALL.ViewXY.SampleDataSeries);
v.YAxes.AddRange(_wavesModel.CreateYAxisChart(smList.ToList(), LChartALL));
v.LegendBoxes[0].Position = LegendBoxPositionXY.RightCenter;
v.LegendBoxes[0].Offset.SetValues(-10, 180);
v.LegendBoxes[0].Layout = LegendBoxLayout.Vertical;
v.LegendBoxes[0].Visible = false;
v.AutoSpaceLegendBoxes = true;
v.AxisLayout.SegmentsGap = 3;
v.LegendBoxes[0].Shadow.Visible =false;
LChartALL.ViewXY.YAxes.AddRange(_wavesModel.CreateYAxisChart(smList.ToList(), LChartALL));
int seriesIndex = 0;
foreach (var axisY in LChartALL.ViewXY.YAxes)
StationModel stationModel = smList.ElementAt(0);
if (AxisValueType.DateTime == v.XAxes[0].ValueType)
{
//设置X轴的开始时间
v.XAxes[0].AutoFormatLabels = false;
v.XAxes[0].LabelsTimeFormat = "HH:mm:ss.ff";
v.XAxes[0].DateOriginYear = CurrentEventTime.otime.Year;
v.XAxes[0].DateOriginDay = CurrentEventTime.otime.Day;
v.XAxes[0].DateOriginMonth = CurrentEventTime.otime.Month;
DateTime MaxDateTime = CurrentEventTime.otime.AddSeconds(_samplingFrequency == 500 ? 30 : 60);
v.XAxes[0].SetRange(v.XAxes[0].DateTimeToAxisValue(CurrentEventTime.otime), v.XAxes[0].DateTimeToAxisValue(MaxDateTime));
}
double firstSampleTimeStamp = v.XAxes[0].DateTimeToAxisValue(CurrentEventTime.otime);
for (int i = 0; i < smList.Count; i++)
{
for (int k = 0; k < smList.ElementAt(i).Dzne.Count; k++)
{
int seriesIndex = i * 3 + k;
AxisY axisY= v.YAxes[seriesIndex];
axisY.LabelsColor = Colors.Black;
// axisY.AxisColor = Colors.Black;
axisY.Title.Shadow.DropColor = Colors.Transparent;
axisY.Title.Shadow.ContrastColor = Colors.Transparent;
axisY.AllowAutoYFit = false;
axisY.Units.Visible = false;
axisY.LabelsAngle = 0;
@ -395,11 +558,9 @@ namespace mseedChart.MainModule.ViewModels
axisY.MajorGrid.Visible = true;
axisY.MinorGrid.Visible = false;
axisY.MajorGrid.Pattern = LinePattern.Solid;
axisY.AutoDivSpacing = false;
// axisY.AutoDivSeparationPercent = 100;
axisY.Visible = true;
// axisY.MajorDiv = 1;
axisY.MajorDivCount = 2;
axisY.MajorDivTickStyle.Visible = true;
axisY.MinorDivTickStyle.Visible = false;
@ -408,27 +569,36 @@ namespace mseedChart.MainModule.ViewModels
axisY.MajorDivTickStyle.Color = Colors.Black;
axisY.Title.Color = Colors.Black;
axisY.Title.Font = new WpfFont("Segoe UI", 10, false, false);
// axisY.Title.HorizontalAlign = seriesIndex % 2 == 0 ? YAxisTitleAlignmentHorizontal.Left : YAxisTitleAlignmentHorizontal.Right;
axisY.PanningEnabled = false;
axisY.AllowScrolling = false;
axisY.AllowScaling = false;
seriesIndex++;
SampleDataSeries series = new SampleDataSeries(v, v.XAxes[0], axisY);
series.ShowInLegendBox = true;
series.FirstSampleTimeStamp = firstSampleTimeStamp;
series.SamplingFrequency = _samplingFrequency;
series.Title.Text = axisY.Title.Text;
series.SampleFormat = SampleFormat.DoubleFloat;
if (k % 3 == 0)
{
series.LineStyle.Color = System.Windows.Media.Colors.Blue;
}
else if (k % 3 == 1)
{
series.LineStyle.Color = System.Windows.Media.Colors.Red;
}
else if (k % 3 == 2)
{
series.LineStyle.Color = System.Windows.Media.Colors.Green;
}
series.LineStyle.Width =0.5;
series.LineStyle.AntiAliasing = LineAntialias.None;
series.ScrollModePointsKeepLevel = 1;
series.ScrollingStabilizing = true;
series.AllowUserInteraction = false;
v.SampleDataSeries.Add(series);
}
}
LChartALL.ViewXY.LegendBoxes[0].Position = LegendBoxPositionXY.RightCenter;
LChartALL.ViewXY.LegendBoxes[0].Offset.SetValues(-10, 180);
LChartALL.ViewXY.LegendBoxes[0].Layout = LegendBoxLayout.Vertical;
LChartALL.ViewXY.LegendBoxes[0].ShowIcons = false;
LChartALL.ViewXY.AutoSpaceLegendBoxes = true;
LChartALL.ViewXY.AxisLayout.SegmentsGap = 3;
LChartALL.ViewXY.LegendBoxes[0].Shadow.Visible =false;
LChartALL.ViewXY.XAxes[0].Maximum = CurPoints / _samplingFrequency;
LChartALL.ViewXY.XAxes[0].LabelsColor = Colors.Black;
LChartALL.ViewXY.SampleDataSeries.AddRange(
_wavesModel.GetSampleDataSeriesPingPu(smList.ToList(), LChartALL, LChartALL.ViewXY.XAxes[0],
LChartALL.ViewXY.YAxes, _samplingFrequency));
}
private void UpdateChartData()
{
@ -494,15 +664,11 @@ namespace mseedChart.MainModule.ViewModels
private void FeedNewDataToChar(double[][] data)
{
LChartALL.BeginUpdate();
_wavesModel.CreateAxisYEventTime(EventTime, LChartALL.ViewXY);
_wavesModel.CreateAxisYEventTime(CurrentEventTime, LChartALL.ViewXY, smList.ToList());
for (int channelIndex = 0; channelIndex < _channelCount; channelIndex++)
{
LChartALL.ViewXY.SampleDataSeries[channelIndex].AddSamples(data[channelIndex], true);
}
// _previousX = (double)_samplesOutput / _samplingFrequency;
// LChartALL.ViewXY.XAxes[0].ScrollPosition = _previousX;
LChartALL.EndUpdate();
}

@ -19,8 +19,14 @@
VerticalAlignment="Top" Margin="0,162,0,0" Grid.Row="1" />
<DockPanel>
<CheckBox Command="{Binding AxesYVisibleCommand}" CommandParameter="{Binding RelativeSource={RelativeSource Mode=Self},Path=IsChecked}" Content="Y轴显示" VerticalContentAlignment="Center" IsChecked="True" FontSize="15" Foreground="Black" Margin="5,0,5,0" FontWeight="Bold" />
<Button Grid.Column="1" Grid.Row="1" Command="{Binding FileSelectorCommand}" Margin="0,0,50,0" Background="#FF66B1FF" HorizontalAlignment="Right" >Open</Button>
<!--<ComboBox ItemsSource="{Binding }"></ComboBox>-->
<CheckBox Command="{Binding OtimeSortCommand}" CommandParameter="{Binding RelativeSource={RelativeSource Mode=Self},Path=IsChecked}" Content="排序" VerticalContentAlignment="Center" FontSize="15" Foreground="Black" Margin="5,0,5,0" FontWeight="Bold"></CheckBox>
<ComboBox ItemsSource="{Binding YaxisItems}" SelectedIndex="{Binding SelectIndex}" />
<CheckBox Command="{Binding YasixZENVisibleCommand}" CommandParameter="{Binding RelativeSource={RelativeSource Mode=Self},Path=IsChecked}" Content="ZEN" VerticalContentAlignment="Center" FontSize="15" Foreground="Black" Margin="5,0,5,0" FontWeight="Bold"></CheckBox>
<TextBlock VerticalAlignment="Center">X轴时间间隔:</TextBlock>
<TextBox Text="{Binding XaisInterval}" Width="80" VerticalAlignment="Center"></TextBox>
<Button Grid.Column="1" Grid.Row="1" Command="{Binding IntervalSureCommand}" Margin="20,0,50,0" Background="#FF66B1FF" HorizontalAlignment="Right" Width="60">OK</Button>
<CheckBox IsChecked="{Binding IsMultFiles}" Content="MultFiles" VerticalContentAlignment="Center" FontSize="15" Foreground="Black" FontWeight="Bold" DockPanel.Dock="Right"></CheckBox>
<Button Grid.Column="1" Grid.Row="1" Command="{Binding FileSelectorCommand}" Margin="0,0,50,0" Background="#FF66B1FF" HorizontalAlignment="Right" Width="60">Open</Button>
</DockPanel>
<ContentControl x:Name="contentControl" Content="{Binding ChildContent}" Grid.Row="1" />
</Grid>

@ -3,7 +3,7 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:prism="http://prismlibrary.com/"
prism:ViewModelLocator.AutoWireViewModel="True"
Title="{Binding Title}" Height="350" Width="525"
Title="{Binding Title}" Height="550" Width="825"
xmlns:core="clr-namespace:mseedChart.Core;assembly=mseedChart.Core">
<Grid>
<ContentControl prism:RegionManager.RegionName= "{x:Static core:RegionNames.ContentRegion}"/>

Loading…
Cancel
Save