private void load(object sender, RoutedEventArgs e) { if (e.Handled) { return; } e.Handled = true; MyTreeViewItem item = e.OriginalSource as MyTreeViewItem; if (item.ShowMessageWindow) { MessageViewWindow window = MessageViewWindow.CreateMessageViewWindow(item.MessageType, item.Argument); new Thread(new ThreadStart(() => { this.Dispatcher.Invoke((Action)(() => { window.Show(); })); })).Start(); window.Load(); } item.IsSelected = false; }
void Update() { while (true) { try { if (!Globals.Ribbons.Ribbon.keepUpdateBtn.Checked) { continue; } //Fill home List <DisplayMembership> members = _client.GetJoinedGroup(); this.Dispatcher.Invoke((Action)(() => { _homeItem.Items.Clear(); foreach (var member in members) { MyTreeViewItem item = new MyTreeViewItem(member.DisplayName, true, MessageViewType.Home, new Dictionary <string, object>() { { "GroupID", member.GroupID }, { "UserID", Utils.GetCurrentUserID() } }); _homeItem.Items.Add(item); } })); //Fill topic List <DisplayFavouriteTopic> topics = _client.GetMyFavouriteTopic(); this.Dispatcher.Invoke((Action)(() => { _topicItem.Items.Clear(); foreach (var topic in topics) { MyTreeViewItem item = new MyTreeViewItem( string.Format("{0}({1})", topic.topicName, topic.UnreadMsgCount), true, MessageViewType.Topic, new Dictionary <string, object>() { { "GroupID", topic.GroupID }, { "TopicName", topic.topicName } }); _topicItem.Items.Add(item); } })); //Fill Following List <DisplayUserProfile> followings = _client.GetFollowings(); this.Dispatcher.Invoke((Action)(() => { _followingItem.Items.Clear(); foreach (var user in followings) { MyTreeViewItem item = new MyTreeViewItem( string.Format("{0}({1})", user.DisplayName, user.Userid), true, MessageViewType.User, new Dictionary <string, object>() { { "DisplayName", user.DisplayName }, { "UserID", user.Userid } }); _followingItem.Items.Add(item); } })); //Update Notification count NotificationCount notif = _client.GetNotificationCount(); this.Dispatcher.Invoke((Action)(() => { _homeItem.Header = string.Format("Home({0})", notif.UnreadHomelineMsgCount); _ownItem.Header = string.Format("Own({0})", notif.UnreadOwnerlineMsgCount); _mentionItem.Header = string.Format("Mention({0})", notif.UnreadAtlineMsgCount); })); } catch (Exception e) { MessageBox.Show(e.Message + "\r\n" + e.StackTrace, "Error", MessageBoxButton.OK, MessageBoxImage.Error); } finally { Thread.Sleep(1000 * 120); } } }