client/src/Iri.Modernisation.Controls/View/HeaderProduction/HeaderProductionPartControler.xaml.cs
author totetm <>
Thu, 04 Feb 2010 16:38:04 +0100
changeset 38 bd33267300aa
parent 27 f292db96b050
permissions -rw-r--r--
- FranceCulture Project - Ldt and Iri Parse Method - Bug MenuableUserControl
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
27
f292db96b050 Generalization of Book Structure
Matthieu Totet
parents: 16
diff changeset
    16
		public bool HighLighted
f292db96b050 Generalization of Book Structure
Matthieu Totet
parents: 16
diff changeset
    17
        {
f292db96b050 Generalization of Book Structure
Matthieu Totet
parents: 16
diff changeset
    18
            get { return (bool)GetValue(HighLightProperty); }
f292db96b050 Generalization of Book Structure
Matthieu Totet
parents: 16
diff changeset
    19
            set { 
f292db96b050 Generalization of Book Structure
Matthieu Totet
parents: 16
diff changeset
    20
                
f292db96b050 Generalization of Book Structure
Matthieu Totet
parents: 16
diff changeset
    21
                SetValue(HighLightProperty, value); 
f292db96b050 Generalization of Book Structure
Matthieu Totet
parents: 16
diff changeset
    22
            }
f292db96b050 Generalization of Book Structure
Matthieu Totet
parents: 16
diff changeset
    23
        }
16
dde0338cb539 Update ProductionView and Components
Matthieu Totet
parents:
diff changeset
    24
27
f292db96b050 Generalization of Book Structure
Matthieu Totet
parents: 16
diff changeset
    25
        // Using a DependencyProperty as the backing store for HighLight.  This enables animation, styling, binding, etc...
f292db96b050 Generalization of Book Structure
Matthieu Totet
parents: 16
diff changeset
    26
        public static readonly DependencyProperty HighLightProperty =
f292db96b050 Generalization of Book Structure
Matthieu Totet
parents: 16
diff changeset
    27
            DependencyProperty.Register("HighLighted", typeof(bool), typeof(HeaderProductionPartControler), new PropertyMetadata(new PropertyChangedCallback(HighLightChange)));
f292db96b050 Generalization of Book Structure
Matthieu Totet
parents: 16
diff changeset
    28
        private static void HighLightChange(DependencyObject sender, DependencyPropertyChangedEventArgs e)
16
dde0338cb539 Update ProductionView and Components
Matthieu Totet
parents:
diff changeset
    29
        {
27
f292db96b050 Generalization of Book Structure
Matthieu Totet
parents: 16
diff changeset
    30
f292db96b050 Generalization of Book Structure
Matthieu Totet
parents: 16
diff changeset
    31
            if((bool)e.NewValue)
f292db96b050 Generalization of Book Structure
Matthieu Totet
parents: 16
diff changeset
    32
            {
f292db96b050 Generalization of Book Structure
Matthieu Totet
parents: 16
diff changeset
    33
                ((HeaderProductionPartControler)sender).Select();
f292db96b050 Generalization of Book Structure
Matthieu Totet
parents: 16
diff changeset
    34
            }
f292db96b050 Generalization of Book Structure
Matthieu Totet
parents: 16
diff changeset
    35
            else
f292db96b050 Generalization of Book Structure
Matthieu Totet
parents: 16
diff changeset
    36
            {
f292db96b050 Generalization of Book Structure
Matthieu Totet
parents: 16
diff changeset
    37
                ((HeaderProductionPartControler)sender).UnSelect();
f292db96b050 Generalization of Book Structure
Matthieu Totet
parents: 16
diff changeset
    38
            }
f292db96b050 Generalization of Book Structure
Matthieu Totet
parents: 16
diff changeset
    39
        }
f292db96b050 Generalization of Book Structure
Matthieu Totet
parents: 16
diff changeset
    40
        public bool Active
