private void EditTimelineCommand_Executed(object sender, ExecutedRoutedEventArgs e) { var timeline = e.Parameter as Timeline ?? (Timeline)TimelineTabControl.SelectedItem; if (timeline.Type != TimelineType.User && timeline.Type != TimelineType.List && timeline.Type != TimelineType.Search) { MessageBox.Show("无法编辑此标签页", App.NAME); return; } var dialog = new TimelineDialog { Timeline = timeline, Owner = this, Lists = lists }; if (!(dialog.ShowDialog() ?? false)) { return; } timeline.Clear(); if (timeline.Type == TimelineType.User) { timeline.Update(Timelines.TypeAt(TimelineType.Recent).Items.Concat(Timelines.TypeAt(TimelineType.Replies).Items)); } else if (timeline.Type == TimelineType.Search) { ThreadPool.QueueUserWorkItem(state => { this.Invoke(p => timeline.Update(p), TClient.Search(timeline.Tag, timeline.SinceID)); }); } else if (timeline.Type == TimelineType.List) { ThreadPool.QueueUserWorkItem(state => { this.Invoke(p => timeline.Update(p), TClient.GetListStatuses(timeline.Tag, timeline.SinceID)); }); } RefreshTimelineSettings(); }
private void AddTimelineCommand_Executed(object sender, ExecutedRoutedEventArgs e) { var dialog = new TimelineDialog { Owner = this, Lists = lists }; if (!(dialog.ShowDialog() ?? false)) { return; } var timeline = dialog.Timeline; if (timeline.Type == TimelineType.User) { timeline.Update(Timelines.TypeAt(TimelineType.Recent).Items.Concat(Timelines.TypeAt(TimelineType.Replies).Items)); } else if (timeline.Type == TimelineType.Search) { ThreadPool.QueueUserWorkItem(state => { this.Invoke(p => timeline.Update(p), TClient.Search(timeline.Tag, timeline.SinceID)); }); } else if (timeline.Type == TimelineType.List) { ThreadPool.QueueUserWorkItem(state => { var tmpList = TClient.Lists; this.Invoke(p => this.lists = p, tmpList); this.Invoke(p => timeline.Update(p), TClient.GetListStatuses(timeline.Tag, timeline.SinceID)); }); } timeline.Sort(Settings.Default.SortCategory, Settings.Default.SortDirection); Timelines.Add(timeline); RefreshTimelineSettings(); }