diff --git a/Correlator/Correlator.csproj b/Correlator/Correlator.csproj
index 1bbcfe0..dc91f84 100644
--- a/Correlator/Correlator.csproj
+++ b/Correlator/Correlator.csproj
@@ -234,6 +234,7 @@
+
diff --git a/Correlator/Correlator.csproj b/Correlator/Correlator.csproj
index 1bbcfe0..dc91f84 100644
--- a/Correlator/Correlator.csproj
+++ b/Correlator/Correlator.csproj
@@ -234,6 +234,7 @@
+
diff --git a/Correlator/Dialog/CheckResponseDialog.xaml b/Correlator/Dialog/CheckResponseDialog.xaml
index 2c66627..add4074 100644
--- a/Correlator/Dialog/CheckResponseDialog.xaml
+++ b/Correlator/Dialog/CheckResponseDialog.xaml
@@ -2,7 +2,7 @@
x:Class="Correlator.Dialog.CheckResponseDialog"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
- xmlns:converter="clr-namespace:Correlator.Converter"
+ xmlns:cvt="clr-namespace:Correlator.Converter"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:hc="https://handyorg.github.io/handycontrol"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
@@ -24,7 +24,7 @@
-
+
-
-
-
-
+
+
+
+
@@ -182,7 +170,7 @@
VerticalAlignment="Top"
hc:BorderElement.CornerRadius="17.5"
Content="下一步"
- IsEnabled="{Binding ElementName=RedSensorStepBar, Path=StepIndex, Converter={StaticResource StepButtonStateConverter}}"
+ IsEnabled="{Binding StepIndex, ElementName=RedSensorStepBar, Converter={StaticResource StateConverter}}"
Style="{StaticResource FunctionButtonStyle}" />
@@ -204,22 +192,10 @@
-
-
-
-
+
+
+
+
diff --git a/Correlator/Correlator.csproj b/Correlator/Correlator.csproj
index 1bbcfe0..dc91f84 100644
--- a/Correlator/Correlator.csproj
+++ b/Correlator/Correlator.csproj
@@ -234,6 +234,7 @@
+
diff --git a/Correlator/Dialog/CheckResponseDialog.xaml b/Correlator/Dialog/CheckResponseDialog.xaml
index 2c66627..add4074 100644
--- a/Correlator/Dialog/CheckResponseDialog.xaml
+++ b/Correlator/Dialog/CheckResponseDialog.xaml
@@ -2,7 +2,7 @@
x:Class="Correlator.Dialog.CheckResponseDialog"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
- xmlns:converter="clr-namespace:Correlator.Converter"
+ xmlns:cvt="clr-namespace:Correlator.Converter"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:hc="https://handyorg.github.io/handycontrol"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
@@ -24,7 +24,7 @@
-
+
-
-
-
-
+
+
+
+
@@ -182,7 +170,7 @@
VerticalAlignment="Top"
hc:BorderElement.CornerRadius="17.5"
Content="下一步"
- IsEnabled="{Binding ElementName=RedSensorStepBar, Path=StepIndex, Converter={StaticResource StepButtonStateConverter}}"
+ IsEnabled="{Binding StepIndex, ElementName=RedSensorStepBar, Converter={StaticResource StateConverter}}"
Style="{StaticResource FunctionButtonStyle}" />
@@ -204,22 +192,10 @@
-
-
-
-
+
+
+
+
diff --git a/Correlator/Dialog/ImportResponseDialog.xaml b/Correlator/Dialog/ImportResponseDialog.xaml
index d7dca60..99e7bf1 100644
--- a/Correlator/Dialog/ImportResponseDialog.xaml
+++ b/Correlator/Dialog/ImportResponseDialog.xaml
@@ -2,13 +2,14 @@
x:Class="Correlator.Dialog.ImportResponseDialog"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+ xmlns:b="http://schemas.microsoft.com/xaml/behaviors"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:hc="https://handyorg.github.io/handycontrol"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:prism="http://prismlibrary.com/"
xmlns:vm="clr-namespace:Correlator.ViewModels"
Width="650"
- Height="450"
+ Height="600"
d:DataContext="{d:DesignInstance Type=vm:ImportResponseDialogViewModel}"
mc:Ignorable="d">
@@ -39,7 +40,7 @@
-
+
@@ -69,103 +70,184 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
+
+
+
+
+
-
+
+
+
+
+
-
+
-
+
-
-
-
-
-
+
-
+
+
+
+
+
-
-
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
+
\ No newline at end of file
diff --git a/Correlator/Correlator.csproj b/Correlator/Correlator.csproj
index 1bbcfe0..dc91f84 100644
--- a/Correlator/Correlator.csproj
+++ b/Correlator/Correlator.csproj
@@ -234,6 +234,7 @@
+
diff --git a/Correlator/Dialog/CheckResponseDialog.xaml b/Correlator/Dialog/CheckResponseDialog.xaml
index 2c66627..add4074 100644
--- a/Correlator/Dialog/CheckResponseDialog.xaml
+++ b/Correlator/Dialog/CheckResponseDialog.xaml
@@ -2,7 +2,7 @@
x:Class="Correlator.Dialog.CheckResponseDialog"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
- xmlns:converter="clr-namespace:Correlator.Converter"
+ xmlns:cvt="clr-namespace:Correlator.Converter"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:hc="https://handyorg.github.io/handycontrol"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
@@ -24,7 +24,7 @@
-
+
-
-
-
-
+
+
+
+
@@ -182,7 +170,7 @@
VerticalAlignment="Top"
hc:BorderElement.CornerRadius="17.5"
Content="下一步"
- IsEnabled="{Binding ElementName=RedSensorStepBar, Path=StepIndex, Converter={StaticResource StepButtonStateConverter}}"
+ IsEnabled="{Binding StepIndex, ElementName=RedSensorStepBar, Converter={StaticResource StateConverter}}"
Style="{StaticResource FunctionButtonStyle}" />
@@ -204,22 +192,10 @@
-
-
-
-
+
+
+
+
diff --git a/Correlator/Dialog/ImportResponseDialog.xaml b/Correlator/Dialog/ImportResponseDialog.xaml
index d7dca60..99e7bf1 100644
--- a/Correlator/Dialog/ImportResponseDialog.xaml
+++ b/Correlator/Dialog/ImportResponseDialog.xaml
@@ -2,13 +2,14 @@
x:Class="Correlator.Dialog.ImportResponseDialog"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+ xmlns:b="http://schemas.microsoft.com/xaml/behaviors"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:hc="https://handyorg.github.io/handycontrol"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:prism="http://prismlibrary.com/"
xmlns:vm="clr-namespace:Correlator.ViewModels"
Width="650"
- Height="450"
+ Height="600"
d:DataContext="{d:DesignInstance Type=vm:ImportResponseDialogViewModel}"
mc:Ignorable="d">
@@ -39,7 +40,7 @@
-
+
@@ -69,103 +70,184 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
+
+
+
+
+
-
+
+
+
+
+
-
+
-
+
-
-
-
-
-
+
-
+
+
+
+
+
-
-
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
+
\ No newline at end of file
diff --git a/Correlator/Dialog/ImportResponseDialog.xaml.cs b/Correlator/Dialog/ImportResponseDialog.xaml.cs
index 79c2c1a..a160e16 100644
--- a/Correlator/Dialog/ImportResponseDialog.xaml.cs
+++ b/Correlator/Dialog/ImportResponseDialog.xaml.cs
@@ -1,4 +1,6 @@
using System.Windows.Controls;
+using Correlator.Events;
+using Prism.Events;
namespace Correlator.Dialog
{
@@ -7,9 +9,11 @@
///
public partial class ImportResponseDialog : UserControl
{
- public ImportResponseDialog()
+ public ImportResponseDialog(IEventAggregator eventAggregator)
{
InitializeComponent();
+
+ eventAggregator.GetEvent().Subscribe(delegate { ImportDataStepBar.Next(); });
}
}
}
\ No newline at end of file
diff --git a/Correlator/Correlator.csproj b/Correlator/Correlator.csproj
index 1bbcfe0..dc91f84 100644
--- a/Correlator/Correlator.csproj
+++ b/Correlator/Correlator.csproj
@@ -234,6 +234,7 @@
+
diff --git a/Correlator/Dialog/CheckResponseDialog.xaml b/Correlator/Dialog/CheckResponseDialog.xaml
index 2c66627..add4074 100644
--- a/Correlator/Dialog/CheckResponseDialog.xaml
+++ b/Correlator/Dialog/CheckResponseDialog.xaml
@@ -2,7 +2,7 @@
x:Class="Correlator.Dialog.CheckResponseDialog"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
- xmlns:converter="clr-namespace:Correlator.Converter"
+ xmlns:cvt="clr-namespace:Correlator.Converter"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:hc="https://handyorg.github.io/handycontrol"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
@@ -24,7 +24,7 @@
-
+
-
-
-
-
+
+
+
+
@@ -182,7 +170,7 @@
VerticalAlignment="Top"
hc:BorderElement.CornerRadius="17.5"
Content="下一步"
- IsEnabled="{Binding ElementName=RedSensorStepBar, Path=StepIndex, Converter={StaticResource StepButtonStateConverter}}"
+ IsEnabled="{Binding StepIndex, ElementName=RedSensorStepBar, Converter={StaticResource StateConverter}}"
Style="{StaticResource FunctionButtonStyle}" />
@@ -204,22 +192,10 @@
-
-
-
-
+
+
+
+
diff --git a/Correlator/Dialog/ImportResponseDialog.xaml b/Correlator/Dialog/ImportResponseDialog.xaml
index d7dca60..99e7bf1 100644
--- a/Correlator/Dialog/ImportResponseDialog.xaml
+++ b/Correlator/Dialog/ImportResponseDialog.xaml
@@ -2,13 +2,14 @@
x:Class="Correlator.Dialog.ImportResponseDialog"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+ xmlns:b="http://schemas.microsoft.com/xaml/behaviors"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:hc="https://handyorg.github.io/handycontrol"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:prism="http://prismlibrary.com/"
xmlns:vm="clr-namespace:Correlator.ViewModels"
Width="650"
- Height="450"
+ Height="600"
d:DataContext="{d:DesignInstance Type=vm:ImportResponseDialogViewModel}"
mc:Ignorable="d">
@@ -39,7 +40,7 @@
-
+
@@ -69,103 +70,184 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
+
+
+
+
+
-
+
+
+
+
+
-
+
-
+
-
-
-
-
-
+
-
+
+
+
+
+
-
-
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
+
\ No newline at end of file
diff --git a/Correlator/Dialog/ImportResponseDialog.xaml.cs b/Correlator/Dialog/ImportResponseDialog.xaml.cs
index 79c2c1a..a160e16 100644
--- a/Correlator/Dialog/ImportResponseDialog.xaml.cs
+++ b/Correlator/Dialog/ImportResponseDialog.xaml.cs
@@ -1,4 +1,6 @@
using System.Windows.Controls;
+using Correlator.Events;
+using Prism.Events;
namespace Correlator.Dialog
{
@@ -7,9 +9,11 @@
///
public partial class ImportResponseDialog : UserControl
{
- public ImportResponseDialog()
+ public ImportResponseDialog(IEventAggregator eventAggregator)
{
InitializeComponent();
+
+ eventAggregator.GetEvent().Subscribe(delegate { ImportDataStepBar.Next(); });
}
}
}
\ No newline at end of file
diff --git a/Correlator/Events/UpdateStepBarEvent.cs b/Correlator/Events/UpdateStepBarEvent.cs
new file mode 100644
index 0000000..25ba96c
--- /dev/null
+++ b/Correlator/Events/UpdateStepBarEvent.cs
@@ -0,0 +1,8 @@
+using Prism.Events;
+
+namespace Correlator.Events
+{
+ public class UpdateStepBarEvent : PubSubEvent
+ {
+ }
+}
\ No newline at end of file
diff --git a/Correlator/Correlator.csproj b/Correlator/Correlator.csproj
index 1bbcfe0..dc91f84 100644
--- a/Correlator/Correlator.csproj
+++ b/Correlator/Correlator.csproj
@@ -234,6 +234,7 @@
+
diff --git a/Correlator/Dialog/CheckResponseDialog.xaml b/Correlator/Dialog/CheckResponseDialog.xaml
index 2c66627..add4074 100644
--- a/Correlator/Dialog/CheckResponseDialog.xaml
+++ b/Correlator/Dialog/CheckResponseDialog.xaml
@@ -2,7 +2,7 @@
x:Class="Correlator.Dialog.CheckResponseDialog"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
- xmlns:converter="clr-namespace:Correlator.Converter"
+ xmlns:cvt="clr-namespace:Correlator.Converter"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:hc="https://handyorg.github.io/handycontrol"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
@@ -24,7 +24,7 @@
-
+
-
-
-
-
+
+
+
+
@@ -182,7 +170,7 @@
VerticalAlignment="Top"
hc:BorderElement.CornerRadius="17.5"
Content="下一步"
- IsEnabled="{Binding ElementName=RedSensorStepBar, Path=StepIndex, Converter={StaticResource StepButtonStateConverter}}"
+ IsEnabled="{Binding StepIndex, ElementName=RedSensorStepBar, Converter={StaticResource StateConverter}}"
Style="{StaticResource FunctionButtonStyle}" />
@@ -204,22 +192,10 @@
-
-
-
-
+
+
+
+
diff --git a/Correlator/Dialog/ImportResponseDialog.xaml b/Correlator/Dialog/ImportResponseDialog.xaml
index d7dca60..99e7bf1 100644
--- a/Correlator/Dialog/ImportResponseDialog.xaml
+++ b/Correlator/Dialog/ImportResponseDialog.xaml
@@ -2,13 +2,14 @@
x:Class="Correlator.Dialog.ImportResponseDialog"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+ xmlns:b="http://schemas.microsoft.com/xaml/behaviors"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:hc="https://handyorg.github.io/handycontrol"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:prism="http://prismlibrary.com/"
xmlns:vm="clr-namespace:Correlator.ViewModels"
Width="650"
- Height="450"
+ Height="600"
d:DataContext="{d:DesignInstance Type=vm:ImportResponseDialogViewModel}"
mc:Ignorable="d">
@@ -39,7 +40,7 @@
-
+
@@ -69,103 +70,184 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
+
+
+
+
+
-
+
+
+
+
+
-
+
-
+
-
-
-
-
-
+
-
+
+
+
+
+
-
-
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
+
\ No newline at end of file
diff --git a/Correlator/Dialog/ImportResponseDialog.xaml.cs b/Correlator/Dialog/ImportResponseDialog.xaml.cs
index 79c2c1a..a160e16 100644
--- a/Correlator/Dialog/ImportResponseDialog.xaml.cs
+++ b/Correlator/Dialog/ImportResponseDialog.xaml.cs
@@ -1,4 +1,6 @@
using System.Windows.Controls;
+using Correlator.Events;
+using Prism.Events;
namespace Correlator.Dialog
{
@@ -7,9 +9,11 @@
///
public partial class ImportResponseDialog : UserControl
{
- public ImportResponseDialog()
+ public ImportResponseDialog(IEventAggregator eventAggregator)
{
InitializeComponent();
+
+ eventAggregator.GetEvent().Subscribe(delegate { ImportDataStepBar.Next(); });
}
}
}
\ No newline at end of file
diff --git a/Correlator/Events/UpdateStepBarEvent.cs b/Correlator/Events/UpdateStepBarEvent.cs
new file mode 100644
index 0000000..25ba96c
--- /dev/null
+++ b/Correlator/Events/UpdateStepBarEvent.cs
@@ -0,0 +1,8 @@
+using Prism.Events;
+
+namespace Correlator.Events
+{
+ public class UpdateStepBarEvent : PubSubEvent
+ {
+ }
+}
\ No newline at end of file
diff --git a/Correlator/ViewModels/ImportResponseDialogViewModel.cs b/Correlator/ViewModels/ImportResponseDialogViewModel.cs
index b687697..ba95641 100644
--- a/Correlator/ViewModels/ImportResponseDialogViewModel.cs
+++ b/Correlator/ViewModels/ImportResponseDialogViewModel.cs
@@ -4,11 +4,15 @@
using System.Linq;
using System.Threading;
using System.Windows;
+using Correlator.Events;
using Correlator.Model;
using Correlator.SensorHubTag;
using Correlator.Util;
+using HandyControl.Controls;
using Microsoft.Win32;
+using Newtonsoft.Json;
using Prism.Commands;
+using Prism.Events;
using Prism.Mvvm;
using Prism.Services.Dialogs;
using MessageBox = HandyControl.Controls.MessageBox;
@@ -20,19 +24,37 @@
#region DelegateCommand
public DelegateCommand GoBackCommand { get; set; }
+ public DelegateCommand StepChangedCommand { get; set; }
+ public DelegateCommand SelectParamConfigFileCommand { get; set; }
public DelegateCommand SelectRedSensorFileCommand { get; set; }
public DelegateCommand SelectBlueSensorFileCommand { get; set; }
+ public DelegateCommand DetermineParamCommand { get; set; }
#endregion
public event Action RequestClose;
private bool _isRedSensor;
+ private readonly IEventAggregator _eventAggregator;
private readonly BackgroundWorker _backgroundWorker;
private readonly CorrelatorDataModel _dataModel;
+ private ParamConfigModel _configModel;
#region VM
public string Title { get; private set; } = string.Empty;
+
+ private string _paramConfigFilePath;
+
+ public string ParamConfigFilePath
+ {
+ get => _paramConfigFilePath;
+ set
+ {
+ _paramConfigFilePath = value;
+ RaisePropertyChanged();
+ }
+ }
+
private string _redSensorFilePath;
public string RedSensorFilePath
@@ -81,10 +103,48 @@
}
}
+ private bool _isRedSensorButtonEnabled;
+
+ public bool IsRedSensorButtonEnabled
+ {
+ get => _isRedSensorButtonEnabled;
+ set
+ {
+ _isRedSensorButtonEnabled = value;
+ RaisePropertyChanged();
+ }
+ }
+
+ private bool _isBlueSensorButtonEnabled;
+
+ public bool IsBlueSensorButtonEnabled
+ {
+ get => _isBlueSensorButtonEnabled;
+ set
+ {
+ _isBlueSensorButtonEnabled = value;
+ RaisePropertyChanged();
+ }
+ }
+
+ private bool _isDetermineButtonEnabled;
+
+ public bool IsDetermineButtonEnabled
+ {
+ get => _isDetermineButtonEnabled;
+ set
+ {
+ _isDetermineButtonEnabled = value;
+ RaisePropertyChanged();
+ }
+ }
+
#endregion
- public ImportResponseDialogViewModel()
+ public ImportResponseDialogViewModel(IEventAggregator eventAggregator)
{
+ _eventAggregator = eventAggregator;
+
_backgroundWorker = new BackgroundWorker();
_backgroundWorker.WorkerReportsProgress = true;
_backgroundWorker.WorkerSupportsCancellation = true;
@@ -96,13 +156,49 @@
GoBackCommand = new DelegateCommand(delegate
{
- if (_dataModel.LeftDeviceDataArray == null || _dataModel.RightDeviceDataArray == null)
+ RequestClose?.Invoke(new DialogResult(ButtonResult.Cancel));
+ });
+
+ StepChangedCommand = new DelegateCommand(delegate(StepBar stepBar)
+ {
+ switch (stepBar.StepIndex)
{
- RequestClose?.Invoke(new DialogResult(ButtonResult.Cancel));
+ case 1:
+ IsRedSensorButtonEnabled = true;
+ break;
+ case 2:
+ IsBlueSensorButtonEnabled = true;
+ break;
+ case 3:
+ IsDetermineButtonEnabled = true;
+ break;
+ default:
+ IsRedSensorButtonEnabled = false;
+ IsBlueSensorButtonEnabled = false;
+ IsDetermineButtonEnabled = false;
+ break;
}
- else
+ });
+
+ SelectParamConfigFileCommand = new DelegateCommand(delegate
+ {
+ var fileDialog = new OpenFileDialog
{
- RequestClose?.Invoke(new DialogResult(ButtonResult.OK));
+ // 设置默认格式
+ DefaultExt = ".json",
+ Filter = "参数配置文件(*.json)|*.json"
+ };
+ var result = fileDialog.ShowDialog();
+ if (result == true)
+ {
+ ParamConfigFilePath = fileDialog.FileName;
+ //处理JSON
+ var fromFile = _paramConfigFilePath.ReadFromFile();
+ //参数配置就一行
+ var configJson = fromFile[0];
+ _configModel = JsonConvert.DeserializeObject(configJson);
+ //更新步骤条
+ _eventAggregator.GetEvent().Publish();
}
});
@@ -153,6 +249,17 @@
_backgroundWorker.RunWorkerAsync();
}
});
+
+ DetermineParamCommand = new DelegateCommand(delegate
+ {
+ RequestClose?.Invoke(new DialogResult(
+ ButtonResult.OK, new DialogParameters
+ {
+ { "ParamConfigModel", _configModel }
+ }
+ )
+ );
+ });
}
private void Worker_OnDoWork(object sender, DoWorkEventArgs e)
@@ -190,7 +297,7 @@
e.Cancel = true;
return;
}
-
+
var dataFromFile = BlueSensorFilePath.ReadFromFile();
var doubleArrays = dataFromFile.Select(HandleSerialPortData).ToList();
@@ -216,10 +323,20 @@
if (_isRedSensor)
{
RedProgressBarValue = e.ProgressPercentage;
+ if (RedProgressBarValue == 100)
+ {
+ //更新步骤条
+ _eventAggregator.GetEvent().Publish();
+ }
}
else
{
BlueProgressBarValue = e.ProgressPercentage;
+ if (BlueProgressBarValue == 100)
+ {
+ //更新步骤条
+ _eventAggregator.GetEvent().Publish();
+ }
}
}
diff --git a/Correlator/Correlator.csproj b/Correlator/Correlator.csproj
index 1bbcfe0..dc91f84 100644
--- a/Correlator/Correlator.csproj
+++ b/Correlator/Correlator.csproj
@@ -234,6 +234,7 @@
+
diff --git a/Correlator/Dialog/CheckResponseDialog.xaml b/Correlator/Dialog/CheckResponseDialog.xaml
index 2c66627..add4074 100644
--- a/Correlator/Dialog/CheckResponseDialog.xaml
+++ b/Correlator/Dialog/CheckResponseDialog.xaml
@@ -2,7 +2,7 @@
x:Class="Correlator.Dialog.CheckResponseDialog"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
- xmlns:converter="clr-namespace:Correlator.Converter"
+ xmlns:cvt="clr-namespace:Correlator.Converter"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:hc="https://handyorg.github.io/handycontrol"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
@@ -24,7 +24,7 @@
-
+
-
-
-
-
+
+
+
+
@@ -182,7 +170,7 @@
VerticalAlignment="Top"
hc:BorderElement.CornerRadius="17.5"
Content="下一步"
- IsEnabled="{Binding ElementName=RedSensorStepBar, Path=StepIndex, Converter={StaticResource StepButtonStateConverter}}"
+ IsEnabled="{Binding StepIndex, ElementName=RedSensorStepBar, Converter={StaticResource StateConverter}}"
Style="{StaticResource FunctionButtonStyle}" />
@@ -204,22 +192,10 @@
-
-
-
-
+
+
+
+
diff --git a/Correlator/Dialog/ImportResponseDialog.xaml b/Correlator/Dialog/ImportResponseDialog.xaml
index d7dca60..99e7bf1 100644
--- a/Correlator/Dialog/ImportResponseDialog.xaml
+++ b/Correlator/Dialog/ImportResponseDialog.xaml
@@ -2,13 +2,14 @@
x:Class="Correlator.Dialog.ImportResponseDialog"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+ xmlns:b="http://schemas.microsoft.com/xaml/behaviors"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:hc="https://handyorg.github.io/handycontrol"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:prism="http://prismlibrary.com/"
xmlns:vm="clr-namespace:Correlator.ViewModels"
Width="650"
- Height="450"
+ Height="600"
d:DataContext="{d:DesignInstance Type=vm:ImportResponseDialogViewModel}"
mc:Ignorable="d">
@@ -39,7 +40,7 @@
-
+
@@ -69,103 +70,184 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
+
+
+
+
+
-
+
+
+
+
+
-
+
-
+
-
-
-
-
-
+
-
+
+
+
+
+
-
-
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
+
\ No newline at end of file
diff --git a/Correlator/Dialog/ImportResponseDialog.xaml.cs b/Correlator/Dialog/ImportResponseDialog.xaml.cs
index 79c2c1a..a160e16 100644
--- a/Correlator/Dialog/ImportResponseDialog.xaml.cs
+++ b/Correlator/Dialog/ImportResponseDialog.xaml.cs
@@ -1,4 +1,6 @@
using System.Windows.Controls;
+using Correlator.Events;
+using Prism.Events;
namespace Correlator.Dialog
{
@@ -7,9 +9,11 @@
///
public partial class ImportResponseDialog : UserControl
{
- public ImportResponseDialog()
+ public ImportResponseDialog(IEventAggregator eventAggregator)
{
InitializeComponent();
+
+ eventAggregator.GetEvent().Subscribe(delegate { ImportDataStepBar.Next(); });
}
}
}
\ No newline at end of file
diff --git a/Correlator/Events/UpdateStepBarEvent.cs b/Correlator/Events/UpdateStepBarEvent.cs
new file mode 100644
index 0000000..25ba96c
--- /dev/null
+++ b/Correlator/Events/UpdateStepBarEvent.cs
@@ -0,0 +1,8 @@
+using Prism.Events;
+
+namespace Correlator.Events
+{
+ public class UpdateStepBarEvent : PubSubEvent
+ {
+ }
+}
\ No newline at end of file
diff --git a/Correlator/ViewModels/ImportResponseDialogViewModel.cs b/Correlator/ViewModels/ImportResponseDialogViewModel.cs
index b687697..ba95641 100644
--- a/Correlator/ViewModels/ImportResponseDialogViewModel.cs
+++ b/Correlator/ViewModels/ImportResponseDialogViewModel.cs
@@ -4,11 +4,15 @@
using System.Linq;
using System.Threading;
using System.Windows;
+using Correlator.Events;
using Correlator.Model;
using Correlator.SensorHubTag;
using Correlator.Util;
+using HandyControl.Controls;
using Microsoft.Win32;
+using Newtonsoft.Json;
using Prism.Commands;
+using Prism.Events;
using Prism.Mvvm;
using Prism.Services.Dialogs;
using MessageBox = HandyControl.Controls.MessageBox;
@@ -20,19 +24,37 @@
#region DelegateCommand
public DelegateCommand GoBackCommand { get; set; }
+ public DelegateCommand StepChangedCommand { get; set; }
+ public DelegateCommand SelectParamConfigFileCommand { get; set; }
public DelegateCommand SelectRedSensorFileCommand { get; set; }
public DelegateCommand SelectBlueSensorFileCommand { get; set; }
+ public DelegateCommand DetermineParamCommand { get; set; }
#endregion
public event Action RequestClose;
private bool _isRedSensor;
+ private readonly IEventAggregator _eventAggregator;
private readonly BackgroundWorker _backgroundWorker;
private readonly CorrelatorDataModel _dataModel;
+ private ParamConfigModel _configModel;
#region VM
public string Title { get; private set; } = string.Empty;
+
+ private string _paramConfigFilePath;
+
+ public string ParamConfigFilePath
+ {
+ get => _paramConfigFilePath;
+ set
+ {
+ _paramConfigFilePath = value;
+ RaisePropertyChanged();
+ }
+ }
+
private string _redSensorFilePath;
public string RedSensorFilePath
@@ -81,10 +103,48 @@
}
}
+ private bool _isRedSensorButtonEnabled;
+
+ public bool IsRedSensorButtonEnabled
+ {
+ get => _isRedSensorButtonEnabled;
+ set
+ {
+ _isRedSensorButtonEnabled = value;
+ RaisePropertyChanged();
+ }
+ }
+
+ private bool _isBlueSensorButtonEnabled;
+
+ public bool IsBlueSensorButtonEnabled
+ {
+ get => _isBlueSensorButtonEnabled;
+ set
+ {
+ _isBlueSensorButtonEnabled = value;
+ RaisePropertyChanged();
+ }
+ }
+
+ private bool _isDetermineButtonEnabled;
+
+ public bool IsDetermineButtonEnabled
+ {
+ get => _isDetermineButtonEnabled;
+ set
+ {
+ _isDetermineButtonEnabled = value;
+ RaisePropertyChanged();
+ }
+ }
+
#endregion
- public ImportResponseDialogViewModel()
+ public ImportResponseDialogViewModel(IEventAggregator eventAggregator)
{
+ _eventAggregator = eventAggregator;
+
_backgroundWorker = new BackgroundWorker();
_backgroundWorker.WorkerReportsProgress = true;
_backgroundWorker.WorkerSupportsCancellation = true;
@@ -96,13 +156,49 @@
GoBackCommand = new DelegateCommand(delegate
{
- if (_dataModel.LeftDeviceDataArray == null || _dataModel.RightDeviceDataArray == null)
+ RequestClose?.Invoke(new DialogResult(ButtonResult.Cancel));
+ });
+
+ StepChangedCommand = new DelegateCommand(delegate(StepBar stepBar)
+ {
+ switch (stepBar.StepIndex)
{
- RequestClose?.Invoke(new DialogResult(ButtonResult.Cancel));
+ case 1:
+ IsRedSensorButtonEnabled = true;
+ break;
+ case 2:
+ IsBlueSensorButtonEnabled = true;
+ break;
+ case 3:
+ IsDetermineButtonEnabled = true;
+ break;
+ default:
+ IsRedSensorButtonEnabled = false;
+ IsBlueSensorButtonEnabled = false;
+ IsDetermineButtonEnabled = false;
+ break;
}
- else
+ });
+
+ SelectParamConfigFileCommand = new DelegateCommand(delegate
+ {
+ var fileDialog = new OpenFileDialog
{
- RequestClose?.Invoke(new DialogResult(ButtonResult.OK));
+ // 设置默认格式
+ DefaultExt = ".json",
+ Filter = "参数配置文件(*.json)|*.json"
+ };
+ var result = fileDialog.ShowDialog();
+ if (result == true)
+ {
+ ParamConfigFilePath = fileDialog.FileName;
+ //处理JSON
+ var fromFile = _paramConfigFilePath.ReadFromFile();
+ //参数配置就一行
+ var configJson = fromFile[0];
+ _configModel = JsonConvert.DeserializeObject(configJson);
+ //更新步骤条
+ _eventAggregator.GetEvent().Publish();
}
});
@@ -153,6 +249,17 @@
_backgroundWorker.RunWorkerAsync();
}
});
+
+ DetermineParamCommand = new DelegateCommand(delegate
+ {
+ RequestClose?.Invoke(new DialogResult(
+ ButtonResult.OK, new DialogParameters
+ {
+ { "ParamConfigModel", _configModel }
+ }
+ )
+ );
+ });
}
private void Worker_OnDoWork(object sender, DoWorkEventArgs e)
@@ -190,7 +297,7 @@
e.Cancel = true;
return;
}
-
+
var dataFromFile = BlueSensorFilePath.ReadFromFile();
var doubleArrays = dataFromFile.Select(HandleSerialPortData).ToList();
@@ -216,10 +323,20 @@
if (_isRedSensor)
{
RedProgressBarValue = e.ProgressPercentage;
+ if (RedProgressBarValue == 100)
+ {
+ //更新步骤条
+ _eventAggregator.GetEvent().Publish();
+ }
}
else
{
BlueProgressBarValue = e.ProgressPercentage;
+ if (BlueProgressBarValue == 100)
+ {
+ //更新步骤条
+ _eventAggregator.GetEvent().Publish();
+ }
}
}
diff --git a/Correlator/ViewModels/MainWindowViewModel.cs b/Correlator/ViewModels/MainWindowViewModel.cs
index 145a3e2..137d22e 100644
--- a/Correlator/ViewModels/MainWindowViewModel.cs
+++ b/Correlator/ViewModels/MainWindowViewModel.cs
@@ -544,9 +544,9 @@
private void StartCalculateData()
{
- var it = FlowStatus.CorrelatorData;
DialogHub.Get.ShowLoadingDialog(_mainWindow, "数据计算中,请稍后...");
- //开始计算就不收集收据了
+ //开始计算就不收集收据了且不能点击开始按钮
+ StartButtonEnabled = false;
FlowStatus.CanCollectData = false;
if (!FlowStatus.IsHydrophone)
{
@@ -575,15 +575,15 @@
//计算
//异步计算数据
- new Thread(() => CalculateData(it)).Start();
+ new Thread(CalculateData).Start();
}
///
/// 算法计算
///
- ///
- private void CalculateData(CorrelatorDataModel dataModel)
+ private void CalculateData()
{
+ var dataModel = FlowStatus.CorrelatorData;
if (dataModel.LeftDeviceDataArray != null && dataModel.RightDeviceDataArray != null)
{
Debug.WriteLine("MainWindowViewModel => 开始计算");
@@ -836,6 +836,17 @@
return;
}
+ if (result.Result == ButtonResult.OK)
+ {
+ var configModel = result.Parameters.GetValue("ParamConfigModel");
+
+ MaterialName = configModel.PipeMaterial;
+ PipeDiameter = configModel.PipeDiameter;
+ PipeLength = configModel.PipeLength;
+ LowFrequency = configModel.MinFrequency;
+ HighFrequency = configModel.MaxFrequency;
+ }
+
//导入数据完成,可以计算数据
StartCalculateData();
});
@@ -900,7 +911,6 @@
if (CheckParamLegitimacy())
{
_isResetParam = false;
- StartButtonEnabled = false;
//每次计算之前都需要判断是否已经完成之前的计算,然后清空上一次的计算数据
ResetParam();