Пример #1
0
        private void MenuItem_AddNewTimeline_Click(object sender, RoutedEventArgs e)
        {
            NewTimelineWindow win = new NewTimelineWindow (_mgr);
            win.Owner = this;
            bool? ret = win.ShowDialog ();
            if (!ret.HasValue || !ret.Value)
                return;

            TimelineBase info = null;
            TwitterAccount account = win.SelectedAccount;
            if (win.IsCheckedAccountTimeline) {
                info = new TimelineInfo (_mgr, _rootTLs, account, win.SelectedAccountTimeline);
            } else if (win.IsCheckedNewSearch && win.SearchKeyword.Length > 0) {
                SearchStatuses search = new SearchStatuses (account, win.SearchKeyword);
                if (win.IsUseStreamingForSearch)
                    search.StreamingClient = new StreamingClient (new TwitterAccount[] {account}, search.Keyword, search, false);
                _mgr.AddSearchInfo (search);
                info = new TimelineInfo (_rootTLs, search);
            } else if (win.IsCheckedExistedSearch && win.SelectedExistedSearch != null) {
                info = new TimelineInfo (_rootTLs, win.SelectedExistedSearch);
            } else if (win.IsCheckedNewTab && win.NewTabTitle.Length > 0) {
                info = new TabInfo (_rootTLs, win.NewTabTitle);
            } else if (win.IsCheckedList) {
                ListStatuses listStatuses = new ListStatuses (win.SelectedAccount, win.SelectedList);
                if (win.IsUseStreamingForList)
                    listStatuses.StreamingClient = new StreamingClient (new TwitterAccount[] {win.SelectedListStreamingAccount}, win.SelectedAccount, win.SelectedList, listStatuses, false);
                _mgr.AddListInfo (listStatuses);
                info = new TimelineInfo (_rootTLs, listStatuses);
            }
            if (info != null) {
                _rootTLs.TimeLines.Add (info);
                SaveConfig ();
            }
        }
Пример #2
0
 void LoadConfigInternal(JsonArray array, TimelineBase timelines)
 {
     for (int i = 0; i < array.Length; i ++) {
         JsonObject obj = array[i] as JsonObject;
         if (obj != null) {
             TimelineBase info = null;
             switch ((obj.Value["type"] as JsonString).Value) {
                 case "account":
                     string subtype = (obj.Value["subtype"] as JsonString).Value;
                     string name = (obj.Value["name"] as JsonString).Value;
                     TwitterAccount account = null;
                     foreach (TwitterAccount item in _mgr.Accounts)
                         if (name.Equals (item.ScreenName)) {
                             account = item;
                             break;
                         }
                     if (account == null) continue;
                     switch (subtype) {
                         case "home": info = new TimelineInfo (_mgr, timelines, account, account.HomeTimeline); break;
                         case "mentions": info = new TimelineInfo (_mgr, timelines, account, account.Mentions); break;
                         case "directmessages": info = new TimelineInfo (_mgr, timelines, account, account.DirectMessages); break;
                     }
                     break;
                 case "search":
                     string keywords = (obj.Value["keywords"] as JsonString).Value;
                     foreach (SearchStatuses search in _mgr.Searches)
                         if (keywords.Equals (search.Keyword)) {
                             info = new TimelineInfo (timelines, search);
                             break;
                         }
                     break;
                 case "tab":
                     string title = (obj.Value["title"] as JsonString).Value;
                     TabInfo tb = new TabInfo (timelines, title);
                     LoadConfigInternal ((JsonArray)obj.Value["windows"], tb);
                     info = tb;
                     break;
                 case "list":
                     ulong id = (ulong)(obj.Value["id"] as JsonNumber).Value;
                     foreach (ListStatuses list in _mgr.Lists)
                         if (id == list.List.ID) {
                             info = new TimelineInfo (timelines, list);
                             break;
                         }
                     break;
             }
             if (info != null)
                 timelines.TimeLines.Add (info);
         }
     }
 }