public static async void OpenEpub(Frame frame, Windows.Storage.IStorageFile file, FrameworkElement sender) { if (file is null) { return; } if (sender is null) { return; } SetTitleByResource(sender, "Epub"); var tabPage = GetCurrentTabPage(sender); var epubType = SettingStorage.GetValue("EpubViewerType") as SettingStorage.SettingEnums.EpubViewerType?; EpubResolverBase resolver = epubType switch { //SettingStorage.SettingEnums.EpubViewerType.Bibi => EpubResolverFile.GetResolverBibi(file), SettingStorage.SettingEnums.EpubViewerType.Bibi => await EpubResolverBase.GetResolverBibiZip(file), SettingStorage.SettingEnums.EpubViewerType.EpubJsReader => EpubResolverBase.GetResolverBasicFile(file), _ => await EpubResolverBase.GetResolverBibiZip(file), }; frame.Navigate(typeof(kurema.BrowserControl.Views.BrowserControl), null); if (frame.Content is kurema.BrowserControl.Views.BrowserControl content) { OpenBrowser_BookmarkSetViewModel(content?.DataContext as kurema.BrowserControl.ViewModels.BrowserControlViewModel); Uri uri = content.Control.BuildLocalStreamUri("epub", resolver.PathHome); content.Control.NavigateToLocalStreamUri(uri, resolver); if (tabPage is not null) { content.Control.NewWindowRequested += async(s, e) => { await tabPage.OpenTabWebPreferedBrowser(e.Uri.ToString()); e.Handled = true; }; } if (content.DataContext is kurema.BrowserControl.ViewModels.BrowserControlViewModel vm) { vm.ControllerCollapsed = true; } { { //普通ブラウザでもダークモード対応するのも選択肢。でもbackgroundとか修正しないといけないし、とりあえずなし。 var defaultDark = (bool)SettingStorage.GetValue("EpubViewerDarkMode") && Application.Current.RequestedTheme == ApplicationTheme.Dark; var checkbox = new CheckBox() { Content = ResourceManager.Loader.GetString("Browser/Addon/DarkMode"), IsChecked = defaultDark, HorizontalAlignment = HorizontalAlignment.Stretch }; async Task applyDarkMode() { if (checkbox.IsChecked ?? false) { //if (epubType == SettingStorage.SettingEnums.EpubViewerType.Bibi) await content.Control.InvokeScriptAsync("eval", new[] { @"if(document.body.style.background===""""){document.body.style.background='white';}" }); await content.Control.InvokeScriptAsync("eval", new[] { @"document.body.style.filter='invert(100%) hue-rotate(180deg)';" }); } else { //if (epubType == SettingStorage.SettingEnums.EpubViewerType.Bibi) await content.Control.InvokeScriptAsync("eval", new[] { @"if(document.body.style.background===""white""){document.body.style.background='';}" }); await content.Control.InvokeScriptAsync("eval", new[] { @"document.body.style.filter='none';" }); } } checkbox.Checked += async(s, e) => { await applyDarkMode(); }; checkbox.Unchecked += async(s, e) => { await applyDarkMode(); }; content.Control.NavigationCompleted += async(s, e) => { await applyDarkMode(); }; content.AddOnSpace.Add(checkbox); } { var checkbox = new CheckBox() { Content = ResourceManager.Loader.GetString("Setting_EpubViewerDarkMode/Title"), IsChecked = (bool)SettingStorage.GetValue("EpubViewerDarkMode"), HorizontalAlignment = HorizontalAlignment.Stretch, }; ToolTipService.SetToolTip(checkbox, ResourceManager.Loader.GetString("Setting_EpubViewerDarkMode/Description")); checkbox.Checked += (s, e) => SettingStorage.SetValue("EpubViewerDarkMode", true); checkbox.Unchecked += (s, e) => SettingStorage.SetValue("EpubViewerDarkMode", false); content.AddOnSpace.Add(checkbox); } } //content.Control.ScriptNotify += (s, e) => //{ // //window.external.notify(document.body.style.background); // var v = e.Value; //}; } HistoryManager.AddEntry(file); //await HistoryStorage.AddHistory(file, null); }