Beispiel #1
0
        private void AddConversationToModel(ConversationLightViewModel newConversation)
        {
            if (newConversation != null)
            {
                // First remove this conversation if already in the model
                RemoveRBConversationFromModel(newConversation.Id);

                lock (lockObservableConversations)
                {
                    Boolean itemAdded = false;
                    int     nb        = ConversationsLightList.Count;
                    for (int i = 0; i < nb; i++)
                    {
                        if (newConversation.LastMessageDateTime.ToUniversalTime() > ConversationsLightList[i].LastMessageDateTime.ToUniversalTime())
                        {
                            ConversationsLightList.Insert(i, newConversation);
                            log.LogDebug("[AddConversationToModel] INSERT Conversation.id:[{0}] IN index:[{1}]", newConversation.Id, i);
                            itemAdded = true;
                            break;
                        }
                    }
                    if (!itemAdded)
                    {
                        ConversationsLightList.Add(newConversation);
                        log.LogDebug("[AddConversationToModel] ADD Conversation.id:[{0}] ", newConversation.Id);
                    }

                    // Check if we nee to update the view due to DateTime purpose
                    //CheckIfUpdateModelForDateTimePurpose(newConversation.LastMessageDateTime);
                }
            }
        }
Beispiel #2
0
        private void LoadFakeConversations()
        {
            DateTime utcNow = DateTime.UtcNow;

            ConversationLightViewModel conversationLight = null;

            // SET NEW FAKE Conversation Light
            conversationLight                     = new ConversationLightViewModel();
            conversationLight.Id                  = "convID1";
            conversationLight.Jid                 = "*****@*****.**";
            conversationLight.PeerId              = "peerId1";
            conversationLight.Type                = "user";
            conversationLight.Name                = conversationLight.Id + "User Name1";
            conversationLight.Topic               = "";
            conversationLight.PresenceSource      = "presence_online.png";
            conversationLight.NbMsgUnread         = 1;
            conversationLight.LastMessage         = "Last message";
            conversationLight.LastMessageDateTime = utcNow;
            //conversationLight.LastMessageTimeDisplay = Helpers.Helper.HumanizeDateTime(conversationLight.LastMessageDateTime);
            conversationLight.AvatarImageSource = Helper.GetBitmapImageFromResource("avatar1.jpg");

            ConversationsLightList.Add(conversationLight);

            // SET NEW FAKE Conversation Light
            conversationLight                     = new ConversationLightViewModel();
            conversationLight.Id                  = "convID2";
            conversationLight.Jid                 = "*****@*****.**";
            conversationLight.PeerId              = "peerId2";
            conversationLight.Type                = "user";
            conversationLight.Name                = conversationLight.Id + "User Name2 avec tres tres tres tres long";
            conversationLight.Topic               = "";
            conversationLight.PresenceSource      = "presence_busy.png";
            conversationLight.NbMsgUnread         = 15;
            conversationLight.LastMessage         = "-01:00 Last message very veryveryveryveryvery veryvery veryvery veryvery veryvery veryvery veryvery veryvery veryverylong";
            conversationLight.LastMessageDateTime = utcNow.AddHours(-1);
            //conversationLight.LastMessageTimeDisplay = Helpers.Helper.HumanizeDateTime(conversationLight.LastMessageDateTime);
            conversationLight.AvatarImageSource = Helper.GetBitmapImageFromResource("avatar2.jpg");

            ConversationsLightList.Add(conversationLight);

            // SET NEW FAKE Conversation Light
            conversationLight                     = new ConversationLightViewModel();
            conversationLight.Id                  = "convID3";
            conversationLight.Jid                 = "*****@*****.**";
            conversationLight.PeerId              = "peerId3";
            conversationLight.Type                = "group";
            conversationLight.Name                = conversationLight.Id + "Group Name3";
            conversationLight.Topic               = "";
            conversationLight.PresenceSource      = "";
            conversationLight.NbMsgUnread         = 0;
            conversationLight.LastMessage         = "+01:00 Last message";
            conversationLight.LastMessageDateTime = utcNow.AddHours(1);
            //conversationLight.LastMessageTimeDisplay = Helpers.Helper.HumanizeDateTime(conversationLight.LastMessageDateTime);
            conversationLight.AvatarImageSource = Helper.GetBitmapImageFromResource("avatar3.jpg");

            ConversationsLightList.Add(conversationLight);

            // SET NEW FAKE Conversation Light
            conversationLight                     = new ConversationLightViewModel();
            conversationLight.Id                  = "convID4";
            conversationLight.Jid                 = "*****@*****.**";
            conversationLight.PeerId              = "peerId4";
            conversationLight.Type                = "group";
            conversationLight.Name                = conversationLight.Id + "Group Name4 tres tres tres long";
            conversationLight.Topic               = "";
            conversationLight.PresenceSource      = "";
            conversationLight.NbMsgUnread         = 99;
            conversationLight.LastMessage         = "-02:00 Last message";
            conversationLight.LastMessageDateTime = utcNow.AddHours(-2);
            //conversationLight.LastMessageTimeDisplay = Helpers.Helper.HumanizeDateTime(conversationLight.LastMessageDateTime);
            conversationLight.AvatarImageSource = Helper.GetBitmapImageFromResource("avatar4.jpg");

            ConversationsLightList.Add(conversationLight);

            // SET NEW FAKE Conversation Light
            conversationLight                     = new ConversationLightViewModel();
            conversationLight.Id                  = "convID5";
            conversationLight.Jid                 = "*****@*****.**";
            conversationLight.PeerId              = "peerId6";
            conversationLight.Type                = "group";
            conversationLight.Name                = conversationLight.Id + "Group Name6";
            conversationLight.Topic               = "";
            conversationLight.PresenceSource      = "";
            conversationLight.NbMsgUnread         = 99;
            conversationLight.LastMessage         = "-1 day";
            conversationLight.LastMessageDateTime = utcNow.AddDays(-1);
            //conversationLight.LastMessageTimeDisplay = Helpers.Helper.HumanizeDateTime(conversationLight.LastMessageDateTime);
            conversationLight.AvatarImageSource = Helper.GetBitmapImageFromResource("avatar1.jpg");

            ConversationsLightList.Add(conversationLight);

            // SET NEW FAKE Conversation Light
            conversationLight                     = new ConversationLightViewModel();
            conversationLight.Id                  = "convID6";
            conversationLight.Jid                 = "*****@*****.**";
            conversationLight.PeerId              = "peerId6";
            conversationLight.Type                = "group";
            conversationLight.Name                = conversationLight.Id + "Group Name6 tres tres tres tres long";
            conversationLight.Topic               = "";
            conversationLight.PresenceSource      = "";
            conversationLight.NbMsgUnread         = 25;
            conversationLight.LastMessage         = "-1 Year Last message";
            conversationLight.LastMessageDateTime = utcNow.AddYears(-1);
            //conversationLight.LastMessageTimeDisplay = Helpers.Helper.HumanizeDateTime(conversationLight.LastMessageDateTime);
            conversationLight.AvatarImageSource = Helper.GetBitmapImageFromResource("avatar2.jpg");

            ConversationsLightList.Add(conversationLight);


            // SET NEW FAKE Conversation Light
            conversationLight                     = new ConversationLightViewModel();
            conversationLight.Id                  = "convID7";
            conversationLight.Jid                 = "*****@*****.**";
            conversationLight.PeerId              = "peerId7";
            conversationLight.Type                = "group";
            conversationLight.Name                = conversationLight.Id + "Group Name7 tres tres tres long";
            conversationLight.Topic               = "";
            conversationLight.PresenceSource      = "";
            conversationLight.NbMsgUnread         = 0;
            conversationLight.LastMessage         = "-1 Month Last message";
            conversationLight.LastMessageDateTime = utcNow.AddMonths(-1);
            //conversationLight.LastMessageTimeDisplay = Helpers.Helper.HumanizeDateTime(conversationLight.LastMessageDateTime);
            conversationLight.AvatarImageSource = Helper.GetBitmapImageFromResource("avatar3.jpg");

            ConversationsLightList.Add(conversationLight);
        }