/*
* GNU AFFERO GENERAL PUBLIC LICENSE
* Version 3, 19 November 2007
* Copyright (C) 2007 Free Software Foundation, Inc.
* 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;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using System.Timers;
using Avalonia;
using Avalonia.Controls;
using Avalonia.Controls.Primitives;
using Avalonia.Input;
using Avalonia.Interactivity;
using Avalonia.Threading;
using Emgu.CV;
using Emgu.CV.CvEnum;
using Emgu.CV.Structure;
using Emgu.CV.Util;
using UVtools.AvaloniaControls;
using UVtools.Core;
using UVtools.Core.Extensions;
using UVtools.Core.PixelEditor;
using UVtools.WPF.Controls;
using UVtools.WPF.Extensions;
using UVtools.WPF.Structures;
using Color = UVtools.WPF.Structures.Color;
using Helpers = UVtools.WPF.Controls.Helpers;
using Point = System.Drawing.Point;
using Size = System.Drawing.Size;
namespace UVtools.WPF
{
public partial class MainWindow
{
#region Enum
public enum ZoomToFitType : byte
{
Auto,
Image,
Volume,
Selection
};
#endregion
public AdvancedImageBox LayerImageBox { get; private set; }
public Slider LayerSlider;
public Track LayerSlicerTrack;
public Panel LayerNavigationTooltipPanel;
public Border LayerNavigationTooltipBorder;
private Canvas _issuesSliderCanvas;
private Timer _layerNavigationTooltipTimer = new(0.1) { AutoReset = false };
private uint _actualLayer;
private bool _showLayerImageRotated;
private bool _showLayerImageRotateCwDirection = true;
private bool _showLayerImageRotateCcwDirection;
private bool _showLayerImageFlipped;
private bool _showLayerImageFlippedHorizontally = true;
private bool _showLayerImageFlippedVertically;
private bool _showLayerImageDifference;
private bool _showLayerImageIssues = true;
private bool _showLayerImageCrosshairs = true;
private bool _isPixelEditorActive;
private bool _showLayerOutlinePrintVolumeBoundary;
private bool _showLayerOutlineLayerBoundary;
private bool _showLayerOutlineHollowAreas;
private bool _showLayerOutlineEdgeDetection;
private bool _showLayerOutlineSkeletonize;
private bool _isTooltipOverlayVisible;
private string _tooltipOverlayText;
private long _showLayerRenderMs;
public LayerCache LayerCache = new ();
private Point _lastPixelMouseLocation = Point.Empty;
private readonly List _maskPoints = new ();
public void InitLayerPreview()
{
LayerImageBox = this.FindControl("LayerImage");
LayerSlider = this.FindControl("Layer.Navigation.Slider");
LayerNavigationTooltipPanel = this.FindControl("Layer.Navigation.Tooltip.Panel");
LayerNavigationTooltipBorder = this.FindControl("Layer.Navigation.Tooltip.Border");
_issuesSliderCanvas = this.Find