comparison MetroWpf/MetroWpf.Xaml/Transitions/Transition.cs @ 24:a8b50a087544

Stocks and FxRates working, new menu introduced. Working nicely so far
author adminsh@apollo
date Tue, 20 Mar 2012 20:18:35 +0000
parents
children
comparison
equal deleted inserted replaced
23:399398841fd0 24:a8b50a087544
1 using System.Windows;
2 using System.Windows.Controls;
3 using System.Windows.Media;
4
5 namespace MetroWpf.Xaml.Transitions
6 {
7 // Base class for all transitions.
8 public class Transition : DependencyObject
9 {
10 public bool ClipToBounds
11 {
12 get { return (bool)GetValue(ClipToBoundsProperty); }
13 set { SetValue(ClipToBoundsProperty, value); }
14 }
15
16 public static readonly DependencyProperty ClipToBoundsProperty =
17 DependencyProperty.Register("ClipToBounds",
18 typeof(bool),
19 typeof(Transition),
20 new UIPropertyMetadata(false));
21
22 public bool IsNewContentTopmost
23 {
24 get { return (bool)GetValue(IsNewContentTopmostProperty); }
25 set { SetValue(IsNewContentTopmostProperty, value); }
26 }
27
28 public static readonly DependencyProperty IsNewContentTopmostProperty =
29 DependencyProperty.Register("IsNewContentTopmost",
30 typeof(bool),
31 typeof(Transition),
32 new UIPropertyMetadata(true));
33
34 // Called when an element is Removed from the TransitionPresenter's visual tree
35 protected internal virtual void BeginTransition(TransitionPresenter transitionElement, ContentPresenter oldContent, ContentPresenter newContent)
36 {
37 EndTransition(transitionElement, oldContent, newContent);
38 }
39
40 //Transitions should call this method when they are done
41 protected void EndTransition(TransitionPresenter transitionElement, ContentPresenter oldContent, ContentPresenter newContent)
42 {
43 OnTransitionEnded(transitionElement, oldContent, newContent);
44
45 transitionElement.OnTransitionCompleted();
46 }
47
48 //Transitions can override this to perform cleanup at the end of the transition
49 protected virtual void OnTransitionEnded(TransitionPresenter transitionElement, ContentPresenter oldContent, ContentPresenter newContent)
50 {
51 }
52
53 // Returns a clone of the element and hides it in the main tree
54 protected static Brush CreateBrush(ContentPresenter content)
55 {
56 ((Decorator)content.Parent).Visibility = Visibility.Hidden;
57
58 VisualBrush brush = new VisualBrush(content);
59 brush.ViewportUnits = BrushMappingMode.Absolute;
60 RenderOptions.SetCachingHint(brush, CachingHint.Cache);
61 RenderOptions.SetCacheInvalidationThresholdMinimum(brush, 40);
62 return brush;
63 }
64 }
65 }