f292db96b050 Generalization of Book Structure
Matthieu Totet
parents: 16
diff changeset
    41
        {
f292db96b050 Generalization of Book Structure
Matthieu Totet
parents: 16
diff changeset
    42
            get { return (bool)GetValue(ActiveProperty); }
16
dde0338cb539 Update ProductionView and Components
Matthieu Totet
parents:
diff changeset
    43
            set 
dde0338cb539 Update ProductionView and Components
Matthieu Totet
parents:
diff changeset
    44
            { 
dde0338cb539 Update ProductionView and Components
Matthieu Totet
parents:
diff changeset
    45
                
27
f292db96b050 Generalization of Book Structure
Matthieu Totet
parents: 16
diff changeset
    46
               
f292db96b050 Generalization of Book Structure
Matthieu Totet
parents: 16
diff changeset
    47
                SetValue(ActiveProperty, value);
16
dde0338cb539 Update ProductionView and Components
Matthieu Totet
parents:
diff changeset
    48
                if (value)
dde0338cb539 Update ProductionView and Components
Matthieu Totet
parents:
diff changeset
    49
                {
27
f292db96b050 Generalization of Book Structure
Matthieu Totet
parents: 16
diff changeset
    50
                    Activate();
f292db96b050 Generalization of Book Structure
Matthieu Totet
parents: 16
diff changeset
    51
                    if (HighLighted)
f292db96b050 Generalization of Book Structure
Matthieu Totet
parents: 16
diff changeset
    52
                    {
f292db96b050 Generalization of Book Structure
Matthieu Totet
parents: 16
diff changeset
    53
                        Select();
f292db96b050 Generalization of Book Structure
Matthieu Totet
parents: 16
diff changeset
    54
                    }
16
dde0338cb539 Update ProductionView and Components
Matthieu Totet
parents:
diff changeset
    55
                }
dde0338cb539 Update ProductionView and Components
Matthieu Totet
parents:
diff changeset
    56
                else
dde0338cb539 Update ProductionView and Components
Matthieu Totet
parents:
diff changeset
    57
                {
dde0338cb539 Update ProductionView and Components
Matthieu Totet
parents:
diff changeset
    58
                }
dde0338cb539 Update ProductionView and Components
Matthieu Totet
parents:
diff changeset
    59
            }
dde0338cb539 Update ProductionView and Components
Matthieu Totet
parents:
diff changeset
    60
        }
dde0338cb539 Update ProductionView and Components
Matthieu Totet
parents:
diff changeset
    61
dde0338cb539 Update ProductionView and Components
Matthieu Totet
parents:
diff changeset
    62
        // Using a DependencyProperty as the backing store for IsActive.  This enables animation, styling, binding, etc...
27
f292db96b050 Generalization of Book Structure
Matthieu Totet
parents: 16
diff changeset
    63
        public  static readonly DependencyProperty ActiveProperty =
f292db96b050 Generalization of Book Structure
Matthieu Totet
parents: 16
diff changeset
    64
            DependencyProperty.Register("Active", typeof(bool), typeof(HeaderProductionPartControler), new PropertyMetadata(new PropertyChangedCallback(ItemsSourceChanged)));
f292db96b050 Generalization of Book Structure
Matthieu Totet
parents: 16
diff changeset
    65
        private static void ItemsSourceChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
f292db96b050 Generalization of Book Structure
Matthieu Totet
parents: 16
diff changeset
    66
        {
f292db96b050 Generalization of Book Structure
Matthieu Totet
parents: 16
diff changeset
    67
f292db96b050 Generalization of Book Structure
Matthieu Totet
parents: 16
diff changeset
    68
            ((HeaderProductionPartControler)sender).Active =(bool)e.NewValue;
f292db96b050 Generalization of Book Structure
Matthieu Totet
parents: 16
diff changeset
    69
        }
f292db96b050 Generalization of Book Structure
Matthieu Totet
parents: 16
diff changeset
    70
16
dde0338cb539 Update ProductionView and Components
Matthieu Totet
parents:
diff changeset
    71
dde0338cb539 Update ProductionView and Components
Matthieu Totet
parents:
diff changeset
    72
