예제 #1
0
        protected void StarCore()
        {
            var previousSelection = new List <Message>(SelectedMessages);

            // Contains instance copies of messages, this will be the old data
            // before the do is applied.
            var messagesCopy = SelectedMessages
                               .Select(m => m.DuckCopy <Message>())
                               .ToList();

            #region Do action

            Action doAction = delegate
            {
                foreach (var message in SelectedMessages.ToList())
                {
                    if (SelectedMessage.IsStarred)
                    {
                        SelectedMessage.SetUnstarred();
                    }
                    else
                    {
                        SelectedMessage.SetStarred();
                    }
                }

                viewFilter.UpdateCurrentViewAsync();

                flipper.Delay();
            };

            #endregion

            #region Undo action

            Action undoAction = delegate
            {
                foreach (var message in previousSelection)
                {
                    // Get old message from copied data
                    Message message1 = message;

                    var oldMessage = messagesCopy.Single(m => m.MessageId == message1.MessageId);

                    // Reverts the previous action
                    message.IsStarred          = oldMessage.IsStarred;
                    message.TargetMessageState = oldMessage.TargetMessageState;

                    AsyncUpdateQueue.Enqueue(message);
                }

                // We cannot use the IEditableObject appraoch here because the conversation in question
                // probably might not be in view anymore. So instead we will refresh the whole view.
                viewFilter.RebuildCurrentViewAsync();
            };

            #endregion

            ClientState.Current.UndoManager.Execute(new HistoryAction(doAction, undoAction));
        }
예제 #2
0
        void Star_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            if (SelectedMessage.IsStarred)
            {
                ClientStats.LogEvent("Star in message details view");

                SelectedMessage.SetUnstarred();
            }
            else
            {
                ClientStats.LogEvent("Unstar in message details view");

                SelectedMessage.SetStarred();
            }
        }