client/src/Iri.Modernisation.Controls/View/HeaderProduction/HeaderProductionPartControler.xaml.cs
changeset 27 f292db96b050
parent 16 dde0338cb539
child 38 bd33267300aa
equal deleted inserted replaced
26:44a2dc869e28 27:f292db96b050
    11 namespace Iri.Modernisation.Controls.View
    11 namespace Iri.Modernisation.Controls.View
    12 {
    12 {
    13 	public partial class HeaderProductionPartControler : UserControl
    13 	public partial class HeaderProductionPartControler : UserControl
    14 	{
    14 	{
    15 
    15 
       
    16 		public bool HighLighted
       
    17         {
       
    18             get { return (bool)GetValue(HighLightProperty); }
       
    19             set { 
       
    20                 
       
    21                 SetValue(HighLightProperty, value); 
       
    22             }
       
    23         }
    16 
    24 
       
    25         // Using a DependencyProperty as the backing store for HighLight.  This enables animation, styling, binding, etc...
       
    26         public static readonly DependencyProperty HighLightProperty =
       
    27             DependencyProperty.Register("HighLighted", typeof(bool), typeof(HeaderProductionPartControler), new PropertyMetadata(new PropertyChangedCallback(HighLightChange)));
       
    28         private static void HighLightChange(DependencyObject sender, DependencyPropertyChangedEventArgs e)
       
    29         {
    17 
    30 
    18         public bool IsActive
    31             if((bool)e.NewValue)
       
    32             {
       
    33                 ((HeaderProductionPartControler)sender).Select();
       
    34             }
       
    35             else
       
    36             {
       
    37                 ((HeaderProductionPartControler)sender).UnSelect();
       
    38             }
       
    39         }
       
    40         public bool Active
    19         {
    41         {
    20             get { return (bool)GetValue(IsActiveProperty); }
    42             get { return (bool)GetValue(ActiveProperty); }
    21             set 
    43             set 
    22             { 
    44             { 
    23                 
    45                 
       
    46                
       
    47                 SetValue(ActiveProperty, value);
    24                 if (value)
    48                 if (value)
    25                 {
    49                 {
    26                     Active();
    50                     Activate();
       
    51                     if (HighLighted)
       
    52                     {
       
    53                         Select();
       
    54                     }
    27                 }
    55                 }
    28                 else
    56                 else
    29                 {
    57                 {
    30                 }
    58                 }
    31                 SetValue(IsActiveProperty, value);
       
    32             }
    59             }
    33         }
    60         }
    34 
    61 
    35         // Using a DependencyProperty as the backing store for IsActive.  This enables animation, styling, binding, etc...
    62         // Using a DependencyProperty as the backing store for IsActive.  This enables animation, styling, binding, etc...
    36         public static readonly DependencyProperty IsActiveProperty =
    63         public  static readonly DependencyProperty ActiveProperty =
    37             DependencyProperty.Register("IsActive", typeof(bool), typeof(HeaderProductionPartControler), new PropertyMetadata(false));
    64             DependencyProperty.Register("Active", typeof(bool), typeof(HeaderProductionPartControler), new PropertyMetadata(new PropertyChangedCallback(ItemsSourceChanged)));
       
    65         private static void ItemsSourceChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
       
    66         {
       
    67 
       
    68             ((HeaderProductionPartControler)sender).Active =(bool)e.NewValue;
       
    69         }
       
    70 
    38 
    71 
    39 
    72 
    40 
    73 
    41         public String Text
    74         public String Text
    42         {
    75         {
    55 		
    88 		
    56 		public HeaderProductionPartControler()
    89 		public HeaderProductionPartControler()
    57 		{
    90 		{
    58 			// Required to initialize variables
    91 			// Required to initialize variables
    59 			InitializeComponent();
    92 			InitializeComponent();
    60             IsActive = false;
    93            
    61 			_activated = false;
    94 			_activated = false;
    62 			_finished= false;
    95 			_finished= false;
    63           
    96           
    64             
    97             
    65            
    98            
    67 		}
   100 		}
    68 		
   101 		
    69         private bool _activated;
   102         private bool _activated;
    70 		private bool _finished;
   103 		private bool _finished;
    71 		
   104 		
    72 		public void Active()
   105 		public void Activate()
    73 		{
   106 		{
    74 			if(!_activated && !_finished)
   107 			if(!_activated && !_finished)
    75 			{
   108 			{
    76 				VisualStateManager.GoToState(this,"Available",true);
   109 				VisualStateManager.GoToState(this,"Available",true);
    77 				_activated=true;
   110 				_activated=true;
    79             
   112             
    80 		}
   113 		}
    81 		
   114 		
    82 		public void UnSelect()
   115 		public void UnSelect()
    83 		{
   116 		{
    84 			if(_activated && !_finished)
   117             if (_activated && !_finished)
    85 			VisualStateManager.GoToState(this,"Available",true);
   118             {
       
   119                 VisualStateManager.GoToState(this, "Available", true);
       
   120             }
    86 		}
   121 		}
    87 		private void Button_MouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
   122 		private void Button_MouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
    88 		{
   123 		{
    89            
   124            
    90 		
   125 		
   117             {
   152             {
   118                 if (HeaderProductionPartSelected != null)
   153                 if (HeaderProductionPartSelected != null)
   119                     HeaderProductionPartSelected(this, new HeaderProductionPartControlerEventArgs(this));
   154                     HeaderProductionPartSelected(this, new HeaderProductionPartControlerEventArgs(this));
   120             }
   155             }
   121         }
   156         }
   122         public event EventHandler<HeaderProductionPartControlerEventArgs> HeaderProductionPartUnSelected;
       
   123         public event EventHandler<HeaderProductionPartControlerEventArgs> HeaderProductionPartFinished;
   157         public event EventHandler<HeaderProductionPartControlerEventArgs> HeaderProductionPartFinished;
   124         public event EventHandler<HeaderProductionPartControlerEventArgs> HeaderProductionPartSelected;
   158         public event EventHandler<HeaderProductionPartControlerEventArgs> HeaderProductionPartSelected;
   125 	}
   159 	}
   126 
   160 
   127     public class HeaderProductionPartControlerEventArgs : EventArgs
   161     public class HeaderProductionPartControlerEventArgs : EventArgs