-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature/fix triggers on load event when replace image (#317)
## Target <!-- Why are you making this change? --> Fix triggers on load event when replace image #### Open Questions <!-- OPTIONAL - [ ] Use the GitHub checklists to spark discussion on issues that may arise from your approach. Please tick the box and explain your answer. --> ## Checklist <!-- It serves as a gentle reminder for common tasks. Confirm it's done and check everything that applies. --> - [x] Documentation updated - [x] Tests cover new or modified code - [x] I have performed a self-review of my own code - [x] I have commented my code, particularly in hard-to-understand areas - [x] I have made corresponding changes to the documentation - [x] My changes generate no new warnings - [x] New dependencies added - [ ] Includes breaking changes - [ ] Version bumped ## Visuals <!-- OPTIONAL Show results both before and after this change. When the output changes, it can be a screenshot of a trace, metric, or log illustrating the change. --> --------- Co-authored-by: ColdForeign <[email protected]>
- Loading branch information
1 parent
b3bf289
commit faea1ec
Showing
34 changed files
with
639 additions
and
74 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,5 +21,4 @@ public App() | |
|
||
protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp(); | ||
} | ||
|
||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<Application x:Class="Cropper.Blazor.WPF.Net6.App" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:local="clr-namespace:Cropper.Blazor.WPF.Net6" | ||
StartupUri="MainWindow.xaml"> | ||
<Application.Resources> | ||
|
||
</Application.Resources> | ||
</Application> |
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,12 @@ | ||
using System.Windows; | ||
|
||
namespace Cropper.Blazor.WPF.Net6 | ||
{ | ||
/// <summary> | ||
/// Interaction logic for App.xaml | ||
/// </summary> | ||
public partial class App : Application | ||
{ | ||
} | ||
|
||
} |
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,10 @@ | ||
using System.Windows; | ||
|
||
[assembly: ThemeInfo( | ||
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located | ||
//(used if a resource is not found in the page, | ||
// or application resource dictionaries) | ||
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located | ||
//(used if a resource is not found in the page, | ||
// app, or any theme specific resource dictionaries) | ||
)] |
20 changes: 20 additions & 0 deletions
20
examples/Cropper.Blazor.WPF.Net6/Cropper.Blazor.WPF.Net6.csproj
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 @@ | ||
<Project Sdk="Microsoft.NET.Sdk.Razor"> | ||
|
||
<PropertyGroup> | ||
<OutputType>WinExe</OutputType> | ||
<TargetFramework>net6.0-windows</TargetFramework> | ||
<Nullable>enable</Nullable> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<UseWPF>true</UseWPF> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.AspNetCore.Components.WebView.Wpf" Version="6.0.553" /> | ||
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\Cropper.Blazor.WebView.Net6\Cropper.Blazor.WebView.Net6.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
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 @@ | ||
<Window x:Class="Cropper.Blazor.WPF.Net6.MainWindow" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
xmlns:local="clr-namespace:Cropper.Blazor.WPF.Net6" | ||
xmlns:imgrazor="clr-namespace:Cropper.Blazor.WebView.Net6;assembly=Cropper.Blazor.WebView.Net6" | ||
xmlns:blazor="http://schemas.microsoft.com/winfx/2006/xaml/presentation/blazor" | ||
mc:Ignorable="d" | ||
Title="MainWindow" Height="450" Width="800"> | ||
<Grid> | ||
<blazor:BlazorWebView HostPage="wwwroot\index.html" Services="{DynamicResource services}"> | ||
<blazor:BlazorWebView.RootComponents> | ||
<blazor:RootComponent | ||
Selector="#app" | ||
ComponentType="{x:Type imgrazor:Component}" /> | ||
</blazor:BlazorWebView.RootComponents> | ||
</blazor:BlazorWebView> | ||
</Grid> | ||
</Window> |
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,29 @@ | ||
using System.Windows; | ||
using Cropper.Blazor.Extensions; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using MudBlazor.Services; | ||
|
||
namespace Cropper.Blazor.WPF.Net6 | ||
{ | ||
/// <summary> | ||
/// Interaction logic for MainWindow.xaml | ||
/// </summary> | ||
public partial class MainWindow : Window | ||
{ | ||
// https://www.infoq.com/news/2021/04/dotnet-6-webview-winforms-wpf/ | ||
public MainWindow() | ||
{ | ||
InitializeComponent(); | ||
|
||
var serviceCollection = new ServiceCollection(); | ||
serviceCollection.AddWpfBlazorWebView(); | ||
serviceCollection.AddCropper(); | ||
serviceCollection.AddMudServices(); | ||
|
||
#if DEBUG | ||
serviceCollection.AddBlazorWebViewDeveloperTools(); | ||
#endif | ||
Resources.Add("services", serviceCollection.BuildServiceProvider()); | ||
} | ||
} | ||
} |
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,56 @@ | ||
@using Cropper.Blazor.Components | ||
@using Cropper.Blazor.Models | ||
@using Microsoft.AspNetCore.Components.Forms | ||
@using MudBlazor | ||
|
||
<MudThemeProvider /> | ||
<MudDialogProvider /> | ||
<MudSnackbarProvider /> | ||
|
||
<PageTitle>Cropper Blazor Server Demo</PageTitle> | ||
|
||
<MudButtonGroup Color="Color.Primary" Variant="Variant.Filled"> | ||
<MudTooltip Text="Import image with Blob URLs"> | ||
<InputFile id="imageInput" OnChange="InputFileChange" accept="image/*" hidden multiple /> | ||
<MudIconButton HtmlTag="label" Icon="@Icons.Filled.PhotoCamera" for="imageInput" Title="Upload image file" /> | ||
</MudTooltip> | ||
<MudTooltip Text="cropper.getCroppedCanvas({ maxWidth: 4096, maxHeight: 4096 })"> | ||
<MudButton Color="Color.Secondary" Variant="Variant.Filled" | ||
OnClick="@(()=>GetCroppedCanvasDataURL(new GetCroppedCanvasOptions(){ MaxHeight = 4096, MaxWidth = 4096}))"> | ||
Get Cropped Canvas | ||
</MudButton> | ||
</MudTooltip> | ||
</MudButtonGroup> | ||
|
||
<div class="img-container"> | ||
<CropperComponent Class="cropper-container big-img" | ||
ErrorLoadImageClass="cropper-error-load" | ||
@ref="cropperComponent" | ||
OnCropStartEvent="OnCropStartEvent" | ||
OnCropEndEvent="OnCropEndEvent" | ||
OnCropEvent="OnCropEvent" | ||
OnZoomEvent="OnZoomEvent" | ||
OnCropMoveEvent="OnCropMoveEvent" | ||
OnReadyEvent="OnCropReadyEvent" | ||
OnLoadImageEvent="OnLoadImageEvent" | ||
Src="@Src" | ||
InputAttributes="@InputAttributes" | ||
ErrorLoadImageSrc="@_errorLoadImageSrc" | ||
IsErrorLoadImage="@IsErrorLoadImage" | ||
OnErrorLoadImageEvent="OnErrorLoadImageEvent" | ||
Options="options" /> | ||
</div> | ||
|
||
<style> | ||
.big-img { | ||
max-height: 400px; | ||
/* This rule is very important, please don't ignore this */ | ||
max-width: 100%; | ||
} | ||
.img-container { | ||
max-height: 400px; | ||
width: 100%; | ||
} | ||
</style> |
Oops, something went wrong.