using System; using System.Collections.Generic; using System.Globalization; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows; namespace Szmedi.AIScriptRunner.Converters { /// /// Converts a of a window into an enabled state of an according caption button. /// public class WindowCaptionButtonEnabledConverter : WindowCaptionButtonBaseConverter { /// /// Creates a new . /// public WindowCaptionButtonEnabledConverter() : base() { } public override object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) { try { if (values != null && values.Length == 2) { string buttonName = (string)values[0]; ResizeMode resizeMode = (ResizeMode)values[1]; if (buttonName == CloseButtonName) { return true; } else if (buttonName == MinimizeButtonName) { return resizeMode != ResizeMode.NoResize; } else if (buttonName == MaximizeRestoreButtonName) { return resizeMode != ResizeMode.NoResize && resizeMode != ResizeMode.CanMinimize; } } } catch (Exception) { // use the default return value below } return true; } } }