private SysDicViewModels() { #if DEBUG Write.Stopwatch.Start(); #endif VirtualRoot.BuildEventPath <ServerContextReInitedEvent>("ServerContext刷新后刷新VM内存", LogEnum.DevConsole, action: message => { _dicByCode.Clear(); _dicById.Clear(); Init(); }); VirtualRoot.BuildEventPath <ServerContextVmsReInitedEvent>("ServerContext的VM集刷新后刷新视图界面", LogEnum.DevConsole, action: message => { OnPropertyChangeds(); }); this.Add = new DelegateCommand(() => { new SysDicViewModel(Guid.NewGuid()).Edit.Execute(null); }); BuildEventPath <SysDicAddedEvent>("添加了系统字典后调整VM内存", LogEnum.DevConsole, action: (message) => { if (!_dicById.ContainsKey(message.Source.GetId())) { SysDicViewModel sysDicVm = new SysDicViewModel(message.Source); _dicById.Add(message.Source.GetId(), sysDicVm); if (!_dicByCode.ContainsKey(message.Source.Code)) { _dicByCode.Add(message.Source.Code, sysDicVm); } OnPropertyChangeds(); } }); BuildEventPath <SysDicUpdatedEvent>("更新了系统字典后调整VM内存", LogEnum.DevConsole, action: (message) => { if (_dicById.ContainsKey(message.Source.GetId())) { SysDicViewModel entity = _dicById[message.Source.GetId()]; int sortNumber = entity.SortNumber; entity.Update(message.Source); if (sortNumber != entity.SortNumber) { this.OnPropertyChanged(nameof(List)); } } }); BuildEventPath <SysDicRemovedEvent>("删除了系统字典后调整VM内存", LogEnum.DevConsole, action: (message) => { _dicById.Remove(message.Source.GetId()); _dicByCode.Remove(message.Source.Code); OnPropertyChangeds(); }); Init(); #if DEBUG var elapsedMilliseconds = Write.Stopwatch.Stop(); if (elapsedMilliseconds.ElapsedMilliseconds > NTStopwatch.ElapsedMilliseconds) { Write.DevTimeSpan($"耗时{elapsedMilliseconds} {this.GetType().Name}.ctor"); } #endif }
private void Init() { foreach (var item in NTMinerContext.Instance.ServerContext.SysDicSet.AsEnumerable()) { SysDicViewModel sysDicVm = new SysDicViewModel(item); _dicById.Add(item.GetId(), sysDicVm); _dicByCode.Add(item.Code, sysDicVm); } }
private void Init() { foreach (var item in NTMinerRoot.Instance.SysDicSet) { SysDicViewModel sysDicVm = new SysDicViewModel(item); _dicById.Add(item.GetId(), sysDicVm); _dicByCode.Add(item.Code, sysDicVm); } }
public static void ShowEditWindow(SysDicViewModel source) { ContainerWindow.ShowWindow(new ContainerWindowViewModel { IsDialogWindow = true, CloseVisible = System.Windows.Visibility.Visible, IconName = "Icon_SysDic" }, ucFactory: (window) => { SysDicViewModel vm = new SysDicViewModel(source); vm.CloseWindow = () => window.Close(); return(new SysDicEdit(vm)); }, fixedSize: true); }
private SysDicViewModels() { if (WpfUtil.IsInDesignMode) { return; } VirtualRoot.AddEventPath <ServerContextReInitedEvent>("ServerContext刷新后刷新VM内存", LogEnum.DevConsole, action: message => { _dicByCode.Clear(); _dicById.Clear(); Init(); }, location: this.GetType()); VirtualRoot.AddEventPath <ServerContextReInitedEventHandledEvent>("ServerContext的VM集刷新后刷新视图界面", LogEnum.DevConsole, action: message => { OnPropertyChangeds(); }, location: this.GetType()); this.Add = new DelegateCommand(() => { new SysDicViewModel(Guid.NewGuid()).Edit.Execute(null); }); AddEventPath <SysDicAddedEvent>("添加了系统字典后调整VM内存", LogEnum.DevConsole, action: (message) => { if (!_dicById.ContainsKey(message.Source.GetId())) { SysDicViewModel sysDicVm = new SysDicViewModel(message.Source); _dicById.Add(message.Source.GetId(), sysDicVm); if (!_dicByCode.ContainsKey(message.Source.Code)) { _dicByCode.Add(message.Source.Code, sysDicVm); } OnPropertyChangeds(); } }, location: this.GetType()); AddEventPath <SysDicUpdatedEvent>("更新了系统字典后调整VM内存", LogEnum.DevConsole, action: (message) => { if (_dicById.TryGetValue(message.Source.GetId(), out SysDicViewModel vm)) { int sortNumber = vm.SortNumber; vm.Update(message.Source); if (sortNumber != vm.SortNumber) { this.OnPropertyChanged(nameof(List)); } } }, location: this.GetType()); AddEventPath <SysDicRemovedEvent>("删除了系统字典后调整VM内存", LogEnum.DevConsole, action: (message) => { _dicById.Remove(message.Source.GetId()); _dicByCode.Remove(message.Source.Code); OnPropertyChangeds(); }, location: this.GetType()); Init(); }
public static void ShowWindow(FormType formType, SysDicViewModel source) { ContainerWindow.ShowWindow(new ContainerWindowViewModel { Title = "系统字典", FormType = formType, Width = 500, IsMaskTheParent = true, CloseVisible = System.Windows.Visibility.Visible, IconName = "Icon_SysDic" }, ucFactory: (window) => { SysDicViewModel vm = new SysDicViewModel(source); window.AddCloseWindowOnecePath(vm.Id); return(new SysDicEdit(vm)); }, fixedSize: true); }
public static void ShowWindow(FormType formType, SysDicViewModel source) { ContainerWindow.ShowWindow(new ContainerWindowViewModel { Title = "系统字典", FormType = formType, Width = 500, IsMaskTheParent = true, CloseVisible = System.Windows.Visibility.Visible, IconName = "Icon_SysDic" }, ucFactory: (window) => { SysDicViewModel vm = new SysDicViewModel(source); window.AddOnecePath <CloseWindowCommand>("处理关闭窗口命令", LogEnum.DevConsole, action: message => { window.Close(); }, pathId: vm.Id, location: typeof(SysDicEdit)); return(new SysDicEdit(vm)); }, fixedSize: true); }
public static void ShowWindow(FormType formType, SysDicViewModel source) { ContainerWindow.ShowWindow(new ContainerWindowViewModel { Title = "系统字典", FormType = formType, Width = 500, IsDialogWindow = true, CloseVisible = System.Windows.Visibility.Visible, IconName = "Icon_SysDic" }, ucFactory: (window) => { SysDicViewModel vm = new SysDicViewModel(source) { CloseWindow = () => window.Close() }; return(new SysDicEdit(vm)); }, fixedSize: true); }
public static void ShowEditWindow(SysDicViewModel source) { string title; if (!DevMode.IsDevMode) { title = "字典详情"; } else { if (NTMinerRoot.Current.SysDicSet.ContainsKey(source.Id)) { title = "编辑字典"; } else { title = "添加字典"; } } ContainerWindow.ShowWindow(new ContainerWindowViewModel { Title = title, IsDialogWindow = true, SaveVisible = System.Windows.Visibility.Visible, CloseVisible = System.Windows.Visibility.Visible, IconName = "Icon_SysDic", OnOk = (uc) => { var vm = ((SysDicEdit)uc).Vm; if (NTMinerRoot.Current.SysDicSet.ContainsKey(source.Id)) { Global.Execute(new UpdateSysDicCommand(vm)); } else { Global.Execute(new AddSysDicCommand(vm)); } return(true); } }, ucFactory: (window) => { SysDicViewModel vm = new SysDicViewModel(source.Id).Update(source); return(new SysDicEdit(vm)); }, fixedSize: true); }
public SysDicEdit(SysDicViewModel vm) { this.DataContext = vm; InitializeComponent(); }
public SysDicEdit(SysDicViewModel vm) { this.DataContext = vm; InitializeComponent(); ResourceDictionarySet.Instance.FillResourceDic(this, this.Resources); }
public SysDicEditCommand(FormType formType, SysDicViewModel source) { this.FormType = formType; this.Source = source; }
public bool TryGetSysDicVm(string dicCode, out SysDicViewModel sysDicVm) { return(_dicByCode.TryGetValue(dicCode, out sysDicVm)); }
public bool TryGetSysDicVm(Guid dicId, out SysDicViewModel sysDicVm) { return(_dicById.TryGetValue(dicId, out sysDicVm)); }