Exemple #1
0
 private KernelInputViewModels()
 {
     if (WpfUtil.IsInDesignMode)
     {
         return;
     }
     VirtualRoot.BuildEventPath <ServerContextReInitedEvent>("ServerContext刷新后刷新VM内存", LogEnum.DevConsole,
                                                             path: message => {
         _dicById.Clear();
         Init();
     }, location: this.GetType());
     VirtualRoot.BuildEventPath <ServerContextReInitedEventHandledEvent>("ServerContext的VM集刷新后刷新视图界面", LogEnum.DevConsole,
                                                                         path: message => {
         OnPropertyChangeds();
     }, location: this.GetType());
     BuildEventPath <KernelInputAddedEvent>("添加了内核输入后刷新VM内存", LogEnum.DevConsole,
                                            path: message => {
         var vm = new KernelInputViewModel(message.Source);
         _dicById.Add(message.Source.GetId(), vm);
         OnPropertyChangeds();
     }, location: this.GetType());
     BuildEventPath <KernelInputUpdatedEvent>("更新了内核输入后刷新VM内存", LogEnum.DevConsole,
                                              path: message => {
         if (_dicById.TryGetValue(message.Source.GetId(), out KernelInputViewModel vm))
         {
             if (vm != null)
             {
                 bool isSupportDualMine = vm.IsSupportDualMine;
                 string args            = vm.Args;
                 vm.Update(message.Source);
                 if (args != vm.Args)
                 {
                     CoinViewModel coinVm = MinerProfileVm.CoinVm;
                     if (coinVm != null && coinVm.CoinKernel != null && coinVm.CoinKernel.Kernel.KernelInputId == vm.Id)
                     {
                         NTMinerContext.RefreshArgsAssembly.Invoke("当前选用的内核引用的内核输入的形参发生了变更");
                     }
                 }
                 if (isSupportDualMine != vm.IsSupportDualMine)
                 {
                     foreach (var coinKernelVm in CoinKernelVms.AllCoinKernels.Where(a => a.KernelId == message.Source.GetId()))
                     {
                         coinKernelVm.OnPropertyChanged(nameof(coinKernelVm.IsSupportDualMine));
                     }
                 }
             }
         }
     }, location: this.GetType());
     BuildEventPath <KernelInputRemovedEvent>("移除了内核输入后刷新VM内存", LogEnum.DevConsole,
                                              path: message => {
         if (_dicById.ContainsKey(message.Source.GetId()))
         {
             _dicById.Remove(message.Source.GetId());
             OnPropertyChangeds();
         }
     }, location: this.GetType());
     Init();
 }
 public static void ShowEditWindow(KernelInputViewModel source)
 {
     ContainerWindow.ShowWindow(new ContainerWindowViewModel {
         IconName       = "Icon_KernelInput",
         IsDialogWindow = true,
         CloseVisible   = System.Windows.Visibility.Visible
     }, ucFactory: (window) => {
         KernelInputViewModel vm = new KernelInputViewModel(source);
         vm.CloseWindow          = () => window.Close();
         return(new KernelInputEdit(vm));
     }, fixedSize: true);
 }
Exemple #3
0
 public static void ShowWindow(FormType formType, KernelInputViewModel source)
 {
     ContainerWindow.ShowWindow(new ContainerWindowViewModel {
         Title           = "内核输入",
         FormType        = formType,
         IconName        = "Icon_KernelInput",
         Width           = 660,
         IsMaskTheParent = true,
         CloseVisible    = System.Windows.Visibility.Visible
     }, ucFactory: (window) => {
         KernelInputViewModel vm = new KernelInputViewModel(source);
         window.BuildCloseWindowOnecePath(vm.Id);
         return(new KernelInputEdit(vm));
     }, fixedSize: true);
 }
