protected override async void OnNavigatedTo(NavigationEventArgs e) { parameter = e.Parameter as WebViewParameter; if (parameter != null) { if (!string.IsNullOrEmpty(parameter.Title)) { titleTextBlock.Text = parameter.Title; } switch (parameter.DisplayType) { case "1": break; case "2": // pure html if (!string.IsNullOrEmpty(parameter.WebViewUri)) { webView.Navigate(new Uri(parameter.WebViewUri)); } break; case "3": if (!string.IsNullOrEmpty(parameter.WebViewUri)) { webView.Navigate(new Uri(parameter.WebViewUri)); } stackPanel.Visibility = Visibility.Collapsed; return; } string documentId = parameter.DocumentId; if (!string.IsNullOrEmpty(documentId)) { ViewModel.LoadDocument(documentId, parameter.DisplayType); documentExtra = await ApiService.Instance.GetDocumentExtraAsync(documentId); if (documentExtra != null && documentExtra.HackJs != null) { if (!string.IsNullOrEmpty(documentExtra.HackJs.DocumentLoaded)) { await InvokeScriptAsync("eval", new string[] { documentExtra.HackJs.DocumentLoaded }); } if (appTheme == ElementTheme.Dark) { Dark(); } else { Light(); } } } } }
private void faqBtn_Click(object sender, RoutedEventArgs e) { WebViewParameter paramter = new WebViewParameter() { Title = "如何复制", WebViewUri = "http://dailyapi.ibaozou.com/faq?category_id=1", DisplayType = "3" }; NavigationHelper.DetailFrameNavigate(typeof(WebViewPage), paramter); }
private void TaskInfo(object sender, TappedRoutedEventArgs e) { WebViewParameter paramter = new WebViewParameter() { Title = "任务介绍", WebViewUri = "http://dailyapi.ibaozou.com/task_info", DisplayType = "3" }; NavigationHelper.DetailFrameNavigate(typeof(WebViewPage), paramter); }
public void CoinRank() { string uri = string.Format(Http.ServiceUri.MyCoins, DataShareManager.Current.User.AccessToken); WebViewParameter paramter = new WebViewParameter() { Title = "我的金币", WebViewUri = uri, DisplayType = "3" }; NavigationHelper.DetailFrameNavigate(typeof(WebViewPage), paramter); }
private void contributeListView_ItemClick(object sender, ItemClickEventArgs e) { var contribute = e.ClickedItem as Contribute; if (contribute != null) { WebViewParameter parameter = new WebViewParameter() { Title = contribute.Title, DocumentId = contribute.DocumentId, DisplayType = contribute.DisplayType, WebViewUri = contribute.Url }; MasterDetailPage.Current.DetailFrame.Navigate(typeof(WebViewPage), parameter); } }
private void headerFlipView_SelectionChanged(object sender, SelectionChangedEventArgs e) { var story = headerFlipView.SelectedItem as Document; if (story != null) { WebViewParameter parameter = new WebViewParameter() { Title = "", WebViewUri = story.Url, DocumentId = story.DocumentId, DisplayType = story.DisplayType }; MasterDetailPage.Current.DetailFrame.Navigate(typeof(WebViewPage), parameter); } }
public void documentListView_ItemClick(object sender, ItemClickEventArgs e) { var story = e.ClickedItem as Document; if (story != null) { WebViewParameter parameter = new WebViewParameter() { Title = story.Title, WebViewUri = story.Url, DocumentId = story.DocumentId, DisplayType = story.DisplayType }; NavigationHelper.DetailFrameNavigate(typeof(WebViewPage), parameter); } }
public void ListView_ItemClick(object sender, ItemClickEventArgs e) { var story = e.ClickedItem as Document; if (story != null) { WebViewParameter parameter = new WebViewParameter() { Title = "", WebViewUri = story.Url, DocumentId = story.DocumentId, DisplayType = story.DisplayType }; MasterDetailPage.Current.DetailFrame.Navigate(typeof(WebViewPage), parameter); } }
private void Button_Click(object sender, RoutedEventArgs e) { Comment comment = ((Button)sender)?.DataContext as Comment; if (comment != null && comment.Article != null) { if (!comment.Article.DisplayType.Equals("3")) { WebViewParameter parameter = new WebViewParameter() { Title = "", DocumentId = comment.Article.DocumentId, DisplayType = "1" }; MasterDetailPage.Current.DetailFrame.Navigate(typeof(WebViewPage), parameter); } else { NavigationHelper.DetailFrameNavigate(typeof(VideoPage), comment.Article.DocumentId); } } }
public void documentListView_ItemClick(object sender, ItemClickEventArgs e) { var document = e.ClickedItem as Document; if (document != null) { if (!document.DisplayType.Equals("3")) { WebViewParameter parameter = new WebViewParameter() { Title = "", WebViewUri = document.Url, DocumentId = document.DocumentId, DisplayType = document.DisplayType }; MasterDetailPage.Current.DetailFrame.Navigate(typeof(WebViewPage), parameter); } else { NavigationHelper.DetailFrameNavigate(typeof(VideoPage), document.DocumentId); } } }
private void voteArticleBtn_Click(object sender, RoutedEventArgs e) { Message message = ((Button)sender)?.DataContext as Message; if (message != null && message.VotedComment != null) { var article = message.VotedComment.Article; if (article != null) { if (!article.DisplayType.Equals("3")) { WebViewParameter parameter = new WebViewParameter() { Title = article.Title, DocumentId = article.DocumentId, DisplayType = "1" }; MasterDetailPage.Current.DetailFrame.Navigate(typeof(WebViewPage), parameter); } else { NavigationHelper.DetailFrameNavigate(typeof(VideoPage), article.DocumentId); } } } }
/// <summary> /// 处理Toast通知 /// </summary> /// <param name="args"></param> private void HandleNotification(IActivatedEventArgs args) { // 通过Toast通知从后台打开 if (args is ToastNotificationActivatedEventArgs) { var toastActivationArgs = args as ToastNotificationActivatedEventArgs; string argument = (string)LocalSettings.Values["args"]; QueryString queryString; if (!string.IsNullOrEmpty(toastActivationArgs.Argument)) { queryString = QueryString.Parse(toastActivationArgs.Argument); } else { queryString = QueryString.Parse(argument); } string type = string.Empty; if (!queryString.TryGetValue("type", out type)) { return; } switch (type) { // 首页 case "mainpage": // 投稿 case "contribute": WebViewParameter parameter = new WebViewParameter() { Title = "", WebViewUri = queryString["uri"], DocumentId = queryString["documentId"], DisplayType = queryString["displayType"] }; try { if (MasterDetailPage.Current == null) { Frame rootFrame = Window.Current.Content as Frame; if (rootFrame.Content == null) { // When the navigation stack isn't restored navigate to the first page, // configuring the new page by passing required information as a navigation // parameter rootFrame.Navigate(typeof(MasterDetailPage), new SlideNavigationTransitionInfo()); } } NavigationHelper.DetailFrameNavigate(typeof(WebViewPage), parameter); } catch (Exception e) { LogHelper.WriteLine(e); } break; // 视频 case "video": try { if (MasterDetailPage.Current == null) { Frame rootFrame = Window.Current.Content as Frame; if (rootFrame.Content == null) { // When the navigation stack isn't restored navigate to the first page, // configuring the new page by passing required information as a navigation // parameter rootFrame.Navigate(typeof(MasterDetailPage), new SlideNavigationTransitionInfo()); } } NavigationHelper.DetailFrameNavigate(typeof(VideoPage), queryString["documentId"]); } catch (Exception e) { LogHelper.WriteLine(e); } break; } } }