//Function that animates the circle to a certain state with a certain timing public void AnimateCircleAngle(double PercentBefore, double PercentAfter, double seconds, bool initialAnimation = true, bool useEase = true) { //We multiply the percentage by 3.6 because a full circle is 360 degrees, divide 360 by 100 and you get 3.6 //So half a circle would be 50(%) * 3.6 = 180 degrees, half a circle. DoubleAnimation da = new DoubleAnimation(PercentBefore * 3.6, PercentAfter * 3.6, TimeSpan.FromSeconds(seconds)); if (useEase) { SineEase ease = new SineEase(); da.EasingFunction = ease; } if (initialAnimation) { da.Completed += (sender, e) => { AnimateCircleThickness(5, 15); Status = "Aan het verwerken"; }; Status = "Een ogenblik geduld"; AnimateLabelPeriods(statusLabel); } ProgressGraphic.BeginAnimation(Microsoft.Expression.Shapes.Arc.EndAngleProperty, da); }
public void StopAnimations() { DoubleAnimation da = new DoubleAnimation(ProgressGraphic.StrokeThickness, ProgressGraphic.StrokeThickness, TimeSpan.FromMilliseconds(700)); ProgressGraphic.BeginAnimation(Microsoft.Expression.Shapes.Arc.StrokeThicknessProperty, da); ProgressGraphic.BeginAnimation(Microsoft.Expression.Shapes.Arc.StartAngleProperty, null); ProgressGraphic.BeginAnimation(Microsoft.Expression.Shapes.Arc.EndAngleProperty, null); ProgressGraphic.EndAngle = 360; // To keep it full AnimateCircleThickness(ProgressGraphic.StrokeThickness, 5, false, false); statusLabel.Opacity = 0; }
public override void Draw(DrawArgs drawArgs) { if (_delayedEventPublisher == null && SynchronizationContext.Current != null) { _delayedEventPublisher = new DelayedEventPublisher(OnDelayedProgressChanged, 1000, DelayedEventPublisherTriggerMode.Periodic); } var asyncFrame = Frame; using (asyncFrame.AcquireLock()) { if (!asyncFrame.IsAsyncLoaded) { if (!Visible) // if this is an off-screen draw, wait for data to be loaded { lock (_waitPixelData) { if (!asyncFrame.IsAsyncLoaded) { var completionHandler = new EventHandler((s, e) => { lock (_waitPixelData) { Monitor.Pulse(_waitPixelData); } }); var onFrameAsyncLoaded = new AsyncPixelDataEventHandler(completionHandler); var onFrameAsyncFaulted = new AsyncPixelDataFaultEventHandler(completionHandler); asyncFrame.AsyncLoaded += onFrameAsyncLoaded; asyncFrame.AsyncFaulted += onFrameAsyncFaulted; asyncFrame.GetNormalizedPixelData(); // check the flag again, in case the event actually fired before we hooked up the handler if (!asyncFrame.IsAsyncLoaded) { Monitor.Wait(_waitPixelData); } asyncFrame.AsyncLoaded -= onFrameAsyncLoaded; asyncFrame.AsyncFaulted -= onFrameAsyncFaulted; } } } else if (!ApplicationGraphics.OfType <ProgressGraphic>().Any()) { ProgressGraphic.Show(this, ApplicationGraphics, true, ProgressBarGraphicStyle.Continuous, false); } } base.Draw(drawArgs); } }
//Function that animates the circle to a certain state private void AnimateCircleAngle(double PercentBefore, double PercentAfter) { //Make time relative based on how much we are animating double time = PercentAfter - PercentBefore; //We multiply the percentage by 3.6 because a full circle is 360 degrees, divide 360 by 100 and you get 3.6 //So half a circle would be 50(%) * 3.6 = 180 degrees, half a circle. DoubleAnimation da = new DoubleAnimation(PercentBefore * 3.6, PercentAfter * 3.6, TimeSpan.FromSeconds(time * 0.025)); SineEase ease = new SineEase(); da.EasingFunction = ease; ProgressGraphic.BeginAnimation(Microsoft.Expression.Shapes.Arc.EndAngleProperty, da); }
public void AnimateCircleThickness(double widthBefore, double widthAfter, bool RepeatForever = true, bool AutoReverse = true) { DoubleAnimation da = new DoubleAnimation(widthBefore, widthAfter, TimeSpan.FromMilliseconds(700)); da.AutoReverse = AutoReverse; if (RepeatForever) { da.RepeatBehavior = RepeatBehavior.Forever; } SineEase ease = new SineEase(); da.EasingFunction = ease; ProgressGraphic.BeginAnimation(Microsoft.Expression.Shapes.Arc.StrokeThicknessProperty, da); }