Ver Fonte

Updated Desktop Frameworks for better MAUI support

frankvandenbos há 2 meses atrás
pai
commit
664c680998

+ 1 - 1
PRS.Avalonia/PRS.Avalonia.Desktop/PRS.Avalonia.Desktop.csproj

@@ -1,7 +1,7 @@
 <Project Sdk="Microsoft.NET.Sdk">
     <PropertyGroup>
         <OutputType>WinExe</OutputType>
-        <TargetFramework>net8.0-windows10.0.19041.0</TargetFramework>
+        <TargetFramework>net9.0-windows10.0.26100.0</TargetFramework>
         <Nullable>enable</Nullable>
         <BuiltInComInteropSupport>true</BuiltInComInteropSupport>
         <Platforms>x64</Platforms>

+ 6 - 1
PRS.Avalonia/PRS.Avalonia.Desktop/Program.cs

@@ -1,7 +1,9 @@
 using System;
+using System.Security.Policy;
 using Avalonia;
 using InABox.Avalonia.Platform;
 using InABox.Avalonia.Platform.Desktop;
+using Microsoft.Maui.ApplicationModel;
 
 namespace PRS.Avalonia.Desktop;
 
@@ -21,7 +23,8 @@ sealed class Program
         PlatformTools.Register<IPdfRenderer, Desktop_PdfRenderer>();
         PlatformTools.Register<IBluetooth, Desktop_Bluetooth>();
         PlatformTools.Register<IAppVersion, Desktop_AppVersion>();
-        
+        PlatformTools.Register<IImageTools, Desktop_ImageTools>();
+            
         return AppBuilder.Configure<App>()
             .UsePlatformDetect()
             .WithInterFont()
@@ -29,4 +32,6 @@ sealed class Program
     }
     
     
+    
+    
 }

+ 4 - 0
PRS.Avalonia/PRS.Avalonia/App.axaml.cs

@@ -45,6 +45,8 @@ public class App : Application
         MobileLogging.LogError(CoreUtils.FormatException(e));
     }
 
+    public static TopLevel? TopLevel { get; private set; }
+    
     public override void OnFrameworkInitializationCompleted()
     {
         if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
@@ -59,6 +61,7 @@ public class App : Application
                 Height = 700,
                 WindowStartupLocation = WindowStartupLocation.CenterScreen
             };
+            TopLevel = TopLevel.GetTopLevel(desktop.MainWindow);
         }
         else if (ApplicationLifetime is ISingleViewApplicationLifetime singleViewPlatform)
         {
@@ -66,6 +69,7 @@ public class App : Application
             {
                 DataContext = new MainViewModel()
             };
+            TopLevel = TopLevel.GetTopLevel(singleViewPlatform.MainView);
         }
 
         base.OnFrameworkInitializationCompleted();

+ 1 - 0
PRS.Avalonia/PRS.Avalonia/HomePage/HomePageViewModel.cs

@@ -42,6 +42,7 @@ public partial class HomePageViewModel : ViewModelBase
         Modules.Add<ViewMobileAssignmentsModule, AssignmentsViewModel>("Assignments", "", Images.schedule, isVisible: false);
         Modules.Add<ViewMobileDeliveriesModule, DeliveryModuleViewModel>("Deliveries", "", Images.delivery);
         Modules.Add<ViewMobileEquipmentModule, EquipmentModuleViewModel>("Equipment", "", Images.drill);
+        Modules.Add<ViewMobileDocumentScannerModule, DocumentScannerViewModel>("Scanner", "", Images.camera);
         Modules.Add<ViewMobileFormsModule, FormsViewModel>("Forms", "", Images.digitalform);
         Modules.Add<ViewMobileInOutModule, InOutViewModel>("In/Out", "", Images.clock);
         Modules.Add<ViewMobileManufacturingModule, ManufacturingViewModel>("Factory", "", Images.factory, isVisible: false);

+ 30 - 0
PRS.Avalonia/PRS.Avalonia/Modules/DocumentScanner/DocumentScannerView.axaml

@@ -0,0 +1,30 @@
+<UserControl xmlns="https://github.com/avaloniaui"
+             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:PRS.Avalonia.Modules"
+             xmlns:converters="clr-namespace:InABox.Avalonia.Converters;assembly=InABox.Avalonia"
+             mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
+             x:Class="PRS.Avalonia.Modules.DocumentScannerView"
+             x:DataType="local:DocumentScannerViewModel">
+    <UserControl.Resources>
+        <converters:BooleanToColorConverter x:Key="BooleanToColorConverter" />
+    </UserControl.Resources>
+    <Grid>
+        <Grid.RowDefinitions>
+            <RowDefinition Height="*"/>
+            <RowDefinition Height="*"/>
+        </Grid.RowDefinitions>
+        <Image
+            Grid.Row="0"
+            Source="{Binding ImageSource}" />
+    <Button 
+        Grid.Row="1"
+        Command="{Binding ToggleCameraCommand}" 
+        Content="Start" 
+        Background="{Binding Active, Converter={StaticResource BooleanToColorConverter}}"
+        VerticalAlignment="Center" 
+        HorizontalAlignment="Center" 
+        Padding="40" />
+    </Grid>
+</UserControl>

+ 13 - 0
PRS.Avalonia/PRS.Avalonia/Modules/DocumentScanner/DocumentScannerView.axaml.cs

@@ -0,0 +1,13 @@
+using Avalonia;
+using Avalonia.Controls;
+using Avalonia.Markup.Xaml;
+
+namespace PRS.Avalonia.Modules;
+
+public partial class DocumentScannerView : UserControl
+{
+    public DocumentScannerView()
+    {
+        InitializeComponent();
+    }
+}

+ 26 - 1
PRS.Avalonia/PRS.Avalonia/Modules/DocumentScanner/DocumentScannerViewModel.cs

@@ -1,6 +1,31 @@
+using System.Threading.Tasks;
+using Avalonia.Controls;
+using Avalonia.Media;
+using CommunityToolkit.Mvvm.ComponentModel;
+using CommunityToolkit.Mvvm.Input;
+using InABox.Avalonia;
+
 namespace PRS.Avalonia.Modules;
 
-public class DocumentScannerViewModel : ModuleViewModel
+public partial class DocumentScannerViewModel : ModuleViewModel
 {
     public override string Title => "Doc Scanner";
+    
+    [ObservableProperty] private IImage? _imageSource;
+
+    [ObservableProperty] private bool _active;
+    
+    [RelayCommand]
+    private async Task ToggleCamera(Button button)
+    {
+        if (Active)
+        {
+            Active = false;
+        }
+        else
+        {
+            Active = true;
+        }
+        var doc = await MobileDocument.From(App.TopLevel, new MobileDocumentCameraOptions());
+    }
 }

+ 1 - 1
PRS.DigitalKey/Prs.DigitalKey.Desktop/Prs.DigitalKey.Desktop.csproj

@@ -1,7 +1,7 @@
 <Project Sdk="Microsoft.NET.Sdk">
     <PropertyGroup>
         <OutputType>WinExe</OutputType>
-        <TargetFramework>net8.0-windows10.0.19041.0</TargetFramework>
+        <TargetFramework>net9.0-windows10.0.26100.0</TargetFramework>
         <Nullable>enable</Nullable>
         <BuiltInComInteropSupport>true</BuiltInComInteropSupport>
         <Platforms>x64</Platforms>