public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { Visibility rv = Visibility.Visible; if (value != null) { TriStateBoolean theValue = (TriStateBoolean)value; if (theValue.HasValue) { if (theValue.IsFalse) { rv = Visibility.Hidden; } } } return(rv); }
/// <summary> /// Retrieve the indicated integer value from the Windows Registry, from under subkeyPath (which is under BaseKeyPath). /// If the retrieval fails then the provided default value is returned. /// </summary> /// <param name="valueName">the name of the Registry value to retrieve it from</param> /// <param name="defaultValue">the default value to return if the retrieval fails</param> /// <param name="subkeyPath">the Registry subkey (under BaseKeyPath) under which to retrieve it from</param> /// <returns>The value from the Registry, or the default value if there's a failure</returns> protected TriStateBoolean GetTriStateBoolean(string valueName, bool?defaultValue, string subkeyPath = null) { TriStateBoolean result = TriStateBoolean.From(defaultValue); int integerDefaultValue = result.NumericValue; using (var registryKey = this.OpenSubkeyUnderBasekey(false, subkeyPath)) { if (registryKey != null) { int integerValue = (int)registryKey.GetValue(valueName, integerDefaultValue); result = TriStateBoolean.From(integerValue); } else { Console.WriteLine("in RegistryBase.GetTriStateBoolean(" + valueName + ",), access failed so returning the default value."); } } return(result); }