Files
UVtools/UVtools.WPF/MainWindow.GCode.cs
T
Tiago Conceição 44b1289daa v2.25.2
- **About box:**
   - (Add) Processor name
   - (Add) Memory RAM (Used / Total GB)
   - (Add) OpenCV and Assemblies tab
   - (Add) "Copy information" button to copy the whole dialog information, usefull for bug reports
   - (Improvement) Enumerate the loaded assemblies
   - (Improvement) Rearrange the elements and put them inside scroll viewers to not strech the window
   - (Improvement) Allow to resize and maximize the window
- (Fix) Auto updater: From this version forward, the linux packages are correctly identified (linux, arch, rhel) and will download the same package as installed. Were downloading the linux-x64 no matter what
2021-11-25 02:41:21 +00:00

78 lines
2.4 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.Core.SystemOS;
using UVtools.WPF.Extensions;
using Helpers = UVtools.WPF.Controls.Helpers;
namespace UVtools.WPF
{
public partial class MainWindow
{
public bool HaveGCode => IsFileLoaded && SlicerFile.SupportsGCode;
public uint GCodeLines => !HaveGCode ? 0 : SlicerFile.GCode.LineCount;
public void OnClickRebuildGcode()
{
if (!HaveGCode) return;
var temp = SlicerFile.SuppressRebuildGCode;
SlicerFile.SuppressRebuildGCode = false;
SlicerFile.RebuildGCode();
SlicerFile.SuppressRebuildGCode = temp;
RaisePropertyChanged(nameof(GCodeLines));
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;
SystemAware.StartProcess(file);
}
public void OnClickGCodeSaveClipboard()
{
if (!HaveGCode) return;
Application.Current.Clipboard.SetTextAsync(SlicerFile.GCodeStr);
}
}
}