Esempio n. 1
0
 private void SubscribeProfilesChanged()
 {
     ChatModel.Profiles.CollectionChanged += ((sender, e) =>
     {
         if (e.OldItems != null)
         {
             foreach (ProfileModel it in e.OldItems)
             {
                 Profiles.RemoveAt(Profiles.FindIndex(x => x.ProfileModel == it));
             }
         }
         if (e.NewItems != null)
         {
             foreach (ProfileModel it in e.NewItems)
             {
                 int i = 0;
                 for (; i < Profiles.Count; i++)
                 {
                     if (Profiles[i].ProfileModel.Id > it.Id)
                     {
                         break;
                     }
                 }
                 var mb = new ProfileLineViewModel(_manager)
                 {
                     ProfileModel = it
                 };
                 Profiles.Insert(i, mb);
             }
         }
     });
 }
 public MessageBlockViewModel(IClientManager manager, MessageModel messageModel)
 {
     _manager     = manager;
     MessageModel = messageModel;
     SubscribeProfileLineChanged();
     ProfileLine = new ProfileLineViewModel(manager)
     {
         ProfileModel = messageModel.Profile
     };
 }
Esempio n. 3
0
 private void InitProfiles()
 {
     foreach (var model in ChatModel.Profiles)
     {
         var view = new ProfileLineViewModel(_manager)
         {
             ProfileModel = model
         };
         Profiles.Add(view);
     }
 }
Esempio n. 4
0
 public ChatGridViewModel(IClientManager manager)
 {
     _manager = manager;
     MyProfile = new MyProfileModel(manager);
     ServerStateLine = new ServerStateLineViewModel(manager);
     EditChatLine = new EditChatLineViewModel(manager);
     //MessagesFeed = new MessagesFeedViewModel(manager);
     MyProfileLine = new ProfileLineViewModel(manager)
     {
         ProfileModel = MyProfile.MyProfile
     };
     ChatCollection = new ChatCollectionViewModel(manager, MyProfile.Chats);
 }