Exemple #4
0
 public static void ShowWindow(FormType formType, KernelInputViewModel source)
 {
     ContainerWindow.ShowWindow(new ContainerWindowViewModel {
         Title           = "内核输入",
         FormType        = formType,
         IconName        = "Icon_KernelInput",
         Width           = 660,
         IsMaskTheParent = true,
         CloseVisible    = System.Windows.Visibility.Visible
     }, ucFactory: (window) => {
         KernelInputViewModel vm = new KernelInputViewModel(source);
         window.AddOnecePath <CloseWindowCommand>("处理关闭窗口命令", LogEnum.DevConsole, action: message => {
             window.Close();
         }, pathId: vm.Id, location: typeof(KernelInputEdit));
         return(new KernelInputEdit(vm));
     }, fixedSize: true);
 }
 public static void ShowWindow(FormType formType, KernelInputViewModel source)
 {
     ContainerWindow.ShowWindow(new ContainerWindowViewModel {
         Title          = "内核输入",
         FormType       = formType,
         IconName       = "Icon_KernelInput",
         Width          = 660,
         IsDialogWindow = true,
         CloseVisible   = System.Windows.Visibility.Visible
     }, ucFactory: (window) => {
         KernelInputViewModel vm = new KernelInputViewModel(source)
         {
             CloseWindow = () => window.Close()
         };
         return(new KernelInputEdit(vm));
     }, fixedSize: true);
 }
 public KernelInputEdit(KernelInputViewModel vm)
 {
     this.DataContext = vm;
     InitializeComponent();
     ResourceDictionarySet.Instance.FillResourceDic(this, this.Resources);
 }
 public bool TryGetKernelInputVm(Guid id, out KernelInputViewModel kernelInputVm)
 {
     return(_dicById.TryGetValue(id, out kernelInputVm));
 }
            private KernelInputViewModels()
            {
#if DEBUG
                VirtualRoot.Stopwatch.Restart();
#endif
                VirtualRoot.On <ServerContextReInitedEvent>("ServerContext刷新后刷新VM内存", LogEnum.DevConsole,
                                                            action: message => {
                    _dicById.Clear();
                    Init();
                });
                VirtualRoot.On <ServerContextVmsReInitedEvent>("ServerContext的VM集刷新后刷新视图界面", LogEnum.DevConsole,
                                                               action: message => {
                    OnPropertyChangeds();
                });
                On <KernelInputAddedEvent>("添加了内核输入后刷新VM内存", LogEnum.DevConsole,
                                           action: message => {
                    var vm = new KernelInputViewModel(message.Source);
                    _dicById.Add(message.Source.GetId(), vm);
                    OnPropertyChangeds();
                });
                On <KernelInputUpdatedEvent>("更新了内核输入后刷新VM内存", LogEnum.DevConsole,
                                             action: message => {
                    if (_dicById.ContainsKey(message.Source.GetId()))
                    {
                        var item = _dicById[message.Source.GetId()];
                        if (item != null)
                        {
                            bool isSupportDualMine = item.IsSupportDualMine;
                            string args            = item.Args;
                            string dualFullArgs    = item.DualFullArgs;
                            item.Update(message.Source);
                            if (args != item.Args || dualFullArgs != item.DualFullArgs)
                            {
                                CoinViewModel coinVm = AppContext.Instance.MinerProfileVm.CoinVm;
                                if (coinVm != null && coinVm.CoinKernel != null && coinVm.CoinKernel.Kernel.KernelInputId == item.Id)
                                {
                                    NTMinerRoot.RefreshArgsAssembly.Invoke();
                                }
                            }
                            if (isSupportDualMine != item.IsSupportDualMine)
                            {
                                foreach (var coinKernelVm in AppContext.Instance.CoinKernelVms.AllCoinKernels.Where(a => a.KernelId == message.Source.GetId()))
                                {
                                    coinKernelVm.OnPropertyChanged(nameof(coinKernelVm.IsSupportDualMine));
                                    coinKernelVm.OnPropertyChanged(nameof(coinKernelVm.DualCoinGroup));
                                }
                            }
                        }
                    }
                });
                On <KernelInputRemovedEvent>("移除了内核输入后刷新VM内存", LogEnum.DevConsole,
                                             action: message => {
                    if (_dicById.ContainsKey(message.Source.GetId()))
                    {
                        _dicById.Remove(message.Source.GetId());
                        OnPropertyChangeds();
                    }
                });
                Init();
#if DEBUG
                Write.DevWarn($"耗时{VirtualRoot.Stopwatch.ElapsedMilliseconds}毫秒 {this.GetType().Name}.ctor");
#endif
            }
