-
-
Notifications
You must be signed in to change notification settings - Fork 7
feat(PdfReader): add ResetToolbarView function #749
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
a903b0b
85c4fa5
8259622
c534598
92f05e8
6864e63
0a0e565
3adb3d9
f90ef5f
a048ef4
8f3ebee
9f070e8
a8f60aa
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
This file was deleted.
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -4,7 +4,6 @@ | |||||
|
|
||||||
| using Microsoft.AspNetCore.Components; | ||||||
| using Microsoft.Extensions.Localization; | ||||||
| using System.Globalization; | ||||||
|
|
||||||
| namespace BootstrapBlazor.Components; | ||||||
|
|
||||||
|
|
@@ -135,57 +134,13 @@ public partial class PdfReader | |||||
| .AddClassFromAttributes(AdditionalAttributes) | ||||||
| .Build(); | ||||||
|
|
||||||
| private string? ViewBodyString => CssBuilder.Default("bb-view-group bb-view-toolbar-main") | ||||||
| .AddClass("fit-width", FitMode == PdfReaderFitMode.PageHeight) | ||||||
| .Build(); | ||||||
|
|
||||||
| private string? _docTitle; | ||||||
| private PdfReaderFitMode _fitMode; | ||||||
| private uint _currentPage; | ||||||
| private string? _url; | ||||||
| private string? _currentScale; | ||||||
| private string? _dropdownItemCheckIcon; | ||||||
| private string? _dropdownItemDefaultIcon; | ||||||
| private bool _enableThumbnails = true; | ||||||
|
|
||||||
| private string CurrentPageString | ||||||
| { | ||||||
| get => CurrentPage.ToString(CultureInfo.InvariantCulture); | ||||||
| set => SetCurrentPage(value); | ||||||
| } | ||||||
|
|
||||||
| private void SetCurrentPage(string value) | ||||||
| { | ||||||
| if (uint.TryParse(value, NumberStyles.Integer, CultureInfo.InvariantCulture, out var num)) | ||||||
| { | ||||||
| CurrentPage = num; | ||||||
| } | ||||||
| } | ||||||
|
|
||||||
| private string CurrentScaleString | ||||||
| { | ||||||
| get => $"{CurrentScale ?? "100"}%"; | ||||||
| set => SetCurrentScale(value); | ||||||
| } | ||||||
|
|
||||||
| private void SetCurrentScale(string value) | ||||||
| { | ||||||
| if (string.IsNullOrEmpty(value)) | ||||||
| { | ||||||
| CurrentScale = "100"; | ||||||
| } | ||||||
| else if (float.TryParse(value.TrimEnd("%"), out var v)) | ||||||
| { | ||||||
| v = v switch | ||||||
| { | ||||||
| > 500 => 500, | ||||||
| < 25 => 25, | ||||||
| _ => v | ||||||
| }; | ||||||
|
|
||||||
| CurrentScale = v.ToString(CultureInfo.InvariantCulture); | ||||||
| } | ||||||
| } | ||||||
| private bool _showToolbar = true; | ||||||
|
|
||||||
| /// <summary> | ||||||
| /// <inheritdoc/> | ||||||
|
|
@@ -216,33 +171,29 @@ protected override async Task OnAfterRenderAsync(bool firstRender) | |||||
|
|
||||||
| if (firstRender) | ||||||
| { | ||||||
| _fitMode = FitMode; | ||||||
| _currentPage = CurrentPage; | ||||||
| _url = Url; | ||||||
| _currentScale = CurrentScale; | ||||||
| _currentPage = CurrentPage; | ||||||
| _enableThumbnails = EnableThumbnails; | ||||||
| _showToolbar = ShowToolbar; | ||||||
| } | ||||||
|
|
||||||
| if (_url != Url) | ||||||
| { | ||||||
| _url = Url; | ||||||
| await InvokeInitAsync(); | ||||||
| } | ||||||
|
|
||||||
| if (_fitMode != FitMode) | ||||||
| { | ||||||
| _fitMode = FitMode; | ||||||
| await InvokeVoidAsync("setScaleValue", Id, _fitMode.ToDescriptionString()); | ||||||
| } | ||||||
| if (_currentPage != CurrentPage) | ||||||
| { | ||||||
| _currentPage = CurrentPage; | ||||||
| await NavigateToPageAsync(_currentPage); | ||||||
| } | ||||||
| if (_currentScale != CurrentScale) | ||||||
| if (_showToolbar != ShowToolbar) | ||||||
| { | ||||||
| _currentScale = CurrentScale; | ||||||
| await InvokeVoidAsync("scale", Id, _currentScale); | ||||||
| _showToolbar = ShowToolbar; | ||||||
| if (_showToolbar) | ||||||
| { | ||||||
| await InvokeVoidAsync("resetToolbar", Id); | ||||||
| } | ||||||
| } | ||||||
| if (_enableThumbnails != EnableThumbnails) | ||||||
| { | ||||||
|
|
@@ -263,6 +214,7 @@ protected override async Task OnAfterRenderAsync(bool firstRender) | |||||
| Url, | ||||||
| FitMode, | ||||||
| EnableThumbnails, | ||||||
| CurrentPage, | ||||||
| TriggerPagesInit = OnPagesInitAsync != null, | ||||||
| TriggerPagesLoaded = OnPagesLoadedAsync != null, | ||||||
| TriggerPageChanged = OnPageChangedAsync != null, | ||||||
|
|
@@ -277,27 +229,21 @@ protected override async Task OnAfterRenderAsync(bool firstRender) | |||||
| public Task NavigateToPageAsync(uint pageNumber) => InvokeVoidAsync("navigateToPage", Id, pageNumber); | ||||||
|
|
||||||
| /// <summary> | ||||||
| /// 适应页面宽度 | ||||||
| /// 设置页面适配模式方法 | ||||||
| /// </summary> | ||||||
| public void SetFitMode(PdfReaderFitMode mode) => FitMode = mode; | ||||||
| public Task SetFitMode(PdfReaderFitMode mode) => InvokeVoidAsync("setScaleValue", Id, mode.ToDescriptionString()); | ||||||
|
||||||
| public Task SetFitMode(PdfReaderFitMode mode) => InvokeVoidAsync("setScaleValue", Id, mode.ToDescriptionString()); | |
| public Task SetFitModeAsync(PdfReaderFitMode mode) => InvokeVoidAsync("setScaleValue", Id, mode.ToDescriptionString()); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -79,11 +79,11 @@ | |
| width: 1%; | ||
| } | ||
|
|
||
| .bb-view-toolbar-main.fit-width .bb-view-fit-height { | ||
| .bb-view-toolbar-main .fit-height .bb-view-fit-height { | ||
| display: none; | ||
| } | ||
|
|
||
| .bb-view-toolbar-main.fit-width .bb-view-fit-width { | ||
| .bb-view-toolbar-main .fit-height .bb-view-fit-width { | ||
| display: block; | ||
| } | ||
|
Comment on lines
+82
to
88
|
||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing parameter documentation: The
modeparameter is not documented. Add a<param name="mode">tag to describe the fit mode parameter.