Пример #1
0
        void InlineSearch()
        {
            var query = SearchTextBox.Text.Trim();

            if (String.IsNullOrEmpty(query))
            {
                return;
            }

            if (query.Length < 3)
            {
                return;
            }

            // Delay new search if another search is still pending
            if (IsSearching)
            {
                searchFlipper.Delay();
            }

            IsSearching = true;
            OnPropertyChanged("IsSearching");
            ((Storyboard)FindResource("RunLoaderStoryboard")).Begin(this);

            new BackgroundActionTask(() => InlineSearchAsync(query)).ExecuteAsync();
        }
Пример #2
0
        void Editor_PreviewKeyDown(object sender, KeyEventArgs e)
        {
            _flipper.Delay();

            switch (e.Key)
            {
            case Key.Up:
                // Move selection up
                if (AutoCompletionListBox.SelectedIndex > 0)
                {
                    AutoCompletionListBox.SelectedIndex--;
                }

                e.Handled = true;

                break;

            case Key.Down:
                // Move selection down
                if (AutoCompletionListBox.SelectedIndex < AutoCompletionListBox.Items.Count)
                {
                    AutoCompletionListBox.SelectedIndex++;
                }

                e.Handled = true;

                break;

            case Key.Escape:
                // Restore state before we opened the list
                if (AutoCompletionPopup.IsOpen)
                {
                    HideList();
                }
                else
                {
                    EventBroker.Publish(AppEvents.RequestFocus);
                }

                break;

            case Key.Tab:
            case Key.Enter:
            case Key.Space:
                if (IsPopupOpen && CanInsertSelectedVisualLabel())
                {
                    InsertSelectedVisualLabel();
                }
                else
                {
                    ProcessCurrentWord();
                }

                e.Handled = true;

                break;
            }
        }
Пример #3
0
        void ContactsListView_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (e.AddedItems.Count == 0)
            {
                return;
            }

            selectionFlipper.Delay();
        }
Пример #4
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");
        }
Пример #5
0
        static void InterceptKeys_KeyPressed(object sender, EventArgs e)
        {
            // If the _flipper is not running, start it
            // Otherwise continue with showing the launcher
            if (!_Flipper.IsRunning)
            {
                _Flipper.Delay();
                return;
            }

            // Execute on UI thread
            Dispatcher.CurrentDispatcher.BeginInvoke((Action) delegate
            {
                LauncherWindow window = new LauncherWindow();

                window.Show();
                window.Topmost = true;
                window.Activate();
            });
        }
Пример #6
0
 void StreamListView_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     selectionFlipper.Delay();
 }
Пример #7
0
        public void Delete(bool deleteConversations)
        {
            // Contains the same references as in SelectedMessages,
            // these references can change when un-doing so keep a snapshot around
            var previousSelection = deleteConversations ?
                                    SelectedMessages.SelectMany(m => m.Conversation.Messages)
                                    .Distinct()             // Select all messages from selected conversations
                                    .ToList()
                                : new List <Message>(SelectedMessages);

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

            #region Do action

            Action doAction = delegate
            {
                foreach (var message in previousSelection)
                {
                    message.MarkDeleted();
                }

                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);

                    message.IsRead             = oldMessage.IsRead;
                    message.TargetMessageState = oldMessage.TargetMessageState;
                    message.MessageFolder      = oldMessage.MessageFolder;

                    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));
        }
        void SearchTextBox_OnKeyDown(object sender, KeyEventArgs e)
        {
            OnPropertyChanged("IsInSearchMode");

            searchFlipper.Delay();
        }
Пример #9
0
 void Editor_KeyUp(object sender, KeyEventArgs e)
 {
     autocompleteFlipper.Delay();
 }
Пример #10
0
        void Editor_PreviewKeyDown(object sender, KeyEventArgs e)
        {
            wordFlipper.Delay();

            switch (e.Key)
            {
            case Key.Up:
                // Move selection up
                if (AutoCompletionListBox.SelectedIndex > 0)
                {
                    AutoCompletionListBox.SelectedIndex--;
                }

                e.Handled = true;

                break;

            case Key.Down:
                // Move selection down
                if (AutoCompletionListBox.SelectedIndex < AutoCompletionListBox.Items.Count)
                {
                    AutoCompletionListBox.SelectedIndex++;
                }

                e.Handled = true;

                break;

            case Key.Enter:
                // Accept selection
                if (IsPopupOpen)
                {
                    InsertSelectedContact();
                }

                break;

            case Key.Escape:
                // Restore state before we opened the list
                HideList();

                e.Handled = true;
                break;

            case Key.Tab:
                if (IsPopupOpen)
                {
                    InsertSelectedContact();
                }
                else
                {
                    TextRange range = WordBreaker.GetWordRange(Editor.CaretPosition);

                    string text = range.Text.Trim();

                    // Break out when use tabs and nothing has been entered
                    if (String.IsNullOrEmpty(text.Trim()))
                    {
                        return;
                    }

                    ProcessCurrentWord();
                }

                e.Handled = true;

                break;

            case Key.Space:
            case Key.OemComma:
            case Key.OemSemicolon:
                // Add word being typed in by user
                ProcessCurrentWord();

                break;

            default:
                // Clear color of range
                TextRange currentRange = WordBreaker.GetWordRange(Editor.CaretPosition);
                currentRange.ApplyPropertyValue(TextBlock.ForegroundProperty, Brushes.Black);

                break;
            }
        }