// // RuleControl.xaml.cs // // Author: // Jacob Johnston (jacobj@inchoatethoughts.com) // // Copyright (C) 2009 Jacob Johnston // // 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 Lesser 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 . using System.Windows; using System.Windows.Controls; using System.Windows.Data; namespace ZenLibrary { /// /// Interaction logic for RuleControl.xaml /// public partial class RuleControl : UserControl { private Rule rule; public RuleControl(Rule rule) { InitializeComponent(); this.Rule = rule; // Bind the enabled property Binding ruleEnabledBinding = new Binding("IsEnabled"); ruleEnabledBinding.Source = rule; ruleCheck.SetBinding(CheckBox.IsCheckedProperty, ruleEnabledBinding); // Bind the rule name Binding ruleNameBinding = new Binding("Name"); ruleNameBinding.Source = rule; ruleLabel.SetBinding(AccessText.TextProperty, ruleNameBinding); } public Rule Rule { get { return rule; } set { rule = value; if (rule is ConfigurableRule) { configureButton.Visibility = Visibility.Visible; ruleCheck.Margin = new Thickness(0.0d, 0.0d, 75.0d, 0.0d); } else { configureButton.Visibility = Visibility.Hidden; ruleCheck.Margin = new Thickness(0.0d, 0.0d, 0.0d, 0.0d); } } } private void configureButton_Click(object sender, RoutedEventArgs e) { ((ConfigurableRule)rule).Configure(); } } }