client/src/Iri.Modernisation.Controls/View/HeaderProduction/HeaderProductionPartControler.xaml.cs
changeset 16 dde0338cb539
child 27 f292db96b050
equal deleted inserted replaced
15:3f70aee2432f 16:dde0338cb539
       
     1 using System;
       
     2 using System.Windows;
       
     3 using System.Windows.Controls;
       
     4 using System.Windows.Documents;
       
     5 using System.Windows.Ink;
       
     6 using System.Windows.Input;
       
     7 using System.Windows.Media;
       
     8 using System.Windows.Media.Animation;
       
     9 using System.Windows.Shapes;
       
    10 using System.Windows.Data;
       
    11 namespace Iri.Modernisation.Controls.View
       
    12 {
       
    13 	public partial class HeaderProductionPartControler : UserControl
       
    14 	{
       
    15 
       
    16 
       
    17 
       
    18         public bool IsActive
       
    19         {
       
    20             get { return (bool)GetValue(IsActiveProperty); }
       
    21             set 
       
    22             { 
       
    23                 
       
    24                 if (value)
       
    25                 {
       
    26                     Active();
       
    27                 }
       
    28                 else
       
    29                 {
       
    30                 }
       
    31                 SetValue(IsActiveProperty, value);
       
    32             }
       
    33         }
       
    34 
       
    35         // Using a DependencyProperty as the backing store for IsActive.  This enables animation, styling, binding, etc...
       
    36         public static readonly DependencyProperty IsActiveProperty =
       
    37             DependencyProperty.Register("IsActive", typeof(bool), typeof(HeaderProductionPartControler), new PropertyMetadata(false));
       
    38 
       
    39 
       
    40 
       
    41         public String Text
       
    42         {
       
    43             get { return (String)GetValue(TextProperty); }
       
    44             set 
       
    45             { SetValue(TextProperty, value); 
       
    46                 textBlock.Text = value; 
       
    47             }
       
    48         }
       
    49             
       
    50         // Using a DependencyProperty as the backing store for Text.  This enables animation, styling, binding, etc...
       
    51         public static readonly DependencyProperty TextProperty =
       
    52             DependencyProperty.Register("Text", typeof(String), typeof(HeaderProductionPartControler), new PropertyMetadata(""));
       
    53 
       
    54 
       
    55 		
       
    56 		public HeaderProductionPartControler()
       
    57 		{
       
    58 			// Required to initialize variables
       
    59 			InitializeComponent();
       
    60             IsActive = false;
       
    61 			_activated = false;
       
    62 			_finished= false;
       
    63           
       
    64             
       
    65            
       
    66 
       
    67 		}
       
    68 		
       
    69         private bool _activated;
       
    70 		private bool _finished;
       
    71 		
       
    72 		public void Active()
       
    73 		{
       
    74 			if(!_activated && !_finished)
       
    75 			{
       
    76 				VisualStateManager.GoToState(this,"Available",true);
       
    77 				_activated=true;
       
    78 			}
       
    79             
       
    80 		}
       
    81 		
       
    82 		public void UnSelect()
       
    83 		{
       
    84 			if(_activated && !_finished)
       
    85 			VisualStateManager.GoToState(this,"Available",true);
       
    86 		}
       
    87 		private void Button_MouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
       
    88 		{
       
    89            
       
    90 		
       
    91 		}
       
    92 
       
    93 		private void but_Click(object sender, System.Windows.RoutedEventArgs e)
       
    94 		{
       
    95 		     	
       
    96 				if(_activated)
       
    97 				{
       
    98 					VisualStateManager.GoToState(this,"Finished",true);
       
    99                     if (HeaderProductionPartFinished!=null)
       
   100                     {
       
   101                       HeaderProductionPartFinished(this, new HeaderProductionPartControlerEventArgs(sender));
       
   102                     }
       
   103 					_finished=true;
       
   104                     
       
   105 				}
       
   106 		}
       
   107         public void Select()
       
   108         {
       
   109             if (_activated && !_finished)
       
   110             {
       
   111                 VisualStateManager.GoToState(this, "Selected", true);
       
   112             }
       
   113         }
       
   114 		private void textBlock_MouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
       
   115 		{
       
   116             if (_activated && !_finished)
       
   117             {
       
   118                 if (HeaderProductionPartSelected != null)
       
   119                     HeaderProductionPartSelected(this, new HeaderProductionPartControlerEventArgs(this));
       
   120             }
       
   121         }
       
   122         public event EventHandler<HeaderProductionPartControlerEventArgs> HeaderProductionPartUnSelected;
       
   123         public event EventHandler<HeaderProductionPartControlerEventArgs> HeaderProductionPartFinished;
       
   124         public event EventHandler<HeaderProductionPartControlerEventArgs> HeaderProductionPartSelected;
       
   125 	}
       
   126 
       
   127     public class HeaderProductionPartControlerEventArgs : EventArgs
       
   128     {
       
   129         public object sender { get; set; }
       
   130         public HeaderProductionPartControlerEventArgs(object psender)
       
   131         {
       
   132             sender = psender;
       
   133         }
       
   134 
       
   135     }
       
   136 }