Exemple #9
0
 public KernelInputEditCommand(FormType formType, KernelInputViewModel source)
 {
     this.FormType = formType;
     this.Source   = source;
 }
Exemple #10
0
            private KernelInputViewModels()
            {
                if (WpfUtil.IsInDesignMode)
                {
                    return;
                }
#if DEBUG
                NTStopwatch.Start();
#endif
                VirtualRoot.AddEventPath <ServerContextReInitedEvent>("ServerContext刷新后刷新VM内存", LogEnum.DevConsole,
                                                                      action: message => {
                    _dicById.Clear();
                    Init();
                }, location: this.GetType());
                VirtualRoot.AddEventPath <ServerContextVmsReInitedEvent>("ServerContext的VM集刷新后刷新视图界面", LogEnum.DevConsole,
                                                                         action: message => {
                    OnPropertyChangeds();
                }, location: this.GetType());
                AddEventPath <KernelInputAddedEvent>("添加了内核输入后刷新VM内存", LogEnum.DevConsole,
                                                     action: message => {
                    var vm = new KernelInputViewModel(message.Source);
                    _dicById.Add(message.Source.GetId(), vm);
                    OnPropertyChangeds();
                }, location: this.GetType());
                AddEventPath <KernelInputUpdatedEvent>("更新了内核输入后刷新VM内存", LogEnum.DevConsole,
                                                       action: message => {
                    if (_dicById.TryGetValue(message.Source.GetId(), out KernelInputViewModel vm))
                    {
                        if (vm != null)
                        {
                            bool isSupportDualMine = vm.IsSupportDualMine;
                            string args            = vm.Args;
                            vm.Update(message.Source);
                            if (args != vm.Args)
                            {
                                CoinViewModel coinVm = MinerProfileVm.CoinVm;
                                if (coinVm != null && coinVm.CoinKernel != null && coinVm.CoinKernel.Kernel.KernelInputId == vm.Id)
                                {
                                    NTMinerContext.RefreshArgsAssembly.Invoke("当前选用的内核引用的内核输入的形参发生了变更");
                                }
                            }
                            if (isSupportDualMine != vm.IsSupportDualMine)
                            {
                                foreach (var coinKernelVm in CoinKernelVms.AllCoinKernels.Where(a => a.KernelId == message.Source.GetId()))
                                {
                                    coinKernelVm.OnPropertyChanged(nameof(coinKernelVm.IsSupportDualMine));
                                }
                            }
                        }
                    }
                }, location: this.GetType());
                AddEventPath <KernelInputRemovedEvent>("移除了内核输入后刷新VM内存", LogEnum.DevConsole,
                                                       action: message => {
                    if (_dicById.ContainsKey(message.Source.GetId()))
                    {
                        _dicById.Remove(message.Source.GetId());
                        OnPropertyChangeds();
                    }
                }, location: this.GetType());
                Init();
#if DEBUG
                var elapsedMilliseconds = NTStopwatch.Stop();
                if (elapsedMilliseconds.ElapsedMilliseconds > NTStopwatch.ElapsedMilliseconds)
                {
                    Write.DevTimeSpan($"耗时{elapsedMilliseconds} {this.GetType().Name}.ctor");
                }
#endif
            }
Exemple #11
0
 public KernelInputEdit(KernelInputViewModel vm)
 {
     this.DataContext = vm;
     InitializeComponent();
 }