blob: 71c173d36cb4a4a866929b1b5816921fb7b83e48 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
using System;
using Avalonia.Markup.Xaml;
using UVtools.Core.FileFormats;
using UVtools.Core.Operations;
namespace UVtools.WPF.Controls.Tools
{
public class ToolCalculatorControl : ToolControl
{
private decimal _lightOffDelayPrintTimeHours;
public OperationCalculator Operation => BaseOperation as OperationCalculator;
public FileFormat SlicerFile => App.SlicerFile;
public decimal LightOffDelayPrintTimeHours
{
get => _lightOffDelayPrintTimeHours;
set => RaiseAndSetIfChanged(ref _lightOffDelayPrintTimeHours, value);
}
public ToolCalculatorControl()
{
InitializeComponent();
BaseOperation = new OperationCalculator
{
CalcMillimetersToPixels = new OperationCalculator.MillimetersToPixels(SlicerFile.Resolution, SlicerFile.Display),
CalcLightOffDelay = new OperationCalculator.LightOffDelayC(
(decimal)SlicerFile.LiftHeight, (decimal)SlicerFile.BottomLiftHeight,
(decimal)SlicerFile.LiftSpeed, (decimal)SlicerFile.BottomLiftSpeed,
(decimal)SlicerFile.RetractSpeed, (decimal)SlicerFile.RetractSpeed)
};
Operation.CalcLightOffDelay.PropertyChanged += (sender, e) =>
{
if (e.PropertyName != nameof(Operation.CalcLightOffDelay.LightOffDelay) &&
e.PropertyName != nameof(Operation.CalcLightOffDelay.BottomLightOffDelay)) return;
LightOffDelayPrintTimeHours = Math.Round(
(FileFormat.ExtraPrintTime +
SlicerFile.BottomLayerCount * (Operation.CalcLightOffDelay.BottomLightOffDelay + (decimal) SlicerFile.BottomExposureTime) +
SlicerFile.NormalLayerCount * (Operation.CalcLightOffDelay.LightOffDelay + (decimal)SlicerFile.ExposureTime))
/ 3600, 2);
};
_lightOffDelayPrintTimeHours = (decimal) SlicerFile.PrintTimeHours;
}
private void InitializeComponent()
{
AvaloniaXamlLoader.Load(this);
}
public void LightOffDelaySetParameters(byte side)
{
if (side == 0) // Bottom layers
{
SlicerFile.BottomLiftHeight = (float)Operation.CalcLightOffDelay.BottomLiftHeight;
SlicerFile.BottomLiftSpeed = (float)Operation.CalcLightOffDelay.BottomLiftSpeed;
SlicerFile.RetractSpeed = (float)Operation.CalcLightOffDelay.RetractSpeed;
SlicerFile.BottomLayerOffTime = (float)Operation.CalcLightOffDelay.BottomLightOffDelay;
}
else // Normal layers
{
SlicerFile.LiftHeight = (float)Operation.CalcLightOffDelay.LiftHeight;
SlicerFile.LiftSpeed = (float)Operation.CalcLightOffDelay.LiftSpeed;
SlicerFile.RetractSpeed = (float)Operation.CalcLightOffDelay.RetractSpeed;
SlicerFile.LayerOffTime = (float)Operation.CalcLightOffDelay.LightOffDelay;
}
LightOffDelayPrintTimeHours = (decimal)SlicerFile.PrintTimeHours;
App.MainWindow.CanSave = true;
}
}
}
|