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