public LocalMessagesViewModel()
        {
            if (WpfUtil.IsInDesignMode)
            {
                return;
            }
            foreach (var messageChannel in LocalMessageChannelEnumItems)
            {
                var values = new Dictionary <LocalMessageType, MessageTypeItem <LocalMessageType> >();
                foreach (var messageType in NTMinerContext.LocalMessageTypeEnumItems)
                {
                    values.Add(messageType.Value, new MessageTypeItem <LocalMessageType>(messageType, LocalMessageViewModel.GetIcon, LocalMessageViewModel.GetIconFill, RefreshQueryResults));
                }
                _count.Add(messageChannel, values);
            }
            _selectedChannel = LocalMessageChannelEnumItems.FirstOrDefault();
            Init();

            this.ClearKeyword = new DelegateCommand(() => {
                this.Keyword = string.Empty;
            });
            this.Clear = new DelegateCommand(() => {
                this.ShowSoftDialog(new DialogWindowViewModel(message: "确定清空吗?", title: "确认", onYes: () => {
                    VirtualRoot.Execute(new ClearLocalMessageSetCommand());
                }));
            });
            VirtualRoot.AddEventPath <LocalMessageSetClearedEvent>("清空本地消息集后刷新VM内存", LogEnum.DevConsole,
                                                                   action: message => {
                Init();
            }, location: this.GetType());
            VirtualRoot.AddEventPath <LocalMessageAddedEvent>("发生了本地消息后刷新Vm内存", LogEnum.DevConsole,
                                                              action: message => {
                UIThread.Execute(() => () => {
                    var vm = new LocalMessageViewModel(message.Source);
                    _localMessageVms.Insert(0, vm);
                    if (IsSatisfyQuery(vm))
                    {
                        _queyResults.Insert(0, vm);
                    }
                    foreach (var item in message.Removes)
                    {
                        var toRemove = _localMessageVms.FirstOrDefault(a => a.Id == item.Id);
                        if (toRemove != null)
                        {
                            _localMessageVms.Remove(toRemove);
                            if (IsSatisfyQuery(toRemove))
                            {
                                _queyResults.Remove(toRemove);
                            }
                        }
                    }
                    int removedCount = message.Removes.Count(a => a.MessageType == vm.MessageTypeEnum.GetName());
                    if (removedCount != 1)
                    {
                        _count[vm.ChannelEnum.GetEnumItem()][vm.MessageTypeEnum].Count += 1 - removedCount;
                        UpdateChannelAll();
                    }
                    OnPropertyChanged(nameof(IsNoRecord));
                });
            }, location: this.GetType());
            VirtualRoot.AddEventPath <NewDayEvent>("新的一天到来时刷新消息集中的可读性时间戳展示", LogEnum.DevConsole,
                                                   action: message => {
                if (QueryResults == null)
                {
                    return;
                }
                foreach (var item in QueryResults)
                {
                    if (item.Timestamp.Date.AddDays(3) >= message.BornOn.Date)
                    {
                        item.OnPropertyChanged(nameof(item.TimestampText));
                    }
                    else
                    {
                        // 因为是按照时间倒叙排列的,所以可以break
                        break;
                    }
                }
            }, location: this.GetType());
        }
        public LocalMessagesViewModel()
        {
            if (WpfUtil.IsInDesignMode)
            {
                return;
            }
            foreach (var messageChannel in LocalMessageChannelEnumItems)
            {
                var values = new Dictionary <LocalMessageType, MessageTypeItem <LocalMessageType> >();
                foreach (var messageType in EnumItem <LocalMessageType> .GetEnumItems())
                {
                    values.Add(messageType.Value, new MessageTypeItem <LocalMessageType>(messageType, LocalMessageViewModel.GetIcon, LocalMessageViewModel.GetIconFill, RefreshQueryResults));
                }
                _count.Add(messageChannel, values);
            }
            _selectedChannel = LocalMessageChannelEnumItems.FirstOrDefault();
            Init();

            this.ClearKeyword = new DelegateCommand(() => {
                this.Keyword = string.Empty;
            });
            this.Clear = new DelegateCommand(() => {
                this.ShowDialog(new DialogWindowViewModel(message: "确定清空吗?", title: "确认", onYes: () => {
                    VirtualRoot.LocalMessages.Clear();
                }));
            });
            VirtualRoot.BuildEventPath <LocalMessageClearedEvent>("清空挖矿消息集后刷新VM内存", LogEnum.DevConsole,
                                                                  action: message => {
                UIThread.Execute(() => {
                    Init();
                });
            });
            VirtualRoot.BuildEventPath <LocalMessageAddedEvent>("发生了挖矿事件后刷新Vm内存", LogEnum.DevConsole,
                                                                action: message => {
                UIThread.Execute(() => {
                    var vm = new LocalMessageViewModel(message.Source);
                    _localMessageVms.Insert(0, vm);
                    if (IsSatisfyQuery(vm))
                    {
                        _queyResults.Insert(0, vm);
                    }
                    foreach (var item in message.Removes)
                    {
                        var toRemove = _localMessageVms.FirstOrDefault(a => a.Id == item.Id);
                        if (toRemove != null)
                        {
                            _localMessageVms.Remove(toRemove);
                            if (IsSatisfyQuery(toRemove))
                            {
                                _queyResults.Remove(toRemove);
                            }
                        }
                    }
                    int removedCount = message.Removes.Count(a => a.MessageType == vm.MessageTypeEnum.GetName());
                    if (removedCount != 1)
                    {
                        _count[vm.ChannelEnum.GetEnumItem()][vm.MessageTypeEnum].Count += 1 - removedCount;
                        UpdateChannelAll();
                    }
                    OnPropertyChanged(nameof(IsNoRecord));
                });
            });
        }