Example #1
0
        /// <summary>
        /// Update UI with messages 
        /// </summary>
        public void loadMessages()
        {
            if (null != host.messages.messages_result)
            {
                if (null != host.messages.messages_result.messages)  // cache may be incomplete
                {
                    GreatCircle gc = new GreatCircle();

                    Deployment.Current.Dispatcher.BeginInvoke(() => { App.ViewModelHost.messageItems.Clear(); });

                    // Handle messages list being empty
                    int len = host.messages.messages_result.messages.Count;
                    if (len < 1)
                    {
                        Deployment.Current.Dispatcher.BeginInvoke(() =>
                        {
                            App.ViewModelHost.messageItems.Add(new MessagesItemViewModel()
                            {
                                Header1 = WebResources.none,
                            });
                        });
                    }
                    else
                    {
                        foreach (var message in host.messages.messages_result.messages)
                        {
                            long date = message.last_updated;
                            string header = gc.date_mmmddyyyy(date);

                            if (1 == message.is_new)
                            {
                                header += " " + message.is_new.ToString() + " " + WebResources.NewMessageReceived;
                            }
                            else if (1 < message.is_new)    // is_new represents the number of new messages, it's not a new message boolean!
                            {
                                header += " " + message.is_new.ToString() + " " + WebResources.NewMessagesReceived;
                            }

                            Deployment.Current.Dispatcher.BeginInvoke(() =>
                            {
                                App.ViewModelHost.messageItems.Add(new MessagesItemViewModel()
                                {
                                    Header1 = message.subject,
                                    Header2 = header,
                                    threadID = message.thread_id
                                });
                            });
                        }
                    }
                }
            }
        }
        private void UpdateLine2()
        {
            GreatCircle gc = new GreatCircle();

            //  return;  // Todo:  Fake names for screen shots

            string line = gc.date_mmmddyyyy(_time);
            if (_newMessageCount > 0)
            {
                line += " " + _newMessageCount.ToString() + " ";

                if (_newMessageCount == 1)
                {
                     line += WebResources.NewMessage;
                }
                else
                {
                    line += WebResources.NewMessages;
                }
            }
            line2 = line;
        }
Example #3
0
        /// <summary>
        /// Update UI with message 
        /// </summary>
        public void loadMessage()
        {
            GreatCircle gc = new GreatCircle();

            Deployment.Current.Dispatcher.BeginInvoke(() =>
            {
                App.ViewModelMessage.messageItems.Clear();

                // Handle message list being empty
                int len = messageThread.message_result.messages.Count();
                if (len < 1)
                {
                    App.ViewModelMessage.messageItems.Add(new MessageItemViewModel()
                    {
                        Header1 = WebResources.none,
                    });
                }
                else
                {
                    App.ViewModelMessage.subject = messageThread.message_result.subject;
                    for (int i = len - 1; i >= 0; i--)
                    {   // Display most recent message first
                        MessageThread.Message message = messageThread.message_result.messages[i];

                        long date = message.timestamp;

                        //Lookup author fullname
                        int uid;
                        int.TryParse(message.author, out uid);
                        string author = getFullName(uid);

                        string header = WebResources.SentBy + " " + author + " " + WebResources.On + " " + gc.date_mmmddyyyy(date);
                        if (1 == message.is_new) header += " - " + WebResources.New;

                        App.ViewModelMessage.messageItems.Add(new MessageItemViewModel()
                        {
                            Header1 = header,
                            Body = message.body
                        });
                    }
                }
            });
        }