private void SearchBox_QuerySubmitted(AutoSuggestBox sender, AutoSuggestBoxQuerySubmittedEventArgs args) { if (WebStatusHelper.IsOnline()) { Frame.Navigate(typeof(Views.Search), SearchBox.Text, new Windows.UI.Xaml.Media.Animation.DrillInNavigationTransitionInfo()); } }
private void SearchBox_QuerySubmitted(AutoSuggestBox sender, AutoSuggestBoxQuerySubmittedEventArgs args) { if (WebStatusHelper.IsOnline()) { Frame.Navigate(typeof(Search), SearchBox.Text, new DrillInNavigationTransitionInfo()); } }
protected async override void OnNavigatedTo(NavigationEventArgs e) { string url = "http://bangumi.bilibili.com/api/tags?appkey=" + ApiHelper.appkey + "&build=424000&mobi_app=wp&platform=wp&page=1&pagesize=60&ts=" + ApiHelper.GetLinuxTS().ToString(); url += ApiHelper.GetSign(url); List <Tags> tags = await ContentServ.GetTagsAsync(url); if (WebStatusHelper.IsOnline()) { gridview.Items.Add(new Tags { Cover = "http://i0.hdslb.com/bfs/bangumi/2da98805cad609d9d55d469b76d556520fc943dc.jpg", TagID = "109", TagName = "新番推荐" }); } if (tags == null) { return; } foreach (var item in tags) { gridview.Items.Add(new Tags { Cover = item.Cover, TagID = item.TagID, TagName = item.TagName }); } }
// async void topShowOrHide() // { // if (_appSettings.Values["_topbar"].ToString() == "False") // { // await sb.ShowAsync(); // sb.BackgroundColor = Color.FromArgb(1, 226, 115, 170); // } // else if (_appSettings.Values["_topbar"].ToString() == "True") // { // await sb.HideAsync(); // } // } // StatusBar sb = StatusBar.GetForCurrentView(); private void SearchBox_QuerySubmitted(AutoSuggestBox sender, AutoSuggestBoxQuerySubmittedEventArgs args) { if (WebStatusHelper.IsOnline()) { mainframe.Navigate(typeof(Views.Search), SearchBox.Text); } }
public Video() { this.InitializeComponent(); this.NavigationCacheMode = NavigationCacheMode.Disabled; isInited = true; this.DataContext = this; timer.Interval = TimeSpan.FromSeconds(1); timer_danmaku.Interval = TimeSpan.FromSeconds(1); timer.Tick += Timer_Tick; timer_repeat.Tick += Timer_repeat_Tick; timer_danmaku.Tick += Timer_danmaku_Tick; timer.Start(); // 横向屏幕 DisplayInformation.AutoRotationPreferences = DisplayOrientations.Landscape; if (!WebStatusHelper.IsOnline()) { txt_mydanmu.PlaceholderText = "没有联网哦,不能发弹幕"; txt_mydanmu.IsEnabled = false; } // 保持屏幕常亮 displayRq.RequestActive(); if (SettingHelper.DeviceType == DeviceType.PC) { menu_full.Visibility = Visibility.Visible; MouseDevice.GetForCurrentView().MouseMoved += Video_MouseMoved; CoreWindow.GetForCurrentThread().KeyDown += Video_KeyDown; } SettingInit(); }
/// <summary> /// 获取弹幕数据(网络) /// </summary> /// <param name="cid"></param> /// <returns></returns> async Task <List <DanmuModel> > GetDanmu(string cid) { List <DanmuModel> list = new List <DanmuModel>(); XmlDocument doc = new XmlDocument(); try { //http://comment.bilibili.com/10631099.xml if (WebStatusHelper.IsOnline() && cid.Length > 0) //离线视频需要加个cid { string url = "http://comment.bilibili.com/" + cid + ".xml"; string txt = await BaseService.SentGetAsync(url); doc.LoadXml(txt); return(AnalysisDanmaku(doc)); } else { status.Text += "没有下载弹幕且当前无网络连接,跳过"; return(null); }; } catch { return(null); } }
/// <summary> /// 获取弹幕数据(网络) /// </summary> /// <param name="cid"></param> /// <returns></returns> async Task <List <DanmuModel> > GetDanmu(string cid) { List <DanmuModel> list = new List <DanmuModel>(); XmlDocument doc = new XmlDocument(); try { // http://comment.bilibili.com/10631099.xml?rnd=991 if (WebStatusHelper.IsOnline() && cid.Length > 0) { string url = "http://comment.bilibili.com/" + cid + ".xml?rnd=" + new Random().Next(500, 1000); string txt = await BaseService.SentGetAsync(url); doc.LoadXml(txt); if (DanmuPool != null && (bool)SettingHelper.GetValue("_autokill") == true) { StartKill(); } return(AnalysisDanmaku(doc)); } else { status.Text += "没有下载弹幕且当前无网络连接,跳过"; return(null); }; } catch { return(null); } }
public Video() { this.InitializeComponent(); this.NavigationCacheMode = NavigationCacheMode.Disabled; isInited = true; this.DataContext = this; timer.Interval = TimeSpan.FromSeconds(1); timer_danmaku.Interval = TimeSpan.FromSeconds(1); timer.Tick += Timer_Tick; timer_repeat.Tick += Timer_repeat_Tick; timer_danmaku.Tick += Timer_danmaku_Tick; timer.Start(); DisplayInformation.AutoRotationPreferences = DisplayOrientations.Landscape; //横向屏幕 ApplicationView.GetForCurrentView().TryEnterFullScreenMode(); if (SettingHelper.ContainsKey("_vol")) { sli_vol.Value = Convert.ToInt32(SettingHelper.GetValue("_vol")); } if (SettingHelper.ContainsKey("_light")) { sli_light.Value = double.Parse(SettingHelper.GetValue("_light").ToString()); } else { sli_light.Value = 1; } if (!WebStatusHelper.IsOnline()) { txt_mydanmu.PlaceholderText = "没有联网哦,不能发弹幕"; txt_mydanmu.IsEnabled = false; } displayRq.RequestActive(); //保持屏幕常亮 CoreWindow.GetForCurrentThread().KeyDown += Video_KeyDown; }
private async void SearchBox_TextChanged(AutoSuggestBox sender, AutoSuggestBoxTextChangedEventArgs args) { if (!WebStatusHelper.IsOnline()) { return; } string url = "http://api.bilibili.com/suggest?_device=wp&appkey=" + ApiHelper.appkey + "&bangumi_acc_num=0&bangumi_num=0&build=429001&func=suggest&main_ver=v3&mobi_app=win&special_acc_num=0&special_num=0&suggest_type=accurate&term=" + SearchBox.Text + "&topic_acc_num=0&topic_num=0&upuser_acc_num=0&upuser_num=0&_hwid=0100d4c50200c2a6&platform=uwp_mobile"; url += ApiHelper.GetSign(url); JsonObject json = await BaseService.GetJson(url); try { if (json.ContainsKey("tag")) { List <string> list = new List <string>(); json = JsonObject.Parse(json["tag"].ToString()); int i = 0; do { i++; } while (json.ContainsKey(i.ToString())); for (int j = 0; j < i; j++) { JsonObject json2 = JsonObject.Parse(json[j.ToString()].ToString()); if (json2.ContainsKey("value")) { list.Add(json2["value"].GetString()); } } SearchBox.ItemsSource = list; } } catch { } }
private void Button_Click(object sender, RoutedEventArgs e) { if (!WebStatusHelper.IsOnline()) { Report("没有网络连接"); return; } Button btn = sender as Button; switch (btn.Tag.ToString()) { case "1": { if (!ApiHelper.IsLogin()) { Report("请先登录"); return; } Frame.Navigate(typeof(MyConcerns), UserHelper.Mid, new SlideNavigationTransitionInfo()); } break; case "2": Frame.Navigate(typeof(Timeline), null, new SlideNavigationTransitionInfo()); break; case "3": Frame.Navigate(typeof(Bangumi), null, new SlideNavigationTransitionInfo()); break; } }
public Partition() { this.InitializeComponent(); this.NavigationCacheMode = Windows.UI.Xaml.Navigation.NavigationCacheMode.Required; if (!WebStatusHelper.IsOnline()) { popup.Show("没有网络连接", 3000); } comment.Navi += Comment_Navi; comment.Info += Comment_Info; comment.live += Comment_live; }
private void Timer_Tick(object sender, object e) { switch (WebStatusHelper.GetConnType()) { case ConnectionType.DataConn: txt_web.Text = "数据流量"; break; case ConnectionType.WlanConn: txt_web.Text = "WiFi"; break; case ConnectionType.PPPoE: txt_web.Text = "宽带"; break; case ConnectionType.NoConn: txt_web.Text = "无连接"; break; } txt_now.Text = DateTime.Now.Hour.ToString("00") + " :" + DateTime.Now.Minute.ToString("00"); txt_bat.Text = ((double)Battery.AggregateBattery.GetReport().RemainingCapacityInMilliwattHours / (double)Battery.AggregateBattery.GetReport().FullChargeCapacityInMilliwattHours * 100).ToString("00") + "%"; }
private async void Random_Tapped(object sender, Windows.UI.Xaml.Input.TappedRoutedEventArgs e) { if (!WebStatusHelper.IsOnline()) { Report("没有网络连接"); return; } int aid = 0; Details details = new Details(); do { aid = new Random().Next(10000, 5000000); string a = "http://app.bilibili.com/x/view?_device=android&_ulv=10000&plat=0&build=424000&aid="; details = await ContentServ.GetDetailsAsync(a + aid, true); } while (details == null || details.Aid == null); Frame.Navigate(typeof(Detail_P), aid); }
/// <summary> /// 自动登录 /// </summary> async Task <bool> autologin() { try { if (!WebStatusHelper.IsOnline()) { return(false); } if (!SettingHelper.ContainsKey("_accesskey")) { SettingHelper.SetValue("_accesskey", string.Empty); } if (SettingHelper.ContainsKey("_autologin")) { if (bool.Parse(SettingHelper.GetValue("_autologin").ToString()) == true) { string p = string.Empty; string u = string.Empty; if (!string.IsNullOrEmpty(SettingHelper.GetValue("_epassword").ToString())) { p = SettingHelper.GetValue("_epassword").ToString(); } if (!string.IsNullOrEmpty(SettingHelper.GetValue("_username").ToString())) { u = SettingHelper.GetValue("_username").ToString(); } await ApiHelper.login(p, u); } } if (ApiHelper.IsLogin()) { return(true); } else { return(false); } } catch { return(false); } }
protected async override void OnNavigatedTo(NavigationEventArgs e) { mainframe.Navigate(typeof(Views.Partition)); // 处理跳转参数 if (e.Parameter is StorageFile) { mainframe.Navigate(typeof(Views.Video), e.Parameter); } else { if (e.Parameter != null) { string arg = e.Parameter.ToString(); if (WebStatusHelper.IsOnline()) { if (!string.IsNullOrEmpty(arg)) { if (arg[0] == 't') { mainframe.Navigate(typeof(Views.Detail_P), arg.Substring(1)); } else if (arg[0] == 's') { mainframe.Navigate(typeof(Views.Detail), arg.Substring(1)); } else if (arg[0] == 'm') { mainframe.Navigate(typeof(Views.Message), arg.Substring(2)); } } } else { await popup.Show("没有网络连接"); } } } if (ApiHelper.IsLogin()) { await ShowStatus(); } }
protected async override void OnNavigatedTo(NavigationEventArgs e) { if (WebStatusHelper.IsOnline()) { await autologin(); if (SettingHelper.GetValue("_pull") != null) { if ((bool)SettingHelper.GetValue("_pull") == true) { await RegisterBackgroundTask(typeof(BackgroundTask.TileTask), "TileTask", new TimeTrigger(15, false), null); } } } else { timer.Interval = new TimeSpan(0, 0, 1); timer.Tick += Timer_Tick; } }
/// <summary> /// 动态刷新基本信息 /// </summary> private async void Timer_Tick(object sender, object e) { switch (WebStatusHelper.GetConnType()) { case ConnectionType.DataConn: txt_web.Text = "数据流量"; break; case ConnectionType.WlanConn: txt_web.Text = "WiFi"; break; case ConnectionType.PPPoE: txt_web.Text = "宽带"; break; case ConnectionType.NoConn: txt_web.Text = "无连接"; break; } txt_now.Text = DateTime.Now.Hour.ToString("00") + " :" + DateTime.Now.Minute.ToString("00"); txt_bat.Text = ((double)Battery.AggregateBattery.GetReport().RemainingCapacityInMilliwattHours / (double)Battery.AggregateBattery.GetReport().FullChargeCapacityInMilliwattHours * 100).ToString("00") + "%"; if (SettingHelper.ContainsKey("_cursor")) { if ((bool)SettingHelper.GetValue("_cursor") == false) { return; } } await HideCursor(); }
// private void Refesh_Click(object sender, RoutedEventArgs e) // { // loadItems(); // } private async void mainpivot_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (WebStatusHelper.IsOnline()) { try { switch (mainpivot.SelectedIndex) { case 0: { if (!isTopicLoaded) { // string url = "http://api.bilibili.com/x/web-show/res/loc?jsonp=jsonp&pf=0&id=23"; // List<Models.Topic> MyList = await ContentServ.GetTopicListAsync(url); // foreach (var item in MyList) // { // show_1.Source.Add(new Controls.RecommandShow.MySource { bmp = new BitmapImage { UriSource = new Uri(item.Pic) }, url = item.Url }); // } // show_1.show(); await comment.init(); header_Home.init(await ContentServ.GetHomeBanners()); header_Home.navi += Header_navi; isTopicLoaded = true; } } break; case 1: { if (!await addcomment(cursor)) { await addcomment(cursor); } header_bangumi.init(await ContentServ.GetBangumiBanners()); if (list_lastupdate.Items.Count == 0) { list_lastupdate.ItemsSource = await ContentServ.GetLastUpdateAsync(); } header_bangumi.navi += Header_navi; } break; case 2: { if (!isFriendsLoaded) { await loadpulls(1); isFriendsLoaded = true; } } break; case 3: { // 发现 if (list_hottags.Items.Count == 0) { list_hottags.ItemsSource = await ContentServ.GetHotSearchAsync(); } } break; } } catch (Exception err) { string a = err.Message; } } }
async void SendDanmu() { if (!ApiHelper.IsLogin() || !WebStatusHelper.IsOnline()) { return; } if (string.IsNullOrWhiteSpace(txt_mydanmu.Text)) { messagepop.Show("弹幕内容不能为空哦!"); return; } try { string url = "http://api.bilibili.com/comment/post?_device=android&_ulv=10000&build=424000&access_key=" + ApiHelper.accesskey + "&appkey=" + ApiHelper.appkey + "&aid=" + aid + "&cid=" + cid + "&pid=1&platform=wp"; url += ApiHelper.GetSign(url); int SendMode = 1; if (cb_SendMode.SelectedIndex == 0) { SendMode = 1; } if (cb_SendMode.SelectedIndex == 1) { SendMode = 4; } if (cb_SendMode.SelectedIndex == 2) { SendMode = 5; } int a = 255 << 24 | byte.Parse(r.Text) << 16 | byte.Parse(g.Text) << 8 | byte.Parse(b.Text); string color = a.ToString(); string Args = "mid=" + UserHelper.mid + "&msg=" + txt_mydanmu.Text + "&type=json" + "&pool=0&playTime=" + media.Position.TotalSeconds.ToString() + "&cid=" + cid + "&fontsize=25&mode=" + SendMode.ToString() + "&rnd=" + new Random().Next(1000, 9999).ToString() + "&color=" + color; string code = await BaseService.SendPostAsync(url, Args, "http://api.bilibili.com"); JsonObject json = JsonObject.Parse(code); if (json.ContainsKey("code")) { if (json["code"].ToString() == "0") { switch (SendMode) { case 1: danmaku.AddBasic(new DanmuModel { Message = txt_mydanmu.Text, Color = color, Size = "25" }, true); break; case 4: danmaku.AddTop(new DanmuModel { Message = txt_mydanmu.Text, Color = color, Size = "25", Mode = "5" }, true); break; case 5: danmaku.AddTop(new DanmuModel { Message = txt_mydanmu.Text, Color = color, Size = "25", Mode = "4" }, true); break; } return; } } } catch (Exception e) { messagepop.Show("发送失败" + e.Message); } finally { txt_mydanmu.Text = string.Empty; } }
/// <summary> /// 发送弹幕(手动) /// </summary> async void SendDanmu() { if (!ApiHelper.IsLogin() || !WebStatusHelper.IsOnline()) { return; } if (string.IsNullOrEmpty(cid)) { messagepop.Show("只有来自b站的视频才能发送弹幕哦!"); return; } if (string.IsNullOrWhiteSpace(txt_mydanmu.Text)) { messagepop.Show("弹幕内容不能为空哦!"); return; } try { /* * int v = int.Parse(Color, System.Globalization.NumberStyles.HexNumber); * SolidColorBrush solid = new SolidColorBrush(new Color() * { * A = Convert.ToByte(255), * R = Convert.ToByte((v >> 16) & 255), * G = Convert.ToByte((v >> 8) & 255), * B = Convert.ToByte((v >> 0) & 255) * }); */ string url = "http://api.bilibili.com/comment/post?_device=wp&_ulv=10000&build=430000&access_key=" + ApiHelper.accesskey + "&appkey=" + ApiHelper.appkey + "&aid=" + aid + "&cid=" + cid + "&pid=1&platform=android&scale=xhdpi"; url += ApiHelper.GetSign(url); int a = (byte.Parse(sli_r.Value.ToString()) << 16) + (byte.Parse(sli_g.Value.ToString()) << 8) + (byte.Parse(sli_b.Value.ToString()) << 0);// 位运算的优先级最低! string color = a.ToString(); string Args = "mid=" + UserHelper.Mid + "&type=json" + "&cid=" + cid + "&playTime=" + media.Position.TotalSeconds.ToString() + "&color=" + color + "&msg=" + txt_mydanmu.Text + "&fontsize=25&mode=" + danmakuMode + "&pool=0&rnd=" + new Random().Next(1000, 2000).ToString(); string code = await BaseService.SendPostAsync(url, Args, "http://api.bilibili.com"); JsonObject json = JsonObject.Parse(code); if (json.ContainsKey("code")) { if (json["code"].ToString() == "0") { switch (danmakuMode) { case "1": danmaku.AddBasic(new DanmuModel { Message = txt_mydanmu.Text, Color = color, Size = "25" }, true); break; case "4": danmaku.AddTop(new DanmuModel { Message = txt_mydanmu.Text, Color = color, Size = "25", Mode = "5" }, true); break; case "5": danmaku.AddTop(new DanmuModel { Message = txt_mydanmu.Text, Color = color, Size = "25", Mode = "4" }, true); break; } return; } } } catch (Exception e) { messagepop.Show("发送失败" + e.Message); } finally { txt_mydanmu.Text = string.Empty; } }
//private void Refesh_Click(object sender, RoutedEventArgs e) //{ // loadItems(); //} private async void mainpivot_SelectionChanged(object sender, SelectionChangedEventArgs e) { TextBlock txt = this.FindName(string.Format("h{0}", mainpivot.SelectedIndex)) as TextBlock; for (int i = 0; i < mainpivot.Items.Count; i++) { TextBlock temp = this.FindName(string.Format("h{0}", i)) as TextBlock; temp.Foreground = new SolidColorBrush(Colors.LightGray); } txt.Foreground = new SolidColorBrush(Colors.White); if (WebStatusHelper.IsOnline()) { try { switch (mainpivot.SelectedIndex) { case 0: { if (!isTopicLoaded) { bar.Visibility = Visibility.Visible; //string url = "http://api.bilibili.com/x/web-show/res/loc?jsonp=jsonp&pf=0&id=23"; //List<Models.Topic> MyList = await ContentServ.GetTopicListAsync(url); //foreach (var item in MyList) //{ // show_1.Source.Add(new Controls.RecommandShow.MySource { bmp = new BitmapImage { UriSource = new Uri(item.Pic) }, url = item.Url }); //} //show_1.show(); await comment.init(); bar.Visibility = Visibility.Collapsed; isTopicLoaded = true; } } break; case 1: { bar.Visibility = Visibility.Visible; if (!await addcomment(cursor)) { await addcomment(cursor); } header_bangumi.init(await ContentServ.GetFilpItems(), 3.2); if (list_lastupdate.Items.Count == 0) { list_lastupdate.ItemsSource = await ContentServ.GetLastUpdateAsync(); } header_bangumi.navi += Header_bangumi_navi; bar.Visibility = Visibility.Collapsed; } break; case 2: { if (!isFriendsLoaded) { bar.Visibility = Visibility.Collapsed; await loadfriends(); bar.Visibility = Visibility.Visible; isFriendsLoaded = true; } } break; case 3: { //list_live } break; case 4: { //发现 if (list_hottags.Items.Count == 0) { list_hottags.ItemsSource = await ContentServ.GetHotSearchAsync(); } } break; } } catch { } } }