예제 #1
0
        public void Navigate(IPausableControl nextPage)
        {
            Dispatcher.BeginInvoke(DispatcherPriority.Normal, new Action <IPausableControl>
                                       ((p) =>
            {
                if (p != null)
                {
                    Debug.WriteLine("Switching to new View " + p.GetType().Name);
                    var page     = p as UserControl;
                    page.Opacity = 0.0;
                    DoubleAnimation animation = new DoubleAnimation
                    {
                        From     = 0.0,
                        To       = 1.0,
                        Duration =
                            new Duration(TimeSpan.FromMilliseconds(400.0)),
                        AutoReverse = false,
                    };


                    //Grid parent = page.Parent as Grid;
                    //if (parent != null)
                    //{
                    //    parent.Children.Remove(page);
                    //}

                    MediaGrid.Children.Remove(page);

                    p.UnPause();
                    this.MediaGrid.Children.Add(page);
                    page.BeginAnimation(UIElement.OpacityProperty, animation);
                }

                if (Switcher.LastPage != null && Switcher.LastPage != p)
                {
                    Debug.WriteLine("Removing LastPAge Added" + Switcher.LastPage.GetType().Name);
                    Charging lastPage = Switcher.LastPage as Charging;
                    if (lastPage != null)
                    {
                        lastPage.LocationWidget.Visibility = Visibility.Hidden;
                    }
                    DoubleAnimation animation2 = new DoubleAnimation
                    {
                        From        = 1.0,
                        To          = 0.0,
                        Duration    = new Duration(TimeSpan.FromMilliseconds(400.0)),
                        AutoReverse = false
                    };
                    var lp = Switcher.LastPage as UserControl;

                    Debug.WriteLine("Removing LastPAge BeginAni");
                    MediaGrid.Children.Remove(lp);
                    Switcher.LastPage.Pause();
                    Debug.WriteLine("Pased LastPAge ");
                    lp.BeginAnimation(UIElement.OpacityProperty, animation2);
                }
            }), nextPage);
        }
예제 #2
0
파일: Switcher.cs 프로젝트: afrog33k/eAd
 public static void Switch(IPausableControl newPage)
 {
     LastPage = CurrentPage;
     ClientManager.Navigate(newPage);
     CurrentPage = newPage;
 }
예제 #3
0
        public void Navigate(IPausableControl nextPage)
        {
         Dispatcher.BeginInvoke(DispatcherPriority.Normal, new Action<IPausableControl>
                ((p) =>
                     {
                         if (p != null)
                         {
                             Debug.WriteLine("Switching to new View " + p.GetType().Name);
                             var page = p as UserControl;
                             page.Opacity = 0.0;
                             DoubleAnimation animation = new DoubleAnimation
                                                             {
                                                                 From = 0.0,
                                                                 To = 1.0,
                                                                 Duration =
                                                                     new Duration(TimeSpan.FromMilliseconds(400.0)),
                                                                 AutoReverse = false,
                                                             };
                        
                            
                             //Grid parent = page.Parent as Grid;
                             //if (parent != null)
                             //{
                             //    parent.Children.Remove(page);
                             //}
                           
                             MediaGrid.Children.Remove(page);
                            
                             p.UnPause();
                             this.MediaGrid.Children.Add(page);
                            page.BeginAnimation(UIElement.OpacityProperty, animation);
                         }

                         if (Switcher.LastPage != null && Switcher.LastPage!=p)
                         {
                             Debug.WriteLine("Removing LastPAge Added" + Switcher.LastPage.GetType().Name);
                             Charging lastPage = Switcher.LastPage as Charging;
                             if (lastPage != null)
                             {
                                 lastPage.LocationWidget.Visibility = Visibility.Hidden;
                             }
                             DoubleAnimation animation2 = new DoubleAnimation
                             {
                                 From = 1.0,
                                 To = 0.0,
                                 Duration = new Duration(TimeSpan.FromMilliseconds(400.0)),
                                 AutoReverse = false
                             };
                             var lp = Switcher.LastPage as UserControl;
                           
                             Debug.WriteLine("Removing LastPAge BeginAni");
                             MediaGrid.Children.Remove(lp);
                             Switcher.LastPage.Pause();
                             Debug.WriteLine("Pased LastPAge ");
                             lp.BeginAnimation(UIElement.OpacityProperty, animation2);
                         }



                     }), nextPage);
        }