mirror of
https://github.com/riegera2412/UVtools.git
synced 2026-07-08 17:42:31 +02:00
Add UVtools.WPF
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
<Application xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
x:Class="UVtools.WPF.App">
|
||||
<Application.Styles>
|
||||
<StyleInclude Source="avares://Avalonia.Themes.Default/DefaultTheme.xaml"/>
|
||||
<StyleInclude Source="avares://Avalonia.Themes.Default/Accents/BaseLight.xaml"/>
|
||||
</Application.Styles>
|
||||
</Application>
|
||||
@@ -0,0 +1,24 @@
|
||||
using Avalonia;
|
||||
using Avalonia.Controls.ApplicationLifetimes;
|
||||
using Avalonia.Markup.Xaml;
|
||||
|
||||
namespace UVtools.WPF
|
||||
{
|
||||
public class App : Application
|
||||
{
|
||||
public override void Initialize()
|
||||
{
|
||||
AvaloniaXamlLoader.Load(this);
|
||||
}
|
||||
|
||||
public override void OnFrameworkInitializationCompleted()
|
||||
{
|
||||
if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
|
||||
{
|
||||
desktop.MainWindow = new MainWindow();
|
||||
}
|
||||
|
||||
base.OnFrameworkInitializationCompleted();
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,131 @@
|
||||
using System;
|
||||
using Avalonia;
|
||||
|
||||
namespace UVtools.WPF.Extensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Avalonia Matrix helper methods.
|
||||
/// </summary>
|
||||
public static class MatrixHelper
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a translation matrix using the specified offsets.
|
||||
/// </summary>
|
||||
/// <param name="offsetX">X-coordinate offset.</param>
|
||||
/// <param name="offsetY">Y-coordinate offset.</param>
|
||||
/// <returns>The created translation matrix.</returns>
|
||||
public static Matrix Translate(double offsetX, double offsetY)
|
||||
{
|
||||
return new Matrix(1.0, 0.0, 0.0, 1.0, offsetX, offsetY);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Prepends a translation around the center of provided matrix.
|
||||
/// </summary>
|
||||
/// <param name="matrix">The matrix to prepend translation.</param>
|
||||
/// <param name="offsetX">X-coordinate offset.</param>
|
||||
/// <param name="offsetY">Y-coordinate offset.</param>
|
||||
/// <returns>The created translation matrix.</returns>
|
||||
public static Matrix TranslatePrepend(Matrix matrix, double offsetX, double offsetY)
|
||||
{
|
||||
return Translate(offsetX, offsetY) * matrix;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a matrix that scales along the x-axis and y-axis.
|
||||
/// </summary>
|
||||
/// <param name="scaleX">Scaling factor that is applied along the x-axis.</param>
|
||||
/// <param name="scaleY">Scaling factor that is applied along the y-axis.</param>
|
||||
/// <returns>The created scaling matrix.</returns>
|
||||
public static Matrix Scale(double scaleX, double scaleY)
|
||||
{
|
||||
return new Matrix(scaleX, 0, 0, scaleY, 0.0, 0.0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a matrix that is scaling from a specified center.
|
||||
/// </summary>
|
||||
/// <param name="scaleX">Scaling factor that is applied along the x-axis.</param>
|
||||
/// <param name="scaleY">Scaling factor that is applied along the y-axis.</param>
|
||||
/// <param name="centerX">The center X-coordinate of the scaling.</param>
|
||||
/// <param name="centerY">The center Y-coordinate of the scaling.</param>
|
||||
/// <returns>The created scaling matrix.</returns>
|
||||
public static Matrix ScaleAt(double scaleX, double scaleY, double centerX, double centerY)
|
||||
{
|
||||
return new Matrix(scaleX, 0, 0, scaleY, centerX - (scaleX * centerX), centerY - (scaleY * centerY));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Prepends a scale around the center of provided matrix.
|
||||
/// </summary>
|
||||
/// <param name="matrix">The matrix to prepend scale.</param>
|
||||
/// <param name="scaleX">Scaling factor that is applied along the x-axis.</param>
|
||||
/// <param name="scaleY">Scaling factor that is applied along the y-axis.</param>
|
||||
/// <param name="centerX">The center X-coordinate of the scaling.</param>
|
||||
/// <param name="centerY">The center Y-coordinate of the scaling.</param>
|
||||
/// <returns>The created scaling matrix.</returns>
|
||||
public static Matrix ScaleAtPrepend(Matrix matrix, double scaleX, double scaleY, double centerX, double centerY)
|
||||
{
|
||||
return ScaleAt(scaleX, scaleY, centerX, centerY) * matrix;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a skew matrix.
|
||||
/// </summary>
|
||||
/// <param name="angleX">Angle of skew along the X-axis in radians.</param>
|
||||
/// <param name="angleY">Angle of skew along the Y-axis in radians.</param>
|
||||
/// <returns>When the method completes, contains the created skew matrix.</returns>
|
||||
public static Matrix Skew(float angleX, float angleY)
|
||||
{
|
||||
return new Matrix(1.0, Math.Tan(angleX), Math.Tan(angleY), 1.0, 0.0, 0.0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a matrix that rotates.
|
||||
/// </summary>
|
||||
/// <param name="radians">Angle of rotation in radians. Angles are measured clockwise when looking along the rotation axis.</param>
|
||||
/// <returns>The created rotation matrix.</returns>
|
||||
public static Matrix Rotation(double radians)
|
||||
{
|
||||
double cos = Math.Cos(radians);
|
||||
double sin = Math.Sin(radians);
|
||||
return new Matrix(cos, sin, -sin, cos, 0, 0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a matrix that rotates about a specified center.
|
||||
/// </summary>
|
||||
/// <param name="angle">Angle of rotation in radians.</param>
|
||||
/// <param name="centerX">The center X-coordinate of the rotation.</param>
|
||||
/// <param name="centerY">The center Y-coordinate of the rotation.</param>
|
||||
/// <returns>The created rotation matrix.</returns>
|
||||
public static Matrix Rotation(double angle, double centerX, double centerY)
|
||||
{
|
||||
return Translate(-centerX, -centerY) * Rotation(angle) * Translate(centerX, centerY);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a matrix that rotates about a specified center.
|
||||
/// </summary>
|
||||
/// <param name="angle">Angle of rotation in radians.</param>
|
||||
/// <param name="center">The center of the rotation.</param>
|
||||
/// <returns>The created rotation matrix.</returns>
|
||||
public static Matrix Rotation(double angle, Vector center)
|
||||
{
|
||||
return Translate(-center.X, -center.Y) * Rotation(angle) * Translate(center.X, center.Y);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Transforms a point by this matrix.
|
||||
/// </summary>
|
||||
/// <param name="matrix">The matrix to use as a transformation matrix.</param>
|
||||
/// <param name="point">>The original point to apply the transformation.</param>
|
||||
/// <returns>The result of the transformation for the input point.</returns>
|
||||
public static Point TransformPoint(Matrix matrix, Point point)
|
||||
{
|
||||
return new Point(
|
||||
(point.X * matrix.M11) + (point.Y * matrix.M21) + matrix.M31,
|
||||
(point.X * matrix.M12) + (point.Y * matrix.M22) + matrix.M32);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
using Avalonia;
|
||||
|
||||
namespace UVtools.WPF.Extensions
|
||||
{
|
||||
public static class PrimitivesExtensions
|
||||
{
|
||||
public static bool IsEmpty(this Point point)
|
||||
{
|
||||
return point.X == 0 && point.Y == 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
<Window 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:uc="clr-namespace:UVtools.WPF.Controls"
|
||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||
x:Class="UVtools.WPF.MainWindow"
|
||||
Title="UVtools">
|
||||
|
||||
<DockPanel>
|
||||
<StackPanel DockPanel.Dock="Top" Orientation="Horizontal">
|
||||
<Button Name="zoomtofit">Zoom to fit</Button>
|
||||
<Button Name="center">Center image</Button>
|
||||
</StackPanel>
|
||||
|
||||
<uc:AdvancedImageBox
|
||||
GridCellSize="15"
|
||||
Name="Layer.ImageOld"
|
||||
/>
|
||||
</DockPanel>
|
||||
</Window>
|
||||
@@ -0,0 +1,42 @@
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Markup.Xaml;
|
||||
using UVtools.WPF.Controls;
|
||||
|
||||
namespace UVtools.WPF
|
||||
{
|
||||
public class MainWindow : Window
|
||||
{
|
||||
public AdvancedImageBox LayerImage;
|
||||
public Button ZoomToFitButton;
|
||||
public Button CenterButton;
|
||||
public MainWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
#if DEBUG
|
||||
this.AttachDevTools();
|
||||
#endif
|
||||
LayerImage = this.FindControl<AdvancedImageBox>("Layer.ImageOld");
|
||||
ZoomToFitButton = this.FindControl<Button>("zoomtofit");
|
||||
CenterButton = this.FindControl<Button>("center");
|
||||
LayerImage.LoadImage(@"D:\Tiago\Desktop\UVtools\body_Tough0.1mm_SL1_5h16m_HOLLOW_DRAIN\body_Tough0.1mm_SL1_5h16m_HOLLOW_DRAIN00000.png");
|
||||
|
||||
ZoomToFitButton.Click += (sender, args) => LayerImage.ZoomToFit();
|
||||
CenterButton.Click += (sender, args) => LayerImage.CenterAt(1440/2,2560/2);
|
||||
//var layerImage = this.FindControl<AdvancedPictureBox>("Layer.ImageOld");
|
||||
//layerImage.LoadImage(@"D:\Tiago\Desktop\UVtools\body_Tough0.1mm_SL1_5h16m_HOLLOW_DRAIN\body_Tough0.1mm_SL1_5h16m_HOLLOW_DRAIN00000.png");
|
||||
}
|
||||
|
||||
private void InitializeComponent()
|
||||
{
|
||||
AvaloniaXamlLoader.Load(this);
|
||||
}
|
||||
|
||||
public override void EndInit()
|
||||
{
|
||||
base.EndInit();
|
||||
|
||||
//layerImage.LoadImage(@"D:\Tiago\Desktop\UVtools\body_Tough0.1mm_SL1_5h16m_HOLLOW_DRAIN\body_Tough0.1mm_SL1_5h16m_HOLLOW_DRAIN00000.png");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
using Avalonia;
|
||||
using Avalonia.Logging.Serilog;
|
||||
|
||||
namespace UVtools.WPF
|
||||
{
|
||||
class Program
|
||||
{
|
||||
// Initialization code. Don't use any Avalonia, third-party APIs or any
|
||||
// SynchronizationContext-reliant code before AppMain is called: things aren't initialized
|
||||
// yet and stuff might break.
|
||||
public static void Main(string[] args) => BuildAvaloniaApp()
|
||||
.StartWithClassicDesktopLifetime(args);
|
||||
|
||||
// Avalonia configuration, don't remove; also used by visual designer.
|
||||
public static AppBuilder BuildAvaloniaApp()
|
||||
=> AppBuilder.Configure<App>()
|
||||
.UsePlatformDetect()
|
||||
.With(new Win32PlatformOptions
|
||||
{
|
||||
AllowEglInitialization = true,
|
||||
})
|
||||
.LogToDebug();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||
<AssemblyName>UVtools</AssemblyName>
|
||||
<ApplicationIcon>UVtools.ico</ApplicationIcon>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Avalonia" Version="0.9.11" />
|
||||
<PackageReference Include="Avalonia.Angle.Windows.Natives" Version="2.1.0.2019013001" />
|
||||
<PackageReference Include="Avalonia.Desktop" Version="0.9.11" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\UVtools.Core\UVtools.Core.csproj" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 122 KiB |
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<!--
|
||||
To use the Avalonia CI feed to get unstable packages, move this file to the root of your solution.
|
||||
-->
|
||||
|
||||
<configuration>
|
||||
<packageSources>
|
||||
<add key="AvaloniaCI" value="https://www.myget.org/F/avalonia-ci/api/v2" />
|
||||
</packageSources>
|
||||
</configuration>
|
||||
+17
@@ -19,6 +19,11 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UVtools.Cmd", "UVtools.Cmd\
|
||||
{7C9927F8-132E-4A37-B894-440E0FD5AA3D} = {7C9927F8-132E-4A37-B894-440E0FD5AA3D}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UVtools.WPF", "UVtools.WPF\UVtools.WPF.csproj", "{B1B40A7B-D30B-4056-AE6F-C4F0519FD8D4}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{7C9927F8-132E-4A37-B894-440E0FD5AA3D} = {7C9927F8-132E-4A37-B894-440E0FD5AA3D}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
@@ -81,6 +86,18 @@ Global
|
||||
{36E5877E-6AA6-4368-A9EA-46D7C7C90302}.Release|x64.Build.0 = Release|x64
|
||||
{36E5877E-6AA6-4368-A9EA-46D7C7C90302}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{36E5877E-6AA6-4368-A9EA-46D7C7C90302}.Release|x86.Build.0 = Release|Any CPU
|
||||
{B1B40A7B-D30B-4056-AE6F-C4F0519FD8D4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{B1B40A7B-D30B-4056-AE6F-C4F0519FD8D4}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{B1B40A7B-D30B-4056-AE6F-C4F0519FD8D4}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{B1B40A7B-D30B-4056-AE6F-C4F0519FD8D4}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{B1B40A7B-D30B-4056-AE6F-C4F0519FD8D4}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{B1B40A7B-D30B-4056-AE6F-C4F0519FD8D4}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{B1B40A7B-D30B-4056-AE6F-C4F0519FD8D4}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{B1B40A7B-D30B-4056-AE6F-C4F0519FD8D4}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{B1B40A7B-D30B-4056-AE6F-C4F0519FD8D4}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{B1B40A7B-D30B-4056-AE6F-C4F0519FD8D4}.Release|x64.Build.0 = Release|Any CPU
|
||||
{B1B40A7B-D30B-4056-AE6F-C4F0519FD8D4}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{B1B40A7B-D30B-4056-AE6F-C4F0519FD8D4}.Release|x86.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
||||
Reference in New Issue
Block a user