Files
UVtools/UVtools.WPF/MainWindow.GCode.cs
T
Tiago Conceição 74b6335f64 v2.13.4
- (Fix) ZCode: lcd.gcode was blank / not generating when converting from any file format
- (Fix) Zcodex: Change MaterialId from `uint` to `string` (#223, #224)
- (Fix) CXDLP: Set the default printer name to `CL-89` when creating new instance, was `null` before
- (Fix) Some tools were unable to pull certain settings from profiles and imported settings:
   - Elephant foot
   - Exposure finder
   - Grayscale
   - Stress tower
   - Tolerance
   - XYZ Accuracy
   - Change resolution
   - Dynamic lifts
- (Change) `Layer repair` icon at Issues tab and `Outline` icon on preview toolbar (#227)
- (Developers) Created `UVtools.AvaloniaControls` project with `AdvancedImageBox` control for AvaloniaUI
2021-06-25 21:43:30 +01:00

76 lines
2.3 KiB
C#

/*
* GNU AFFERO GENERAL PUBLIC LICENSE
* Version 3, 19 November 2007
* Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
* Everyone is permitted to copy and distribute verbatim copies
* of this license document, but changing it is not allowed.
*/
using System;
using System.IO;
using Avalonia;
using Avalonia.Controls;
using MessageBox.Avalonia.Enums;
using UVtools.WPF.Extensions;
using Helpers = UVtools.WPF.Controls.Helpers;
namespace UVtools.WPF
{
public partial class MainWindow
{
public bool HaveGCode => IsFileLoaded && SlicerFile.SupportsGCode;
public string GCodeStr => SlicerFile?.GCodeStr;
public uint GCodeLines => !HaveGCode ? 0 : SlicerFile.GCode.LineCount;
public void OnClickRebuildGcode()
{
if (!HaveGCode) return;
SlicerFile.RebuildGCode();
RaisePropertyChanged(nameof(GCodeLines));
RaisePropertyChanged(nameof(GCodeStr));
CanSave = true;
}
public async void OnClickGCodeSaveFile()
{
if (!HaveGCode) return;
var dialog = new SaveFileDialog
{
Filters = Helpers.IniFileFilter,
Directory = Path.GetDirectoryName(SlicerFile.FileFullPath),
InitialFileName = $"{Path.GetFileNameWithoutExtension(SlicerFile.FileFullPath)}_gcode.txt"
};
var file = await dialog.ShowAsync(this);
if (string.IsNullOrEmpty(file)) return;
try
{
await using TextWriter tw = new StreamWriter(file);
await tw.WriteAsync(SlicerFile.GCodeStr);
tw.Close();
}
catch (Exception e)
{
await this.MessageBoxError(e.ToString(), "Error occur while save gcode");
return;
}
var result = await this.MessageBoxQuestion(
"GCode save was successful. Do you want open the file in the default editor?",
"GCode save complete");
if (result != ButtonResult.Yes) return;
App.StartProcess(file);
}
public void OnClickGCodeSaveClipboard()
{
if (!HaveGCode) return;
Application.Current.Clipboard.SetTextAsync(GCodeStr);
}
}
}