示例#1
0
            protected override Freezable CreateInstanceCore()
            {
                DoubleAnimationPlus p = new DoubleAnimationPlus();

                p.TargetElement = this.TargetElement;
                return(p);
            }
示例#2
0
        private void ShrinkAnimationCompleted(object sender, EventArgs e)
        {
            Clock c = sender as Clock;
            DoubleAnimationPlus anim = c.Timeline as DoubleAnimationPlus;

            if (anim != null)
            {
                if (anim.TargetElement != null)
                {
                    //Console.WriteLine("DoubleAnimation TargetElement is set!");
                    StackPanel sp = anim.TargetElement as StackPanel;
                    shrink(sp);
                }
            }
        }
示例#3
0
        private void option1_click(object sender, RoutedEventArgs e)
        {
            StackPanel sp       = sender as StackPanel;
            StackPanel usedToBe = currentlyExpanded;

            if (currentlyExpanded != null)
            {
                double initialHeight = usedToBe.DesiredSize.Height;

                StackPanel sub = new StackPanel();

                shrink();
                this.UpdateLayout();
                double finalHeight = views[usedToBe].stub.DesiredSize.Height;
                sub.Height = initialHeight - finalHeight;
                usedToBe.Children.Add(sub);
                //views[sp].stub.Height = initialHeight;
                this.UpdateLayout();

                Duration            duration        = new Duration(TimeSpan.FromSeconds(0.50));
                DoubleAnimationPlus doubleanimation = new DoubleAnimationPlus();
                doubleanimation.Duration = duration;
                doubleanimation.To       = 0;

                doubleanimation.TargetElement = usedToBe;


                doubleanimation.Completed += new EventHandler(ShrinkAnimationCompleted);

                //views[sp].stub.BeginAnimation(HeightProperty, doubleanimation);
                sub.BeginAnimation(HeightProperty, doubleanimation);
            }
            if (usedToBe != sp)
            {
                double initialHeight = sp.DesiredSize.Height;

                expand(sp);
                this.UpdateLayout();
                double finalHeight = views[sp].DesiredSize.Height;
                //shrink();
                views[sp].Height = initialHeight;
                this.UpdateLayout();



                //StackPanel sub = new StackPanel();
                //sp.Children.Add(sub);

                //sub.Height = 0;


                Duration            duration        = new Duration(TimeSpan.FromSeconds(0.50));
                DoubleAnimationPlus doubleanimation = new DoubleAnimationPlus();
                doubleanimation.Duration = duration;
                //doubleanimation.To = finalHeight - initialHeight;
                doubleanimation.To   = finalHeight;
                doubleanimation.From = initialHeight;

                doubleanimation.TargetElement = sp;

                doubleanimation.Completed += new EventHandler(AnimationCompleted);

                //sub.BeginAnimation(HeightProperty, doubleanimation);
                views[sp].BeginAnimation(HeightProperty, doubleanimation);
            }
        }
示例#4
0
 protected override Freezable CreateInstanceCore()
 {
     DoubleAnimationPlus p = new DoubleAnimationPlus();
     p.TargetElement = this.TargetElement;
     return p;
 }
示例#5
0
        private void option1_click(object sender, RoutedEventArgs e)
        {
            StackPanel sp = sender as StackPanel;
            StackPanel usedToBe = currentlyExpanded;

            if (currentlyExpanded != null)
            {
                double initialHeight = usedToBe.DesiredSize.Height;

                StackPanel sub = new StackPanel();

                shrink();
                this.UpdateLayout();
                double finalHeight = views[usedToBe].stub.DesiredSize.Height;
                sub.Height = initialHeight - finalHeight;
                usedToBe.Children.Add(sub);
                //views[sp].stub.Height = initialHeight;
                this.UpdateLayout();

                Duration duration = new Duration(TimeSpan.FromSeconds(0.50));
                DoubleAnimationPlus doubleanimation = new DoubleAnimationPlus();
                doubleanimation.Duration = duration;
                doubleanimation.To = 0;

                doubleanimation.TargetElement = usedToBe;

                doubleanimation.Completed += new EventHandler(ShrinkAnimationCompleted);

                //views[sp].stub.BeginAnimation(HeightProperty, doubleanimation);
                sub.BeginAnimation(HeightProperty, doubleanimation);

            }
            if (usedToBe != sp)
            {
                double initialHeight = sp.DesiredSize.Height;

                expand(sp);
                this.UpdateLayout();
                double finalHeight = views[sp].DesiredSize.Height;
                //shrink();
                views[sp].Height = initialHeight;
                this.UpdateLayout();

                //StackPanel sub = new StackPanel();
                //sp.Children.Add(sub);

                //sub.Height = 0;

                Duration duration = new Duration(TimeSpan.FromSeconds(0.50));
                DoubleAnimationPlus doubleanimation = new DoubleAnimationPlus();
                doubleanimation.Duration = duration;
                //doubleanimation.To = finalHeight - initialHeight;
                doubleanimation.To = finalHeight;
                doubleanimation.From = initialHeight;

                doubleanimation.TargetElement = sp;

                doubleanimation.Completed += new EventHandler(AnimationCompleted);

                //sub.BeginAnimation(HeightProperty, doubleanimation);
                views[sp].BeginAnimation(HeightProperty, doubleanimation);
            }
        }