Example #1
0
        public void Show(Message message)
        {
            // This is for our fake message
            if (message.MessageId < 0)
            {
                return;
            }

            this.message = message;

            QuickReplyAll.Text = String.Empty;

            // if document hasn't loaded (the first time), loadcomplete will take care of show for us
            if (initialized)
            {
                BuildAndShowMessage();
            }

            // When message is shown due to system selection, do not track the read action
            if (!ThreadFlag.IsSet)
            {
                message.TrackAction(ActionType.Read);
            }

            if (flipper != null)
            {
                flipper.Dispose();
            }

            // Mark message read if after setting is enabled
            var markReadAFter = SettingsManager.ClientSettings.AppConfiguration.MarkReadWhenViewingAfter;

            if (markReadAFter.HasValue)
            {
                flipper = new Flipper(TimeSpan.FromSeconds(markReadAFter.Value), delegate
                {
                    if (!message.IsRead)
                    {
                        message.MarkRead();
                    }
                });

                flipper.Delay();
            }
            else if (SettingsManager.ClientSettings.AppConfiguration.MarkReadWhenViewing)
            {
                message.MarkRead();
            }

            OnPropertyChanged("Message");
        }
        public void Show(Message message)
        {
            // This is for our fake message
            if (message.MessageId < 0)
                return;

            this.message = message;

            QuickReplyAll.Text = String.Empty;

            // if document hasn't loaded (the first time), loadcomplete will take care of show for us
            if (initialized)
                BuildAndShowMessage();

            // When message is shown due to system selection, do not track the read action
            if (!ThreadFlag.IsSet)
                message.TrackAction(ActionType.Read);

            if (flipper != null)
                flipper.Dispose();

            // Mark message read if after setting is enabled
            var markReadAFter = SettingsManager.ClientSettings.AppConfiguration.MarkReadWhenViewingAfter;

            if (markReadAFter.HasValue)
            {
                flipper = new Flipper(TimeSpan.FromSeconds(markReadAFter.Value), delegate
                {
                    if (!message.IsRead)
                        message.MarkRead();
                });

                flipper.Delay();
            }
            else if (SettingsManager.ClientSettings.AppConfiguration.MarkReadWhenViewing)
                message.MarkRead();

            OnPropertyChanged("Message");
        }
Example #3
0
        void Send_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            ClientStats.LogEvent("Quick reply all send");

            if (String.IsNullOrEmpty(QuickReplyAll.Text.Trim()))
            {
                return;
            }

            var newMessage = new Message();

            #region Create message

            var channel = message.SourceChannelId == 0 ?
                          ChannelsManager.GetDefaultChannel() :
                          ChannelsManager.GetChannelObject(Message.SourceChannelId);

            var recipients    = new SourceAddressCollection();
            var sourceAddress = channel.InputChannel.GetSourceAddress();

            recipients.Add(Message.From);
            recipients.AddRange(Message.To);

            // Remove our own address from recipient list
            if (recipients.Contains(sourceAddress))
            {
                recipients.Remove(sourceAddress);
            }

            newMessage.InReplyTo = Message.MessageIdentifier;
            newMessage.ConversationIdentifier = Message.ConversationIdentifier;
            newMessage.Context         = "Re: " + Message.Context;
            newMessage.From            = channel.InputChannel.GetSourceAddress();
            newMessage.TargetChannelId = channel.Configuration.ChannelId;
            newMessage.To.AddRange(recipients);
            newMessage.CC.AddRange(Message.CC);

            var access = new ClientMessageAccess(newMessage, null,
                                                 MessageBodyGenerator.CreateBodyTextForReply(Message, QuickReplyAll.Text.Nl2Br()));

            newMessage.BodyHtmlStreamName = access.WriteBodyHtml();
            newMessage.BodyPreview        = access.GetBodyPreview();
            newMessage.IsRead             = true;
            newMessage.DateSent           = DateTime.Now;
            newMessage.MessageFolder      = Folders.SentItems;
            newMessage.DateSent           = DateTime.Now;
            newMessage.DateCreated        = DateTime.Now;

            #endregion

            #region Send message

            ClientState.Current.DataService.Save(newMessage);

            // Add message to mailbox
            EventBroker.Publish(AppEvents.MessageStored, newMessage);

            // Save command
            CommandQueue.Enqueue(AppCommands.SendMessage, newMessage);

            if (!NetworkInterface.GetIsNetworkAvailable())
            {
                ClientState.Current.ShowMessage(
                    new AppMessage(Strings.MessageWillBeSentLater)
                {
                    EntityId   = newMessage.MessageId.Value,
                    EntityType = EntityType.Message
                }, MessageType.Success);
            }

            QuickReplyAll.Text = String.Empty;

            message.TrackAction(ActionType.ReplyForward);

            #endregion
        }