Ejemplo n.º 1
0
        private void KernelOutputTranslaterDataGrid_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            DataGrid dg = (DataGrid)sender;

            if (dg.SelectedItem != null)
            {
                KernelOutputTranslaterViewModel kernelOutputTranslaterVm = (KernelOutputTranslaterViewModel)dg.SelectedItem;
                kernelOutputTranslaterVm.Edit.Execute(null);
            }
        }
 private void Init()
 {
     foreach (var item in NTMinerRoot.Instance.KernelOutputTranslaterSet)
     {
         if (!_dicByKernelOutputId.ContainsKey(item.KernelOutputId))
         {
             _dicByKernelOutputId.Add(item.KernelOutputId, new List <KernelOutputTranslaterViewModel>());
         }
         var vm = new KernelOutputTranslaterViewModel(item);
         _dicByKernelOutputId[item.KernelOutputId].Add(vm);
         _dicById.Add(item.GetId(), vm);
     }
 }
 private void Init()
 {
     foreach (var item in NTMinerContext.Instance.ServerContext.KernelOutputTranslaterSet.AsEnumerable().ToArray())
     {
         if (!_dicByKernelOutputId.ContainsKey(item.KernelOutputId))
         {
             _dicByKernelOutputId.Add(item.KernelOutputId, new List <KernelOutputTranslaterViewModel>());
         }
         var vm = new KernelOutputTranslaterViewModel(item);
         _dicByKernelOutputId[item.KernelOutputId].Add(vm);
         _dicById.Add(item.GetId(), vm);
     }
 }
        public static void ShowEditWindow(KernelOutputTranslaterViewModel source)
        {
            int sortNumber = source.SortNumber;

            ContainerWindow.ShowWindow(new ContainerWindowViewModel {
                IsDialogWindow = true,
                CloseVisible   = System.Windows.Visibility.Visible,
                IconName       = "Icon_Coin"
            }, ucFactory: (window) =>
            {
                KernelOutputTranslaterViewModel vm = new KernelOutputTranslaterViewModel(source);
                vm.CloseWindow = () => window.Close();
                return(new KernelOutputTranslaterEdit(vm));
            }, fixedSize: true);
        }
