private static Interop.AccentFlags GetAccentFlagsForTaskbarPosition() { var flags = Interop.AccentFlags.DrawAllBorders; switch (TaskbarService.GetWinTaskbarState().TaskbarPosition) { case TaskbarPosition.Top: flags &= ~Interop.AccentFlags.DrawTopBorder; break; case TaskbarPosition.Bottom: flags &= ~Interop.AccentFlags.DrawBottomBorder; break; case TaskbarPosition.Left: flags &= ~Interop.AccentFlags.DrawLeftBorder; break; case TaskbarPosition.Right: flags &= ~Interop.AccentFlags.DrawRightBorder; break; } return(flags); }
public void UpdateWindowPosition() { var taskbarState = TaskbarService.GetWinTaskbarState(); switch (taskbarState.TaskbarPosition) { case TaskbarPosition.Left: Left = (taskbarState.TaskbarSize.right / this.DpiWidthFactor()); Top = (taskbarState.TaskbarSize.bottom / this.DpiHeightFactor()) - Height; break; case TaskbarPosition.Right: Left = (taskbarState.TaskbarSize.left / this.DpiWidthFactor()) - Width; Top = (taskbarState.TaskbarSize.bottom / this.DpiHeightFactor()) - Height; break; case TaskbarPosition.Top: Left = (taskbarState.TaskbarSize.right / this.DpiWidthFactor()) - Width; Top = (taskbarState.TaskbarSize.bottom / this.DpiHeightFactor()); break; case TaskbarPosition.Bottom: Left = (taskbarState.TaskbarSize.right / this.DpiWidthFactor()) - Width; Top = (taskbarState.TaskbarSize.top / this.DpiHeightFactor()) - Height; break; } }
private void UpdateWindowPosition() { LayoutRoot.UpdateLayout(); LayoutRoot.Measure(new Size(double.PositiveInfinity, MaxHeight)); Height = LayoutRoot.DesiredSize.Height; var taskbarState = TaskbarService.GetWinTaskbarState(); switch (taskbarState.TaskbarPosition) { case TaskbarPosition.Left: Left = (taskbarState.TaskbarSize.right / this.DpiWidthFactor()); Top = (taskbarState.TaskbarSize.bottom / this.DpiHeightFactor()) - Height; break; case TaskbarPosition.Right: Left = (taskbarState.TaskbarSize.left / this.DpiWidthFactor()) - Width; Top = (taskbarState.TaskbarSize.bottom / this.DpiHeightFactor()) - Height; break; case TaskbarPosition.Top: Left = (taskbarState.TaskbarSize.right / this.DpiWidthFactor()) - Width; Top = (taskbarState.TaskbarSize.bottom / this.DpiHeightFactor()); break; case TaskbarPosition.Bottom: Left = (taskbarState.TaskbarSize.right / this.DpiWidthFactor()) - Width; Top = (taskbarState.TaskbarSize.top / this.DpiHeightFactor()) - Height; break; } }
protected override void OnClick() { if (Command is IAsyncCommand asyncCommand) { _busy.Task(async() => { try { SetValue(IsProcessingPropertyKey, true); using (_cancellation = new CancellationTokenSource()) using (_taskbar = TaskbarService.Create(1200)) { await _commandInvoke.Invoke(asyncCommand, this, _cancellation.Token, CommandParameter); if (_commandPercentageProgress) { // Report(new AsyncProgressEntry(Progress.Message, 1d)); Report(AsyncProgressEntry.Finished); } } } catch (Exception e) when(e.IsCanceled()) { } catch (Exception e) { NonfatalError.Notify("Unhandled error", e); } finally { _cancellation = null; SetValue(IsProcessingPropertyKey, false); } }).Forget(); } else { base.OnClick(); } }
public static void ShowWithAnimation(this Window window) { if (showAnimationInProgress) { return; } try { showAnimationInProgress = true; window.Visibility = Visibility.Visible; window.Topmost = false; window.Activate(); var showAnimation = new DoubleAnimation { Duration = new Duration(TimeSpan.FromSeconds(0.3)), FillBehavior = FillBehavior.Stop, EasingFunction = new ExponentialEase { EasingMode = EasingMode.EaseOut } }; var taskbarPosition = TaskbarService.GetWinTaskbarState().TaskbarPosition; switch (taskbarPosition) { case TaskbarPosition.Left: case TaskbarPosition.Right: showAnimation.To = window.Left; break; default: showAnimation.To = window.Top; break; } showAnimation.From = (taskbarPosition == TaskbarPosition.Top || taskbarPosition == TaskbarPosition.Left) ? showAnimation.To - 60 : showAnimation.To + 60; showAnimation.Completed += (s, e) => { window.Topmost = true; showAnimationInProgress = false; window.Focus(); }; switch (taskbarPosition) { case TaskbarPosition.Left: case TaskbarPosition.Right: window.ApplyAnimationClock(Window.LeftProperty, showAnimation.CreateClock()); break; default: window.ApplyAnimationClock(Window.TopProperty, showAnimation.CreateClock()); break; } } catch { showAnimationInProgress = false; } }
public static void HideWithAnimation(this Window window) { if (hideAnimationInProgress) { return; } try { hideAnimationInProgress = true; var hideAnimation = new DoubleAnimation { Duration = new Duration(TimeSpan.FromSeconds(0.2)), FillBehavior = FillBehavior.Stop, EasingFunction = new ExponentialEase { EasingMode = EasingMode.EaseIn } }; var taskbarPosition = TaskbarService.GetWinTaskbarState().TaskbarPosition; switch (taskbarPosition) { case TaskbarPosition.Left: case TaskbarPosition.Right: hideAnimation.From = window.Left; break; default: hideAnimation.From = window.Top; break; } hideAnimation.To = (taskbarPosition == TaskbarPosition.Top || taskbarPosition == TaskbarPosition.Left) ? hideAnimation.From - 30 : hideAnimation.From + 30; hideAnimation.Completed += (s, e) => { window.Visibility = Visibility.Hidden; hideAnimationInProgress = false; }; switch (taskbarPosition) { case TaskbarPosition.Left: case TaskbarPosition.Right: window.ApplyAnimationClock(Window.LeftProperty, hideAnimation.CreateClock()); break; default: window.ApplyAnimationClock(Window.TopProperty, hideAnimation.CreateClock()); break; } } catch { hideAnimationInProgress = false; } }
protected override TaskbarHolder GetTaskbarProgress() { return(TaskbarService.Create(5)); }
protected override TaskbarHolder GetTaskbarProgress() { return(TaskbarService.Create("Loading cars", 5)); }
protected override TaskbarHolder GetTaskbarProgress() { return(TaskbarService.Create("Loading tracks", 4.9)); }