Beispiel #1
0
 public CharacterConversationViewModel(Func <Command, bool> commandHandler, IMessageManager messageManager, ILogManager logManager, CharacterViewModel character) :
     base(commandHandler, messageManager)
 {
     MaxMessageBytes     = messageManager.MaxPrivateBytes;
     Character           = character;
     this.messageManager = messageManager;
     messages            = new ObservableList <MessageViewModel>(logManager.LoadReverse(logManager.GetLogId(character.Character), false, 20).Select(x => new MessageViewModel(x, true)));
     Messages            = new UIThreadObservableList <MessageViewModel>(messages);
     messageManager.CharacterMessageReceived += (c, message) => {
         if (c == character.Character)
         {
             AddToMessages(messages, new MessageViewModel(message));
         }
     };
     EnteredTextChanged += () => SetTyping(!string.IsNullOrEmpty(EnteredText));
     IsPinned            = CharacterSettings.Instance.PinnedCharacters.Contains(Name);
     TypingCommand       = new MvxCommand <bool>(SetTyping);
 }
Beispiel #2
0
        public TabbedPeopleViewModel(ICharacterManager characterManager)
        {
            var cache        = Mvx.GetSingleton <CharacterViewModels>();
            var nameComparer = Comparer <CharacterViewModel> .Create((x, y) => CultureInfo.CurrentUICulture.CompareInfo.Compare(x.Character.Name, y.Character.Name));

            var onlineCharacters = new MappingObservableList <Character, CharacterViewModel>(characterManager.OnlineCharacters, x => cache.GetCharacterViewModel(x));

            Tabs = new List <Tab> {
                new Tab(Strings.People_Friends, new UIThreadObservableList <CharacterViewModel>(new SortingObservableList <CharacterViewModel>(
                                                                                                    new FilteringObservableList <CharacterViewModel, bool>(onlineCharacters, x => x.Character.IsFriend, x => x), nameComparer))),
                new Tab(Strings.People_Bookmarks, new UIThreadObservableList <CharacterViewModel>(new SortingObservableList <CharacterViewModel>(
                                                                                                      new FilteringObservableList <CharacterViewModel, bool>(onlineCharacters, x => x.Character.IsBookmarked, x => x), nameComparer))),
                new Tab(Strings.People_All, new UIThreadObservableList <CharacterViewModel>(new SortingObservableList <CharacterViewModel>(onlineCharacters, nameComparer)))
            };
            SelectedTab        = Tabs[0];
            TabSelectedCommand = new MvxCommand <Tab>(tab => {
                SelectedTab       = tab;
                SelectedCharacter = null;
            });
        }