dde0338cb539 Update ProductionView and Components
Matthieu Totet
parents:
diff changeset
    73
dde0338cb539 Update ProductionView and Components
Matthieu Totet
parents:
diff changeset
    74
        public String Text
dde0338cb539 Update ProductionView and Components
Matthieu Totet
parents:
diff changeset
    75
        {
dde0338cb539 Update ProductionView and Components
Matthieu Totet
parents:
diff changeset
    76
            get { return (String)GetValue(TextProperty); }
dde0338cb539 Update ProductionView and Components
Matthieu Totet
parents:
diff changeset
    77
            set 
dde0338cb539 Update ProductionView and Components
Matthieu Totet
parents:
diff changeset
    78
            { SetValue(TextProperty, value); 
dde0338cb539 Update ProductionView and Components
Matthieu Totet
parents:
diff changeset
    79
                textBlock.Text = value; 
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
            
dde0338cb539 Update ProductionView and Components
Matthieu Totet
parents:
diff changeset
    83
        // 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
    84
        public static readonly DependencyProperty TextProperty =
dde0338cb539 Update ProductionView and Components
Matthieu Totet
parents:
diff changeset
    85
            DependencyProperty.Register("Text", typeof(String), typeof(HeaderProductionPartControler), new PropertyMetadata(""));
dde0338cb539 Update ProductionView and Components
Matthieu Totet
parents:
diff changeset
    86
dde0338cb539 Update ProductionView and Components
Matthieu Totet
parents:
diff changeset
    87
dde0338cb539 Update ProductionView and Components
Matthieu Totet
parents:
diff changeset
    88
		
dde0338cb539 Update ProductionView and Components
Matthieu Totet
parents:
diff changeset
    89
		public HeaderProductionPartControler()
dde0338cb539 Update ProductionView and Components
Matthieu Totet
parents:
diff changeset
    90
		{
dde0338cb539 Update ProductionView and Components
Matthieu Totet
parents:
diff changeset
    91
			// Required to initialize variables
dde0338cb539 Update ProductionView and Components
Matthieu Totet
parents:
diff changeset
    92
			InitializeComponent();
27
f292db96b050 Generalization of Book Structure
Matthieu Totet
parents: 16
diff changeset
    93
           
16
dde0338cb539 Update ProductionView and Components
Matthieu Totet
parents:
diff changeset
    94
			_activated = false;
dde0338cb539 Update ProductionView and Components
Matthieu Totet
parents:
diff changeset
    95
			_finished= false;
dde0338cb539 Update ProductionView and Components
Matthieu Totet
parents:
diff changeset
    96
          
dde0338cb539 Update ProductionView and Components
Matthieu Totet
parents:
diff changeset
    97
            
dde0338cb539 Update ProductionView and Components
Matthieu Totet
parents:
diff changeset
    98
           
dde0338cb539 Update ProductionView and Components
Matthieu Totet
parents:
diff changeset
    99
dde0338cb539 Update ProductionView and Components
Matthieu Totet
parents:
diff changeset
   100
		}
dde0338cb539 Update ProductionView and Components
Matthieu Totet
parents:
diff changeset
   101
		
dde0338cb539 Update ProductionView and Components
Matthieu Totet
parents:
diff changeset
   102
        private bool _activated;
dde0338cb539 Update ProductionView and Components
Matthieu Totet
parents:
diff changeset
   103
		private bool _finished;
dde0338cb539 Update ProductionView and Components
Matthieu Totet
parents:
diff changeset
   104
		
27
f292db96b050 Generalization of Book Structure
Matthieu Totet
parents: 16
diff changeset
   105
		public void Activate()
16
dde0338cb539 Update ProductionView and Components
Matthieu Totet
parents:
diff changeset
   106
		{
dde0338cb539 Update ProductionView and Components
Matthieu Totet
parents:
diff changeset
   107
			if(!_activated && !_finished)
dde0338cb539 Update ProductionView and Components
Matthieu Totet
parents:
diff changeset
   108
			{
dde0338cb539 Update ProductionView and Components
Matthieu Totet
parents:
diff changeset
   109
				VisualStateManager.GoToState(this,"Available",true);
dde0338cb539 Update ProductionView and Components
Matthieu Totet
parents:
diff changeset
   110
				_activated=true;
dde0338cb539 Update ProductionView and Components
Matthieu Totet
parents:
diff changeset
   111
			}
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
		
dde0338cb539 Update ProductionView and Components
Matthieu Totet
parents:
diff changeset
   115
		public void UnSelect()
dde0338cb539 Update ProductionView and Components
Matthieu Totet
parents:
diff changeset
   116
		{
27
f292db96b050 Generalization of Book Structure
Matthieu Totet
parents: 16
diff changeset
   117
            if (_activated && !_finished)
f292db96b050 Generalization of Book Structure
Matthieu Totet
parents: 16
diff changeset
   118
            {
f292db96b050 Generalization of Book Structure
Matthieu Totet
parents: 16
diff changeset
   119
                VisualStateManager.GoToState(this, "Available", true);
f292db96b050 Generalization of Book Structure
Matthieu Totet
parents: 16
diff changeset
   120
            }
16
dde0338cb539 Update ProductionView and Components
Matthieu Totet
parents:
diff changeset
   121
		}
dde0338cb539 Update ProductionView and Components
Matthieu Totet
parents:
diff changeset
   122
		private void Button_MouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
dde0338cb539 Update ProductionView and Components
Matthieu Totet
parents:
diff changeset
   123
		{
dde0338cb539 Update ProductionView and Components
Matthieu Totet
parents:
diff changeset
   124
           
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
dde0338cb539 Update ProductionView and Components
Matthieu Totet
parents:
diff changeset
   128
		private void but_Click(object sender, System.Windows.RoutedEventArgs e)
dde0338cb539 Update ProductionView and Components
Matthieu Totet
parents:
diff changeset
   129
		{
dde0338cb539 Update ProductionView and Components
Matthieu Totet
parents:
diff changeset
   130
		     	
dde0338cb539 Update ProductionView and Components
Matthieu Totet
parents:
diff changeset
   131
				if(_activated)
dde0338cb539 Update ProductionView and Components
Matthieu Totet
parents:
diff changeset
   132
				{
38
bd33267300aa - FranceCulture Project
totetm <>
parents: 27
diff changeset
   133
                    Clicked(this, new EventArgs());
bd33267300aa - FranceCulture Project
totetm <>
parents: 27
diff changeset
   134
bd33267300aa - FranceCulture Project
totetm <>
parents: 27
diff changeset
   135
                      
16
dde0338cb539 Update ProductionView and Components
Matthieu Totet
parents:
diff changeset
   136
				}
dde0338cb539 Update ProductionView and Components
Matthieu Totet
parents:
diff changeset
   137
		}
38
bd33267300aa - FranceCulture Project
totetm <>
parents: 27
diff changeset
   138
        public void Finish()
bd33267300aa - FranceCulture Project
totetm <>
parents: 27
diff changeset
   139
        {
bd33267300aa - FranceCulture Project
totetm <>
parents: 27
diff changeset
   140
            VisualStateManager.GoToState(this,"Finished",true);
bd33267300aa - FranceCulture Project
totetm <>
parents: 27
diff changeset
   141
                           if (HeaderProductionPartFinished!=null)
bd33267300aa - FranceCulture Project
totetm <>
parents: 27
diff changeset
   142
                           {
bd33267300aa - FranceCulture Project
totetm <>
parents: 27
diff changeset
   143
                             HeaderProductionPartFinished(this, new HeaderProductionPartControlerEventArgs(this));
bd33267300aa - FranceCulture Project
totetm <>
parents: 27
diff changeset
   144
                           }
bd33267300aa - FranceCulture Project
totetm <>
parents: 27
diff changeset
   145
                           _finished = true;
bd33267300aa - FranceCulture Project
totetm <>
parents: 27
diff changeset
   146
        }
bd33267300aa - FranceCulture Project
totetm <>
parents: 27
diff changeset
   147
        public event EventHandler Clicked;
16
dde0338cb539 Update ProductionView and Components
Matthieu Totet
parents:
diff changeset
   148
        public void Select()
dde0338cb539 Update ProductionView and Components
Matthieu Totet
parents:
diff changeset
   149
        {
dde0338cb539 Update ProductionView and Components
Matthieu Totet
parents:
diff changeset
   150
            if (_activated && !_finished)
dde0338cb539 Update ProductionView and Components
Matthieu Totet
parents:
diff changeset
   151
            {
dde0338cb539 Update ProductionView and Components
Matthieu Totet
parents:
diff changeset
   152
                VisualStateManager.GoToState(this, "Selected", true);
dde0338cb539 Update ProductionView and Components
Matthieu Totet
parents:
diff changeset
   153
            }
dde0338cb539 Update ProductionView and Components
Matthieu Totet
parents:
diff changeset
   154
        }
dde0338cb539 Update ProductionView and Components
Matthieu Totet
parents:
diff changeset
   155
		private void textBlock_MouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
dde0338cb539 Update ProductionView and Components
Matthieu Totet
parents:
diff changeset
   156
		{
dde0338cb539 Update ProductionView and Components
Matthieu Totet
parents:
diff changeset
   157
            if (_activated && !_finished)
dde0338cb539 Update ProductionView and Components
Matthieu Totet
parents:
diff changeset
   158
            {
dde0338cb539 Update ProductionView and Components
Matthieu Totet
parents:
diff changeset
   159
                if (HeaderProductionPartSelected != null)
dde0338cb539 Update ProductionView and Components
Matthieu Totet
parents:
diff changeset
   160
                    HeaderProductionPartSelected(this, new HeaderProductionPartControlerEventArgs(this));
dde0338cb539 Update ProductionView and Components
Matthieu Totet
parents:
diff changeset
   161
            }
dde0338cb539 Update ProductionView and Components
Matthieu Totet
parents:
diff changeset
   162
        }
dde0338cb539 Update ProductionView and Components
Matthieu Totet
parents:
diff changeset
   163
        public event EventHandler<HeaderProductionPartControlerEventArgs> HeaderProductionPartFinished;
dde0338cb539 Update ProductionView and Components
Matthieu Totet
parents:
diff changeset
   164
        public event EventHandler<HeaderProductionPartControlerEventArgs> HeaderProductionPartSelected;
dde0338cb539 Update ProductionView and Components
Matthieu Totet
parents:
diff changeset
   165
	}
dde0338cb539 Update ProductionView and Components
Matthieu Totet
parents:
diff changeset
   166
dde0338cb539 Update ProductionView and Components
Matthieu Totet
parents:
diff changeset
   167
    public class HeaderProductionPartControlerEventArgs : EventArgs
dde0338cb539 Update ProductionView and Components
Matthieu Totet
parents:
diff changeset
   168
    {
dde0338cb539 Update ProductionView and Components
Matthieu Totet
parents:
diff changeset
   169
        public object sender { get; set; }
dde0338cb539 Update ProductionView and Components
Matthieu Totet
parents:
diff changeset
   170
        public HeaderProductionPartControlerEventArgs(object psender)
dde0338cb539 Update ProductionView and Components
Matthieu Totet
parents:
diff changeset
   171
        {
dde0338cb539 Update ProductionView and Components
Matthieu Totet
parents:
diff changeset
   172
            sender = psender;
dde0338cb539 Update ProductionView and Components
Matthieu Totet
parents:
diff changeset
   173
        }
dde0338cb539 Update ProductionView and Components
Matthieu Totet
parents:
diff changeset
   174
dde0338cb539 Update ProductionView and Components
Matthieu Totet
parents:
diff changeset
   175
    }
dde0338cb539 Update ProductionView and Components
Matthieu Totet
parents:
diff changeset
   176
}