|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135 |
- using BPA.Helper;
- using BPASmartClient.Model;
- using BPASmartClient.MorkM.Model;
- using BPASmartClient.MorkM.View;
- using BPA.Helper;
-
- using System;
- using System.Collections.Generic;
- using System.Collections.ObjectModel;
- using System.ComponentModel;
- using System.Diagnostics;
- using System.Linq;
- using System.Runtime.CompilerServices;
- using System.Text;
- using System.Threading.Tasks;
-
- namespace BPASmartClient.MorkM.ViewModel
- {
- internal class DebugViewModel : NotifyBase
- {
- public DebugViewModel()
- {
-
-
- AddSimDataCommand = new BPARelayCommand(() =>
- {
- SimOrderConfitView simOrderConfitView = new SimOrderConfitView();
- simOrderConfitView.Show();
- });
-
- SimOrderCommand = new BPARelayCommand(() =>
- {
- List<ushort> locs = new List<ushort>();
- foreach (var item in simOrderConfig)
- {
- if (item.IsSelected)
- locs.Add((ushort)(new Random().Next(item.MinValue, item.MaxValue + 1)));
- else
- locs.Add(item.Loc);
- }
- if (locs.Count == 0)
- {
- locs.Add((ushort)(new Random().Next(1, 5)));
- locs.Add(10);
- }
-
- ActionManage.GetInstance.Send(locs, "SimOrder");
- //下发模拟订单
- Trace.WriteLine("下发模拟订单。。。");
- });
-
- InitCommand = new BPARelayCommand(() =>
- {
- ActionManage.GetInstance.Send("InitDevice");
- //初始化按钮
- Trace.WriteLine("已点击初始化按钮。。。");
- });
-
- LoopSimOrderCommand = new BPARelayCommand(() =>
- {
- if (LoopOrderButtonContent == "循环跑单") ActionManage.GetInstance.Send("EnableForOrder");
- if (LoopOrderButtonContent == "停止跑单") ActionManage.GetInstance.Send("StopForOrder");
- LoopOrderButtonContent = LoopOrderButtonContent == "循环跑单" ? "停止跑单" : "循环跑单";
-
- });
-
-
- EditCommand = new BPARelayCommand<object>((o) =>
- {
- if (o != null)
- {
- var res = Json<KeepDataBase>.Data.simOrderConfig.FirstOrDefault(p => p.Text == o.ToString());
- if (res != null)
- {
- SimOrderConfitView simOrderConfitView = new SimOrderConfitView();
- simOrderConfitView.Show();
- ActionManage.GetInstance.Send(res, "SendSimData");
- }
- }
-
- });
-
- RemoveCommand = new BPARelayCommand<object>((o) =>
- {
- if (o != null)
- {
- var res = Json<KeepDataBase>.Data.simOrderConfig.FirstOrDefault(p => p.Text == o.ToString());
- if (res != null) Json<KeepDataBase>.Data.simOrderConfig.Remove(res);
- }
- });
- }
-
- public static bool EnableLocalSimOrder { get { return GeneralConfig.EnableLocalSimOrder; } set { GeneralConfig.EnableLocalSimOrder = value; OnStaticPropertyChanged(); } }
-
- public ObservableCollection<SimOrderVisibleData> simOrderConfig
- {
- get
- {
- return Json<KeepDataBase>.Data.simOrderConfig;
- }
- set
- {
- Json<KeepDataBase>.Data.simOrderConfig = value;
- }
- }
-
- public BPARelayCommand AddSimDataCommand { get; set; }
-
- public BPARelayCommand SimOrderCommand { get; set; }
-
- public BPARelayCommand InitCommand { get; set; }
-
- public BPARelayCommand LoopSimOrderCommand { get; set; }
-
- public BPARelayCommand<object> EditCommand { get; set; }
-
- public BPARelayCommand<object> RemoveCommand { get; set; }
-
-
- public static event EventHandler<PropertyChangedEventArgs> StaticPropertyChanged;
- public static void OnStaticPropertyChanged([CallerMemberName] string PropName = "")
- {
- StaticPropertyChanged?.Invoke(null, new PropertyChangedEventArgs(PropName));
- }
-
- public static string LoopOrderButtonContent { get { return _mLoopOrderButtonContent; } set { _mLoopOrderButtonContent = value; OnStaticPropertyChanged(); } }
- private static string _mLoopOrderButtonContent = "循环跑单";
-
-
-
-
-
- }
- }
-
|