- Olbert_Utilities.zip
- Olbert.Utilities
- CryptorLib
- documentation
- bin
- Content Layout.content
- Creative Commons Attribution Share Alike.aml
- Cryptor Overview.aml
- GLPL.aml
- GPL.aml
- Licenses.aml
- Miscellaneous Utilities Overview.aml
- nHydrate Installer Overview.aml
- nHydrate Utilities.aml
- Olbert.Utils.shfbproj
- Open Source License v3.aml
- overview.aml
- Release Notes.aml
- Wizard Framework.aml
- WPF Utilities.aml
- MiscUtilities
- MiscUtilitiesCore
- nHydrateInstaller
- nHydrateUtils
- NotMine
- NotMineWPF
- OlbertUtilities.sln
- OlbertUtilities.suo
- WPFUtilities
- WPFWizard
|
/*
* Olbert.Utils.WPF
* Converters and Validators for use in WPF applications
* Copyright (C) 2011 Mark A. Olbert
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Data;
namespace Olbert.Utilities.WPF
{
/// <summary>
/// Does a logical OR on all the values given to it for conversion, which should be booleans
/// (if a value isn't a boolean, it's treated as a false by default)
/// </summary>
public class AnyTrueConverter : IMultiValueConverter
{
/// <summary>
/// Returns true if at least one of the values being checked is a boolean true. Non-boolean values
/// are interpreted as false.
/// </summary>
/// <param name="values">the values to be converted</param>
/// <param name="targetType">ignored</param>
/// <param name="parameter">ignored</param>
/// <param name="culture">ignored</param>
/// <returns>true if at least one of the supplied values is true, false otherwise</returns>
public object Convert( object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture )
{
bool curBool = false;
foreach( object curVal in values )
{
if( curVal is bool ) curBool = (bool) curVal;
else curBool = false;
if( curBool ) return true;
}
return false;
}
/// <summary>
/// Not implemented, because there's no way to know what kind of objects the supplied value was
/// originally derived from. Throws a NotImplementedException.
/// </summary>
/// <param name="value">ignored</param>
/// <param name="targetTypes">ignored</param>
/// <param name="parameter">ignored</param>
/// <param name="culture">ignored</param>
/// <returns>not applicable</returns>
public object[] ConvertBack( object value, Type[] targetTypes, object parameter, System.Globalization.CultureInfo culture )
{
throw new NotImplementedException();
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
Some people like to do crossword puzzles to hone their problem-solving skills. Me, I like to write software for the same reason.
A few years back I passed my 50th anniversary of programming. I believe that means it's officially more than a hobby or pastime. In fact, it may qualify as an addiction
.
I mostly work in C# and Windows. But I also play around with Linux (mostly Debian on Raspberry Pis) and Python.