/// <summary> /// 点击选择某项收藏 /// </summary> private void list_Favs_SelectionChanged(object sender, SelectionChangedEventArgs e) { FavUnit f = this.list_Favs.SelectedItem as FavUnit; this.list_Favs.SelectedItem = null; if (f != null) { Tool.ProcessAppLink(f.url); } }
/// <summary> /// 取消收藏 /// </summary> private void menu_Delete_Click(object sender, RoutedEventArgs e) { MenuItem item = sender as MenuItem; FavUnit f = item.DataContext as FavUnit; if (f != null) { Dictionary <string, string> parameters = new Dictionary <string, string> { { "uid", Config.UID.ToString() }, { "objid", f.id.ToString() }, { "type", f.type.ToString() }, }; WebClient client = Tool.SendWebClient(Config.api_fav_delete, parameters); client.DownloadStringCompleted += (s, e1) => { if (e1.Error != null) { System.Diagnostics.Debug.WriteLine("删除收藏时网络错误: {0}", e1.Error.Message); return; } else { ApiResult result = Tool.GetApiResult(e1.Result); switch (result.errorCode) { case 1: this.listBoxHelper.Refresh( ); break; case 0: case -1: case -2: MessageBox.Show(result.errorMessage, "温馨提示", MessageBoxButton.OK); break; default: break; } } }; } }