Mercurial > silverbladetech
annotate MetroWpf/MetroWpf.Xaml/Transitions/TransitionPresenter.cs @ 85:4863009a2edf
renamed bugs to todo
author | Steven Hollidge <stevenhollidge@hotmail.com> |
---|---|
date | Tue, 24 Apr 2012 00:52:39 +0100 |
parents | a8b50a087544 |
children |
rev | line source |
---|---|
24
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
1 using System; |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
2 using System.Windows; |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
3 using System.Windows.Controls; |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
4 using System.Windows.Documents; |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
5 using System.Windows.Media; |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
6 |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
7 namespace MetroWpf.Xaml.Transitions |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
8 { |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
9 [System.Windows.Markup.ContentProperty("Content")] |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
10 public class TransitionPresenter : FrameworkElement |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
11 { |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
12 static TransitionPresenter() |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
13 { |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
14 ClipToBoundsProperty.OverrideMetadata(typeof(TransitionPresenter), new FrameworkPropertyMetadata(null, CoerceClipToBounds)); |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
15 } |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
16 |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
17 // Force clip to be true if the active Transition requires it |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
18 private static object CoerceClipToBounds(object element, object value) |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
19 { |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
20 TransitionPresenter transitionElement = (TransitionPresenter)element; |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
21 bool clip = (bool)value; |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
22 if (!clip && transitionElement.IsTransitioning) |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
23 { |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
24 Transition transition = transitionElement.Transition; |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
25 if (transition.ClipToBounds) |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
26 return true; |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
27 } |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
28 return value; |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
29 } |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
30 |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
31 public object Content |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
32 { |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
33 get { return (object)GetValue(ContentProperty); } |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
34 set { SetValue(ContentProperty, value); } |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
35 } |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
36 |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
37 public static readonly DependencyProperty ContentProperty = |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
38 DependencyProperty.Register("Content", |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
39 typeof(object), |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
40 typeof(TransitionPresenter), |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
41 new UIPropertyMetadata(null, OnContentChanged, CoerceContent)); |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
42 |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
43 // Don't update content until done transitioning |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
44 private static object CoerceContent(object element, object value) |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
45 { |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
46 TransitionPresenter te = (TransitionPresenter)element; |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
47 if (te.IsTransitioning) |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
48 return te.CurrentContentPresenter.Content; |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
49 return value; |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
50 } |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
51 |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
52 private static void OnContentChanged(object element, DependencyPropertyChangedEventArgs e) |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
53 { |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
54 TransitionPresenter te = (TransitionPresenter)element; |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
55 te.BeginTransition(); |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
56 } |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
57 |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
58 public DataTemplate ContentTemplate |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
59 { |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
60 get { return (DataTemplate)GetValue(ContentTemplateProperty); } |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
61 set { SetValue(ContentTemplateProperty, value); } |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
62 } |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
63 |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
64 public static readonly DependencyProperty ContentTemplateProperty = |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
65 DependencyProperty.Register("ContentTemplate", |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
66 typeof(DataTemplate), |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
67 typeof(TransitionPresenter), |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
68 new UIPropertyMetadata(null, OnContentTemplateChanged)); |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
69 |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
70 private static void OnContentTemplateChanged(object element, DependencyPropertyChangedEventArgs e) |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
71 { |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
72 TransitionPresenter te = (TransitionPresenter)element; |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
73 te.CurrentContentPresenter.ContentTemplate = (DataTemplate)e.NewValue; |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
74 } |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
75 |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
76 public DataTemplateSelector ContentTemplateSelector |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
77 { |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
78 get { return (DataTemplateSelector)GetValue(ContentTemplateSelectorProperty); } |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
79 set { SetValue(ContentTemplateSelectorProperty, value); } |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
80 } |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
81 |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
82 public static readonly DependencyProperty ContentTemplateSelectorProperty = |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
83 DependencyProperty.Register("ContentTemplateSelector", |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
84 typeof(DataTemplateSelector), |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
85 typeof(TransitionPresenter), |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
86 new UIPropertyMetadata(null, OnContentTemplateSelectorChanged)); |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
87 |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
88 private static void OnContentTemplateSelectorChanged(object element, DependencyPropertyChangedEventArgs e) |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
89 { |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
90 TransitionPresenter te = (TransitionPresenter)element; |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
91 te.CurrentContentPresenter.ContentTemplateSelector = (DataTemplateSelector)e.NewValue; |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
92 } |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
93 |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
94 public bool IsTransitioning |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
95 { |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
96 get { return (bool)GetValue(IsTransitioningProperty); } |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
97 private set { SetValue(IsTransitioningPropertyKey, value); } |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
98 } |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
99 |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
100 private static readonly DependencyPropertyKey IsTransitioningPropertyKey = |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
101 DependencyProperty.RegisterReadOnly("IsTransitioning", |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
102 typeof(bool), |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
103 typeof(TransitionPresenter), |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
104 new UIPropertyMetadata(false)); |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
105 |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
106 public static readonly DependencyProperty IsTransitioningProperty = |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
107 IsTransitioningPropertyKey.DependencyProperty; |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
108 |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
109 public Transition Transition |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
110 { |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
111 get { return (Transition)GetValue(TransitionProperty); } |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
112 set { SetValue(TransitionProperty, value); } |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
113 } |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
114 |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
115 public static readonly DependencyProperty TransitionProperty = |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
116 DependencyProperty.Register("Transition", typeof(Transition), typeof(TransitionPresenter), new UIPropertyMetadata(null, null, CoerceTransition)); |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
117 |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
118 private static object CoerceTransition(object element, object value) |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
119 { |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
120 TransitionPresenter te = (TransitionPresenter)element; |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
121 if (te.IsTransitioning) return te._activeTransition; |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
122 return value; |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
123 } |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
124 |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
125 public TransitionSelector TransitionSelector |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
126 { |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
127 get { return (TransitionSelector)GetValue(TransitionSelectorProperty); } |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
128 set { SetValue(TransitionSelectorProperty, value); } |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
129 } |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
130 |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
131 public static readonly DependencyProperty TransitionSelectorProperty = |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
132 DependencyProperty.Register("TransitionSelector", typeof(TransitionSelector), typeof(TransitionPresenter), new UIPropertyMetadata(null)); |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
133 |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
134 public TransitionPresenter() |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
135 { |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
136 _children = new UIElementCollection(this, null); |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
137 ContentPresenter currentContent = new ContentPresenter(); |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
138 _currentHost = new AdornerDecorator(); |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
139 _currentHost.Child = currentContent; |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
140 _children.Add(_currentHost); |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
141 |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
142 ContentPresenter previousContent = new ContentPresenter(); |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
143 _previousHost = new AdornerDecorator(); |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
144 _previousHost.Child = previousContent; |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
145 } |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
146 |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
147 private void BeginTransition() |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
148 { |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
149 TransitionSelector selector = TransitionSelector; |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
150 |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
151 Transition transition = selector != null ? |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
152 selector.SelectTransition(CurrentContentPresenter.Content, Content) : |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
153 Transition; |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
154 |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
155 if (transition != null) |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
156 { |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
157 // Swap content presenters |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
158 AdornerDecorator temp = _previousHost; |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
159 _previousHost = _currentHost; |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
160 _currentHost = temp; |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
161 } |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
162 |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
163 ContentPresenter currentContent = CurrentContentPresenter; |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
164 // Set the current content |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
165 currentContent.Content = Content; |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
166 currentContent.ContentTemplate = ContentTemplate; |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
167 currentContent.ContentTemplateSelector = ContentTemplateSelector; |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
168 |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
169 if (transition != null) |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
170 { |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
171 ContentPresenter previousContent = PreviousContentPresenter; |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
172 |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
173 if (transition.IsNewContentTopmost) |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
174 Children.Add(_currentHost); |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
175 else |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
176 Children.Insert(0, _currentHost); |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
177 |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
178 IsTransitioning = true; |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
179 _activeTransition = transition; |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
180 CoerceValue(TransitionProperty); |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
181 CoerceValue(ClipToBoundsProperty); |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
182 transition.BeginTransition(this, previousContent, currentContent); |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
183 } |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
184 } |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
185 |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
186 // Clean up after the transition is complete |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
187 internal void OnTransitionCompleted() |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
188 { |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
189 _children.Clear(); |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
190 _children.Add(_currentHost); |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
191 _currentHost.Visibility = Visibility.Visible; |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
192 _previousHost.Visibility = Visibility.Visible; |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
193 ((ContentPresenter)_previousHost.Child).Content = null; |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
194 |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
195 IsTransitioning = false; |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
196 _activeTransition = null; |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
197 CoerceValue(TransitionProperty); |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
198 CoerceValue(ClipToBoundsProperty); |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
199 CoerceValue(ContentProperty); |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
200 } |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
201 |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
202 protected override Size MeasureOverride(Size availableSize) |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
203 { |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
204 _currentHost.Measure(availableSize); |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
205 return _currentHost.DesiredSize; |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
206 } |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
207 |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
208 protected override Size ArrangeOverride(Size finalSize) |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
209 { |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
210 foreach (UIElement uie in _children) |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
211 uie.Arrange(new Rect(finalSize)); |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
212 return finalSize; |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
213 } |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
214 |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
215 protected override int VisualChildrenCount |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
216 { |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
217 get { return _children.Count; } |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
218 } |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
219 |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
220 protected override Visual GetVisualChild(int index) |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
221 { |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
222 if (index < 0 || index >= _children.Count) |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
223 throw new ArgumentOutOfRangeException("index"); |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
224 return _children[index]; |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
225 } |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
226 |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
227 internal UIElementCollection Children |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
228 { |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
229 get { return _children; } |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
230 } |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
231 |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
232 private ContentPresenter PreviousContentPresenter |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
233 { |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
234 get { return ((ContentPresenter)_previousHost.Child); } |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
235 } |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
236 |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
237 private ContentPresenter CurrentContentPresenter |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
238 { |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
239 get { return ((ContentPresenter)_currentHost.Child); } |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
240 } |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
241 |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
242 private UIElementCollection _children; |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
243 |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
244 private AdornerDecorator _currentHost; |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
245 private AdornerDecorator _previousHost; |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
246 |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
247 private Transition _activeTransition; |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
248 } |
a8b50a087544
Stocks and FxRates working, new menu introduced. Working nicely so far
adminsh@apollo
parents:
diff
changeset
|
249 } |