Files
Tiago Conceição 816898836b v3.9.0
- **File formats:**
  - (Add) File extension: .gktwo.ctb to `ChituboxFile` to be able to convert files for UniFormation GKtwo under special CTB format
  - (Add) UniFormation GKtwo compatibility under CTB format, if exporting JXS rename to CTB before open
  - (Fix) CTB, CBDDLP, PHOTON, FDG, PHZ: Read and write files larger then 4GB (#608)
- **PCB Exposure:**
  - (Add) Offset X/Y to offset the PCB from it origin
  - (Add) Allow to toggle between "Show preview image cropped by it bounds" and "Show full preview image (The final result)"
  - (Improvement) Use rectangle instead of line for center line primitive (#607)
  - (Fix) Implement rotation to polygon and center line primitives (#607)
  - (Fix) Macros in a single line was not being parsed (#607)
  - (Fix) Invert color per file was not affecting primitives
- **Network printers:**
  - (Add) Socket requests with TCP and UDP
  - (Add) AnyCubic printer preset (However it can't upload a file)
  - (Add) Scripts in request path to allow a first request to fetch data to the final request:
    -  A script starts with **<\?** and ends with **?>**
    -  First parameter is the first request to get response content from
    -  Second parameter is the regex pattern to match content with
    -  Third parameter is the final request that supports a parameter from regex matching group, eg: **{#1}** is match Group[1] value
    -  **Example:** <\? getfiles > {0}\/(\d+\.[\da-zA-Z]+), > printfile,{#1} ?>
  - (Change) Allow to print a filename without send it when upload request path is empty
  - (Fix) Do not show printers with empty requests
- (Change) Default layer compression to Lz4 instead of Png
- (Improvement) Application is now culture aware but set part of `NumberFormat` to the `InvariantCulture.NumberFormat`
- (Improvement) Material cost now show with the current culture currency symbol due previous change
- (Improvement) Better submit of bug reports using sections and forms
- (Improvement) Linux: AppImage now have a help manual with possible arguments and parameters
- (Improvement) macOS: Codesign app on auto-installer and auto-upgrade to bypass arm64 run restriction (#431)
- (Improvement) macOS: Rebuilt arm64 libcvextern.dylib to run with less dependencies (#431)
- (Improvement) macOS: Try to show missing dependencies from openCV (if any) on the error message
- (Fix) UI: layers sorted lexicographically instead of numerically in the issues list view (#611)
- (Fix) PrusaSlicer printer parameters: UniFormation GKtwo
2022-12-01 04:27:44 +00:00

201 lines
6.0 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 UVtools.Core.Extensions;
using UVtools.Core.Objects;
namespace UVtools.Core.Network;
public class RemotePrinter : BindableBase
{
#region Members
private bool _isEnabled;
private string _name = null!;
private string _host = "0.0.0.0";
private string? _compatibleExtensions;
private ushort _port;
private RemotePrinterRequest _requestUploadFile = new(RemotePrinterRequest.RequestType.UploadFile, RemotePrinterRequest.RequestMethod.PUT);
private RemotePrinterRequest _requestPrintFile = new(RemotePrinterRequest.RequestType.PrintFile, RemotePrinterRequest.RequestMethod.GET);
private RemotePrinterRequest _requestDeleteFile = new(RemotePrinterRequest.RequestType.DeleteFile, RemotePrinterRequest.RequestMethod.GET);
private RemotePrinterRequest _requestPausePrint = new(RemotePrinterRequest.RequestType.PausePrint, RemotePrinterRequest.RequestMethod.GET);
private RemotePrinterRequest _requestResumePrint = new(RemotePrinterRequest.RequestType.ResumePrint, RemotePrinterRequest.RequestMethod.GET);
private RemotePrinterRequest _requestStopPrint = new(RemotePrinterRequest.RequestType.StopPrint, RemotePrinterRequest.RequestMethod.GET);
private RemotePrinterRequest _requestGetFiles = new(RemotePrinterRequest.RequestType.GetFiles, RemotePrinterRequest.RequestMethod.GET);
private RemotePrinterRequest _requestPrintStatus = new(RemotePrinterRequest.RequestType.PrintStatus, RemotePrinterRequest.RequestMethod.GET);
private RemotePrinterRequest _requestPrinterInfo = new(RemotePrinterRequest.RequestType.PrinterInfo, RemotePrinterRequest.RequestMethod.GET);
//private List<RemotePrinterRequest> _requests = new();
#endregion
#region Properties
public bool IsEnabled
{
get => _isEnabled;
set => RaiseAndSetIfChanged(ref _isEnabled, value);
}
/// <summary>
/// Gets or sets the alias name for this printer.
/// Not used on requests
/// </summary>
public string Name
{
get => _name;
set => RaiseAndSetIfChanged(ref _name, value);
}
/// <summary>
/// Gets or sets the host/ip for the requests
/// </summary>
public string Host
{
get => _host;
set => RaiseAndSetIfChanged(ref _host!, value?.Trim());
}
/// <summary>
/// Gets or sets the host port for the requests.
/// Use 0 to not use a port
/// </summary>
public ushort Port
{
get => _port;
set => RaiseAndSetIfChanged(ref _port, value);
}
public string HostUrl => _port > 0 ? $"{_host}:{_port}" :_host ;
/// <summary>
/// Gets or sets the compatible extensions with this device.
/// Empty or null to be compatible with everything
/// </summary>
public string? CompatibleExtensions
{
get => _compatibleExtensions;
set => RaiseAndSetIfChanged(ref _compatibleExtensions, value);
}
/// <summary>
/// Gets if this host is valid
/// </summary>
public bool IsValid => !string.IsNullOrEmpty(_host) && _host != "0.0.0.0";
public RemotePrinterRequest RequestUploadFile
{
get => _requestUploadFile;
set => RaiseAndSetIfChanged(ref _requestUploadFile, value);
}
public RemotePrinterRequest RequestPrintFile
{
get => _requestPrintFile;
set => RaiseAndSetIfChanged(ref _requestPrintFile, value);
}
public RemotePrinterRequest RequestDeleteFile
{
get => _requestDeleteFile;
set => RaiseAndSetIfChanged(ref _requestDeleteFile, value);
}
public RemotePrinterRequest RequestPausePrint
{
get => _requestPausePrint;
set => RaiseAndSetIfChanged(ref _requestPausePrint, value);
}
public RemotePrinterRequest RequestResumePrint
{
get => _requestResumePrint;
set => RaiseAndSetIfChanged(ref _requestResumePrint, value);
}
public RemotePrinterRequest RequestStopPrint
{
get => _requestStopPrint;
set => RaiseAndSetIfChanged(ref _requestStopPrint, value);
}
public RemotePrinterRequest RequestGetFiles
{
get => _requestGetFiles;
set => RaiseAndSetIfChanged(ref _requestGetFiles, value);
}
public RemotePrinterRequest RequestPrintStatus
{
get => _requestPrintStatus;
set => RaiseAndSetIfChanged(ref _requestPrintStatus, value);
}
public RemotePrinterRequest RequestPrinterInfo
{
get => _requestPrinterInfo;
set => RaiseAndSetIfChanged(ref _requestPrinterInfo, value);
}
public RemotePrinterRequest[] Requests => new []
{
_requestUploadFile,
_requestPrintFile,
_requestDeleteFile,
_requestPausePrint,
_requestResumePrint,
_requestStopPrint,
_requestGetFiles,
_requestPrintStatus,
_requestPrinterInfo,
};
/*
/// <summary>
/// Gets or sets the available requests for this printer
/// </summary>
public List<RemotePrinterRequest> Requests
{
get => _requests;
set => RaiseAndSetIfChanged(ref _requests, value);
}*/
#endregion
#region Constructor
public RemotePrinter()
{
}
public RemotePrinter(string host = "0.0.0.0", ushort port = 0, string name = "", bool isEnabled = false)
{
_isEnabled = isEnabled;
_name = name;
_host = host;
_port = port;
}
#endregion
#region Methods
public override string ToString()
{
var result = HostUrl;
if (!string.IsNullOrWhiteSpace(_name)) result += $" ({_name})";
return result;
}
public RemotePrinter Clone()
{
return this.CloneByXmlSerialization();
}
#endregion
}