public ChatItemViewModel(Chat model, ExtGame game)
        {
            Model           = model;
            GamePersonModel = new GamePersonItemViewModel();

            try
            {
                GamePersonModel.User = model.Creator == "Вестерос" ? MainWindow.GamePortal.Vesteros : MainWindow.GamePortal.GetUser(model.Creator);
            }
            catch
            {
                //если пользователь не найден (написали с сайта)
                GamePersonModel.User = new GPUser(new WCFUser()
                {
                    Login = "******"
                })
                {
                    Title = $"{App.GetResources("titleType_Ghost")}, {model.Creator}"
                };
            }

            if (game != null)
            {
                //ищем игру в истории профиля
                GamePersonModel.HomeType = game.ExtGameUser.SingleOrDefault(p => p.WCFGameUser.Login == Model.Creator)?.ExtHomeType;
                if (GamePersonModel.HomeType == null)
                {
                    string hometype = GamePersonModel.User.UserGames.SingleOrDefault(p => p.GameId == game.WCFGame.Id && model.Time > p.StartTime && (!p.EndTime.HasValue || model.Time < p.EndTime))?.HomeType;
                    if (hometype != null)
                    {
                        GamePersonModel.HomeType = MainWindow.ClientInfo.WorldData.HomeType.Single(p => p.WCFHomeType.Name == hometype);
                    }
                }

                //string hometype = GamePersonModel.User.UserGames.SingleOrDefault(p => p.GameId == game.WCFGame.Id && model.Time > p.StartTime && (!p.EndTime.HasValue || model.Time < p.EndTime))?.HomeType;
                //GamePersonModel.HomeType = hometype != null? MainWindow.ClientInfo.WorldData.HomeType.SingleOrDefault(p => p.WCFHomeType.Name == hometype)
                //    : game.ExtGameUser.SingleOrDefault(p => p.WCFGameUser.Login == Model.Creator)?.ExtHomeType;

                //viewModel.ImageName = hometype != null
                //    ? $"/image/{ExtHomeType.Keys[hometype]}/{ExtHomeType.Keys[hometype]}.png"
                //    : Game?.ExtGameUser.SingleOrDefault(p => p.WCFGameUser.Login == viewModel.Model.Creator)?.ExtHomeType?.ImageName;
            }

            Model.IsVisible = GamePersonModel.User.ChatVisibility == Visibility.Visible ? true : false;
        }
示例#2
0
 void PersonView_DataContextChanged(object sender, DependencyPropertyChangedEventArgs e)
 {
     _ViewModel = e.NewValue as GamePersonItemViewModel;
 }
示例#3
0
 private void GamePersonView_DataContextChanged(object sender, DependencyPropertyChangedEventArgs e)
 {
     ViewModel = (GamePersonItemViewModel)e.NewValue;
 }