private void Button_Click(object sender, RoutedEventArgs e) { string uid = ComboBoxUserId.Text; string server = ComboBoxServer.Text; PlayerQueryResult playerQueryResult = GenshinApi.GetPlayerData(uid, server); if (!playerQueryResult.Success) { if (playerQueryResult.Message.Length == 0) { MessageBox.Show("米游社用户信息可能不完整!\n请在米游社登录账号并完善个人信息\n完善后方可查询任意玩家信息", "查询失败", MessageBoxButton.OK, MessageBoxImage.Information); Process.Start("https://bbs.mihoyo.com/ys/"); } else { MessageBox.Show(playerQueryResult.Message, "查询失败", MessageBoxButton.OK, MessageBoxImage.Information); } return; } WebBrowserMain.NavigateToString(PageRender.RenderPlayerPage(playerQueryResult)); MessageBus.PlayerQueryResult = playerQueryResult; MessageBus.AddQueryHistory(uid); }
public async Task <IActionResult> Read(long pageId) { long tenantId = TenantId; PageView pageView = await _pageViewService.ReadPageViewAsync(tenantId, pageId); pageView.PageViewZones = await _pageViewService.SearchPageViewZonesAsync(tenantId, pageId); foreach (PageViewZone pageViewZone in pageView.PageViewZones) { pageViewZone.PageViewZoneElements = await _pageViewService.SearchPageViewZoneElementsAsync(tenantId, pageId, pageViewZone.MasterPageZoneId); } Dictionary <long, ElementRender> elements = new Dictionary <long, ElementRender>(); foreach (PageViewZone pageViewZone in pageView.PageViewZones) { foreach (PageViewZoneElement pageViewZoneElement in pageViewZone.PageViewZoneElements) { if (!elements.ContainsKey(pageViewZoneElement.ElementId)) { elements.Add(pageViewZoneElement.ElementId, await GetElementRender(tenantId, pageViewZoneElement.ElementTypeId, pageViewZoneElement.ElementId, pageId)); } } } PageRender pageRender = new PageRender { View = pageView, Elements = elements }; return(View("Read", pageRender)); }
private async void ChapterListBox_SelectionChanged(object sender, SelectionChangedEventArgs e) { var i = ChapterListBox.SelectedIndex; if (i < -1) { return; } var chapter = ViewModel.ChapterItems[i]; ViewModel.ChapterTitle = chapter.Title; ViewModel.Tokenizer.SetPage(chapter); await PageRender.SwapToAsync(ViewModel.Tokenizer.Page); }
private async void JumpBtn_Tapped(object sender, TappedRoutedEventArgs e) { if (ViewModel.Tokenizer.PageCount < 1) { return; } var dialog = new ProgressDialog(); dialog.Value = ViewModel.Tokenizer.Page * 100 / ViewModel.Tokenizer.PageCount; var res = await dialog.ShowAsync(); if (res != ContentDialogResult.Primary) { return; } ViewModel.Tokenizer.SetPageScale(dialog.Value, 100); await PageRender.SwapToAsync(ViewModel.Tokenizer.Page); }
/// <summary> /// Sets the report to view in the viewer control /// </summary> /// <param name="report"></param> public void SetReport(Rdl.Render.GenericRender report) { _report = report; _fonts = new Font[_report.StyleList.Count]; // Build a list of fonts corresponding to the styles in the report for (int i = 0; i < _report.StyleList.Count; i++) { if (_report.StyleList[i] is Rdl.Render.TextStyle) { TextStyle ts = _report.StyleList[i] as TextStyle; _fonts[i] = ts.GetWindowsFont(); } } // Render the report to a list of pages. _pageRender = new PageRender(); _pageRender.Render(report); StreamWriter sw; if (_pageRender.Pages.Count > 0) { sw = new StreamWriter(@"pages.txt", false); for (int i = 0; i < _pageRender.Pages.Count; i++) { sw.Write(_pageRender.Pages[i].ToString(0)); sw.WriteLine("\n"); } sw.Close(); } textPages.Text = _pageRender.Pages.Count.ToString(); _currentPageNum = 0; _currentPage = _pageRender.Pages[0]; BuildToggleList(_currentPage); // Set the scrollable position of the panel. panelReport.Invalidate(); }
private async Task OnResizeAsync() { var width = PageRender.ActualWidth; var height = PageRender.ActualHeight - 20; var tokenizer = ViewModel.Tokenizer; if (tokenizer.Width == width && tokenizer.Height == height) { return; } tokenizer.Width = width; tokenizer.Height = height; await tokenizer.Refresh(); ViewModel.Tokenizer.SetPage(ViewModel.Book.Position); PageRender.Flush(); await PageRender.SwapToAsync(tokenizer.Page); LoadingBtn.IsActive = false; }
private static HtmlString Json(this IHtmlHelper helper, string varOwnerName, string varName, object data, bool withTagScript = false) { HtmlString htmlStringResult; StringBuilder builder = new StringBuilder(); string comment = ""; string _varOwnerName; if (!string.IsNullOrEmpty(varOwnerName)) { _varOwnerName = $"\r\t${varOwnerName.Replace("$", "")}"; } else { _varOwnerName = "\r\t$page"; } // set first character of string lowercase //if (!string.IsNullOrEmpty(varName) && char.IsUpper(varName[0])) // varName = char.ToLower(varName[0]) + varName.Substring(1); try { PageRender eVarName = PageRender.None; string json; if (Enum.TryParse(varName, true, out eVarName)) { //varName = $"{_varOwnerName}"; //varName = $"{varName} = "; switch (eVarName) { case PageRender.Model: varName = $"\r\tvar {_varOwnerName} = "; comment = "// auto-generated from c# page model name"; json = data != null ? json = JsonConvert.SerializeObject(GetDictionary(data)) : "{}"; break; case PageRender.Resources: varName = $"{_varOwnerName}.{eVarName.GetDisplayName()} = "; comment = "// auto-generated from c# resource type " + CurrentLocalizer.ResourceType.Name; var dataList = new List <string>(data as string[]); json = JsonConvert.SerializeObject(helper.GetResources(dataList.Distinct().ToList())); break; case PageRender.None: case PageRender.Data: case PageRender.Config: if (eVarName != PageRender.None) { varName = $"{_varOwnerName}.{eVarName.GetDisplayName()} = "; comment = "// auto-generated from c# data"; } else { varName = ""; } json = JsonConvert.SerializeObject(GetDictionary(data)); if (data.GetType() == typeof(bool)) { json = json.ToLower(); } break; case PageRender.Properties: default: varName = $"{_varOwnerName}"; comment = "// auto-generated from c# page properties"; json = helper.AddProperties(varName, data); varName = ""; break; } } else { comment = $"// auto-generated from c# with custom name"; json = helper.AddProperties($"{varName}", data); varName = $"{varName.Replace("\r\t", "")} = {{}};"; } json = $"{(!string.IsNullOrEmpty(comment) ? "\r\t" + comment : "")}" + $"{(!string.IsNullOrEmpty(varName) ? "\r\t" + varName : "")}" + $"{json}"; if (withTagScript) { builder.AppendFormat("<script type='text/javascript'>\t\t{0}\r\t</script>", json); } else { builder.Append($"{json}"); } htmlStringResult = new HtmlString(builder.ToString()); } catch (Exception ex) { Log.Logger.ErrorCall(ex); var value = !data.GetType().IsValueType ? "{}" : "''"; htmlStringResult = new HtmlString($"{varName} = {value}"); } return(htmlStringResult); }
/// <summary> Create javascript value as varName into named pageModel with tagScript</summary> /// <param name="data">value that will pass to javascript</param> /// <returns>javascript string</returns> public static HtmlString Json(this IHtmlHelper helper, PageRender varName, object data, bool withTagScript = false) { var ownerName = varName == PageRender.Model ? data.ToString() : "page"; return(helper.Json(ownerName, varName.ToString(), data, withTagScript)); }
/// <summary> Create javascript value as varName into named pageModel</summary> /// <param name="data">value that will pass to javascript</param> /// <returns>javascript string</returns> public static HtmlString Json(this IHtmlHelper helper, PageRender varName, string pageModelName, object data) { var htmlStringResult = helper.Json(pageModelName, varName.ToString(), data, false); return(htmlStringResult); }