private async Task Rotate(VstsBuildState state) { if (animationCancellationTokenSource != null) { animationCancellationTokenSource.Cancel(); } animationCancellationTokenSource = new CancellationTokenSource(); var cancellationToken = animationCancellationTokenSource.Token; var element = GetClipElementForState(state); Storyboard storyboard = new Storyboard(); cancellationToken.Register(async() => { await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => { storyboard.RepeatBehavior = new RepeatBehavior(0); }); }); element.RenderTransform = new RotateTransform(); DoubleAnimation rotateAnimation = BuildAnimation(); Storyboard.SetTarget(rotateAnimation, element.RenderTransform); Storyboard.SetTargetProperty(rotateAnimation, "Angle"); storyboard.Children.Add(rotateAnimation); await storyboard.BeginAsync(); }
private async void OnStateEnd(object sender, VstsBuildState state, string message = null) { await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => { SetColor(state, STATE_COMPLETE_COLOR); if (animationCancellationTokenSource != null) { animationCancellationTokenSource.Cancel(); animationCancellationTokenSource = null; } }); }
private void ProcessStateChangeNotification(VstsBuildStateChangeNotification notification) { if (state != VstsBuildState.Unknown && state != VstsBuildState.DeployComplete && notification.State != state) { OnStateEnd(this, state); } if (notification?.State == null) { return; } state = notification.State; OnStateBegin(this, notification.State, notification.Message); }
private void SetColor(VstsBuildState state, Color color) { var e = GetElementForState(state); var c = GetClipElementForState(state); if (e == null || c == null) { return; } var darkColor = DarkenColor(color, STATE_CLIP_DARKNESS_RATIO); var ewColor = Windows.UI.Color.FromArgb(color.A, color.R, color.G, color.B); var cwColor = Windows.UI.Color.FromArgb(darkColor.A, darkColor.R, darkColor.G, darkColor.B); e.Fill = new SolidColorBrush(ewColor); c.Fill = new SolidColorBrush(cwColor); }
private Shape GetElementForState(VstsBuildState state) { switch (state) { case VstsBuildState.BuildingApplication: return(ellipse_Step1); case VstsBuildState.PublishingContainer: return(ellipse_Step2); case VstsBuildState.UpgradingCluster: return(ellipse_Step3); case VstsBuildState.DeployComplete: return(ellipse_Step4); default: return(null); } }
private async void OnStateBegin(object sender, VstsBuildState state, string message = null) { await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, async() => { if (message != null) { textBlock_SubStatus.Text = message; } if (_CurrentState == state) { return; } _CurrentState = state; switch (state) { case VstsBuildState.DeployComplete: SetAllColors(STATE_COMPLETE_COLOR); button_Deploy.IsEnabled = true; return; case VstsBuildState.Failed: SetAllColors(STATE_FAILED_COLOR); button_Deploy.IsEnabled = true; return; case VstsBuildState.BuildingApplication: button_Deploy.IsEnabled = false; SetAllColors(STATE_INACTIVE_COLOR, new List <VstsBuildState> { VstsBuildState.BuildingApplication }); break; } SetColor(state, STATE_ACTIVE_COLOR); await Rotate(state); }); }