Exemplo n.º 1
0
        void OnVisualsChanged(object sender, VisualChangeEventArgs e)
        {
            if (_animateStatus)
            {
                StatusText.Text = string.Format(CultureInfo.InvariantCulture, "{0} live visuals of {1} total", grid.LiveVisualCount, _totalVisuals);

                int tick = Environment.TickCount;
                if (e.Added != 0 || e.Removed != 0)
                {
                    addedPerSecond   += e.Added;
                    removedPerSecond += e.Removed;
                    if (tick > lastTick + 100)
                    {
                        Created.BeginAnimation(Rectangle.WidthProperty, new DoubleAnimation(
                                                   Math.Min(addedPerSecond, 450),
                                                   new Duration(TimeSpan.FromMilliseconds(100))));
                        CreatedLabel.Text = addedPerSecond.ToString(CultureInfo.InvariantCulture) + " created";
                        addedPerSecond    = 0;

                        Destroyed.BeginAnimation(Rectangle.WidthProperty, new DoubleAnimation(
                                                     Math.Min(removedPerSecond, 450),
                                                     new Duration(TimeSpan.FromMilliseconds(100))));
                        DestroyedLabel.Text = removedPerSecond.ToString(CultureInfo.InvariantCulture) + " disposed";
                        removedPerSecond    = 0;
                    }
                }
                if (tick > lastTick + 1000)
                {
                    lastTick = tick;
                }
            }
        }
Exemplo n.º 2
0
        void OnAnimateStatus(object sender, RoutedEventArgs e)
        {
            MenuItem item = (MenuItem)sender;

            _animateStatus = item.IsChecked = !item.IsChecked;

            StatusText.Text = "";
            Created.BeginAnimation(Rectangle.WidthProperty, null);
            Created.Width     = 0;
            CreatedLabel.Text = "";
            Destroyed.BeginAnimation(Rectangle.WidthProperty, null);
            Destroyed.Width     = 0;
            DestroyedLabel.Text = "";
        }