public async void OnContentsBrowserWindowShowHide2(bool on) { if (on) { if (ViewTab.SelectedIndex == 0) { } else if (ViewTab.SelectedIndex == 1) { } else if (ViewTab.SelectedIndex == 2) { } } else { if ((ViewTab.SelectedIndex == 0) || (ViewTab.SelectedIndex == 1)) { if (GridInAppWebBrowser.Visibility == Visibility.Visible) { GridInAppWebBrowser.Visibility = Visibility.Collapsed; // Browser await InAppWebBrowser.EnsureCoreWebView2Async(_env); // "Close browser window." InAppWebBrowser.Source = new System.Uri("about:blank", System.UriKind.Absolute); } } else if (ViewTab.SelectedIndex == 2) { if (GridListViewContentPreviewWebBrowser.Visibility == Visibility.Visible) { SplitterListViewContentPreviewWebBrowser.Visibility = Visibility.Collapsed; GridListViewContentPreviewWebBrowser.Visibility = Visibility.Collapsed; // Sets Listview, splitter and browser heights. GridListView.RowDefinitions[1].Height = new GridLength(1, GridUnitType.Star); GridListView.RowDefinitions[2].Height = new GridLength(0); GridListView.RowDefinitions[3].Height = new GridLength(0); // Browser await ListViewContentPreviewWebBrowser.EnsureCoreWebView2Async(_env); // "Close browser window." ListViewContentPreviewWebBrowser.Source = new System.Uri("about:blank", System.UriKind.Absolute); } } } }
public async void OnOpenCurrentUrlInExternalBrowser(Uri arg) { //if (arg == null) // return; if ((ViewTab.SelectedIndex == 0) || (ViewTab.SelectedIndex == 1)) { if (GridInAppWebBrowser.Visibility != Visibility.Visible) { GridInAppWebBrowser.Visibility = Visibility.Visible; } await InAppWebBrowser.EnsureCoreWebView2Async(_env); string url = InAppWebBrowser.Source.AbsoluteUri; //System.Diagnostics.Process.Start(selectedEntry.AltHTMLUri.AbsoluteUri); ProcessStartInfo psi = new ProcessStartInfo(url); psi.UseShellExecute = true; Process.Start(psi); } else if (ViewTab.SelectedIndex == 2) { if (GridListViewContentPreviewWebBrowser.Visibility != Visibility.Visible) { // Re-set Listview, splitter and browser heights. GridListView.RowDefinitions[1].Height = new GridLength(3, GridUnitType.Star); GridListView.RowDefinitions[2].Height = new GridLength(8); GridListView.RowDefinitions[3].Height = new GridLength(5, GridUnitType.Star); SplitterListViewContentPreviewWebBrowser.Visibility = Visibility.Visible; GridListViewContentPreviewWebBrowser.Visibility = Visibility.Visible; } await ListViewContentPreviewWebBrowser.EnsureCoreWebView2Async(_env); string url = ListViewContentPreviewWebBrowser.Source.AbsoluteUri; //System.Diagnostics.Process.Start(selectedEntry.AltHTMLUri.AbsoluteUri); ProcessStartInfo psi = new ProcessStartInfo(url); psi.UseShellExecute = true; Process.Start(psi); } }
private async void InitializeWebView2Async() { // Gets or creates MyDoc\BlogWrite\ (same as database file) var myDocFolerPath = System.IO.Path.Combine(System.Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "BlogWrite"); System.IO.Directory.CreateDirectory(myDocFolerPath); // I really do hate smooth-scrolling. var op = new CoreWebView2EnvironmentOptions("--disable-smooth-scrolling"); _env = await CoreWebView2Environment.CreateAsync(userDataFolder : myDocFolerPath, options : op); //_env = await CoreWebView2Environment.CreateAsync(userDataFolder: System.IO.Path.Combine(System.IO.Path.GetTempPath(), "BlogWrite"), options: op); await ListViewContentPreviewWebBrowser.EnsureCoreWebView2Async(_env); ListViewContentPreviewWebBrowser.CoreWebView2InitializationCompleted += ListViewContentPreviewWebBrowser_InitializationCompleted; await InAppWebBrowser.EnsureCoreWebView2Async(_env); InAppWebBrowser.CoreWebView2InitializationCompleted += InAppWebBrowser_InitializationCompleted; }
public async void OnNavigateUrlToContentPreviewBrowser(Uri arg) { if (arg == null) { return; } if ((ViewTab.SelectedIndex == 0) || (ViewTab.SelectedIndex == 1)) { if (GridInAppWebBrowser.Visibility != Visibility.Visible) { GridInAppWebBrowser.Visibility = Visibility.Visible; } await InAppWebBrowser.EnsureCoreWebView2Async(_env); InAppWebBrowser.Source = arg; } else if (ViewTab.SelectedIndex == 2) { if (GridListViewContentPreviewWebBrowser.Visibility != Visibility.Visible) { // Re-set Listview, splitter and browser heights. GridListView.RowDefinitions[1].Height = new GridLength(3, GridUnitType.Star); GridListView.RowDefinitions[2].Height = new GridLength(8); GridListView.RowDefinitions[3].Height = new GridLength(5, GridUnitType.Star); SplitterListViewContentPreviewWebBrowser.Visibility = Visibility.Visible; GridListViewContentPreviewWebBrowser.Visibility = Visibility.Visible; } await ListViewContentPreviewWebBrowser.EnsureCoreWebView2Async(_env); ListViewContentPreviewWebBrowser.Source = arg; } }