//如果当前是新闻,动弹,或者我的 都可以执行刷新操作 private void icon_Refresh1_Click(object sender, EventArgs e) { switch (this.panorama.SelectedIndex) { //新闻列表刷新 case 0: this.newsList.Refresh( ); break; //动弹列表刷新 //注意这里只需要刷新 case 2: TweetPortal.AnsycGetHottestTweets(true); TweetPortal.AnsycGetHottestTweets(false); break; //我的刷新,注意不是列表刷新,而是 userNotice 刷新显示 case 3: //动态页只有登陆了才有效 if (Config.IsLogin) { Tool.AsyncGetUserNotice( ); } break; } }
/// <summary> /// Construct /// </summary> public MainPage( ) { InitializeComponent( ); Tool.StartUserNoticeThread( ); //弹出消息提示 this.Loaded += (s, e) => { //登陆或注销用户的检测 this.Instance_OnLoginOrLogout(null, null); Tool.AsyncGetUserNotice( ); //我的动弹那里获取自己的头像 this.DisplayMyTweetPortrait( ); EventSingleton.Instance.OnLoginOrLogout += new EventHandler <TagEventArgs>(Instance_OnLoginOrLogout); EventSingleton.Instance.OnGetUserNotice += new EventHandler <TagEventArgs>(Instance_OnGetUserNotice); Console.Write(ScheduledUnit.Instance); }; this.Unloaded += (s, e) => { GC.Collect( ); EventSingleton.Instance.OnLoginOrLogout -= Instance_OnLoginOrLogout; EventSingleton.Instance.OnGetUserNotice -= Instance_OnGetUserNotice; }; //启动 UserNotice 的获取 EventSingleton.Instance.OnUpdatePortrait += (s, e) => { this.DisplayMyTweetPortrait( ); }; }