Esempio n. 1
0
        public StreamView()
        {
            using (new CodeTimer("StreamView/Constructor"))
            {
                InitializeComponent();

                selection = new List<Message>();
                dropHelper = new DropHelper(StreamListView);
                dropHelper.Drop += StreamListView_Drop;

                DataContext = this;

                viewFilter = ViewFilter.Current;
                viewFilter.Filter.FilterChanged += State_CurrentViewChanged;

                selectionFlipper = new Flipper(TimeSpan.FromMilliseconds(200),
                    () => State.SelectedMessages.ReplaceWithCast(StreamListView.SelectedItems));

                EventBroker.Subscribe(AppEvents.RebuildOverview,
                    () => Thread.CurrentThread.ExecuteOnUIThread(CreateChannelsSelection));

                VirtualMailBox.Current.InboxLoadComplete += delegate
                    {
                        using (new ThreadFlag())
                            StreamListView.SelectedIndex = 0;
                    };

                EventBroker.Subscribe(AppEvents.TabChanged, delegate(string newTab)
                    {
                        if (newTab == "DockControl")
                        {
                            // Switched to overview
                            isOverviewActive = true;

                            if (selection.Count > 0)
                                State.SelectedMessages.Replace(selection);
                        }
                        else
                        {
                            // Switched to any other tab
                            if (isOverviewActive)
                            {
                                // Save selection
                                selection.Clear();
                                selection.AddRange(State.SelectedMessages);
                            }

                            isOverviewActive = false;
                        }
                    });
            }
        }
        public ConversationsState()
        {
            viewFilter = ViewFilter.Current;

            ActivityViewSource = new CollectionViewSource { Source = viewFilter.Messages };
            SelectedMessages = new AdvancedObservableCollection<Message>();

            SelectedMessages.CollectionChanged += delegate
            {
                OnPropertyChanged("SelectedMessage");

                OnSelectionChanged();
            };

            flipper = new Flipper(TimeSpan.FromSeconds(25), delegate
                {
                    // Todo run readstates syncornization if no receive task is currently running
                });
        }
        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)));
        }