|
@@ -11,6 +11,7 @@ using System.ComponentModel.DataAnnotations;
|
|
|
using System.Diagnostics.CodeAnalysis;
|
|
|
using System.IO;
|
|
|
using System.Linq;
|
|
|
+using System.Security.AccessControl;
|
|
|
using System.Text;
|
|
|
using System.Threading.Tasks;
|
|
|
using System.Windows;
|
|
@@ -18,6 +19,8 @@ using System.Windows.Controls;
|
|
|
using System.Windows.Input;
|
|
|
using System.Windows.Media;
|
|
|
using System.Windows.Media.Animation;
|
|
|
+using System.Windows.Media.Media3D;
|
|
|
+using System.Windows.Threading;
|
|
|
using XamlAnimatedGif;
|
|
|
|
|
|
namespace ShakerManger.ViewModel
|
|
@@ -30,7 +33,7 @@ namespace ShakerManger.ViewModel
|
|
|
private ObservableCollection<DataMangerItemViewModel> Items { get; } = new ObservableCollection<DataMangerItemViewModel>();
|
|
|
|
|
|
private List<OxyPlot.Series.LineSeries> _LineSeries = new List<OxyPlot.Series.LineSeries>();
|
|
|
- public string GifPath { get => gifPath; set =>UpdateProperty(ref gifPath, value); }
|
|
|
+
|
|
|
public string[] PropertiyNames { get; }= new string[]
|
|
|
{
|
|
|
nameof(DataMangerItemViewModel.OperatingStatus),
|
|
@@ -58,13 +61,13 @@ namespace ShakerManger.ViewModel
|
|
|
nameof(DataMangerItemViewModel.Gain),
|
|
|
};
|
|
|
|
|
|
- public bool ImageVisibily { get => imageVisibily; set =>UpdateProperty(ref imageVisibily,value); }
|
|
|
+ public bool ModelVisibily { get => modelVisibily; set =>UpdateProperty(ref modelVisibily,value); }
|
|
|
public ICommand MenuShowCommand => new DelegateCommand<ExCommandParameter>(MenuShow);
|
|
|
private void MenuShow(ExCommandParameter parameter)
|
|
|
{
|
|
|
if(parameter.EventArgs is MouseButtonEventArgs args)
|
|
|
{
|
|
|
- if (args.ChangedButton == MouseButton.Right)
|
|
|
+ if (args.ChangedButton == MouseButton.Right && (args.OriginalSource == null ? true :!(args.OriginalSource.GetType().FullName.Contains("Helix"))))
|
|
|
{
|
|
|
MenuIsOpen = true;
|
|
|
}
|
|
@@ -138,25 +141,7 @@ namespace ShakerManger.ViewModel
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- public bool StartupCompleted
|
|
|
- {
|
|
|
- get => startupCompleted;
|
|
|
- set
|
|
|
- {
|
|
|
- if (startupCompleted == value) return;
|
|
|
- UpdateProperty(ref startupCompleted, value);
|
|
|
- OnPropertyChanged(nameof(GainSwitchEnabled));
|
|
|
- if (animator == null) return;
|
|
|
- if(value)
|
|
|
- {
|
|
|
- animator?.Play();
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- animator?.Pause();
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+
|
|
|
public bool MenuIsOpen { get => menuIsOpen; set =>UpdateProperty(ref menuIsOpen , value); }
|
|
|
private Data.ShakerViewType lastviewType = ShakerViewType.ShakerControl;
|
|
|
public Data.ShakerViewType ShakerView
|
|
@@ -188,22 +173,61 @@ namespace ShakerManger.ViewModel
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- private bool isVisible = false;
|
|
|
+ public bool StartupCompleted
|
|
|
+ {
|
|
|
+ get => startupCompleted;
|
|
|
+ set
|
|
|
+ {
|
|
|
+ if (startupCompleted == value) return;
|
|
|
+ UpdateProperty(ref startupCompleted, value);
|
|
|
+ OnPropertyChanged(nameof(GainSwitchEnabled));
|
|
|
+ if (value)
|
|
|
+ {
|
|
|
+ animator?.Play();
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ animator.Pause();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ public bool CacheFramesInMemory { get => cacheFramesInMemory; set => UpdateProperty(ref cacheFramesInMemory, value); }
|
|
|
+ public bool AutoStart { get => autoStart; set => UpdateProperty(ref autoStart, value); }
|
|
|
+ [AllowNull]
|
|
|
+ private Animator animator;
|
|
|
+
|
|
|
+ [AllowNull]
|
|
|
+ private Image image;
|
|
|
+
|
|
|
|
|
|
+ public Image Image
|
|
|
+ {
|
|
|
+ get => image;
|
|
|
+ set
|
|
|
+ {
|
|
|
+ image = value;
|
|
|
+ if (animator == null && value != null) animator = AnimationBehavior.GetAnimator(value);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ public RepeatBehavior RepeatBehavior { get => repeatBehavior; set =>UpdateProperty(ref repeatBehavior, value); }
|
|
|
+ public string GifPath { get => gifPath; set => UpdateProperty(ref gifPath, value); }
|
|
|
+ private bool isVisible = false;
|
|
|
+ private static string ModelDirectory=System.AppDomain.CurrentDomain.BaseDirectory + $"Model\\";
|
|
|
public bool IsVisible { get => isVisible; set => UpdateProperty(ref isVisible, value); }
|
|
|
public string[] AnalogNames { get; } = new string[Shaker.Model.DataMangerItemModel.ANALOG_DATA_LENGTH];
|
|
|
public string[] Units { get; } = new string[Shaker.Model.DataMangerItemModel.ANALOG_DATA_LENGTH];
|
|
|
private Dictionary<string, string> Properties { get; init; } = new Dictionary<string, string>();
|
|
|
|
|
|
public ObservableCollection<PlotConfigViewModel> PlotConfig { get; } = new ObservableCollection<PlotConfigViewModel>();
|
|
|
- public RepeatBehavior RepeatBehavior { get => repeatBehavior; set =>UpdateProperty(ref repeatBehavior, value); }
|
|
|
public int Index { get; }
|
|
|
+
|
|
|
public ShakerControlViewModel(Shaker.Model.ShakerControlModel model,int index)
|
|
|
{
|
|
|
Index = index;
|
|
|
- GifPath = System.AppDomain.CurrentDomain.BaseDirectory + $"\\GIF\\Shaker{index}.gif";
|
|
|
- ImageVisibily = File.Exists(GifPath);
|
|
|
Model = model;
|
|
|
+ GifPath = System.AppDomain.CurrentDomain.BaseDirectory + $"\\GIF\\Shaker{index}.gif";
|
|
|
+ ModelVisibily = File.Exists(GifPath);
|
|
|
+
|
|
|
Values.Add(new PLCAnlogViewModel(model.ExcitationVoltage));
|
|
|
Values.Add(new PLCAnlogViewModel(model.ExcitationCurrent)
|
|
|
{
|
|
@@ -416,7 +440,7 @@ namespace ShakerManger.ViewModel
|
|
|
{
|
|
|
GainSwitch = data.GainSwich;
|
|
|
StartupCompleted = data.StartupCompleted;
|
|
|
-
|
|
|
+
|
|
|
});
|
|
|
}, $"{Shaker.Model.GlobalVariable.ShakerIDKey}='{Model.Id}'");
|
|
|
BusManger.Defaut.Bus.PubSub.Subscribe<Shaker.Model.ClientExitModel>((data, pro) =>
|
|
@@ -467,6 +491,7 @@ namespace ShakerManger.ViewModel
|
|
|
MenuIsOpen = true;
|
|
|
}));
|
|
|
}
|
|
|
+
|
|
|
public OxyPlot.IPlotController PlotController { get; } = new OxyPlot.PlotController();
|
|
|
public View.ShakerView Content { get; } = new View.ShakerView();
|
|
|
public bool GainSwitch
|
|
@@ -562,6 +587,13 @@ namespace ShakerManger.ViewModel
|
|
|
{
|
|
|
if (switchon) Open();
|
|
|
else Close();
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if(parameter.Parameter is string val && bool.TryParse(val,out var result))
|
|
|
+ {
|
|
|
+ if (result) Open();
|
|
|
+ else Close();
|
|
|
+ return;
|
|
|
}
|
|
|
}
|
|
|
private void SetGain(short gain)
|
|
@@ -579,8 +611,7 @@ namespace ShakerManger.ViewModel
|
|
|
PromptViewModel.Default.NoVisibility = Visibility.Collapsed;
|
|
|
PromptViewModel.Default.IsOpen = true;
|
|
|
}
|
|
|
- }
|
|
|
- public bool GainSwitchEnabled => CurrentData?.OperatingStatus == OperatingStatus.Run && StartupCompleted;
|
|
|
+ } public bool GainSwitchEnabled => CurrentData?.OperatingStatus == OperatingStatus.Run && StartupCompleted;
|
|
|
public bool GainEnabled => CurrentData != null && (CurrentData.OperatingStatus == OperatingStatus.Run && GainSwitch);
|
|
|
public bool StartEnabled => CurrentData?.OperatingStatus == OperatingStatus.Wait;
|
|
|
public bool StopEnabled => CurrentData?.OperatingStatus == OperatingStatus.Run;
|
|
@@ -659,18 +690,12 @@ namespace ShakerManger.ViewModel
|
|
|
private string activeMQClintID = string.Empty;
|
|
|
private string gifPath = string.Empty;
|
|
|
private RepeatBehavior repeatBehavior = RepeatBehavior.Forever;
|
|
|
- private bool autoStart = false;
|
|
|
+ private bool autoStart = true;
|
|
|
private bool cacheFramesInMemory = true;
|
|
|
|
|
|
- public bool CacheFramesInMemory { get => cacheFramesInMemory; set =>UpdateProperty(ref cacheFramesInMemory, value); }
|
|
|
- public bool AutoStart { get => autoStart; set =>UpdateProperty(ref autoStart ,value); }
|
|
|
public string Title => string.IsNullOrEmpty(Description) ? Name : Description;
|
|
|
- [AllowNull]
|
|
|
- private Animator animator;
|
|
|
|
|
|
- [AllowNull]
|
|
|
- private Image image;
|
|
|
- private bool imageVisibily = false;
|
|
|
+ private bool modelVisibily = false;
|
|
|
|
|
|
public string Name
|
|
|
{
|
|
@@ -681,15 +706,7 @@ namespace ShakerManger.ViewModel
|
|
|
OnPropertyChanged(nameof(Title));
|
|
|
}
|
|
|
}
|
|
|
- public Image Image
|
|
|
- {
|
|
|
- get => image;
|
|
|
- set
|
|
|
- {
|
|
|
- image = value;
|
|
|
- if (animator == null && value!=null) animator = AnimationBehavior.GetAnimator(value);
|
|
|
- }
|
|
|
- }
|
|
|
+
|
|
|
public string Description
|
|
|
{
|
|
|
get => Model.Description;
|