Ejemplo n.º 5
0
        public static void ShowEditWindow(KernelOutputTranslaterViewModel source)
        {
            string title;

            if (!DevMode.IsDevMode)
            {
                title = "翻译器详情";
            }
            else
            {
                if (NTMinerRoot.Current.KernelOutputTranslaterSet.Contains(source.Id))
                {
                    title = "编辑翻译器";
                }
                else
                {
                    title = "添加翻译器";
                }
            }
            int sortNumber = source.SortNumber;

            ContainerWindow.ShowWindow(new ContainerWindowViewModel {
                Title          = title,
                IsDialogWindow = true,
                SaveVisible    = System.Windows.Visibility.Visible,
                CloseVisible   = System.Windows.Visibility.Visible,
                IconName       = "Icon_Coin",
                OnOk           = (uc) => {
                    var vm = ((KernelOutputTranslaterEdit)uc).Vm;
                    if (NTMinerRoot.Current.KernelOutputTranslaterSet.Contains(source.Id))
                    {
                        Global.Execute(new UpdateKernelOutputTranslaterCommand(vm));
                    }
                    else
                    {
                        Global.Execute(new AddKernelOutputTranslaterCommand(vm));
                    }
                    if (sortNumber != vm.SortNumber)
                    {
                        if (KernelViewModels.Current.TryGetKernelVm(vm.KernelId, out KernelViewModel kernelVm))
                        {
                            kernelVm.OnPropertyChanged(nameof(kernelVm.KernelOutputTranslaters));
                        }
                    }
                    return(true);
                }
            }, ucFactory: (window) =>
        public static void ShowWindow(FormType formType, KernelOutputTranslaterViewModel source)
        {
            int sortNumber = source.SortNumber;

            ContainerWindow.ShowWindow(new ContainerWindowViewModel {
                Title           = "内核输出翻译器",
                FormType        = formType,
                IsMaskTheParent = true,
                Width           = 520,
                CloseVisible    = System.Windows.Visibility.Visible,
                IconName        = "Icon_Coin"
            }, ucFactory: (window) =>
            {
                KernelOutputTranslaterViewModel vm = new KernelOutputTranslaterViewModel(source);
                window.BuildCloseWindowOnecePath(vm.Id);
                return(new KernelOutputTranslaterEdit(vm));
            }, fixedSize: true);
        }
        public static void ShowWindow(FormType formType, KernelOutputTranslaterViewModel source)
        {
            int sortNumber = source.SortNumber;

            ContainerWindow.ShowWindow(new ContainerWindowViewModel {
                Title           = "内核输出翻译器",
                FormType        = formType,
                IsMaskTheParent = true,
                Width           = 520,
                CloseVisible    = System.Windows.Visibility.Visible,
                IconName        = "Icon_Coin"
            }, ucFactory: (window) =>
            {
                KernelOutputTranslaterViewModel vm = new KernelOutputTranslaterViewModel(source);
                window.AddOnecePath <CloseWindowCommand>("处理关闭窗口命令", LogEnum.DevConsole, action: message => {
                    window.Close();
                }, pathId: vm.Id, location: typeof(KernelOutputTranslaterEdit));
                return(new KernelOutputTranslaterEdit(vm));
            }, fixedSize: true);
        }
            private KernelOutputTranslaterViewModels()
            {
#if DEBUG
                Write.Stopwatch.Restart();
#endif
                VirtualRoot.On <ServerContextReInitedEvent>("ServerContext刷新后刷新VM内存", LogEnum.DevConsole,
                                                            action: message => {
                    _dicById.Clear();
                    _dicByKernelOutputId.Clear();
                    Init();
                });
                VirtualRoot.On <ServerContextVmsReInitedEvent>("ServerContext的VM集刷新后刷新视图界面", LogEnum.DevConsole,
                                                               action: message => {
                    OnPropertyChanged(nameof(AllKernelOutputTranslaterVms));
                });
                On <KernelOutputTranslaterAddedEvent>("添加了内核输出翻译器后刷新VM内存", LogEnum.DevConsole,
                                                      action: message => {
                    KernelOutputViewModel kernelOutputVm;
                    if (AppContext.Instance.KernelOutputVms.TryGetKernelOutputVm(message.Source.KernelOutputId, out kernelOutputVm))
                    {
                        if (!_dicByKernelOutputId.ContainsKey(message.Source.KernelOutputId))
                        {
                            _dicByKernelOutputId.Add(message.Source.KernelOutputId, new List <KernelOutputTranslaterViewModel>());
                        }
                        var vm = new KernelOutputTranslaterViewModel(message.Source);
                        _dicByKernelOutputId[message.Source.KernelOutputId].Add(vm);
                        _dicById.Add(message.Source.GetId(), vm);
                        kernelOutputVm.OnPropertyChanged(nameof(kernelOutputVm.KernelOutputTranslaters));
                    }
                });
                On <KernelOutputTranslaterUpdatedEvent>("更新了内核输出翻译器后刷新VM内存", LogEnum.DevConsole,
                                                        action: message => {
                    if (_dicByKernelOutputId.ContainsKey(message.Source.KernelOutputId))
                    {
                        var item = _dicByKernelOutputId[message.Source.KernelOutputId].FirstOrDefault(a => a.Id == message.Source.GetId());
                        if (item != null)
                        {
                            item.Update(message.Source);
                        }
                    }
                });
                On <KernelOutputTranslaterRemovedEvent>("移除了内核输出翻译器后刷新VM内存", LogEnum.DevConsole,
                                                        action: message => {
                    if (_dicByKernelOutputId.ContainsKey(message.Source.KernelOutputId))
                    {
                        var item = _dicByKernelOutputId[message.Source.KernelOutputId].FirstOrDefault(a => a.Id == message.Source.GetId());
                        if (item != null)
                        {
                            _dicByKernelOutputId[message.Source.KernelOutputId].Remove(item);
                        }
                    }
                    if (_dicById.ContainsKey(message.Source.GetId()))
                    {
                        _dicById.Remove(message.Source.GetId());
                    }
                    KernelOutputViewModel kernelOutputVm;
                    if (AppContext.Instance.KernelOutputVms.TryGetKernelOutputVm(message.Source.KernelOutputId, out kernelOutputVm))
                    {
                        kernelOutputVm.OnPropertyChanged(nameof(kernelOutputVm.KernelOutputTranslaters));
                    }
                });
                Init();
#if DEBUG
                Write.DevTimeSpan($"耗时{Write.Stopwatch.ElapsedMilliseconds}毫秒 {this.GetType().Name}.ctor");
#endif
            }
Ejemplo n.º 9
0
 public KernelOutputTranslaterEditCommand(FormType formType, KernelOutputTranslaterViewModel source)
 {
     this.FormType = formType;
     this.Source   = source;
 }
Ejemplo n.º 10
0
            private KernelOutputTranslaterViewModels()
            {
                if (WpfUtil.IsInDesignMode)
                {
                    return;
                }
#if DEBUG
                NTStopwatch.Start();
#endif
                VirtualRoot.AddEventPath <ServerContextReInitedEvent>("ServerContext刷新后刷新VM内存", LogEnum.DevConsole,
                                                                      action: message => {
                    _dicById.Clear();
                    _dicByKernelOutputId.Clear();
                    Init();
                }, location: this.GetType());
                VirtualRoot.AddEventPath <ServerContextVmsReInitedEvent>("ServerContext的VM集刷新后刷新视图界面", LogEnum.DevConsole,
                                                                         action: message => {
                    OnPropertyChanged(nameof(AllKernelOutputTranslaterVms));
                }, location: this.GetType());
                AddEventPath <KernelOutputTranslaterAddedEvent>("添加了内核输出翻译器后刷新VM内存", LogEnum.DevConsole,
                                                                action: message => {
                    if (KernelOutputVms.TryGetKernelOutputVm(message.Source.KernelOutputId, out KernelOutputViewModel kernelOutputVm))
                    {
                        if (!_dicByKernelOutputId.ContainsKey(message.Source.KernelOutputId))
                        {
                            _dicByKernelOutputId.Add(message.Source.KernelOutputId, new List <KernelOutputTranslaterViewModel>());
                        }
                        var vm = new KernelOutputTranslaterViewModel(message.Source);
                        _dicByKernelOutputId[message.Source.KernelOutputId].Add(vm);
                        _dicById.Add(message.Source.GetId(), vm);
                        kernelOutputVm.OnPropertyChanged(nameof(kernelOutputVm.KernelOutputTranslaters));
                    }
                }, location: this.GetType());
                AddEventPath <KernelOutputTranslaterUpdatedEvent>("更新了内核输出翻译器后刷新VM内存", LogEnum.DevConsole,
                                                                  action: message => {
                    if (_dicByKernelOutputId.TryGetValue(message.Source.KernelOutputId, out List <KernelOutputTranslaterViewModel> vms))
                    {
                        var vm = vms.FirstOrDefault(a => a.Id == message.Source.GetId());
                        if (vm != null)
                        {
                            vm.Update(message.Source);
                        }
                    }
                }, location: this.GetType());
                AddEventPath <KernelOutputTranslaterRemovedEvent>("移除了内核输出翻译器后刷新VM内存", LogEnum.DevConsole,
                                                                  action: message => {
                    if (_dicByKernelOutputId.ContainsKey(message.Source.KernelOutputId))
                    {
                        var item = _dicByKernelOutputId[message.Source.KernelOutputId].FirstOrDefault(a => a.Id == message.Source.GetId());
                        if (item != null)
                        {
                            _dicByKernelOutputId[message.Source.KernelOutputId].Remove(item);
                        }
                    }
                    if (_dicById.ContainsKey(message.Source.GetId()))
                    {
                        _dicById.Remove(message.Source.GetId());
                    }
                    if (KernelOutputVms.TryGetKernelOutputVm(message.Source.KernelOutputId, out KernelOutputViewModel kernelOutputVm))
                    {
                        kernelOutputVm.OnPropertyChanged(nameof(kernelOutputVm.KernelOutputTranslaters));
                    }
                }, location: this.GetType());
                Init();
#if DEBUG
                var elapsedMilliseconds = NTStopwatch.Stop();
                if (elapsedMilliseconds.ElapsedMilliseconds > NTStopwatch.ElapsedMilliseconds)
                {
                    Write.DevTimeSpan($"耗时{elapsedMilliseconds} {this.GetType().Name}.ctor");
                }
#endif
            }
 public KernelOutputTranslaterEdit(KernelOutputTranslaterViewModel vm)
 {
     this.DataContext = vm;
     InitializeComponent();
 }
 private KernelOutputTranslaterViewModels()
 {
     if (WpfUtil.IsInDesignMode)
     {
         return;
     }
     VirtualRoot.BuildEventPath <ServerContextReInitedEvent>("ServerContext刷新后刷新VM内存", LogEnum.DevConsole,
                                                             path: message => {
         _dicById.Clear();
         _dicByKernelOutputId.Clear();
         Init();
     }, location: this.GetType());
     VirtualRoot.BuildEventPath <ServerContextReInitedEventHandledEvent>("ServerContext的VM集刷新后刷新视图界面", LogEnum.DevConsole,
                                                                         path: message => {
         OnPropertyChanged(nameof(AllKernelOutputTranslaterVms));
     }, location: this.GetType());
     BuildEventPath <KernelOutputTranslaterAddedEvent>("添加了内核输出翻译器后刷新VM内存", LogEnum.DevConsole,
                                                       path: message => {
         if (KernelOutputVms.TryGetKernelOutputVm(message.Source.KernelOutputId, out KernelOutputViewModel kernelOutputVm))
         {
             if (!_dicByKernelOutputId.ContainsKey(message.Source.KernelOutputId))
             {
                 _dicByKernelOutputId.Add(message.Source.KernelOutputId, new List <KernelOutputTranslaterViewModel>());
             }
             var vm = new KernelOutputTranslaterViewModel(message.Source);
             _dicByKernelOutputId[message.Source.KernelOutputId].Add(vm);
             _dicById.Add(message.Source.GetId(), vm);
             kernelOutputVm.OnPropertyChanged(nameof(kernelOutputVm.KernelOutputTranslaters));
         }
     }, location: this.GetType());
     BuildEventPath <KernelOutputTranslaterUpdatedEvent>("更新了内核输出翻译器后刷新VM内存", LogEnum.DevConsole,
                                                         path: message => {
         if (_dicByKernelOutputId.TryGetValue(message.Source.KernelOutputId, out List <KernelOutputTranslaterViewModel> vms))
         {
             var vm = vms.FirstOrDefault(a => a.Id == message.Source.GetId());
             if (vm != null)
             {
                 vm.Update(message.Source);
             }
         }
     }, location: this.GetType());
     BuildEventPath <KernelOutputTranslaterRemovedEvent>("移除了内核输出翻译器后刷新VM内存", LogEnum.DevConsole,
                                                         path: message => {
         if (_dicByKernelOutputId.ContainsKey(message.Source.KernelOutputId))
         {
             var item = _dicByKernelOutputId[message.Source.KernelOutputId].FirstOrDefault(a => a.Id == message.Source.GetId());
             if (item != null)
             {
                 _dicByKernelOutputId[message.Source.KernelOutputId].Remove(item);
             }
         }
         if (_dicById.ContainsKey(message.Source.GetId()))
         {
             _dicById.Remove(message.Source.GetId());
         }
         if (KernelOutputVms.TryGetKernelOutputVm(message.Source.KernelOutputId, out KernelOutputViewModel kernelOutputVm))
         {
             kernelOutputVm.OnPropertyChanged(nameof(kernelOutputVm.KernelOutputTranslaters));
         }
     }, location: this.GetType());
     Init();
 }
 public KernelOutputTranslaterEdit(KernelOutputTranslaterViewModel vm)
 {
     this.DataContext = vm;
     InitializeComponent();
     ResourceDictionarySet.Instance.FillResourceDic(this, this.Resources);
 }