mirror of
https://github.com/riegera2412/UVtools.git
synced 2026-07-13 20:07:40 +02:00
5da3c7e173
* (Add) Auto-updater: When a new version is detected UVtools still show the same green button at top, on click, it will prompt for auto or manual update. On Linux and Mac the script will kill all UVtools instances and auto-upgrade. On Windows the user must close all instances and continue with the shown MSI installation * (Add) Tool profiles: Create and remove named presets for some tools * (Add) Event handler for handling non-UI thread exceptions * (Fix) Mac: File - Open in a new window was not working * (Fix) Tool - Rotate: Allow negative angles * (Fix) Tool - Rotate: The operation was inverting the angle * (Fix) Tools: Select normal layers can crash the program with small files with low layer count, eg: 3 layers total
67 lines
2.2 KiB
C#
67 lines
2.2 KiB
C#
using System;
|
|
using Avalonia.Markup.Xaml;
|
|
using UVtools.Core.Operations;
|
|
using UVtools.WPF.Extensions;
|
|
using UVtools.WPF.Windows;
|
|
|
|
namespace UVtools.WPF.Controls.Tools
|
|
{
|
|
public class ToolPatternControl : ToolControl
|
|
{
|
|
public OperationPattern Operation => BaseOperation as OperationPattern;
|
|
private bool _isDefaultAnchorChecked = true;
|
|
|
|
public bool IsDefaultAnchorChecked
|
|
{
|
|
get => _isDefaultAnchorChecked;
|
|
set => RaiseAndSetIfChanged(ref _isDefaultAnchorChecked, value);
|
|
}
|
|
|
|
public ToolPatternControl()
|
|
{
|
|
InitializeComponent();
|
|
var roi = App.MainWindow.ROI;
|
|
BaseOperation = new OperationPattern(roi.IsEmpty ? App.SlicerFile.LayerManager.BoundingRectangle : roi, App.SlicerFile.Resolution);
|
|
|
|
if (Operation.MaxRows < 2 && Operation.MaxCols < 2)
|
|
{
|
|
App.MainWindow.MessageBoxInfo("The available free volume is not enough to pattern this object.\n" +
|
|
"To run this tool the free space must allow at least 1 copy.", "Unable to pattern");
|
|
CanRun = false;
|
|
return;
|
|
}
|
|
|
|
|
|
Operation.PropertyChanged += (sender, e) =>
|
|
{
|
|
if (e.PropertyName.Equals(nameof(Operation.IsWithinBoundary)))
|
|
{
|
|
ParentWindow.ButtonOkEnabled = Operation.IsWithinBoundary;
|
|
}
|
|
};
|
|
}
|
|
|
|
private void InitializeComponent()
|
|
{
|
|
AvaloniaXamlLoader.Load(this);
|
|
}
|
|
|
|
public override void Callback(ToolWindow.Callbacks callback)
|
|
{
|
|
switch (callback)
|
|
{
|
|
case ToolWindow.Callbacks.Init:
|
|
ParentWindow.IsButton1Visible = true;
|
|
break;
|
|
case ToolWindow.Callbacks.ClearROI:
|
|
Operation.SetRoi(App.SlicerFile.LayerManager.BoundingRectangle);
|
|
break;
|
|
case ToolWindow.Callbacks.Button1:
|
|
Operation.Fill();
|
|
IsDefaultAnchorChecked = true;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|