diff options
Diffstat (limited to 'UVtools.WPF/Controls/Tools/ToolDynamicLayerHeightControl.axaml.cs')
-rw-r--r-- | UVtools.WPF/Controls/Tools/ToolDynamicLayerHeightControl.axaml.cs | 86 |
1 files changed, 86 insertions, 0 deletions
diff --git a/UVtools.WPF/Controls/Tools/ToolDynamicLayerHeightControl.axaml.cs b/UVtools.WPF/Controls/Tools/ToolDynamicLayerHeightControl.axaml.cs new file mode 100644 index 0000000..abe252b --- /dev/null +++ b/UVtools.WPF/Controls/Tools/ToolDynamicLayerHeightControl.axaml.cs @@ -0,0 +1,86 @@ +using System; +using Avalonia.Controls; +using Avalonia.Markup.Xaml; +using UVtools.Core.FileFormats; +using UVtools.Core.Operations; +using UVtools.WPF.Extensions; +using UVtools.WPF.Windows; + +namespace UVtools.WPF.Controls.Tools +{ + public class ToolDynamicLayerHeightControl : ToolControl + { + public OperationDynamicLayerHeight Operation => BaseOperation as OperationDynamicLayerHeight; + + public double LayerHeight => SlicerFile.LayerHeight; + public double MinimumLayerHeight => Math.Round(SlicerFile.LayerHeight*2, 2); + public double MaximumLayerHeight => FileFormat.MaximumLayerHeight; + + private DataGrid ExposureTable; + + public ToolDynamicLayerHeightControl() + { + BaseOperation = new OperationDynamicLayerHeight(SlicerFile); + + if (SlicerFile.LayerHeight * 2 > FileFormat.MaximumLayerHeight) + { + App.MainWindow.MessageBoxError($"This file already uses the maximum layer height possible ({SlicerFile.LayerHeight}mm).\n" + + $"Layers can not be stacked, please re-slice your file with the lowest layer height of 0.01mm.", + $"{BaseOperation.Title} unable to run"); + CanRun = false; + return; + } + + for (uint layerIndex = 1; layerIndex < SlicerFile.LayerCount; layerIndex++) + { + if ((decimal)Math.Round(SlicerFile[layerIndex].PositionZ - SlicerFile[layerIndex - 1].PositionZ, 2) == + (decimal)SlicerFile.LayerHeight) continue; + App.MainWindow.MessageBoxError($"This file contain layer(s) with modified positions, starting at layer {layerIndex}.\n" + + $"This tool requires sequential layers with equal height.\n" + + $"If you run this tool before, you cant re-run.", + $"{BaseOperation.Title} unable to run"); + CanRun = false; + return; + } + + if (!SlicerFile.HavePrintParameterPerLayerModifier(FileFormat.PrintParameterModifier.ExposureSeconds)) + { + App.MainWindow.MessageBoxWaring($"Your printer seems to not support this tool, still you are allowed to run it for analyze, packing layers or simulation.\n" + + $"Do not print this file after run this tool on a not compatible printer, it will result in malformed model and height violation.\n" + + $"Run this at your own risk!", + BaseOperation.Title).ConfigureAwait(false); + } + + + InitializeComponent(); + + ExposureTable = this.FindControl<DataGrid>("ExposureTable"); + } + + private void InitializeComponent() + { + AvaloniaXamlLoader.Load(this); + } + + + public override void Callback(ToolWindow.Callbacks callback) + { + if (SlicerFile is null) return; + switch (callback) + { + case ToolWindow.Callbacks.Init: + case ToolWindow.Callbacks.ProfileLoaded: + /*Operation.PropertyChanged += (sender, e) => + { + if (e.PropertyName.Equals(nameof(Operation.CacheObjectCount))) + { + RaisePropertyChanged(nameof(CacheRAMUsed)); + return; + } + };*/ + Operation.RebuildAutoExposureTable(); + break; + } + } + } +} |