Permalink
Browse files

Added Enable Property

  • Loading branch information...
1 parent 9b68559 commit c0d634bd0837cf8122531afdc1479a138ee1bb4e @mogikanin mogikanin committed Feb 19, 2013
Showing with 26 additions and 0 deletions.
  1. +26 −0 Fleux/UIElements/UIElement.cs
@@ -24,6 +24,7 @@ public UIElement()
// Default transformation parameters
this.TransformationScaling = 1.0;
this.TransformationCenter = new Point(0, 0);
+ Enabled = true;
}
public event EventHandler<SizeChangedEventArgs> SizeChanged;
@@ -34,6 +35,7 @@ public UIElement()
public bool PreTap = false;
private Point location;
+ private bool _enabled;
public Point Location
{
@@ -131,6 +133,20 @@ public virtual Rectangle Bounds
public UIElement Parent { get; set; }
+ /// <summary>
+ /// Gets or sets boolean indicating whether the UIElememt can respond to user interaction.
+ /// </summary>
+ public bool Enabled
+ {
+ get { return _enabled; }
+ set
+ {
+ if (_enabled == value) return;
+ _enabled = value;
+ Update();
+ }
+ }
+
public IEnumerable<UIElement> ChildrenEnumerable
{
get
@@ -230,6 +246,11 @@ public virtual Point ApplyTransformation(Point source)
public virtual bool Tap(Point p)
{
+ if (!Enabled)
+ {
+ return false;
+ }
+
bool handled = false;
if (PreTap && this.TapHandler != null)
{
@@ -247,6 +268,11 @@ public virtual bool Tap(Point p)
public virtual bool DoubleTap(Point p)
{
+ if (!Enabled)
+ {
+ return false;
+ }
+
bool handled = this.TraverseHandle(this.ApplyTransformation(p),
el => el.DoubleTap(this.ApplyTransformation(p).ClientTo(this.ApplyTransformation(el.Location))));
if (!handled && this.DoubleTapHandler != null)

0 comments on commit c0d634b

Please sign in to comment.