-
Notifications
You must be signed in to change notification settings - Fork 309
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ImageCropper): add ImageCropper component (#2511)
* ImageCropper 图像裁剪组件 * doc: 更新示例 --------- Co-authored-by: Argo-AscioTech <argo@live.ca>
- Loading branch information
1 parent
17cfe48
commit 5f56486
Showing
10 changed files
with
159 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
src/BootstrapBlazor.Server/Components/Samples/ImageCroppers.razor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
@page "/image-cropper" | ||
@inject IStringLocalizer<ImageCroppers> Localizer | ||
|
||
<h3>@Localizer["Title"]</h3> | ||
|
||
<PackageTips Name="BootstrapBlazor.ImageCropper" /> | ||
|
||
<DemoBlock Title="@Localizer["ImageCropperNormalText"]" Introduction="@Localizer["ImageCropperNormalIntro"]" Name="Normal"> | ||
<ImageCropper @ref="Cropper" Url="@images[0]" DefaultButton="false" /> | ||
<section ignore> | ||
<BootstrapInputGroup class="mb-3"> | ||
<Button Text="OK" OnClick="(async () => Base64 = await Cropper.Crop())" /> | ||
<Button Text="@Localizer["ImageCropperResetText"]" OnClick="Cropper.Reset" /> | ||
<Button Text="@Localizer["ImageCropperReplaceText"]" OnClick="OnClickReplace" /> | ||
</BootstrapInputGroup> | ||
<Textarea Value="@Base64" rows="3" /> | ||
</section> | ||
</DemoBlock> | ||
|
||
<AttributeTable Items="@GetAttributes()" /> |
93 changes: 93 additions & 0 deletions
93
src/BootstrapBlazor.Server/Components/Samples/ImageCroppers.razor.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
// Copyright (c) Argo Zhang (argo@163.com). All rights reserved. | ||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||
// Website: https://www.blazor.zone or https://argozhang.github.io/ | ||
|
||
using System.ComponentModel; | ||
|
||
namespace BootstrapBlazor.Server.Components.Samples; | ||
|
||
/// <summary> | ||
/// ImageCroppers | ||
/// </summary> | ||
public partial class ImageCroppers | ||
{ | ||
|
||
[NotNull] | ||
ImageCropper? Cropper { get; set; } | ||
|
||
private string[] images = ["./images/picture.jpg", "./images/ImageList2.jpeg"]; | ||
|
||
private int index = 0; | ||
|
||
private string? Base64 { get; set; } | ||
|
||
private async Task OnClickReplace() | ||
{ | ||
index = index == 0 ? 1 : 0; | ||
await Cropper.Replace(images[index]); | ||
} | ||
|
||
/// <summary> | ||
/// GetAttributes | ||
/// </summary> | ||
/// <returns></returns> | ||
protected IEnumerable<AttributeItem> GetAttributes() => new AttributeItem[] | ||
{ | ||
new() | ||
{ | ||
Name = "Url", | ||
Description = Localizer["AttributesImageCropperUrl"], | ||
Type = "string?", | ||
ValueList = "-", | ||
DefaultValue = "-" | ||
}, | ||
new() | ||
{ | ||
Name = "DefaultButton", | ||
Description = Localizer["AttributesImageCropperDefaultButton"], | ||
Type = "bool", | ||
ValueList = "-", | ||
DefaultValue = "true" | ||
}, | ||
new() | ||
{ | ||
Name = "Preview", | ||
Description = Localizer["AttributesImageCropperPreview"], | ||
Type = "bool", | ||
ValueList = "-", | ||
DefaultValue = "true" | ||
}, | ||
new() | ||
{ | ||
Name = "OnResult()", | ||
Description = Localizer["AttributesImageCropperOnResult"], | ||
Type = "Func", | ||
ValueList = "-", | ||
DefaultValue = "-" | ||
}, | ||
new() | ||
{ | ||
Name = "OnBase64Result()", | ||
Description = Localizer["AttributesImageCropperOnBase64Result"], | ||
Type = "Func", | ||
ValueList = "-", | ||
DefaultValue = "-" | ||
}, | ||
new() | ||
{ | ||
Name = "Crop()", | ||
Description = Localizer["AttributesImageCropperCrop"], | ||
Type = "Task", | ||
ValueList = "-", | ||
DefaultValue = "-" | ||
}, | ||
new() | ||
{ | ||
Name = "CropToStream()", | ||
Description = Localizer["AttributesImageCropperCropToStream"], | ||
Type = "Task", | ||
ValueList = "-", | ||
DefaultValue = "-" | ||
}, | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.