diff --git a/Correlator/ViewModels/BigPictureViewModel.cs b/Correlator/ViewModels/BigPictureViewModel.cs index 7f1a055..4dd9fc9 100644 --- a/Correlator/ViewModels/BigPictureViewModel.cs +++ b/Correlator/ViewModels/BigPictureViewModel.cs @@ -1,6 +1,6 @@ using System; +using System.IO; using System.Windows.Media.Imaging; -using Prism.Commands; using Prism.Mvvm; using Prism.Services.Dialogs; @@ -8,7 +8,7 @@ { public class BigPictureViewModel : BindableBase, IDialogAware { - public string Title => string.Empty; + public string Title { get; set; } private BitmapImage _bigPictureBitmapImage; public BitmapImage BigPictureBitmapImage @@ -22,17 +22,6 @@ } public event Action RequestClose; - public DelegateCommand CloseWindowCommand { get; set; } - - public BigPictureViewModel() - { - CloseWindowCommand = new DelegateCommand(CloseWindow); - } - - private void CloseWindow() - { - RequestClose?.Invoke(new DialogResult(ButtonResult.Cancel)); - } public bool CanCloseDialog() { @@ -46,6 +35,7 @@ public void OnDialogOpened(IDialogParameters parameters) { var imageFullPath = parameters.GetValue("ImageFullPath"); + Title = Path.GetFileName(imageFullPath); BigPictureBitmapImage = new BitmapImage(new Uri(imageFullPath, UriKind.Absolute)); } } diff --git a/Correlator/ViewModels/BigPictureViewModel.cs b/Correlator/ViewModels/BigPictureViewModel.cs index 7f1a055..4dd9fc9 100644 --- a/Correlator/ViewModels/BigPictureViewModel.cs +++ b/Correlator/ViewModels/BigPictureViewModel.cs @@ -1,6 +1,6 @@ using System; +using System.IO; using System.Windows.Media.Imaging; -using Prism.Commands; using Prism.Mvvm; using Prism.Services.Dialogs; @@ -8,7 +8,7 @@ { public class BigPictureViewModel : BindableBase, IDialogAware { - public string Title => string.Empty; + public string Title { get; set; } private BitmapImage _bigPictureBitmapImage; public BitmapImage BigPictureBitmapImage @@ -22,17 +22,6 @@ } public event Action RequestClose; - public DelegateCommand CloseWindowCommand { get; set; } - - public BigPictureViewModel() - { - CloseWindowCommand = new DelegateCommand(CloseWindow); - } - - private void CloseWindow() - { - RequestClose?.Invoke(new DialogResult(ButtonResult.Cancel)); - } public bool CanCloseDialog() { @@ -46,6 +35,7 @@ public void OnDialogOpened(IDialogParameters parameters) { var imageFullPath = parameters.GetValue("ImageFullPath"); + Title = Path.GetFileName(imageFullPath); BigPictureBitmapImage = new BitmapImage(new Uri(imageFullPath, UriKind.Absolute)); } } diff --git a/Correlator/ViewModels/MainWindowViewModel.cs b/Correlator/ViewModels/MainWindowViewModel.cs index 3e03006..88f521e 100644 --- a/Correlator/ViewModels/MainWindowViewModel.cs +++ b/Correlator/ViewModels/MainWindowViewModel.cs @@ -956,18 +956,16 @@ var ports = SerialPort.GetPortNames(); foreach (var portName in ports) { - if (portName != RuntimeCache.PortName && !_serialPortService.Sp.IsOpen) - { - _serialPortService.Sp.PortName = portName; - _serialPortService.Sp.BaudRate = 230400; - _serialPortService.Sp.DataBits = 8; - _serialPortService.Sp.StopBits = (StopBits)1; - _serialPortService.Sp.Open(); - "MainWindowViewModel".WriteLog("打开串口"); + if (portName != RuntimeCache.PortName || _serialPortService.Sp.IsOpen) continue; + _serialPortService.Sp.PortName = portName; + _serialPortService.Sp.BaudRate = 230400; + _serialPortService.Sp.DataBits = 8; + _serialPortService.Sp.StopBits = (StopBits)1; + _serialPortService.Sp.Open(); + "MainWindowViewModel".WriteLog("打开串口"); - ConnectColorBrush = "LimeGreen"; - break; - } + ConnectColorBrush = "LimeGreen"; + break; } if (_serialPortService.Sp.IsOpen) diff --git a/Correlator/ViewModels/BigPictureViewModel.cs b/Correlator/ViewModels/BigPictureViewModel.cs index 7f1a055..4dd9fc9 100644 --- a/Correlator/ViewModels/BigPictureViewModel.cs +++ b/Correlator/ViewModels/BigPictureViewModel.cs @@ -1,6 +1,6 @@ using System; +using System.IO; using System.Windows.Media.Imaging; -using Prism.Commands; using Prism.Mvvm; using Prism.Services.Dialogs; @@ -8,7 +8,7 @@ { public class BigPictureViewModel : BindableBase, IDialogAware { - public string Title => string.Empty; + public string Title { get; set; } private BitmapImage _bigPictureBitmapImage; public BitmapImage BigPictureBitmapImage @@ -22,17 +22,6 @@ } public event Action RequestClose; - public DelegateCommand CloseWindowCommand { get; set; } - - public BigPictureViewModel() - { - CloseWindowCommand = new DelegateCommand(CloseWindow); - } - - private void CloseWindow() - { - RequestClose?.Invoke(new DialogResult(ButtonResult.Cancel)); - } public bool CanCloseDialog() { @@ -46,6 +35,7 @@ public void OnDialogOpened(IDialogParameters parameters) { var imageFullPath = parameters.GetValue("ImageFullPath"); + Title = Path.GetFileName(imageFullPath); BigPictureBitmapImage = new BitmapImage(new Uri(imageFullPath, UriKind.Absolute)); } } diff --git a/Correlator/ViewModels/MainWindowViewModel.cs b/Correlator/ViewModels/MainWindowViewModel.cs index 3e03006..88f521e 100644 --- a/Correlator/ViewModels/MainWindowViewModel.cs +++ b/Correlator/ViewModels/MainWindowViewModel.cs @@ -956,18 +956,16 @@ var ports = SerialPort.GetPortNames(); foreach (var portName in ports) { - if (portName != RuntimeCache.PortName && !_serialPortService.Sp.IsOpen) - { - _serialPortService.Sp.PortName = portName; - _serialPortService.Sp.BaudRate = 230400; - _serialPortService.Sp.DataBits = 8; - _serialPortService.Sp.StopBits = (StopBits)1; - _serialPortService.Sp.Open(); - "MainWindowViewModel".WriteLog("打开串口"); + if (portName != RuntimeCache.PortName || _serialPortService.Sp.IsOpen) continue; + _serialPortService.Sp.PortName = portName; + _serialPortService.Sp.BaudRate = 230400; + _serialPortService.Sp.DataBits = 8; + _serialPortService.Sp.StopBits = (StopBits)1; + _serialPortService.Sp.Open(); + "MainWindowViewModel".WriteLog("打开串口"); - ConnectColorBrush = "LimeGreen"; - break; - } + ConnectColorBrush = "LimeGreen"; + break; } if (_serialPortService.Sp.IsOpen) diff --git a/Correlator/Views/BigPictureView.xaml b/Correlator/Views/BigPictureView.xaml index 36104fd..001303b 100644 --- a/Correlator/Views/BigPictureView.xaml +++ b/Correlator/Views/BigPictureView.xaml @@ -14,47 +14,12 @@ - - - + \ No newline at end of file