Esempio n. 1
0
        public async void OnTick(IWeiboAccessToken at)
        {
            if (_tick++%57 != 0)
                return;
            var resp = await WeiboClient.suggestions_statuses_hot_async(at.get(), 20, true, 1, _type);
            if(++_type == hot_status_type.count)
                _type = hot_status_type.musement;

            if (resp.Failed() || resp.Value.Length == 0)
                return;
            var queue = new PriorityQueue<long, Status>();
            foreach(var s in resp.Value)
            {
                queue.Enqueue(EvalMark(s),s);
            }
            while (queue.Size > 5)
                queue.Dequeue();
            while(!queue.IsEmpty)
            {
                var s = queue.Dequeue();
                var ws = new WeiboStatus();
                ws.assign_sina(s);
                await DispatcherHelper.UIDispatcher.BeginInvoke(DispatcherPriority.SystemIdle, (Action) (() =>
                {
                    if(statuses.Count > 10)
                        statuses.RemoveAt(0);
                    statuses.Add(ws);
                }));
            }
        }
Esempio n. 2
0
        internal void ReloadSinaV2(Statuses result,bool reload )
        {
            previous_cursor = result.previous_cursor;
            next_cursor = result.next_cursor;
            total_number = result.total_number;
            Debug.WriteLine("noti: {3}, timeline total: {0},prev: {1},next: {2}",total_number,previous_cursor, next_cursor, notifications);

            if(reload)
                UiInvoke(() => statuses.Clear());
            foreach (var s in result.statuses)
            {
                var ws = new WeiboStatus();
                ws.assign_sina(s);
                UiInvoke(() => statuses.Add(ws));
            }
        }
Esempio n. 3
0
 private static void InsertTokens(TextBlock textblock, WeiboStatus status, TextRenderContext ctx)
 {
     if (textblock == null)
         return;
     if ((bool)textblock.GetValue(DesignerProperties.IsInDesignModeProperty))
         return;
     if (status == null)
         return;
     textblock.Inlines.Clear();
     var ic = new List<Inline>();
     foreach (var sent in status.tokens)
     {
         InsertToken(ic, sent,ctx);
     }
     textblock.Inlines.AddRange(ic);
     if (textblock.Inlines.Count == 0)
         textblock.Visibility = Visibility.Collapsed;
 }
Esempio n. 4
0
 public void assign_sina(Status data)
 {
     assign_sina_data(data);
     var para = new InitializeParam();
     if(data.retweeted_status != null)
     {
         retweeted_status = new WeiboStatus();
         retweeted_status.assign_sina_data(data.retweeted_status);
         retweeted_status.post_initialize(false,para);
     }
     post_initialize(true, para);
     if (url.has_media)
         Messenger.Default.Send(url);
 }
Esempio n. 5
0
 public static void SetWeibo(TextBlock textblock, WeiboStatus status)
 {
     textblock.SetValue(WeiboProperty, status);
 }
 public static void SetItem(DependencyObject o, WeiboStatus value)
 {
     o.SetValue(ItemProperty, value);
 }