private void MainPage_switchNight() { if (SettingHelper.ContainsKey("_night")) { RequestedTheme = (bool)SettingHelper.GetValue("_night") ? ElementTheme.Dark : ElementTheme.Light; } }
private void StartKill() { strs.Clear(); if (!string.IsNullOrWhiteSpace(txt_word.Text)) { foreach (var word in txt_word.Text.Split(' ')) { if (word.Length == 0) { continue; } strs.Add(word); } } if (wordInclude.IsChecked != true) { if (SettingHelper.ContainsKey("_words")) { string[] words = SettingHelper.GetValue("_words").ToString().Split(' '); foreach (string word in words) { if (word.Length > 0) { strs.Add(word); } } } } }
private void UpgradeVersion() { if (!IsolatedStorageSettings.ApplicationSettings.Contains("MigratedScheduler") && ScheduledActionService.Find("PeriodicAgent") as PeriodicTask != null) { //1.0.x대의 스케쥴러 삭제 RemoveAgent("PeriodicAgent"); IsolatedStorageSettings.ApplicationSettings["MigratedScheduler"] = true; //새로운 스케쥴러 등록 StartPeriodicAgent(); } //2.4 버전 색상값 변경 관련 if (SettingHelper.ContainsKey(Constants.LOCKSCREEN_BACKGROUND_COLOR)) { ColorItem colorItem = SettingHelper.Get(Constants.LOCKSCREEN_BACKGROUND_COLOR) as ColorItem; if (colorItem.Color == Colors.Transparent) { SettingHelper.Set(Constants.LOCKSCREEN_BACKGROUND_COLOR, new ColorItem() { Text = AppResources.ColorChrome, Color = ColorItem.ConvertColor(0xFF1F1F1F) }, false); SettingHelper.Set(Constants.LOCKSCREEN_BACKGROUND_OPACITY, 0, false); SettingHelper.Save(); } } }
public void Sort() { string defaultSort = "番剧_13.动画_1.生活_160.电影_23.娱乐_71.鬼畜_119.科技_36.游戏_4.音乐_3.舞蹈_20.时尚_155.广告_166.电视剧_11"; string sort = defaultSort; if (SettingHelper.ContainsKey("_sort")) { string _sort = SettingHelper.GetValue("_sort").ToString(); if (_sort != string.Empty) { sort = _sort; } } else { SettingHelper.SetValue("_sort", defaultSort); } list.Clear(); foreach (var item in sort.Split('.')) { string key = item.Split('_')[0]; string value = item.Split('_')[1]; list.Add(new KeyValuePair <string, string>(key, value)); } }
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; }
protected override void OnNavigatedTo(NavigationEventArgs e) { if (e.Parameter != null) { if (!string.IsNullOrWhiteSpace(e.Parameter.ToString())) { list.Items.Clear(); url = "http://konachan.net/post.json?limit=15&page=" + page.ToString() + "&tags=" + e.Parameter.ToString(); } } else { url = "http://konachan.net/post.json?limit=15&page=" + page.ToString(); } if (SettingHelper.ContainsKey("_safe")) { if ((bool)SettingHelper.GetValue("_safe") == false) { State = true; if (SettingHelper.ContainsKey("_r18")) { if ((bool)SettingHelper.GetValue("_r18") == true) { State = false; } } } } list_index.SelectedIndex = 0; }
bool ChangeTheme(bool a = true) { try { if (SettingHelper.ContainsKey("_Theme")) { var TitleBar = ApplicationView.GetForCurrentView().TitleBar; Color color = ColorRelated.GetColor(); Application.Current.Resources["bili_Theme"] = new SolidColorBrush(color); ChangeDarkMode(currentTheme); ChangeDarkMode(currentTheme); TitleBar.BackgroundColor = color; TitleBar.ButtonBackgroundColor = color; TitleBar.ForegroundColor = Colors.White; TitleBar.ButtonHoverForegroundColor = Colors.Black; TitleBar.ButtonHoverBackgroundColor = Colors.White; if (Windows.Foundation.Metadata.ApiInformation.IsTypePresent("Windows.UI.ViewManagement.StatusBar")) { StatusBar sb = StatusBar.GetForCurrentView(); sb.BackgroundColor = color; sb.BackgroundOpacity = 1; } } return(true); } catch { return(false); } }
void init() { if (SettingHelper.ContainsKey("_nighttheme")) { night.IsOn = SettingHelper.GetValue("_nighttheme").ToString() == "light" ? false : true; } if (SettingHelper.ContainsKey("_downloadcost")) { downstyle.IsOn = SettingHelper.GetValue("_downloadcost").ToString() == "wifionly" ? false : true; } if (SettingHelper.ContainsKey("_downdanmu")) { danmaku.IsOn = Convert.ToBoolean(SettingHelper.GetValue("_downdanmu")); } if (SettingHelper.ContainsKey("_isdirect")) { direct.IsOn = Convert.ToBoolean(SettingHelper.GetValue("_isdirect")); } if (SettingHelper.ContainsKey("_quality")) { quality.SelectedIndex = Convert.ToInt32(SettingHelper.GetValue("_quality").ToString()) - 1; } if (SettingHelper.ContainsKey("_pull")) { background.IsOn = Convert.ToBoolean(SettingHelper.GetValue("_pull")); } }
//락스크린 초기화 private void MainPageLockscreen() { //앱바 생성 CreateLockscreenAppBar(); //잠금화면 공급자 설정 //LockscreenHelper.SetLockscreenProvider(); //락스크린 사용여부 설정 ignoreCheckBoxEvents = true; if (SettingHelper.ContainsKey(Constants.LOCKSCREEN_USE_ROTATOR)) { //잠금화면 공급자가 아니면 스케쥴러 및 락스크린 사용여부 삭제 if (!LockScreenManager.IsProvidedByCurrentApplication) { NoUseLockscreen(); } else { //잠금화면 공급자인데 스케쥴러가 없으면 시작시킴 UseLockscreen.IsChecked = true; //로딩시 락스크린 사용인데 스케줄러에 없으면 시작시킴 if (ScheduledActionService.Find(Constants.PERIODIC_TASK_NAME) == null) { StartPeriodicAgent(); } } } ignoreCheckBoxEvents = false; //경고 숨김 LockscreenEditWarnning = false; }
/// <summary> /// 在将要挂起应用程序执行时调用。 在不知道应用程序 /// 无需知道应用程序会被终止还是会恢复, /// 并让内存内容保持不变。 /// </summary> /// <param name="sender">挂起的请求的源。</param> /// <param name="e">有关挂起请求的详细信息。</param> private void OnSuspending(object sender, SuspendingEventArgs e) { var deferral = e.SuspendingOperation.GetDeferral(); // TODO: 保存应用程序状态并停止任何后台活动 if (SettingHelper.ContainsKey("_autologin")) { if ((bool)SettingHelper.GetValue("_autologin") == false) { ApiHelper.logout(); } } deferral.Complete(); }
/// <summary> /// 开始下载 /// </summary> private async void Btn_ok_Click(object sender, RoutedEventArgs e) { int i = 0; flyout_download.Hide(); foreach (Pages item in ReadyList.SelectedItems) { try { cid = item.Cid; VideoURL url = await ContentServ.GetVedioURL(cid, quality, format); string name = StringDeal.RemoveSpecial(title.Text); string part = StringDeal.RemoveSpecial(item.Part); StorageFolder folder = await DownloadHelper.GetMyFolderAsync(); StorageFolder f1 = await folder.CreateFolderAsync(name, CreationCollisionOption.OpenIfExists); List <DownloadOperation> list = new List <DownloadOperation>(); for (int j = 0; j < url.Ps.Count; j++) { list.Add(await DownloadHelper.Download(url.Ps[j].Url, $"{part}_{j}.{format.ToString()}", f1)); } // 如果await,那么执行完第一个StartAsync()后即退出循环.GetCurrentDownloadsAsync()方法同样会遇到此问题.(Download页) IAsyncOperationWithProgress <DownloadOperation, DownloadOperation> start; for (int k = 0; k < list.Count; k++) { start = list[k].StartAsync(); } i++; await DownloadHelper.AddVideoInfo(part, cid, details.Sid); await popup.Show(i.ToString() + "个视频已加入下载队列"); if (SettingHelper.ContainsKey("_downdanmu")) { if ((bool)SettingHelper.GetValue("_downdanmu") == false) { continue; } } await DownloadHelper.DownloadDanmakuAsync(cid, part, f1); } catch (Exception err) { await popup.Show(err.Message); } } SwitchCommandBar(false); }
private void list_kill_ItemClick(object sender, ItemClickEventArgs e) { if (!isWordEditting) { return; } if (!SettingHelper.ContainsKey("_words")) { SettingHelper.SetValue("_words", string.Empty); } string oldstring = SettingHelper.GetValue("_words").ToString(); string newstring = oldstring.Replace(e.ClickedItem.ToString() + ",", string.Empty); SettingHelper.SetValue("_words", newstring); list_kill.Items.Remove(e.ClickedItem); }
private void addword_Click(object sender, RoutedEventArgs e) { if (!SettingHelper.ContainsKey("_words")) { SettingHelper.SetValue("_words", string.Empty); } string oldstring = SettingHelper.GetValue("_words").ToString(); string word = txt_word.Text; if (!string.IsNullOrEmpty(word) && !oldstring.Contains(word)) { oldstring += word + " "; list_kill.Items.Add(word); SettingHelper.SetValue("_words", oldstring); txt_word.Text = string.Empty; } }
private void btnSearch_Tap(object sender, System.Windows.Input.GestureEventArgs e) { if (txtSearch.Text.Trim() == string.Empty) { MessageBox.Show(AppResources.MsgEnterSearchKeyword); } else { string key = "TodaySearchCount"; string today = DateTime.Today.ToString("yyyyMMdd"); if (SettingHelper.ContainsKey(key)) { string ymdCnt = SettingHelper.GetString(key); string[] val = ymdCnt.Split('_'); if (val[0] == today) { int cnt = 0; Int32.TryParse(val[1], out cnt); cnt++; SettingHelper.Set(key, string.Format("{0}_{1}", today, cnt), true); if (cnt > 5) { MessageBox.Show(AppResources.MsgSearchMaxCount); return; } } else { SettingHelper.Set(key, string.Format("{0}_{1}", today, 1), true); } } else { //System.Diagnostics.Debug.WriteLine(DateTime.Today.ToString("yyyyMMdd")); SettingHelper.Set(key, string.Format("{0}_{1}", today, 1), true); } searchQuery = txtSearch.Text.Trim(); finder.FindImageUrlsFor(searchQuery); SearchingProgressBar.Visibility = System.Windows.Visibility.Visible; } }
/// <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); } }
private void Init() { if (SettingHelper.ContainsKey("_downloadcost")) { cost.IsOn = (bool)SettingHelper.GetValue("_downloadcost"); } if (SettingHelper.ContainsKey("_safe")) { safe.IsOn = (bool)SettingHelper.GetValue("_safe"); } if (SettingHelper.ContainsKey("_r18")) { R18.IsOn = (bool)SettingHelper.GetValue("_r18"); } if (SettingHelper.ContainsKey("_night")) { night.IsOn = (bool)SettingHelper.GetValue("_night"); } if (SettingHelper.ContainsKey("_site")) { site.IsOn = (bool)SettingHelper.GetValue("_site"); } if (SettingHelper.ContainsKey("_path")) { if (!string.IsNullOrEmpty(SettingHelper.GetValue("_path").ToString())) { path.IsOn = true; txt_path.Text = SettingHelper.GetValue("_path").ToString(); } else { path.IsOn = false; txt_path.Text = @"图片库\Konachan"; } } else { path.IsOn = false; txt_path.Text = @"图片库\Konachan"; } R18.Visibility = safe.IsOn ? Visibility.Collapsed : Visibility.Visible; }
private void CheckTrial() { //체험판 체크 IsTrial = new LicenseInformation().IsTrial(); //IsTrial = true; if (IsTrial) { if (SettingHelper.ContainsKey(Constants.CHAMELEON_INSTALL_DTTM)) { DateTime installedDttm = (DateTime)SettingHelper.Get(Constants.CHAMELEON_INSTALL_DTTM); if (DateTime.Today.Subtract(installedDttm).TotalDays > 5) { //체험판 이후 스케쥴러 삭제 try { ScheduledActionService.Remove(Constants.PERIODIC_TASK_NAME); } catch (Exception) { } Deployment.Current.Dispatcher.BeginInvoke(() => { if (MessageBox.Show(AppResources.MsgExpiredTrial, AppResources.Confirm, MessageBoxButton.OKCancel) == MessageBoxResult.OK) { new MarketplaceDetailTask().Show(); } else { Application.Current.Terminate(); } }); } } else { //최초 실행이면 현재 날짜를 저장시킴 SettingHelper.Set(Constants.CHAMELEON_INSTALL_DTTM, DateTime.Today, true); } } }
private void Button_Click(object sender, RoutedEventArgs e) { ham.IsPaneOpen = !ham.IsPaneOpen; if (SettingHelper.ContainsKey("_space")) { sli_space.Value = int.Parse(SettingHelper.GetValue("_space").ToString()); } if (SettingHelper.ContainsKey("_speed")) { sli_speed.Value = int.Parse(SettingHelper.GetValue("_speed").ToString()); } if (SettingHelper.ContainsKey("_fontsize")) { sli_fontsize.Value = int.Parse(SettingHelper.GetValue("_fontsize").ToString()); } if (info.Text.Length == 0 && URL != null) { info.Text = "视频大小:" + (int.Parse(URL.Size) / 1024 / 1024).ToString() + "MB" + Environment.NewLine; } }
async Task read(int index) { danmaku.ClearDanmu(); media.Visibility = Visibility.Collapsed; status.Visibility = Visibility.Visible; cid = infos[index].Cid; aid = infos[0].Title; status.Text = "获取视频地址..."; int quality = 2; if (SettingHelper.ContainsKey("_quality")) { quality = int.Parse(SettingHelper.GetValue("_quality").ToString()); } URL = await ContentServ.GetVedioURL(cid, quality, VideoFormat.mp4); string url = URL.Url; status.Text += (URL == null) ? "失败" : "完毕"; if (URL == null) { return; } status.Text += Environment.NewLine + "加载弹幕数据..."; try { DanmuPool = await GetDanmu(cid); status.Text += "完毕"; } catch { status.Text += "失败"; } media.Source = new Uri(url); txt_title.Text = infos[index].Title; status.Text += Environment.NewLine + "正在缓冲视频..."; loading.Visibility = Visibility.Visible; }
public MainPage() { this.InitializeComponent(); this.DataContext = this; // 后退键 SystemNavigationManager.GetForCurrentView().BackRequested += MainPage_BackRequested; // MainList.SelectedIndex = 0; if (SettingHelper.ContainsKey("_topbar")) { TopShoworHide(); } if (SettingHelper.ContainsKey("_nighttheme")) { if (SettingHelper.GetValue("_nighttheme").ToString() == "dark") { RequestedTheme = ElementTheme.Dark; currentTheme = false; // txt.Text = "日间模式"; } else if (SettingHelper.GetValue("_nighttheme").ToString() == "light") { RequestedTheme = ElementTheme.Light; currentTheme = true; // txt.Text = "夜间模式"; } } else { RequestedTheme = ElementTheme.Light; currentTheme = true; // txt.Text = "夜间模式"; } ChangeTheme(); if (SettingHelper.DeviceType == DeviceType.PC) { CoreWindow.GetForCurrentThread().KeyDown += MainPage_KeyDown; } }
/// <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 RetrieveWeather() { WeatherCity city = SettingHelper.Get(Constants.WEATHER_MAIN_CITY) as WeatherCity; if (SettingHelper.ContainsKey(Constants.WEATHER_LIVE_RESULT)) { LiveWeather liveWeather = SettingHelper.Get(Constants.WEATHER_LIVE_RESULT) as LiveWeather; System.DateTime updDttm = GetDateTime(liveWeather.ObDate); //System.DateTime updDttm = liveWeather.UpdatedDateTime; //업데이트 후 1시간이 지나지 않았다면 if (DateTime.Now.Subtract(updDttm).TotalMinutes < 60) { //도시 설정 weatherBug.DefaultWeatherCity = city; //화면 표시 RenderLiveWeather(liveWeather); //업데이트 불필요 기존 데이터를 다시 로드하여 보여줌 if (SettingHelper.ContainsKey(Constants.WEATHER_FORECAST_RESULT)) { Forecasts forecasts = SettingHelper.Get(Constants.WEATHER_FORECAST_RESULT) as Forecasts; //주간 예보 표시 RenderForecast(forecasts); return; } } } if (city != null) { RetrieveWeather(city); } }
bool ChangeTheme(bool a = true) { string ThemeName = string.Empty; if (SettingHelper.ContainsKey("_Theme")) { ThemeName = SettingHelper.GetValue("_Theme") as string; } else { ThemeName = "Pink"; SettingHelper.SetValue("_Theme", "Pink"); } //Application.Current.Resources.ThemeDictionaries.Clear(); //KeyValuePair<object, object> openWith = new KeyValuePair<object, object>("bili_Theme", new SolidColorBrush(Color.FromArgb(255, 255, 0, 0))); //Application.Current.Resources.ThemeDictionaries.Add(new ResourceDictionary { }); //找不到来自“ms-appx:///Theme//RedTheme.xaml”的资源 ResourceDictionary newDictionary = new ResourceDictionary(); newDictionary.Source = new Uri("ms-appx:///Theme/RedTheme.xaml", UriKind.RelativeOrAbsolute); Application.Current.Resources.MergedDictionaries.Clear(); Application.Current.Resources.MergedDictionaries.Add(newDictionary); return(true); }
public MainPage() { this.InitializeComponent(); this.DataContext = this; //标题栏 var TitleBar = ApplicationView.GetForCurrentView().TitleBar; TitleBar.BackgroundColor = Color.FromArgb(1, 226, 115, 170); TitleBar.ForegroundColor = Colors.White; TitleBar.ButtonBackgroundColor = Color.FromArgb(1, 226, 115, 170); TitleBar.ButtonHoverForegroundColor = Colors.Black; TitleBar.ButtonHoverBackgroundColor = Colors.White; //后退键 SystemNavigationManager.GetForCurrentView().BackRequested += MainPage_BackRequested; MainList.SelectedIndex = 0; mainframe.Navigate(typeof(Views.Partition), null, new Windows.UI.Xaml.Media.Animation.EntranceNavigationTransitionInfo()); if (SettingHelper.ContainsKey("_topbar")) { TopShoworHide(); } if (SettingHelper.ContainsKey("_nighttheme")) { if (SettingHelper.GetValue("_nighttheme").ToString() == "dark") { RequestedTheme = ElementTheme.Dark; currentTheme = false; txt.Text = "日间模式"; } else if (SettingHelper.GetValue("_nighttheme").ToString() == "light") { RequestedTheme = ElementTheme.Light; currentTheme = true; txt.Text = "夜间模式"; } } }
protected async override void OnNavigatedTo(NavigationEventArgs e) { base.OnNavigatedTo(e); if (e.Parameter.GetType() == typeof(List <VideoInfo>)) { // 读取在线视频信息 isLocal = false; infos = e.Parameter as List <VideoInfo>; Index = Convert.ToInt32(infos[0].Cid) + 1; if (Index == 1) { left.Visibility = Visibility.Collapsed; } if (infos.Count <= 2 || Index == infos.Count - 1) { right.Visibility = Visibility.Collapsed; } if (SettingHelper.ContainsKey("_videoformat")) { format = SettingHelper.GetValue("_videoformat").ToString() == "0" ? VideoFormat.mp4 : VideoFormat.flv; } // 默认的格式:mp4 else { format = VideoFormat.mp4; } await read(Index); } else { isLocal = true; btn_Switchffmpeg.Visibility = Visibility.Visible; JsonObject json = new JsonObject(); if (e.Parameter.GetType() == typeof(string)) { // 文件关联 string a = e.Parameter.ToString(); if (a[0] == '@') { left.Visibility = right.Visibility = Visibility.Collapsed; string path = e.Parameter.ToString().Substring(1); file = await StorageFile.GetFileFromPathAsync(path); await GetInfoAsync(); Windows.Storage.AccessCache.StorageApplicationPermissions.FutureAccessList.Add(file); status.Text += "正在读取弹幕..."; var danmupool = await GetDanmu(file); status.Text += Environment.NewLine + "正在读取视频..."; txt_title.Text = file.DisplayName; var stream = await file.OpenAsync(FileAccessMode.Read); media.SetSource(stream, file.ContentType); status.Text += "完毕"; await Task.Delay(500); return; } } // 读取本地视频 if (e.Parameter.GetType() == typeof(StorageFile)) { left.Visibility = right.Visibility = Visibility.Collapsed; file = e.Parameter as StorageFile; await GetInfoAsync(); if (file != null) { Windows.Storage.AccessCache.StorageApplicationPermissions.FutureAccessList.Add(file); status.Text += "正在读取弹幕..."; var danmupool = await GetDanmu(file); status.Text += Environment.NewLine + "正在读取视频..."; txt_title.Text = file.DisplayName; // 系统原生支持的类型 if (VideoHelper.videoExtensions_sys.Contains(file.FileType)) { var stream = await file.OpenAsync(FileAccessMode.Read); media.SetSource(stream, file.ContentType); status.Text += "完毕"; await Task.Delay(500); return; } else { await SetFFmpegSource(file); status.Text += "完毕"; await Task.Delay(500); return; } } } // 下载列表 if (e.Parameter.GetType() == typeof(LocalVideo)) { LocalVideo myVideo = e.Parameter as LocalVideo; if (myVideo != null) { left.Visibility = right.Visibility = Visibility.Collapsed; part = myVideo.Part; folder = myVideo.Folder; StorageFolder myfolder = await KnownFolders.VideosLibrary.GetFolderAsync("哔哩哔哩"); myfolder = await myfolder.GetFolderAsync(folder); // 文件的原本名称是 part_index, 而弹幕文件是 part, 不冲突 string filename = $"{part}{myVideo.Format}"; file = await myfolder.GetFileAsync(filename); await GetInfoAsync(); Windows.Storage.AccessCache.StorageApplicationPermissions.FutureAccessList.Add(file); status.Text += "正在读取弹幕..."; var danmupool = await GetDanmu(file); if (danmupool != null) { DanmuPool = danmupool; } status.Text += Environment.NewLine + "正在读取视频..."; txt_title.Text = part.Split('_')[0]; // 如果是系统原生支持的格式,直接设置媒体源 if (VideoHelper.videoExtensions_sys.Contains(file.FileType)) { var stream = await file.OpenAsync(FileAccessMode.Read); media.SetSource(stream, file.ContentType); status.Text += "完毕"; await Task.Delay(500); return; } // 否则,使用ffmpeg else { await SetFFmpegSource(file); return; } } } } }
private async void FindLocation() { if (!SettingHelper.ContainsKey(Constants.WEATHER_LOCATION_CONSENT)) { MessageBoxResult result = MessageBox.Show(AppResources.MsgConfirmUseLocation, AppResources.AgreeUseLocation, MessageBoxButton.OKCancel); SettingHelper.Set(Constants.WEATHER_LOCATION_CONSENT, (result == MessageBoxResult.OK), false); } if (!SettingHelper.ContainsKey(Constants.WEATHER_LOCATION_CONSENT)) { // The user has opted out of Location. return; } Geolocator geolocator = new Geolocator(); geolocator.DesiredAccuracyInMeters = 50; try { Geoposition geoposition = await geolocator.GetGeopositionAsync( maximumAge : TimeSpan.FromMinutes(5), timeout : TimeSpan.FromSeconds(10) ); DisplayUnit unitType = (DisplayUnit)SettingHelper.Get(Constants.WEATHER_UNIT_TYPE); //날씨 조회 모드 설정 변경 WeatherCity city = new WeatherCity(); city.IsGpsLocation = true; city.Latitude = geoposition.Coordinate.Latitude.ToString(); city.Longitude = geoposition.Coordinate.Longitude.ToString(); //검색조건 저장 SettingHelper.Set(Constants.WEATHER_MAIN_CITY, city, false); //좌표로 날씨 조회 RetrieveWeather(city); } catch (Exception ex) { if ((uint)ex.HResult == 0x80004004) { //로딩 패널 제거 HideLoadingPanel(); // the application does not have the right capability or the location master switch is off //StatusTextBlock.Text = "location is disabled in phone settings."; if (MessageBox.Show(AppResources.MsgFailLocationService, AppResources.Confirm, MessageBoxButton.OKCancel) == MessageBoxResult.OK) { var navigate = Windows.System.Launcher.LaunchUriAsync(new Uri("ms-settings-location:")); } } //else { // something else happened acquring the location } } }
protected async override void OnNavigatedTo(NavigationEventArgs e) { try { base.OnNavigatedTo(e); SwitchCommandBar(false); desc.Visibility = Visibility.Visible; aid = e.Parameter.ToString(); string url = "http://app.bilibili.com/x/view?_device=android&_ulv=10000&plat=0&build=424000&aid=" + aid + "&appkey=" + ApiHelper.appkey + "&access_key=" + ApiHelper.accesskey; url += ApiHelper.GetSign(url); details = await ContentServ.GetDetailsAsync(url); if (details != null) { pageNavi("AV" + details.Aid); BitmapImage bmp = new BitmapImage() { UriSource = new Uri(details.Pic) }; pic.Source = bmp; if (SettingHelper.GetBoolSetting("_blur", true)) { pic_blur.Source = bmp; if (AnimationExtensions.IsBlurSupported) { pic_blur.Blur(duration: 3000, value: 20).Start(); } } title.Text = details.Title; up.Content = details.Upzhu; desc.Text = details.Desc; c_play.Text = "播放:" + details.View + '\t'; c_fav.Text = "收藏:" + details.Fav + '\t'; c_danmaku.Text = "弹幕:" + details.Danmu + '\t'; c_coin.Text = "硬币:" + details.Coins + '\t'; c_comment.Text = "评论:" + details.Reply + '\t'; time.Text = details.Time; if (details.IsFav == "1") { btn_addfav.Icon = new SymbolIcon(Symbol.UnFavorite); btn_addfav.Label = "取消收藏"; } foreach (var item in details.Tags) { if (item.Length > 0) { list_tags.Items.Add(new Tags { Tag = item }); } } foreach (var item in details.Ps) { ReadyList.Items.Add(item); } if (!string.IsNullOrEmpty(details.Sid)) { bangumi.Content = details.BangumiTitle; bangumi.Click += Bangumi_Click; stk_bangumi.Visibility = Visibility.Visible; } // if (UserHelper.concernList.FindIndex(o => o.ID == cid) != -1) // { // btn_addfav.Icon = new SymbolIcon(Symbol.UnFavorite); // btn_addfav.Label = "取消收藏"; // } if (SettingHelper.ContainsKey("_quality")) { (FindName("q" + SettingHelper.GetValue("_quality").ToString()) as RadioButton).IsChecked = true; quality = SettingHelper.GetValue("_quality").ToString(); } if (SettingHelper.ContainsKey("_videoformat")) { (FindName("f" + SettingHelper.GetValue("_videoformat").ToString()) as RadioButton).IsChecked = true; } } else { await popup.Show("视频不存在或已被删除"); } } catch { await popup.Show("加载失败啦~"); } }
private async void btn_ok_Click(object sender, RoutedEventArgs e) { int i = 0; foreach (Pages item in ReadyList.SelectedItems) { try { cid = item.Cid; VideoURL url = await ContentServ.GetVedioURL(cid, 2, VideoFormat.mp4); string name = StringDeal.RemoveSpecial(title.Text); string part = StringDeal.RemoveSpecial(item.Part); StorageFolder folder = await KnownFolders.VideosLibrary.CreateFolderAsync("哔哩哔哩", CreationCollisionOption.OpenIfExists); StorageFolder f1 = await folder.CreateFolderAsync(name, CreationCollisionOption.OpenIfExists); var download = await DownloadHelper.Download(url.Url, part + ".mp4", f1); if (SettingHelper.ContainsKey("_downdanmu")) { if ((bool)SettingHelper.GetValue("_downdanmu") == true) { string xml = await BaseService.SentGetAsync("http://comment.bilibili.com/" + cid + ".xml"); StorageFile file = await f1.CreateFileAsync(part + ".xml"); using (Stream file0 = await file.OpenStreamForWriteAsync()) { using (StreamWriter writer = new StreamWriter(file0)) { writer.Write(xml); } } } } else { string xml = await BaseService.SentGetAsync("http://comment.bilibili.com/" + cid + ".xml"); StorageFile file = await f1.CreateFileAsync(name + ".xml"); using (Stream file0 = await file.OpenStreamForWriteAsync()) { using (StreamWriter writer = new StreamWriter(file0)) { writer.Write(xml); } } } //如果await,那么执行完第一个StartAsync()后即退出循环.GetCurrentDownloadsAsync()方法同样会遇到此问题.(Download页) IAsyncOperationWithProgress <DownloadOperation, DownloadOperation> start = download.StartAsync(); i++; messagepop.Show(i.ToString() + "个视频已加入下载队列"); } catch (Exception err) { messagepop.Show(err.Message); } } }
/// <summary> /// 自动登录 /// </summary> async Task <bool> autologin() { try { 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, false); } } if (ApiHelper.IsLogin()) { ApiHelper.accesskey = SettingHelper.GetValue("_accesskey").ToString(); string url = "http://api.bilibili.com/myinfo?appkey=422fd9d7289a1dd9&access_key=" + SettingHelper.GetValue("_accesskey").ToString(); url += ApiHelper.GetSign(url); JsonObject json = await BaseService.GetJson(url); if (json.ContainsKey("mid")) { UserHelper.mid = json["mid"].ToString(); } if (json.ContainsKey("face")) { face.Fill = new ImageBrush { ImageSource = new BitmapImage(new Uri(StringDeal.delQuotationmarks((json["face"].ToString())))) } } ; if (json.ContainsKey("uname")) { uname.Text = StringDeal.delQuotationmarks(json["uname"].ToString()); } if (json.ContainsKey("level_info")) { JsonObject json2 = JsonObject.Parse(json["level_info"].ToString()); if (json2.ContainsKey("current_level")) { switch (json2["current_level"].ToString()) { case "0": rank.Text = "普通用户"; break; case "1": rank.Text = "注册会员"; break; case "2": rank.Text = "正式会员"; break; case "3": rank.Text = "字幕君"; break; case "4": rank.Text = "VIP用户"; break; case "5": rank.Text = "职人"; break; case "6": rank.Text = "站长大人"; break; } } } } return(true); } catch { return(false); } }
// void InitValue(string key, bool defaultvalue) // { // } void init() { var type = SettingHelper.DeviceType; if (type == DeviceType.PC) { m_top.Visibility = Visibility.Collapsed; } else if (type == DeviceType.Mobile) { pc_fullscreen.Visibility = Visibility.Collapsed; pc_cursor.Visibility = Visibility.Collapsed; } if (SettingHelper.ContainsKey("_nighttheme")) { night.IsOn = SettingHelper.GetValue("_nighttheme").ToString() == "light" ? false : true; } if (SettingHelper.ContainsKey("_downloadcost")) { downstyle.IsOn = SettingHelper.GetValue("_downloadcost").ToString() == "wifionly" ? false : true; } if (SettingHelper.ContainsKey("_downdanmu")) { danmaku.IsOn = Convert.ToBoolean(SettingHelper.GetValue("_downdanmu")); } if (SettingHelper.ContainsKey("_isdirect")) { direct.IsOn = Convert.ToBoolean(SettingHelper.GetValue("_isdirect")); } if (SettingHelper.ContainsKey("_quality")) { quality.SelectedIndex = Convert.ToInt32(SettingHelper.GetValue("_quality").ToString()) - 1; } else { quality.SelectedIndex = 1; } blur.IsOn = SettingHelper.ContainsKey("_blur") ? Convert.ToBoolean(SettingHelper.GetValue("_blur")) :true; background.IsOn = SettingHelper.ContainsKey("_pull") ? Convert.ToBoolean(SettingHelper.GetValue("_pull")) : true; toast.IsOn = SettingHelper.ContainsKey("_toast") ? Convert.ToBoolean(SettingHelper.GetValue("_toast")) : true; if (toast.IsOn) { if (SettingHelper.ContainsKey("_toast_m")) { t_message.IsOn = Convert.ToBoolean(SettingHelper.GetValue("_toast_m")); } else { t_message.IsOn = true; } if (SettingHelper.ContainsKey("_toast_b")) { t_bangumi.IsOn = Convert.ToBoolean(SettingHelper.GetValue("_toast_b")); } else { t_bangumi.IsOn = true; } } autokill.IsOn = SettingHelper.ContainsKey("_autokill") ? Convert.ToBoolean(SettingHelper.GetValue("_autokill")) : true; if (SettingHelper.ContainsKey("_isdanmaku")) { danmakuinit.IsOn = Convert.ToBoolean(SettingHelper.GetValue("_isdanmaku")); } if (SettingHelper.ContainsKey("_Theme")) { switch (SettingHelper.GetValue("_Theme").ToString()) { case "Pink": cb_Theme.SelectedIndex = 0; break; case "Red": cb_Theme.SelectedIndex = 1; break; case "Yellow": cb_Theme.SelectedIndex = 2; break; case "Green": cb_Theme.SelectedIndex = 3; break; case "Blue": cb_Theme.SelectedIndex = 4; break; case "Purple": cb_Theme.SelectedIndex = 5; break; case "Orange": cb_Theme.SelectedIndex = 6; break; default: break; } } else { cb_Theme.SelectedIndex = 0; } if (SettingHelper.ContainsKey("_words")) { string[] words = SettingHelper.GetValue("_words").ToString().Split(' '); foreach (string word in words) { if (word.Length > 0) { list_kill.Items.Add(word); } } } if (SettingHelper.ContainsKey("_path")) { if (!string.IsNullOrEmpty(SettingHelper.GetValue("_path").ToString())) { path.Toggled -= path_Toggled; path.IsOn = true; txt_path.Text = SettingHelper.GetValue("_path").ToString(); path.Toggled += path_Toggled; } else { path.IsOn = false; txt_path.Text = @"视频库\哔哩哔哩"; } } else { path.IsOn = false; txt_path.Text = @"视频库\哔哩哔哩"; } if (SettingHelper.ContainsKey("_space")) { sli_space.Value = int.Parse(SettingHelper.GetValue("_space").ToString()); } if (SettingHelper.ContainsKey("_speed")) { sli_speed.Value = int.Parse(SettingHelper.GetValue("_speed").ToString()); } else { sli_space.Value = 8; } if (SettingHelper.ContainsKey("_fontsize")) { sli_fontsize.Value = int.Parse(SettingHelper.GetValue("_fontsize").ToString()); } else { sli_fontsize.Value = 1; } cb_font.Items.Add("默认"); cb_font.Items.Add("宋体"); cb_font.Items.Add("等线"); cb_font.Items.Add("楷体"); if (type == DeviceType.PC) { cb_font.Items.Add("幼圆"); } if (SettingHelper.ContainsKey("_danmufont")) { cb_font.SelectedIndex = int.Parse(SettingHelper.GetValue("_danmufont").ToString()); } else { cb_font.SelectedIndex = 0; } if (SettingHelper.ContainsKey("_videoformat")) { cb_format.SelectedIndex = int.Parse(SettingHelper.GetValue("_videoformat").ToString()); } else { cb_format.SelectedIndex = 0; } if (SettingHelper.ContainsKey("_backtaskcost")) { backtaskcost.IsOn = Convert.ToBoolean(SettingHelper.GetValue("_backtaskcost")); } // 根据平台分化的设置项 if (type == DeviceType.PC) { if (SettingHelper.ContainsKey("_cursor")) { pc_cursor.IsOn = (bool)(SettingHelper.GetValue("_cursor")); } else { pc_cursor.IsOn = true; } if (SettingHelper.ContainsKey("_autofull")) { pc_fullscreen.IsOn = Convert.ToBoolean(SettingHelper.GetValue("_autofull")); } else { pc_fullscreen.IsOn = true; } if (SettingHelper.ContainsKey("_fvideo")) { f_v.IsOn = (bool)SettingHelper.GetValue("_fvideo"); } else { f_v.IsOn = true; } if (SettingHelper.ContainsKey("_faudio")) { f_a.IsOn = (bool)SettingHelper.GetValue("_faudio"); } else { f_a.IsOn = true; } } else if (type == DeviceType.Mobile) { if (SettingHelper.ContainsKey("_topbar")) { m_top.IsOn = Convert.ToBoolean(SettingHelper.GetValue("_topbar")); } else { m_top.IsOn = true; } if (SettingHelper.ContainsKey("_fvideo")) { f_v.IsOn = (bool)SettingHelper.GetValue("_fvideo"); } else { f_v.IsOn = false; } if (SettingHelper.ContainsKey("_faudio")) { f_a.IsOn = (bool)SettingHelper.GetValue("_faudio"); } else { f_a.IsOn = false; } } }