mirror of
https://github.com/riegera2412/UVtools.git
synced 2026-07-11 19:12:31 +02:00
6d661821b5
* (Add) Changelog description to the new version update dialog * (Add) Tool - Infill: Proper configurable infills * (Add) Pixel area as "px²" to the layer bounds and ROI at layer bottom information bar * (Add) Pixel dimming: Alternate pattern every x layers * (Add) Pixel dimming: Lattice infill * (Add) Solidify: Required minimum/maximum area to solidify found areas (Default values will produce the old behaviour) * (Add) Issues: Allow to hide and ignore selected issues * (Add) Issue - Touch boundary: Allow to configure Left, Top, Right, Bottom margins in pixels, defaults to 5px (#94) * (Add) UVJ: Allow convert to another formats (#96) * (Add) Setters to some internal Core properties for more abstraction * (Improvement) Issue - Touch boundary: Only check boundary pixels if layer bounds overlap the set margins, otherwise, it will not waste cycles on check individual rows of pixels when not need to * (Change) Place .ctb extension show first than .cbddlp due more popular this days * (Change) Pixel dimming: Text "Borders" to "Walls" * (Change) Issues: Remove "Remove" text from button, keep only the icon to free up space * (Change) Ungroup extensions on "covert to" menu (#97) * (Fix) Issues: Detect button has a incorrect "save" icon * (Fix) SL1: Increase NumSlow property limit * (Fix) UVJ: not decoding nor showing preview images * (Fix) "Convert to" menu shows same options than previous loaded file when current file dont support convertions (#96) * (Fix) Hides "Convert to" menu when unable to convert to another format (#96) * (Fix) Program crash when demo file is disabled and tries to load a file in * (Fix) Rare crash on startup when mouse dont move in startup period and user types a key in meanwhile * (Fix) On a slow startup on progress window it will show "Decoded layers" as default text, changed to "Initializing"
107 lines
3.2 KiB
C#
107 lines
3.2 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.Collections.Generic;
|
|
|
|
namespace UVtools.Core.FileFormats
|
|
{
|
|
/// <summary>
|
|
/// Represents a file extension for slicer file formats
|
|
/// </summary>
|
|
public sealed class FileExtension
|
|
{
|
|
#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 $"{nameof(Extension)}: {Extension}, {nameof(Description)}: {Description}";
|
|
}
|
|
|
|
private bool Equals(FileExtension other)
|
|
{
|
|
return Extension == other.Extension;
|
|
}
|
|
|
|
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()
|
|
{
|
|
return FileFormat.FindByExtension(Extension);
|
|
}
|
|
#endregion
|
|
}
|
|
}
|