2025-10-21 01:27:29 +02:00
|
|
|
using System;
|
|
|
|
|
using CommunityToolkit.Mvvm.ComponentModel;
|
2025-10-20 21:10:29 +02:00
|
|
|
using Wino.Core.Domain.Enums;
|
|
|
|
|
|
|
|
|
|
namespace Wino.Core.Domain.Models.Printing;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Wrapper model for CoreWebView2PrintSettings that provides bindable properties for UI controls.
|
|
|
|
|
/// </summary>
|
2025-10-21 01:27:29 +02:00
|
|
|
public partial class WebView2PrintSettingsModel : ObservableObject
|
2025-10-20 21:10:29 +02:00
|
|
|
{
|
2025-10-21 01:27:29 +02:00
|
|
|
[ObservableProperty]
|
|
|
|
|
public partial string PrinterName { get; set; } = string.Empty;
|
2025-10-20 21:10:29 +02:00
|
|
|
|
2025-10-21 01:27:29 +02:00
|
|
|
[ObservableProperty]
|
|
|
|
|
public partial PrintOrientation Orientation { get; set; } = PrintOrientation.Portrait;
|
2025-10-20 21:10:29 +02:00
|
|
|
|
2025-10-21 01:27:29 +02:00
|
|
|
[ObservableProperty]
|
|
|
|
|
public partial PrintColorMode ColorMode { get; set; } = PrintColorMode.Color;
|
2025-10-20 21:10:29 +02:00
|
|
|
|
2025-10-21 01:27:29 +02:00
|
|
|
[ObservableProperty]
|
|
|
|
|
public partial PrintCollation Collation { get; set; } = PrintCollation.Default;
|
2025-10-20 21:10:29 +02:00
|
|
|
|
2025-10-21 01:27:29 +02:00
|
|
|
[ObservableProperty]
|
|
|
|
|
public partial PrintDuplex Duplex { get; set; } = PrintDuplex.Default;
|
2025-10-20 21:10:29 +02:00
|
|
|
|
2025-10-21 01:27:29 +02:00
|
|
|
[ObservableProperty]
|
|
|
|
|
public partial PrintMediaSize MediaSize { get; set; } = PrintMediaSize.Default;
|
2025-10-20 21:10:29 +02:00
|
|
|
|
2025-10-21 01:27:29 +02:00
|
|
|
[ObservableProperty]
|
|
|
|
|
public partial int Copies { get; set; } = 1;
|
2025-10-20 21:10:29 +02:00
|
|
|
|
2025-10-21 01:27:29 +02:00
|
|
|
[ObservableProperty]
|
|
|
|
|
public partial double MarginTop { get; set; } = 1.0;
|
2025-10-20 21:10:29 +02:00
|
|
|
|
2025-10-21 01:27:29 +02:00
|
|
|
[ObservableProperty]
|
|
|
|
|
public partial double MarginBottom { get; set; } = 1.0;
|
2025-10-20 21:10:29 +02:00
|
|
|
|
2025-10-21 01:27:29 +02:00
|
|
|
[ObservableProperty]
|
|
|
|
|
public partial double MarginLeft { get; set; } = 1.0;
|
2025-10-20 21:10:29 +02:00
|
|
|
|
2025-10-21 01:27:29 +02:00
|
|
|
[ObservableProperty]
|
|
|
|
|
public partial double MarginRight { get; set; } = 1.0;
|
2025-10-20 21:10:29 +02:00
|
|
|
|
2025-10-21 01:27:29 +02:00
|
|
|
[ObservableProperty]
|
|
|
|
|
public partial bool ShouldPrintBackgrounds { get; set; } = false;
|
2025-10-20 21:10:29 +02:00
|
|
|
|
2025-10-21 01:27:29 +02:00
|
|
|
[ObservableProperty]
|
|
|
|
|
public partial bool ShouldPrintSelectionOnly { get; set; } = false;
|
2025-10-20 21:10:29 +02:00
|
|
|
|
2025-10-21 01:27:29 +02:00
|
|
|
[ObservableProperty]
|
|
|
|
|
public partial bool ShouldPrintHeaderAndFooter { get; set; } = true;
|
|
|
|
|
|
|
|
|
|
[ObservableProperty]
|
|
|
|
|
public partial string HeaderTitle { get; set; } = string.Empty;
|
|
|
|
|
|
|
|
|
|
[ObservableProperty]
|
|
|
|
|
public partial string FooterUri { get; set; } = string.Empty;
|
|
|
|
|
|
|
|
|
|
[ObservableProperty]
|
|
|
|
|
public partial double ScaleFactor { get; set; } = 1.0;
|
|
|
|
|
|
|
|
|
|
[ObservableProperty]
|
|
|
|
|
public partial int PagesPerSide { get; set; } = 1;
|
|
|
|
|
|
|
|
|
|
[ObservableProperty]
|
|
|
|
|
public partial string PageRanges { get; set; } = string.Empty;
|
2025-10-20 21:10:29 +02:00
|
|
|
|
|
|
|
|
/// <summary>
|
2025-10-21 01:27:29 +02:00
|
|
|
/// Partial method for validation when Copies property changes.
|
2025-10-20 21:10:29 +02:00
|
|
|
/// </summary>
|
2025-10-21 01:27:29 +02:00
|
|
|
partial void OnCopiesChanged(int value)
|
2025-10-20 21:10:29 +02:00
|
|
|
{
|
2025-10-21 01:27:29 +02:00
|
|
|
if (value <= 0)
|
2025-10-20 21:10:29 +02:00
|
|
|
{
|
2025-10-21 01:27:29 +02:00
|
|
|
Copies = 1; // Reset to minimum valid value
|
2025-10-20 21:10:29 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2025-10-21 01:27:29 +02:00
|
|
|
/// Partial method for validation when ScaleFactor property changes.
|
2025-10-20 21:10:29 +02:00
|
|
|
/// </summary>
|
2025-10-21 01:27:29 +02:00
|
|
|
partial void OnScaleFactorChanged(double value)
|
2025-10-20 21:10:29 +02:00
|
|
|
{
|
2025-10-21 01:27:29 +02:00
|
|
|
if (value < 0.1 || value > 2.0)
|
2025-10-20 21:10:29 +02:00
|
|
|
{
|
2025-10-21 01:27:29 +02:00
|
|
|
ScaleFactor = Math.Clamp(value, 0.1, 2.0);
|
2025-10-20 21:10:29 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2025-10-21 01:27:29 +02:00
|
|
|
/// Partial method for validation when PagesPerSide property changes.
|
2025-10-20 21:10:29 +02:00
|
|
|
/// </summary>
|
2025-10-21 01:27:29 +02:00
|
|
|
partial void OnPagesPerSideChanged(int value)
|
2025-10-20 21:10:29 +02:00
|
|
|
{
|
2025-10-21 01:27:29 +02:00
|
|
|
var validValues = new[] { 1, 2, 4, 6, 9, 16 };
|
|
|
|
|
if (System.Array.IndexOf(validValues, value) < 0)
|
2025-10-20 21:10:29 +02:00
|
|
|
{
|
2025-10-21 01:27:29 +02:00
|
|
|
PagesPerSide = 1; // Reset to default valid value
|
2025-10-20 21:10:29 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2025-10-21 01:27:29 +02:00
|
|
|
/// Partial method for validation when margin properties change.
|
2025-10-20 21:10:29 +02:00
|
|
|
/// </summary>
|
2025-10-21 01:27:29 +02:00
|
|
|
partial void OnMarginTopChanged(double value)
|
2025-10-20 21:10:29 +02:00
|
|
|
{
|
2025-10-21 01:27:29 +02:00
|
|
|
if (value < 0)
|
2025-10-20 21:10:29 +02:00
|
|
|
{
|
2025-10-21 01:27:29 +02:00
|
|
|
MarginTop = 0;
|
2025-10-20 21:10:29 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-10-21 01:27:29 +02:00
|
|
|
partial void OnMarginBottomChanged(double value)
|
2025-10-20 21:10:29 +02:00
|
|
|
{
|
2025-10-21 01:27:29 +02:00
|
|
|
if (value < 0)
|
2025-10-20 21:10:29 +02:00
|
|
|
{
|
2025-10-21 01:27:29 +02:00
|
|
|
MarginBottom = 0;
|
2025-10-20 21:10:29 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-10-21 01:27:29 +02:00
|
|
|
partial void OnMarginLeftChanged(double value)
|
2025-10-20 21:10:29 +02:00
|
|
|
{
|
2025-10-21 01:27:29 +02:00
|
|
|
if (value < 0)
|
2025-10-20 21:10:29 +02:00
|
|
|
{
|
2025-10-21 01:27:29 +02:00
|
|
|
MarginLeft = 0;
|
2025-10-20 21:10:29 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-10-21 01:27:29 +02:00
|
|
|
partial void OnMarginRightChanged(double value)
|
2025-10-20 21:10:29 +02:00
|
|
|
{
|
2025-10-21 01:27:29 +02:00
|
|
|
if (value < 0)
|
2025-10-20 21:10:29 +02:00
|
|
|
{
|
2025-10-21 01:27:29 +02:00
|
|
|
MarginRight = 0;
|
2025-10-20 21:10:29 +02:00
|
|
|
}
|
|
|
|
|
}
|
2025-10-21 01:27:29 +02:00
|
|
|
}
|