Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit c070b8b

Browse files
Merge pull request #1 from SyncfusionExamples/834346-SaveImageUsingFileSaver
834346- Save Image using FileSaver in the .NET MAUI ImageEditor
2 parents afb198f + 0e67f8c commit c070b8b

37 files changed

+1122
-2
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.0.31611.283
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FileSaver_CommunityToolkit", "FileSaver_CommunityToolkit\FileSaver_CommunityToolkit.csproj", "{FE679C1C-EA73-4BA3-85B5-60E03D0EEB56}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{FE679C1C-EA73-4BA3-85B5-60E03D0EEB56}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{FE679C1C-EA73-4BA3-85B5-60E03D0EEB56}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{FE679C1C-EA73-4BA3-85B5-60E03D0EEB56}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
17+
{FE679C1C-EA73-4BA3-85B5-60E03D0EEB56}.Release|Any CPU.ActiveCfg = Release|Any CPU
18+
{FE679C1C-EA73-4BA3-85B5-60E03D0EEB56}.Release|Any CPU.Build.0 = Release|Any CPU
19+
{FE679C1C-EA73-4BA3-85B5-60E03D0EEB56}.Release|Any CPU.Deploy.0 = Release|Any CPU
20+
EndGlobalSection
21+
GlobalSection(SolutionProperties) = preSolution
22+
HideSolutionNode = FALSE
23+
EndGlobalSection
24+
GlobalSection(ExtensibilityGlobals) = postSolution
25+
SolutionGuid = {61F7FB11-1E47-470C-91E2-47F8143E1572}
26+
EndGlobalSection
27+
EndGlobal
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version = "1.0" encoding = "UTF-8" ?>
2+
<Application xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
4+
xmlns:local="clr-namespace:FileSaver_CommunityToolkit"
5+
x:Class="FileSaver_CommunityToolkit.App">
6+
<Application.Resources>
7+
<ResourceDictionary>
8+
<ResourceDictionary.MergedDictionaries>
9+
<ResourceDictionary Source="Resources/Styles/Colors.xaml" />
10+
<ResourceDictionary Source="Resources/Styles/Styles.xaml" />
11+
</ResourceDictionary.MergedDictionaries>
12+
</ResourceDictionary>
13+
</Application.Resources>
14+
</Application>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
namespace FileSaver_CommunityToolkit;
2+
3+
public partial class App : Application
4+
{
5+
public App()
6+
{
7+
InitializeComponent();
8+
9+
MainPage = new AppShell();
10+
}
11+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<Shell
3+
x:Class="FileSaver_CommunityToolkit.AppShell"
4+
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
5+
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
6+
xmlns:local="clr-namespace:FileSaver_CommunityToolkit"
7+
Shell.FlyoutBehavior="Disabled">
8+
9+
<ShellContent
10+
Title="Home"
11+
ContentTemplate="{DataTemplate local:MainPage}"
12+
Route="MainPage" />
13+
14+
</Shell>
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
namespace FileSaver_CommunityToolkit;
2+
3+
public partial class AppShell : Shell
4+
{
5+
public AppShell()
6+
{
7+
InitializeComponent();
8+
}
9+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
using CommunityToolkit.Maui.Alerts;
2+
using CommunityToolkit.Maui.Storage;
3+
using Syncfusion.Maui.ImageEditor;
4+
5+
namespace FileSaver_CommunityToolkit
6+
{
7+
public class FileSaverBehavior : Behavior<ContentPage>
8+
{
9+
private SfImageEditor imageEditor;
10+
protected override void OnAttachedTo(ContentPage bindable)
11+
{
12+
base.OnAttachedTo(bindable);
13+
imageEditor = bindable.FindByName<SfImageEditor>("imageEditor");
14+
imageEditor.ImageSaving += OnImageSaving;
15+
16+
}
17+
private void OnImageSaving(object sender, ImageSavingEventArgs e)
18+
{
19+
SaveFile(CancellationToken.None, e.ImageStream);
20+
}
21+
async Task SaveFile(CancellationToken cancellationToken, Stream stream)
22+
{
23+
FileSaverResult fileSaverResult = await FileSaver.Default.SaveAsync("image.png", stream, cancellationToken);
24+
fileSaverResult.EnsureSuccess();
25+
await Toast.Make($"File is saved: {fileSaverResult.FilePath}").Show(cancellationToken);
26+
}
27+
protected override void OnDetachingFrom(ContentPage bindable)
28+
{
29+
base.OnDetachingFrom(bindable);
30+
imageEditor.ImageSaving -= OnImageSaving;
31+
}
32+
}
33+
}
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFrameworks>net7.0-android;net7.0-ios;net7.0-maccatalyst</TargetFrameworks>
5+
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net7.0-windows10.0.19041.0</TargetFrameworks>
6+
<!-- Uncomment to also build the tizen app. You will need to install tizen by following this: https://github.com/Samsung/Tizen.NET -->
7+
<!-- <TargetFrameworks>$(TargetFrameworks);net7.0-tizen</TargetFrameworks> -->
8+
<OutputType>Exe</OutputType>
9+
<RootNamespace>FileSaver_CommunityToolkit</RootNamespace>
10+
<UseMaui>true</UseMaui>
11+
<SingleProject>true</SingleProject>
12+
<ImplicitUsings>enable</ImplicitUsings>
13+
14+
<!-- Display name -->
15+
<ApplicationTitle>FileSaver_CommunityToolkit</ApplicationTitle>
16+
17+
<!-- App Identifier -->
18+
<ApplicationId>com.companyname.filesaver_communitytoolkit</ApplicationId>
19+
<ApplicationIdGuid>07ec1c1b-bafd-424c-98eb-0530f386c098</ApplicationIdGuid>
20+
21+
<!-- Versions -->
22+
<ApplicationDisplayVersion>1.0</ApplicationDisplayVersion>
23+
<ApplicationVersion>1</ApplicationVersion>
24+
25+
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">11.0</SupportedOSPlatformVersion>
26+
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'maccatalyst'">13.1</SupportedOSPlatformVersion>
27+
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">21.0</SupportedOSPlatformVersion>
28+
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</SupportedOSPlatformVersion>
29+
<TargetPlatformMinVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</TargetPlatformMinVersion>
30+
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'tizen'">6.5</SupportedOSPlatformVersion>
31+
</PropertyGroup>
32+
33+
<ItemGroup>
34+
<!-- App Icon -->
35+
<MauiIcon Include="Resources\AppIcon\appicon.svg" ForegroundFile="Resources\AppIcon\appiconfg.svg" Color="#512BD4" />
36+
37+
<!-- Splash Screen -->
38+
<MauiSplashScreen Include="Resources\Splash\splash.svg" Color="#512BD4" BaseSize="128,128" />
39+
40+
<!-- Images -->
41+
<MauiImage Include="Resources\Images\*" />
42+
<MauiImage Update="Resources\Images\dotnet_bot.svg" BaseSize="168,208" />
43+
44+
<!-- Custom Fonts -->
45+
<MauiFont Include="Resources\Fonts\*" />
46+
47+
<!-- Raw Assets (also remove the "Resources\Raw" prefix) -->
48+
<MauiAsset Include="Resources\Raw\**" LogicalName="%(RecursiveDir)%(Filename)%(Extension)" />
49+
</ItemGroup>
50+
51+
<ItemGroup>
52+
<PackageReference Include="CommunityToolkit.Maui" Version="*" />
53+
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="7.0.0" />
54+
<PackageReference Include="Syncfusion.Maui.ImageEditor" Version="*" />
55+
</ItemGroup>
56+
57+
</Project>
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
4+
xmlns:imageEditor ="clr-namespace:Syncfusion.Maui.ImageEditor;assembly=Syncfusion.Maui.ImageEditor"
5+
xmlns:local="clr-namespace:FileSaver_CommunityToolkit"
6+
x:Class="FileSaver_CommunityToolkit.MainPage">
7+
8+
<imageEditor:SfImageEditor x:Name="imageEditor" Source="dotnet_bot.png"/>
9+
<ContentPage.Behaviors>
10+
<local:FileSaverBehavior/>
11+
</ContentPage.Behaviors>
12+
</ContentPage>
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
namespace FileSaver_CommunityToolkit;
2+
3+
public partial class MainPage : ContentPage
4+
{
5+
public MainPage()
6+
{
7+
InitializeComponent();
8+
}
9+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
using Microsoft.Extensions.Logging;
2+
using Syncfusion.Maui.Core.Hosting;
3+
using CommunityToolkit.Maui;
4+
5+
namespace FileSaver_CommunityToolkit;
6+
7+
public static class MauiProgram
8+
{
9+
public static MauiApp CreateMauiApp()
10+
{
11+
var builder = MauiApp.CreateBuilder();
12+
builder
13+
.ConfigureSyncfusionCore()
14+
.UseMauiApp<App>()
15+
.UseMauiCommunityToolkit()
16+
.ConfigureFonts(fonts =>
17+
{
18+
fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
19+
fonts.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold");
20+
});
21+
22+
#if DEBUG
23+
builder.Logging.AddDebug();
24+
#endif
25+
26+
return builder.Build();
27+
}
28+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /