39 lines
1.5 KiB
Plaintext
39 lines
1.5 KiB
Plaintext
|
|
using DTS.Common.Enums;
|
||
|
|
using DTS.Common.Enums.DASFactory;
|
||
|
|
using System;
|
||
|
|
using System.Windows;
|
||
|
|
using System.Windows.Data;
|
||
|
|
|
||
|
|
namespace DTS.Common.Converters
|
||
|
|
{
|
||
|
|
/// <summary>
|
||
|
|
/// This converter will returns a visibility based on whether pretrigger should be shown or not
|
||
|
|
/// it should be bound to RecordingMode an optional parameter allows inverting the return
|
||
|
|
/// </summary>
|
||
|
|
public class RecordingModePreTriggerVisibilityConverter : IValueConverter
|
||
|
|
{
|
||
|
|
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
|
||
|
|
{
|
||
|
|
var showPreTrigger = true;
|
||
|
|
if ((value is RecordingModes mode) &&
|
||
|
|
(RecordingModeExtensions.IsAnActiveMode(mode) || !RecordingModeExtensions.CanProgramPreTrigger(mode)))
|
||
|
|
{
|
||
|
|
showPreTrigger = false;
|
||
|
|
}
|
||
|
|
|
||
|
|
var invert = false;
|
||
|
|
if (bool.TrueString.Equals(parameter)) { invert = true; }
|
||
|
|
if (showPreTrigger)
|
||
|
|
{
|
||
|
|
return invert ? Visibility.Collapsed : Visibility.Visible;
|
||
|
|
}
|
||
|
|
else { return invert ? Visibility.Visible : Visibility.Collapsed; }
|
||
|
|
}
|
||
|
|
|
||
|
|
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
|
||
|
|
{
|
||
|
|
return null != value && value.Equals(Visibility.Visible) ? parameter : Binding.DoNothing;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|