Files
UVtools/UVtools.Core/FileFormats/FileExtension.cs
T
Tiago Conceição 097bbb867d v2.3.0
* **PrusaSlicer:**
   * **In this release is recommended to discard your printer and refresh it with uvtools updated printer or replace notes over**
   * (Add) FILEFORMAT_XXX variable to auto-convert to that file format once open in UVtools
   * (Update) Print profiles fields with new PrusaSlicer version
   * (Remove) LayerOffDelay from printer notes and use only the LightOffDelay variable instead, both were being used, to avoid redundacy LayerOffDelay was dropped. Please update your printer accordingly!
   * (Remove) FLIP_XY compability from printers
   * (Remove) AntiAlias variable from printers
* **(Add) Settings - Automations:**
   * Auto save the file after apply any automation(s)
   * Auto convert SL1 files to the target format when possible and load it back
   * Auto set the extra 'light-off delay' based on lift height and speed.
* (Add) Allow all and future formats to convert between them without knowing each other (Abstraction)
* (Add) XYResolution and XYResolutionUm property to file formats
* (Add) Calculator - Optimal model tilt: Calculates the optimal model tilt angle for printing and to minimize the visual layer effect
* (Add) Bottom layer count to the status bar
* **(Add) FileFormat propertiers:**
    * MirrorDisplay: If images need to be mirrored on lcd to print on the correct orientation (If available)
    * MaxPrintHeight: The maximum Z build volume of the printer (If available)
* (Add) ZCodex: Print paramenter light-off delay"
* (Add) SL1: Implement missing keys: host_type, physical_printer_settings_id and support_small_pillar_diameter_percent
* (Change) File formats: Round all setters floats to 2 decimals
* (Change) Island Repair: "Remove Islands Below Equal Pixels" limit from 255 to 65535 (#124)
* (Change) LightOffTime variables to LayerOffDelay
* (Fix) Files with upper case extensions doesn't load in
* **(Fix) SL1:**
    * Prevent error when bottle volume is 0
    * bool values were incorrectly parsed
* (Fix) **ZIP:**
    * Material volume was set to grams
    * Bed Y was not being set
2021-01-13 23:19:23 +00:00

114 lines
3.5 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.Collections.Generic;
namespace UVtools.Core.FileFormats
{
/// <summary>
/// Represents a file extension for slicer file formats
/// </summary>
public sealed class FileExtension : IEquatable<FileExtension>, IEquatable<string>
{
#region Properties
/// <summary>
/// Gets the extension name without the dot (.)
/// </summary>
public string Extension { get; }
/// <summary>
/// Gets the extension description
/// </summary>
public string Description { get; }
/// <summary>
/// Gets a tag object
/// </summary>
public object Tag { get; }
/// <summary>
/// Gets the file filter for open and save dialogs
/// </summary>
public string Filter => $@"{Description} (*.{Extension})|*.{Extension}";
#endregion
#region Constructor
/// <summary>
/// Constructor
/// </summary>
/// <param name="extension">The extension name without the dot (.)</param>
/// <param name="description">The extension description</param>
/// <param name="tag">Tag object</param>
public FileExtension(string extension, string description, object tag = null)
{
Extension = extension;
Description = description;
Tag = tag;
}
#endregion
#region Overrides
public override string ToString()
{
return $"{Description} ({Extension})";
}
public bool Equals(FileExtension other)
{
return Extension.Equals(other.Extension, StringComparison.InvariantCultureIgnoreCase);
}
public bool Equals(string other)
{
return Extension.Equals(other, StringComparison.InvariantCultureIgnoreCase);
}
public override bool Equals(object obj)
{
return ReferenceEquals(this, obj) || obj is FileExtension other && Equals(other);
}
public override int GetHashCode()
{
return (Extension != null ? Extension.GetHashCode() : 0);
}
private sealed class ExtensionEqualityComparer : IEqualityComparer<FileExtension>
{
public bool Equals(FileExtension x, FileExtension y)
{
if (ReferenceEquals(x, y)) return true;
if (ReferenceEquals(x, null)) return false;
if (ReferenceEquals(y, null)) return false;
if (x.GetType() != y.GetType()) return false;
return x.Extension == y.Extension;
}
public int GetHashCode(FileExtension obj)
{
return (obj.Extension != null ? obj.Extension.GetHashCode() : 0);
}
}
public static IEqualityComparer<FileExtension> ExtensionComparer { get; } = new ExtensionEqualityComparer();
#endregion
#region Methods
public FileFormat GetFileFormat() =>
FileFormat.FindByExtension(Extension);
public static FileExtension Find(string extension)=>
FileFormat.FindExtension(extension);
#endregion
}
}