public WebViewPage() { InitializeComponent(); //Checks if the OS version is supporting CompactOverlay. if (ApplicationView.GetForCurrentView().IsViewModeSupported(ApplicationViewMode.CompactOverlay)) { MiniMode.Visibility = Visibility.Visible; } //replaces the Title Bar with a custom version. Taken from: //https://www.eternalcoding.com/?p=1952 CoreApplicationViewTitleBar coreTitleBar = CoreApplication.GetCurrentView().TitleBar; coreTitleBar.ExtendViewIntoTitleBar = true; TitleBar.Height = coreTitleBar.Height; Window.Current.SetTitleBar(MainTitleBar); Window.Current.Activated += Current_Activated; coreTitleBar.IsVisibleChanged += CoreTitleBar_IsVisibleChanged; coreTitleBar.LayoutMetricsChanged += CoreTitleBar_LayoutMetricsChanged; if (Website == null) { Website = WebsiteViewModel.FromWebsite(WebsiteDataSource.GetDefault()); } }
private void SymbolListView_SelectionChanged(object sender, SelectionChangedEventArgs e) { var icon = (sender as ListView).SelectedValue; SymbolSelect newSymbol = (icon as SymbolSelect); WebsiteDataSource.ChangeSymbol(Website.ID, newSymbol.Symbol); }
private void RightSlide_Click(object sender, EventArgs e) { long iD = Convert.ToInt64((sender as SlidableListItem).Tag.ToString()); WebsiteDataSource.Delete(iD); PopulateNavItems(); }
private void AddButton_Click(object sender, RoutedEventArgs e) { Website currentWebsite = WebsiteDataSource.GetTempSite(); Uri uri = currentWebsite.URL; string Name = currentWebsite.Name; WebsiteDataSource.AddNewAsync(Name, uri); PopulateNavItems(); }
/// <summary> /// Initializes the singleton application object. This is the first line of authored code /// executed, and as such is the logical equivalent of main() or WinMain(). /// </summary> public App() { InitializeComponent(); WebsiteDataSource.LoadAsync(); EnteredBackground += App_EnteredBackground; //Deferred execution until used. Check https://msdn.microsoft.com/library/dd642331(v=vs.110).aspx for further info on Lazy<T> class. _activationService = new Lazy <ActivationService>(CreateActivationService); }
private void OK_ButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args) { long iD = Website.ID; string name = Name_TextBox.Text.ToString(); if (name == "") { name = Website.Name; } WebsiteDataSource.Rename(iD, name); Result = RenameResult.RenameOK; }
//Checks for the Navigation Parameter and changes the ViewModel to the requested Website. private void ContentDialog_Opened(ContentDialog sender, ContentDialogOpenedEventArgs args) { Result = RenameResult.Nothing; long iD = Convert.ToInt64(sender.AccessKey); try { Website = WebsiteViewModel.FromWebsite(WebsiteDataSource.GetWebsite(iD)); } catch { Website = WebsiteViewModel.FromWebsite(WebsiteDataSource.GetDefault()); } }
private void PopulateNavItems() { List <Website> websites = WebsiteDataSource.GetList(); _primaryItems.Clear(); _secondaryItems.Clear(); foreach (Website site in websites) { _primaryItems.Add(ShellNavigationItem.FromType <WebViewPage>(site.Name, site.Symbol, site.ID)); } _secondaryItems.Add(ShellNavigationItem.FromType <SettingsPage>("Shell_Settings".GetLocalized(), Symbol.Setting)); }
//Checks for the Navigation Parameter and changes the WebView.Source to the requested Website. protected override void OnNavigatedTo(NavigationEventArgs e) { base.OnNavigatedTo(e); long iD; try { iD = Convert.ToInt64(e.Parameter); Website = WebsiteViewModel.FromWebsite(WebsiteDataSource.GetWebsite(iD)); } catch { Website = WebsiteViewModel.FromWebsite(WebsiteDataSource.GetDefault()); } }
private void Name_TextBox_KeyUp(object sender, Windows.UI.Xaml.Input.KeyRoutedEventArgs e) { if (e.Key == Windows.System.VirtualKey.Enter) { long iD = Website.ID; string name = Name_TextBox.Text.ToString(); if (name == "") { name = Website.Name; } WebsiteDataSource.Rename(iD, name); Result = RenameResult.RenameOK; } }
private async Task PinTileAsync(long iD) { string tileId = "website" + iD; string displayName = WebsiteDataSource.GetWebsite(iD).Name; string arguments = iD.ToString(); // Initialize the tile with required arguments SecondaryTile tile = new SecondaryTile( tileId, displayName, arguments, new Uri("ms-appx:///Assets/Square150x150Logo.png"), TileSize.Default); // Pin the tile bool isPinned = await tile.RequestCreateAsync(); // TODO: Update UI to reflect whether user can now either unpin or pin }
private void URL_TextBox_KeyUp(object sender, Windows.UI.Xaml.Input.KeyRoutedEventArgs e) { bool validURL = false; Uri newUri = Website.URL; try { newUri = new Uri(URL_TextBox.Text.ToString()); validURL = true; } catch { // Create the message dialog and set its content DisplayDialog("Error", "The URL entered was not a valid URL. A URL has to look like http://www.bing.com "); } if (validURL) { WebsiteDataSource.ChangeUrl(Website.ID, newUri); Result = RenameResult.RenameOK; } }
private async Task SourceUpdated() { bool validUri = true; string newUri = UrlTextBox.Text.ToString(); try { uri = new Uri(newUri); } catch { // Create the message dialog and set its content DisplayDialog("Error", "The URL entered was not a valid URL. A URL has to look like http://www.bing.com "); validUri = false; uri = webView.Source; } if (validUri) { webView.Source = uri; WebsiteDataSource.SetTempSite(uri.Host.ToString(), uri); } }
public async Task ActivateAsync(object activationArgs) { long iD = -1; if (IsInteractive(activationArgs)) { if (((IActivatedEventArgs)activationArgs).Kind == ActivationKind.Protocol) { var targetUrl = Uri.UnescapeDataString(((ProtocolActivatedEventArgs)activationArgs).Uri.Query.Substring(1)); Uri uri = new Uri(targetUrl); string Name = uri.Host; iD = await WebsiteDataSource.AddNewAsync(Name, uri); } // Initialize things like registering background task before the app is loaded await InitializeAsync(); // Do not repeat app initialization when the Window already has content, // just ensure that the window is active if (Window.Current.Content == null) { // Create a Frame to act as the navigation context and navigate to the first page Window.Current.Content = _shell; NavigationService.Frame.NavigationFailed += (sender, e) => { throw new Exception("Failed to load Page " + e.SourcePageType.FullName); }; NavigationService.Frame.Navigated += OnFrameNavigated; if (SystemNavigationManager.GetForCurrentView() != null) { SystemNavigationManager.GetForCurrentView().BackRequested += OnAppViewBackButtonRequested; } } } var activationHandler = GetActivationHandlers() .FirstOrDefault(h => h.CanHandle(activationArgs)); if (activationHandler != null) { await activationHandler.HandleAsync(activationArgs); } if (IsInteractive(activationArgs)) { var defaultHandler = new DefaultLaunchActivationHandler(_defaultNavItem); if (defaultHandler.CanHandle(activationArgs)) { await defaultHandler.HandleAsync(activationArgs); } else { var protocolHandler = new ProtocolActivationHandler(_defaultNavItem, iD); if (protocolHandler.CanHandle(activationArgs)) { await protocolHandler.HandleAsync(activationArgs); } } // Ensure the current window is active Window.Current.Activate(); // Tasks after activation await StartupAsync(); if (iD != -1) //If the app has been launched via protocol { await((Views.WebViewPage)NavigationService.Frame.Content).EnterMiniView(); } } }