mirror of
https://github.com/Microsoft/calculator.git
synced 2025-07-30 19:40:00 -07:00
This is to make the style consistent with the rest of the project as well as removing unused imports.
54 lines
2 KiB
C#
54 lines
2 KiB
C#
// Copyright (c) Microsoft Corporation. All rights reserved.
|
|
// Licensed under the MIT License.
|
|
|
|
using System;
|
|
|
|
using Windows.UI.Xaml;
|
|
|
|
namespace CalculatorApp
|
|
{
|
|
namespace Converters
|
|
{
|
|
/// <summary>
|
|
/// Value converter that translates true to <see cref="Visibility.Visible"/> and false
|
|
/// to <see cref="Visibility.Collapsed"/>.
|
|
/// </summary>
|
|
public sealed class BooleanToVisibilityConverter : Windows.UI.Xaml.Data.IValueConverter
|
|
{
|
|
public static Windows.UI.Xaml.Visibility Convert(bool visibility)
|
|
{
|
|
return visibility ? Windows.UI.Xaml.Visibility.Visible : Windows.UI.Xaml.Visibility.Collapsed;
|
|
}
|
|
|
|
public object Convert(object value, Type targetType, object parameter, string language)
|
|
{
|
|
var boolValue = (value is bool boxedBool && boxedBool);
|
|
return BooleanToVisibilityConverter.Convert(boolValue);
|
|
}
|
|
|
|
public object ConvertBack(object value, Type targetType, object parameter, string language)
|
|
{
|
|
return (value is Visibility visibility && visibility == Visibility.Visible);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Value converter that translates false to <see cref="Visibility.Visible"/> and true
|
|
/// to <see cref="Visibility.Collapsed"/>.
|
|
/// </summary>
|
|
public sealed class BooleanToVisibilityNegationConverter : Windows.UI.Xaml.Data.IValueConverter
|
|
{
|
|
public object Convert(object value, Type targetType, object parameter, string language)
|
|
{
|
|
var boolValue = (value is bool boxedBool && boxedBool);
|
|
return BooleanToVisibilityConverter.Convert(!boolValue);
|
|
}
|
|
|
|
public object ConvertBack(object value, Type targetType, object parameter, string language)
|
|
{
|
|
return (value is Visibility visibility && visibility != Visibility.Visible);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|