private void SetButtonUI(ButtonRefreshMode mode = ButtonRefreshMode.WithAnimation) { if (Status == Models.ConnectionState.Protected) { AnimateOn(mode); this.IsEnabled = true; } if (Status == Models.ConnectionState.Connecting) { AnimateOn(mode); this.IsEnabled = false; } if (Status == Models.ConnectionState.Unprotected) { AnimateOff(mode); this.IsEnabled = true; } if (Status == Models.ConnectionState.Disconnecting) { AnimateOff(mode); this.IsEnabled = false; } }
private void AnimateOff(ButtonRefreshMode mode = ButtonRefreshMode.WithAnimation) { System.Windows.Thickness newThickness = SphereContainer.Margin; if (newThickness.Left == 5) { return; } newThickness.Left = 5; if (mode == ButtonRefreshMode.WithAnimation) { SphereContainer.BeginAnimation(Canvas.MarginProperty, new ThicknessAnimation(newThickness, TimeSpan.FromSeconds(0.15), System.Windows.Media.Animation.FillBehavior.HoldEnd) ); } else { SphereContainer.Margin = newThickness; } SphereContainer.BeginStoryboard(this.FindResource("MakeGrayColor") as Storyboard); if (EnableWhiteSwitchBorder) { SwitchBorder.BorderBrush = this.FindResource("Grey/Grey 10") as Brush; } }