private void _beServer_PlayerHandler(BEItemsMessage <Player> e)
        {
            if (e.ServerId != _serverId)
            {
                return;
            }

            var newItems = new List <Player>();
            var global   = new Player(-1, null, 0, 0, null, "GLOBAL", Player.PlayerState.Ingame);

            newItems.Add(global);
            newItems.AddRange(e.Items.OrderBy(x => x.Name));

            var selected = SelectedPlayer;

            Players = newItems;

            if (selected != null)
            {
                var newSelected = Players.FirstOrDefault(x => x.Num == selected.Num && x.Name == selected.Name);
                if (newSelected != null)
                {
                    SelectedPlayer = newSelected;
                }
            }
            else
            {
                SelectedPlayer = global;
            }

            ProcessPlayers(e);
        }
        public ServerMonitorChatViewModel(ServerInfoDto serverInfo, IEventAggregator eventAggregator, ISettingsStoreSource settingsStoreSource, IServerInfoRepository infoRepository)
        {
            _serverId            = serverInfo.Id;
            _eventAggregator     = eventAggregator;
            _settingsStoreSource = settingsStoreSource;

            AutoScroll = true;
            EnableChat = true;

            _chatHelper = new ChatHelper(_serverId);

            _eventAggregator.GetEvent <BEMessageEvent <BEChatMessage> >()
            .Subscribe(async e => await BeServerChatMessageHandlerAsync(e), ThreadOption.UIThread);

            _eventAggregator.GetEvent <BEMessageEvent <BEAdminLogMessage> >()
            .Subscribe(_beServer_PlayerLog, ThreadOption.UIThread);
            _eventAggregator.GetEvent <BEMessageEvent <BEPlayerLogMessage> >()
            .Subscribe(_beServer_PlayerLog, ThreadOption.UIThread);
            _eventAggregator.GetEvent <BEMessageEvent <BEBanLogMessage> >()
            .Subscribe(_beServer_PlayerLog, ThreadOption.UIThread);

            _eventAggregator.GetEvent <BEMessageEvent <BEItemsMessage <Player> > >()
            .Subscribe(_beServer_PlayerHandler, ThreadOption.UIThread);

            var global = new Player(-1, null, 0, 0, null, "GLOBAL", Player.PlayerState.Ingame);

            Players = new List <Player> {
                global
            };
            SelectedPlayer = global;

            ShowHistoryCommand = new ActionCommand(() =>
            {
                var model       = new ChatHistoryViewModel(_serverId, infoRepository);
                model.StartDate = DateTime.UtcNow.UtcToLocalFromSettings().AddHours(-5);
                var wnd         = new ChatHistory(model);
                wnd.Show();
                wnd.Activate();
            });

            SendCommandMessage = new DelegateCommand(() => SendCommand(), () => string.IsNullOrEmpty(CommandMessage) == false);
        }
Example #3
0
        public ServerMonitorChatViewModel(ILog log, ServerInfo serverInfo, IEventAggregator eventAggregator)
        {
            _log             = log;
            _serverId        = serverInfo.Id;
            _eventAggregator = eventAggregator;

            AutoScroll = true;
            EnableChat = true;

            _chatHelper = new ChatHelper(_log, _serverId);

            _eventAggregator.GetEvent <BEMessageEvent <BEChatMessage> >()
            .Subscribe(BeServerChatMessageHandler, ThreadOption.UIThread);

            _eventAggregator.GetEvent <BEMessageEvent <BEAdminLogMessage> >()
            .Subscribe(_beServer_PlayerLog, ThreadOption.UIThread);
            _eventAggregator.GetEvent <BEMessageEvent <BEPlayerLogMessage> >()
            .Subscribe(_beServer_PlayerLog, ThreadOption.UIThread);
            _eventAggregator.GetEvent <BEMessageEvent <BEBanLogMessage> >()
            .Subscribe(_beServer_PlayerLog, ThreadOption.UIThread);

            _eventAggregator.GetEvent <BEMessageEvent <BEItemsMessage <Player> > >()
            .Subscribe(_beServer_PlayerHandler);

            var global = new Player(-1, null, 0, 0, null, "GLOBAL", Player.PlayerState.Ingame);

            Players = new List <Player> {
                global
            };
            SelectedPlayer = global;

            ShowHistoryCommand = new ActionCommand(() =>
            {
                var model       = new ChatHistoryViewModel(_serverId);
                model.StartDate = DateTime.UtcNow.UtcToLocalFromSettings().AddHours(-5);
                var wnd         = new ChatHistory(model);
                wnd.Show();
                wnd.Activate();
            });
        }