using System.Collections; using System.Windows; using System.Windows.Data; namespace Developpez.Dotnet.Windows.Controls { /// /// Représente un champ de formulaire lié aux données /// public abstract class BoundFormField : FormField { private BindingBase _binding; /// /// Obtient ou définit le Binding qui produit la valeur du champ /// public BindingBase Binding { get { return _binding; } set { _binding = value; SetBinding(ValueProperty, value); } } /// /// Obtient ou définit la valeur actuelle du champ /// /// N'affectez pas explicitement une valeur à cette propriété; /// elle sera gérée automatiquement par la classe BoundFormField. Le seul /// cas où elle doit être utilisée est pour obtenir la valeur actuelle du /// champ dans les templates via un binding. public object Value { get { return GetValue(ValueProperty); } set { SetValue(ValueProperty, value); } } /// /// Identifiant de la propriété Value /// public static readonly DependencyProperty ValueProperty = DependencyProperty.Register( "Value", typeof(object), typeof(BoundFormField), new FrameworkPropertyMetadata( null, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault)); } /// /// Représente un champ de formulaire qui affiche ou modifie une donnée textuelle /// sous forme d'une boite de texte. /// public class TextFormField : BoundFormField { static TextFormField() { DefaultStyleKeyProperty.OverrideMetadata( typeof(TextFormField), new FrameworkPropertyMetadata(typeof(TextFormField))); } } /// /// Représente un champ de formulaire qui afficher ou modifie une donnée booléenne /// sous forme d'une case à cocher. /// public class CheckBoxFormField : BoundFormField { static CheckBoxFormField() { DefaultStyleKeyProperty.OverrideMetadata(typeof(CheckBoxFormField), new FrameworkPropertyMetadata(typeof(CheckBoxFormField))); } /// /// Obtient ou définit une valeur indiquant si la case à cocher a 3 états (coché, non coché, indéterminé) /// public bool IsThreeState { get { return (bool)GetValue(IsThreeStateProperty); } set { SetValue(IsThreeStateProperty, value); } } /// /// Identifiant de la propriété IsThreeState /// public static readonly DependencyProperty IsThreeStateProperty = DependencyProperty.Register("IsThreeState", typeof(bool), typeof(CheckBoxFormField), new UIPropertyMetadata(false)); } /// /// Représente un champ de formulaire qui affiche ou modifie une donnée à /// choisir dans une liste, sous forme d'une liste déroulante. /// public class ComboBoxFormField : BoundFormField { static ComboBoxFormField() { DefaultStyleKeyProperty.OverrideMetadata(typeof(ComboBoxFormField), new FrameworkPropertyMetadata(typeof(ComboBoxFormField))); } /// /// Obtient ou définit la liste des valeurs à afficher dans la liste déroulante. /// public IEnumerable ItemsSource { get { return (IEnumerable)GetValue(ItemsSourceProperty); } set { SetValue(ItemsSourceProperty, value); } } /// /// Identifiant de la propriété ItemsSource /// public static readonly DependencyProperty ItemsSourceProperty = DependencyProperty.Register("ItemsSource", typeof(IEnumerable), typeof(ComboBoxFormField), new UIPropertyMetadata(null)); /// /// Obtient ou définit le style des éléments de la liste déroulante /// public Style ItemContainerStyle { get { return (Style)GetValue(ItemContainerStyleProperty); } set { SetValue(ItemContainerStyleProperty, value); } } /// /// Identifiant de la propriété ItemContainerStyle /// public static readonly DependencyProperty ItemContainerStyleProperty = DependencyProperty.Register("ItemContainerStyle", typeof(Style), typeof(ComboBoxFormField), new UIPropertyMetadata(null)); /// /// Obtient ou définit le modèle pour les éléments de la liste déroulante /// public DataTemplate ItemTemplate { get { return (DataTemplate)GetValue(ItemTemplateProperty); } set { SetValue(ItemTemplateProperty, value); } } /// /// Identifiant de la propriété ItemTemplate /// public static readonly DependencyProperty ItemTemplateProperty = DependencyProperty.Register("ItemTemplate", typeof(DataTemplate), typeof(ComboBoxFormField), new UIPropertyMetadata(null)); /// /// Obtient ou définit le membre à afficher pour les éléments de la liste déroulante /// public string DisplayMemberPath { get { return (string)GetValue(DisplayMemberPathProperty); } set { SetValue(DisplayMemberPathProperty, value); } } /// /// Identifiant de la propriété DisplayMemberPath /// public static readonly DependencyProperty DisplayMemberPathProperty = DependencyProperty.Register("DisplayMemberPath", typeof(string), typeof(ComboBoxFormField), new UIPropertyMetadata(null)); } /// /// Représente un champ de formulaire qui affiche ou modifie un mot de passe. /// public class PasswordBoxFormField : BoundFormField { static PasswordBoxFormField() { DefaultStyleKeyProperty.OverrideMetadata(typeof(PasswordBoxFormField), new FrameworkPropertyMetadata(typeof(PasswordBoxFormField))); } } }