mirror of
http://git.xinwangdao.com/cnnc-embedded-parts-detect/detect.git
synced 2025-06-24 21:44:12 +08:00
30 lines
909 B
C#
30 lines
909 B
C#
using System;
|
|
using System.Globalization;
|
|
using Avalonia.Controls;
|
|
using Avalonia.Data.Converters;
|
|
|
|
namespace detect.gui.Converters;
|
|
|
|
public class WindowStateConverter : IValueConverter
|
|
{
|
|
public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
|
|
{
|
|
var state = value is WindowState windowState ? windowState : WindowState.Normal;
|
|
var param = int.Parse((string?)parameter ?? string.Empty);
|
|
switch (state)
|
|
{
|
|
case WindowState.Maximized when param == 1:
|
|
case WindowState.Normal when param == 2:
|
|
return true;
|
|
case WindowState.Minimized:
|
|
case WindowState.FullScreen:
|
|
default:
|
|
return false;
|
|
}
|
|
}
|
|
|
|
public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
|
|
{
|
|
return value;
|
|
}
|
|
} |