Skip to content

migration of existed xamarin forms example into NET8 MAUI #121

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

Draft
wants to merge 1 commit into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions MigrationForms/MigrationFormsExampleToMAUI.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@

Microsoft Visual Studio Solution File, Format Version 12.00
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MigrationFormsExampleToMAUI", "MigrationFormsExampleToMAUI\MigrationFormsExampleToMAUI.csproj", "{D2BB8C7B-5986-4FAA-93E2-5C4C2F5D8ACA}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{D2BB8C7B-5986-4FAA-93E2-5C4C2F5D8ACA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D2BB8C7B-5986-4FAA-93E2-5C4C2F5D8ACA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D2BB8C7B-5986-4FAA-93E2-5C4C2F5D8ACA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D2BB8C7B-5986-4FAA-93E2-5C4C2F5D8ACA}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal
14 changes: 14 additions & 0 deletions MigrationForms/MigrationFormsExampleToMAUI/App.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version = "1.0" encoding = "UTF-8" ?>
<Application xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:MigrationFormsExampleToMAUI"
x:Class="MigrationFormsExampleToMAUI.App">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Resources/Styles/Colors.xaml" />
<ResourceDictionary Source="Resources/Styles/Styles.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
</Application>
27 changes: 27 additions & 0 deletions MigrationForms/MigrationFormsExampleToMAUI/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using MigrationFormsExampleToMAUI.Model;

namespace MigrationFormsExampleToMAUI;

public partial class App : Application
{
public static Color ScanbotRed = Color.FromRgb(200, 25, 60);

public App()
{
InitializeComponent();

#pragma warning disable CS4014
// There's no requirement to await this, can just disable warning
InitializeAsync();
#pragma warning restore CS4014

MainPage = new AppShell();
}

async Task<bool> InitializeAsync()
{
await PageStorage.Instance.InitializeAsync();
await MigrationFormsExampleToMAUI.Model.Pages.Instance.LoadFromStorage();
return true;
}
}
15 changes: 15 additions & 0 deletions MigrationForms/MigrationFormsExampleToMAUI/AppShell.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Shell
x:Class="MigrationFormsExampleToMAUI.AppShell"
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:MigrationFormsExampleToMAUI"
Shell.FlyoutBehavior="Disabled"
Title="MigrationFormsExampleToMAUI">

<ShellContent
Title="Home"
ContentTemplate="{DataTemplate local:MainPage}"
Route="MainPage" />

</Shell>
9 changes: 9 additions & 0 deletions MigrationForms/MigrationFormsExampleToMAUI/AppShell.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace MigrationFormsExampleToMAUI;

public partial class AppShell : Shell
{
public AppShell()
{
InitializeComponent();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
namespace MigrationFormsExampleToMAUI.DependencyServices;

public partial class MultiImagePicker
{
/// <summary>
/// Get photos paths from gallery with completion handler
/// </summary>
/// <returns></returns>
public partial void PickPhotosAsync(Action<List<ImageSource>> completionHandler);
}


67 changes: 67 additions & 0 deletions MigrationForms/MigrationFormsExampleToMAUI/FilterPage.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
using MigrationFormsExampleToMAUI.Utils;
using ScanbotSDK.MAUI.Constants;
using ScanbotSDK.MAUI.Services;

namespace MigrationFormsExampleToMAUI;

public class FilterPage: ContentPage
{
public StackLayout Container { get; set; }
public Image Image { get; set; }
public Button FilterButton { get; set; }

public ImageFilter CurrentFilter { get; set; }

public IScannedPage CurrentPage { get; set; }

public FilterPage(IScannedPage current)
{
CurrentPage = current;

Container = new StackLayout();
Container.Orientation = StackOrientation.Vertical;
Container.BackgroundColor = Colors.White;

Image = new Image
{
HorizontalOptions = LayoutOptions.FillAndExpand,
BackgroundColor = Colors.LightGray,
Aspect = Aspect.AspectFit
};
Image.SizeChanged += delegate
{
// Don't allow images larger than half of the screen
Image.HeightRequest = Content.Height / 2;
};
Container.Children.Add(Image);

FilterButton = new Button
{
Text = "None",
HorizontalOptions = LayoutOptions.FillAndExpand,
HeightRequest = 50,
Margin = new Thickness(10, 10, 10, 10)
};
FilterButton.Pressed += FilterButtonClicked;
Container.Children.Add(FilterButton);

Image.Source = CurrentPage.Document;

Content = Container;
}

async void FilterButtonClicked(object sender, EventArgs e)
{
if (!SDKUtils.CheckLicense(this)) { return; }

var action = await DisplayActionSheet(
"Filter", "Cancel", null, Enum.GetNames(typeof(ImageFilter))
);

ImageFilter filter;
Enum.TryParse(action, out filter);
CurrentFilter = filter;

Image.Source = await ScanbotSDK.MAUI.ScanbotSDK.SDKService.ApplyImageFilterAsync(Image.Source, filter);
}
}
5 changes: 5 additions & 0 deletions MigrationForms/MigrationFormsExampleToMAUI/MainPage.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="MigrationFormsExampleToMAUI.MainPage">
</ContentPage>
Loading