示例#1
0
 public MinerGroupEdit(MinerGroupViewModel vm)
 {
     this.DataContext = vm;
     InitializeComponent();
 }
示例#2
0
 public bool TryGetMineWorkVm(Guid id, out MinerGroupViewModel minerGroupVm)
 {
     return(_dicById.TryGetValue(id, out minerGroupVm));
 }
示例#3
0
            private MinerGroupViewModels()
            {
#if DEBUG
                NTStopwatch.Start();
#endif
                if (WpfUtil.IsInDesignMode)
                {
                    return;
                }
                foreach (var item in NTMinerContext.Instance.MinerStudioContext.MinerGroupSet.AsEnumerable())
                {
                    if (!_dicById.ContainsKey(item.Id))
                    {
                        _dicById.Add(item.Id, new MinerGroupViewModel(item));
                    }
                }
                AppRoot.AddEventPath <MinerGroupSetInitedEvent>("矿工组集初始化后初始化Vm内存", LogEnum.DevConsole, action: message => {
                    foreach (var item in NTMinerContext.Instance.MinerStudioContext.MinerGroupSet.AsEnumerable())
                    {
                        if (!_dicById.ContainsKey(item.Id))
                        {
                            _dicById.Add(item.Id, new MinerGroupViewModel(item));
                        }
                    }
                    this.OnPropertyChangeds();
                    MinerClientsWindowViewModel.Instance.RefreshMinerClientsSelectedMinerGroup(MinerClientsWindowViewModel.Instance.MinerClients.ToArray());
                }, this.GetType());
                this.Add = new DelegateCommand(() => {
                    new MinerGroupViewModel(Guid.NewGuid()).Edit.Execute(FormType.Add);
                });
                AppRoot.AddEventPath <MinerGroupAddedEvent>("添加矿机分组后刷新VM内存", LogEnum.DevConsole,
                                                            action: message => {
                    if (!_dicById.TryGetValue(message.Source.GetId(), out MinerGroupViewModel vm))
                    {
                        vm = new MinerGroupViewModel(message.Source);
                        _dicById.Add(message.Source.GetId(), vm);
                        OnPropertyChangeds();
                        MinerClientsWindowVm.OnPropertyChanged(nameof(MinerClientsWindowViewModel.SelectedMinerGroup));
                    }
                }, location: this.GetType());
                AppRoot.AddEventPath <MinerGroupUpdatedEvent>("添加矿机分组后刷新VM内存", LogEnum.DevConsole,
                                                              action: message => {
                    if (_dicById.TryGetValue(message.Source.GetId(), out MinerGroupViewModel vm))
                    {
                        vm.Update(message.Source);
                    }
                }, location: this.GetType());
                AppRoot.AddEventPath <MinerGroupRemovedEvent>("移除了矿机组后刷新Vm内容", LogEnum.DevConsole, action: message => {
                    if (_dicById.TryGetValue(message.Source.Id, out MinerGroupViewModel vm))
                    {
                        _dicById.Remove(vm.Id);
                        OnPropertyChangeds();
                        MinerClientsWindowVm.OnPropertyChanged(nameof(MinerClientsWindowViewModel.SelectedMinerGroup));
                    }
                }, this.GetType());
#if DEBUG
                var elapsedMilliseconds = NTStopwatch.Stop();
                if (elapsedMilliseconds.ElapsedMilliseconds > NTStopwatch.ElapsedMilliseconds)
                {
                    Write.DevTimeSpan($"耗时{elapsedMilliseconds} {this.GetType().Name}.ctor");
                }
#endif
            }
示例#4
0
 public MinerGroupEditCommand(FormType formType, MinerGroupViewModel source)
 {
     this.FormType = formType;
     this.Source   = source;
 }
示例#5
0
 public MinerGroupEdit(MinerGroupViewModel vm)
 {
     this.DataContext = vm;
     InitializeComponent();
     ResourceDictionarySet.Instance.FillResourceDic(this, this.Resources);
 }