client/src/Iri.Modernisation.Controls/View/HeaderProduction/HeaderProductionPartControler.xaml.cs
changeset 27 f292db96b050
parent 16 dde0338cb539
child 38 bd33267300aa
--- a/client/src/Iri.Modernisation.Controls/View/HeaderProduction/HeaderProductionPartControler.xaml.cs	Tue Dec 22 16:22:22 2009 +0100
+++ b/client/src/Iri.Modernisation.Controls/View/HeaderProduction/HeaderProductionPartControler.xaml.cs	Mon Jan 04 10:29:39 2010 +0100
@@ -13,28 +13,61 @@
 	public partial class HeaderProductionPartControler : UserControl
 	{
 
-
+		public bool HighLighted
+        {
+            get { return (bool)GetValue(HighLightProperty); }
+            set { 
+                
+                SetValue(HighLightProperty, value); 
+            }
+        }
 
-        public bool IsActive
+        // Using a DependencyProperty as the backing store for HighLight.  This enables animation, styling, binding, etc...
+        public static readonly DependencyProperty HighLightProperty =
+            DependencyProperty.Register("HighLighted", typeof(bool), typeof(HeaderProductionPartControler), new PropertyMetadata(new PropertyChangedCallback(HighLightChange)));
+        private static void HighLightChange(DependencyObject sender, DependencyPropertyChangedEventArgs e)
         {
-            get { return (bool)GetValue(IsActiveProperty); }
+
+            if((bool)e.NewValue)
+            {
+                ((HeaderProductionPartControler)sender).Select();
+            }
+            else
+            {
+                ((HeaderProductionPartControler)sender).UnSelect();
+            }
+        }
+        public bool Active
+        {
+            get { return (bool)GetValue(ActiveProperty); }
             set 
             { 
                 
+               
+                SetValue(ActiveProperty, value);
                 if (value)
                 {
-                    Active();
+                    Activate();
+                    if (HighLighted)
+                    {
+                        Select();
+                    }
                 }
                 else
                 {
                 }
-                SetValue(IsActiveProperty, value);
             }
         }
 
         // Using a DependencyProperty as the backing store for IsActive.  This enables animation, styling, binding, etc...
-        public static readonly DependencyProperty IsActiveProperty =
-            DependencyProperty.Register("IsActive", typeof(bool), typeof(HeaderProductionPartControler), new PropertyMetadata(false));
+        public  static readonly DependencyProperty ActiveProperty =
+            DependencyProperty.Register("Active", typeof(bool), typeof(HeaderProductionPartControler), new PropertyMetadata(new PropertyChangedCallback(ItemsSourceChanged)));
+        private static void ItemsSourceChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
+        {
+
+            ((HeaderProductionPartControler)sender).Active =(bool)e.NewValue;
+        }
+
 
 
 
@@ -57,7 +90,7 @@
 		{
 			// Required to initialize variables
 			InitializeComponent();
-            IsActive = false;
+           
 			_activated = false;
 			_finished= false;
           
@@ -69,7 +102,7 @@
         private bool _activated;
 		private bool _finished;
 		
-		public void Active()
+		public void Activate()
 		{
 			if(!_activated && !_finished)
 			{
@@ -81,8 +114,10 @@
 		
 		public void UnSelect()
 		{
-			if(_activated && !_finished)
-			VisualStateManager.GoToState(this,"Available",true);
+            if (_activated && !_finished)
+            {
+                VisualStateManager.GoToState(this, "Available", true);
+            }
 		}
 		private void Button_MouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
 		{
@@ -119,7 +154,6 @@
                     HeaderProductionPartSelected(this, new HeaderProductionPartControlerEventArgs(this));
             }
         }
-        public event EventHandler<HeaderProductionPartControlerEventArgs> HeaderProductionPartUnSelected;
         public event EventHandler<HeaderProductionPartControlerEventArgs> HeaderProductionPartFinished;
         public event EventHandler<HeaderProductionPartControlerEventArgs> HeaderProductionPartSelected;
 	}