public OverviewColumnTabItem()
        {
            mailbox = VirtualMailBox.Current;

            DataContext = this;

            EventBroker.Subscribe(AppEvents.SyncStatusUpdatesFinished,
                () => ThreadPool.QueueUserWorkItem(UpdateCountAsync));
        }
        public SearchProfilesControl()
        {
            mailbox = VirtualMailBox.Current;

            InitializeComponent();

            DataContext = this;

            Profiles = new AdvancedObservableCollection<Profile>();
        }
        public ReceiveMessagesTask(ChannelConfiguration config, IClientInputChannel channel, ChannelFolder folder, ReceiveRange range)
            : base(config, channel)
        {
            this.config = config;
            this.channel = channel;
            this.folder = folder;
            this.range = range;

            mailbox = VirtualMailBox.Current;
        }
        public ContactsState()
        {
            mailbox = VirtualMailBox.Current;

            SelectedPersons = new AdvancedObservableCollection<Person>();

            PersonsViewSource = new CollectionViewSource { Source = VirtualMailBox.Current.Persons };
            PersonsViewSource.View.Filter = ContactsViewSourceFilter;

            Sort = new SortHelper(PersonsViewSource);
            Sort.LoadSettings();

            Filter = new FilterHelper(PersonsViewSource);

            SelectedPersons.CollectionChanged += delegate
             	{
             		OnPropertyChanged("SelectedPerson");

             		OnSelectionChanged();
             	};

            EventBroker.Subscribe(AppEvents.SyncContactsFinished, () => Thread.CurrentThread.ExecuteOnUIThread(() => PersonsViewSource.View.Refresh()));
        }
        public DetailsView()
        {
            using (new CodeTimer("ColumnSearch/Constructor"))
            {
                dock = new SearchDockControl();
                mailbox = VirtualMailBox.Current;
                messages = new ThreadSafeCollection<Message>();
                documents = new ThreadSafeCollection<Document>();
                persons = new ThreadSafeCollection<Person>();
                statusUpdates = new ThreadSafeCollection<UserStatus>();

                messagesViewSource = new CollectionViewSource { Source = messages };
                messagesViewSource.SortDescriptions.Add(new SortDescription("SortDate", ListSortDirection.Descending));

                documentsViewSource = new CollectionViewSource { Source = documents };
                documentsViewSource.SortDescriptions.Add(new SortDescription("Filename", ListSortDirection.Ascending));

                personsViewSource = new CollectionViewSource { Source = persons };
                personsViewSource.SortDescriptions.Add(new SortDescription("Name", ListSortDirection.Ascending));

                statusUpdatesViewSource = new CollectionViewSource { Source = statusUpdates };
                statusUpdatesViewSource.SortDescriptions.Add(new SortDescription("SortDate", ListSortDirection.Descending));

                InitializeComponent();

                MessagesColumn.OverrideViewSource(messagesViewSource);
                DocumentsColumn.OverrideViewSource(documentsViewSource);
                StatusUpdatesColumn.OverrideViewSource(statusUpdatesViewSource);

                dock.UpdateSearch += delegate
                    {
                        LoadData(new ColumnSearchDataHelper { SearchQuery = dock.SearchQuery });
                    };

                DataContext = this;
            }
        }
        public RealtimeStream(ChannelInstance channel, string keyword)
        {
            this.Channel = channel;
            this.Keyword = keyword;
            this.mailbox = VirtualMailBox.Current;

            this.markreadtimer = new DispatcherTimer(DispatcherPriority.Normal, Dispatcher) { Interval = TimeSpan.FromMilliseconds(400), IsEnabled = false };
            this.markreadtimer.Tick += MarkReadTimerTick;

            InitializeComponent();

            StreamStatusUpdatesSource = new CollectionViewSource { Source = State.StatusUpdates };
            MentionsStatusUpdatesSource = new CollectionViewSource { Source = State.StatusUpdates };

            StreamStatusUpdatesSource.SortDescriptions.Add(new SortDescription("ParentSortDate", ListSortDirection.Descending));
            StreamStatusUpdatesSource.SortDescriptions.Add(new SortDescription("SortDate", ListSortDirection.Ascending));
            StreamStatusUpdatesSource.View.Filter = StreamStatusUpdatesSourceFilter;

            MentionsStatusUpdatesSource.SortDescriptions.Add(new SortDescription("ParentSortDate", ListSortDirection.Descending));
            MentionsStatusUpdatesSource.SortDescriptions.Add(new SortDescription("SortDate", ListSortDirection.Ascending));
            MentionsStatusUpdatesSource.View.Filter = MentionsStatusUpdatesSourceFilter;

            DataContext = this;

            mailbox.InboxLoadComplete += delegate
                {
                    StreamStatusUpdatesSource.View.Refresh();
                    MentionsStatusUpdatesSource.View.Refresh();
                };

            EventBroker.Subscribe(AppEvents.SyncStatusUpdatesFinished, () => ThreadPool.QueueUserWorkItem(UpdateCountAsync));

            Responder.SetIsFirstResponder(SupportsMentions ? Stream2ListView : Stream1ListView, true);

            ThreadPool.QueueUserWorkItem(UpdateCountAsync);
        }
 public UserStatusParser(ChannelConfiguration config)
 {
     this.config = config;
     this.mailbox = VirtualMailBox.Current;
 }
 public PurgeDataTask()
 {
     mailbox = VirtualMailBox.Current;
 }
 public SendMessageCommand(Message message)
 {
     this.message = message;
     this.mailbox = VirtualMailBox.Current;
 }
 public RemoveChannelTask(ChannelConfiguration configuration, bool notify)
 {
     this.configuration = configuration;
     this.mailbox = VirtualMailBox.Current;
     this.notify = notify;
 }
        public FoldersControl()
        {
            mailbox = VirtualMailBox.Current;
            viewFilter = ViewFilter.Current;
            labels = new ThreadSafeCollection<LabelsContainer>();

            LabelsViewSource = new CollectionViewSource { Source = labels };
            LabelsViewSource.SortDescriptions.Add(new SortDescription("Count", ListSortDirection.Descending));
            LabelsViewSource.View.Filter = IsLabelVisible;

            InitializeComponent();

            signal = new AutoResetEvent(false);
            workerThread = new Thread(UpdateCounters)
            {
                Name = "Counter update thread",
                IsBackground = true,
                Priority = ThreadPriority.BelowNormal
            };

            workerThread.Start();

            DataContext = this;

            VirtualMailBox.Current.LoadComplete += delegate { UpdateCountersAsync(); };

            EventBroker.Subscribe(AppEvents.RebuildOverview, UpdateCountersAsync);
            EventBroker.Subscribe(AppEvents.ReceiveMessagesFinished, UpdateCountersAsync);
            EventBroker.Subscribe(AppEvents.MessageUpdated, UpdateCountersAsync);

            EventBroker.Subscribe(AppEvents.View, delegate(ActivityView view)
                {
                    ClientState.Current.ViewController.MoveTo(WellKnownView.Overview);

                    // Find the radio-button with the requested view
                    LogicalTreeWalker.Walk(this, delegate(RadioButton rb)
                        {
                            if (GetActivityView(rb) == view)
                                rb.IsChecked = true;
                        });

                    viewFilter.Filter.CurrentView = view;
                    viewFilter.RebuildCurrentViewAsync();

                    EventBroker.Publish(AppEvents.RequestFocus);
                });

            EventBroker.Subscribe(AppEvents.View, delegate(Label label)
                {
                    EventBroker.Publish(AppEvents.View, ActivityView.Label);

                    viewFilter.Filter.Label = label.Labelname;
                    viewFilter.RebuildCurrentViewAsync();

                    EventBroker.Publish(AppEvents.RequestFocus);
                });

            EventBroker.Subscribe(AppEvents.ShuttingDown, () => Thread.CurrentThread.ExecuteOnUIThread(delegate
                {
                    // Save settings during shutdown
                    SettingsManager.ClientSettings.AppConfiguration.ShowProductivityColumn = ProductivityExpander.IsExpanded;
                    SettingsManager.ClientSettings.AppConfiguration.ShowLabelsColumn = LabelsExpander.IsExpanded;
                    SettingsManager.Save();
                }));

            EventBroker.Subscribe(AppEvents.LabelCreated, (string label) => labels.Add(new LabelsContainer(label)));
        }
 public ContactMatcher(ChannelContact contact)
 {
     this.contact = contact;
     this.mailbox = VirtualMailBox.Current;
 }
 public ProfileMatcher(Message message)
 {
     this.message = message;
     this.mailbox = VirtualMailBox.Current;
 }
 /// <summary>
 /// Private constructor, only allow access through static accessors.
 /// </summary>
 internal MessageMatcher()
 {
     mailbox = VirtualMailBox.Current;
 }