[amd64/tramp] hide interpreter specific trampoline behind ifdef
[mono.git] / mcs / class / referencesource / System.Activities.Presentation / System.Activities.Presentation / System / Activities / Presentation / View / VersionEditor.xaml.cs
1 //----------------------------------------------------------------
2 // <copyright company="Microsoft Corporation">
3 //     Copyright (c) Microsoft Corporation.  All rights reserved.
4 // </copyright>
5 //----------------------------------------------------------------
6
7 namespace System.Activities.Presentation.View
8 {
9     using System;
10     using System.ComponentModel;
11     using System.Diagnostics.CodeAnalysis;
12     using System.Windows;
13     using System.Windows.Controls;
14
15     internal partial class VersionEditor : UserControl, IVersionEditor
16     {
17         private static DependencyProperty versionProperty = DependencyProperty.Register("Version", typeof(Version), typeof(VersionEditor), new PropertyMetadata(new PropertyChangedCallback(VersionEditor.OnVersionChanged)));
18         private static DependencyProperty viewModelProperty = DependencyProperty.Register("ViewModel", typeof(VersionEditorViewModel), typeof(VersionEditor));
19
20         [SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors",
21             Justification = "This value must be set in contructor to ensure that ViewModel could be used")]
22         public VersionEditor()
23         {
24             this.InitializeComponent();
25             this.ViewModel = new VersionEditorViewModel(this);
26             this.ViewModel.PropertyChanged += this.OnViewModelPropertyChanged;
27         }
28
29         public static DependencyProperty VersionProperty
30         {
31             get { return versionProperty; }
32         }
33
34         public Version Version
35         {
36             get { return (Version)GetValue(VersionProperty); }
37             set { SetValue(VersionProperty, value); }
38         }
39
40         private static DependencyProperty ViewModelProperty
41         {
42             get { return viewModelProperty; }
43         }
44
45         private VersionEditorViewModel ViewModel
46         {
47             get { return (VersionEditorViewModel)GetValue(ViewModelProperty); }
48             set { SetValue(ViewModelProperty, value); }
49         }
50
51         void IVersionEditor.ShowErrorMessage(string message)
52         {
53             ErrorReporting.ShowErrorMessage(message);
54         }
55
56         private static void OnVersionChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
57         {
58             ((VersionEditor)sender).OnVersionChanged(e);
59         }
60
61         private void OnVersionChanged(DependencyPropertyChangedEventArgs e)
62         {
63             this.ViewModel.Version = (Version)e.NewValue;
64         }
65
66         private void OnViewModelPropertyChanged(object sender, PropertyChangedEventArgs e)
67         {
68             if (e.PropertyName == "Version")
69             {
70                 this.Version = this.ViewModel.Version;
71             }
72         }
73     }
74 }