Develop and Download Open Source Software

Browse Subversion Repository

Contents of /branches/ProcessWatchImpl/Scone/ControlEnable.cs

Parent Directory Parent Directory | Revision Log Revision Log


Revision 44 - (show annotations) (download)
Tue Dec 15 16:20:54 2009 UTC (14 years, 3 months ago) by netseed
File size: 1163 byte(s)


1 using System.Windows;
2 using System.Windows.Controls;
3 using System.Windows.Interactivity;
4
5 namespace Toast.Scone
6 {
7 //
8 // Action のターゲット要素をその親以外にしたい場合、クラスを
9 // TriggerAction の代わりに TargetedTriggerAction から拡張します
10 //
11 public class ControlEnable : TargetedTriggerAction<Control>
12 {
13 public ControlEnable()
14 {
15 //no need to initialize.
16 }
17
18 protected override void Invoke(object o)
19 {
20 RoutedPropertyChangedEventArgs<bool> e = o as RoutedPropertyChangedEventArgs<bool>;
21
22 if (e == null)
23 {
24 throw new SeedCreate.InconsistencyException("argument type mismatch");
25 }
26
27 if (IsInvert)
28 {
29 Target.IsEnabled = !e.NewValue;
30 }
31 else
32 {
33 Target.IsEnabled = e.NewValue;
34 }
35 }
36
37 public readonly static DependencyProperty IsInvertProperty =
38 DependencyProperty.Register("IsInvert", typeof(bool), typeof(ControlEnable),
39 new UIPropertyMetadata(false));
40
41 public bool IsInvert
42 {
43 get
44 {
45 return (bool)GetValue(IsInvertProperty);
46 }
47 set
48 {
49 SetValue(IsInvertProperty, value);
50 }
51 }
52 }
53 }

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26