Files
UVtools/UVtools.WPF/Controls/Tools/ToolRedrawModelControl.axaml.cs
Tiago Conceição 2c7ad09dc0 v3.13.1
- (Change) `Layer.IsBottomLayer` no longer calculate the value using the position of the layer, a new property `IsBottomLayerByHeight` is now used to get that result
- (Improvement) Tool - Double exposure: Increase the bottom layer count per cloned bottom layer
- (Improvement) Calibration - Exposure time finder: Set the absolute bottom layer count accordingly when also testing for bottom time
- (Improvement) Goo: Enforce Wait times or Light-off-delay flag based on property set
- (Fix) AnyCubic and Goo: `PerLayerSetting` flag was set inverted causing printer not to follow layer settings when it should and also the otherwise (#689)
- (Fix) Tool - Scripting: Prevent from reload UI multiple times when using profiles (#694)
2023-04-27 22:58:05 +01:00

64 lines
2.1 KiB
C#

using Avalonia.Controls;
using Avalonia.Markup.Xaml;
using System.Collections.Generic;
using UVtools.Core.FileFormats;
using UVtools.Core.Operations;
using UVtools.WPF.Windows;
namespace UVtools.WPF.Controls.Tools;
public class ToolRedrawModelControl : ToolControl
{
public OperationRedrawModel Operation => BaseOperation as OperationRedrawModel;
public ToolRedrawModelControl()
{
BaseOperation = new OperationRedrawModel(SlicerFile);
if (!ValidateSpawn()) return;
InitializeComponent();
}
private void InitializeComponent()
{
AvaloniaXamlLoader.Load(this);
}
public override void Callback(ToolWindow.Callbacks callback)
{
switch (callback)
{
case ToolWindow.Callbacks.Init:
case ToolWindow.Callbacks.AfterLoadProfile:
ParentWindow.ButtonOkEnabled = !string.IsNullOrWhiteSpace(Operation.FilePath);
Operation.PropertyChanged += (sender, e) =>
{
if (e.PropertyName == nameof(Operation.FilePath))
{
ParentWindow.ButtonOkEnabled = !string.IsNullOrWhiteSpace(Operation.FilePath);
}
};
break;
}
}
public async void ImportFile()
{
var filters = Helpers.ToAvaloniaFileFilter(FileFormat.AllFileFiltersAvalonia);
var orderedFilters = new List<FileDialogFilter> { filters[UserSettings.Instance.General.DefaultOpenFileExtensionIndex] };
for (int i = 0; i < filters.Count; i++)
{
if (i == UserSettings.Instance.General.DefaultOpenFileExtensionIndex) continue;
orderedFilters.Add(filters[i]);
}
var dialog = new OpenFileDialog
{
AllowMultiple = false,
Filters = orderedFilters,
Directory = UserSettings.Instance.General.DefaultDirectoryOpenFile
};
var files = await dialog.ShowAsync(ParentWindow);
if (files is null || files.Length <= 0) return;
if (FileFormat.FindByExtensionOrFilePath(files[0]) is null) return;
Operation.FilePath = files[0];
}
}