Skip to content
Merged
2 changes: 1 addition & 1 deletion Flow.Launcher/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -377,8 +377,8 @@
HorizontalAlignment="Stretch"
Style="{DynamicResource SeparatorStyle}" />
</ContentControl>

</Grid>

<Border Style="{DynamicResource WindowRadius}">
<Border.Clip>
<MultiBinding Converter="{StaticResource BorderClipConverter}">
Expand Down
82 changes: 41 additions & 41 deletions Flow.Launcher/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ public partial class MainWindow
{
#region Private Fields

private readonly Storyboard _progressBarStoryboard = new Storyboard();
private bool isProgressBarStoryboardPaused;
private Settings _settings;
private NotifyIcon _notifyIcon;
private ContextMenu contextMenu = new ContextMenu();
Expand Down Expand Up @@ -71,8 +69,6 @@ public MainWindow(Settings settings, MainViewModel mainVM)
};
}

DispatcherTimer timer = new DispatcherTimer { Interval = new TimeSpan(0, 0, 0, 0, 500), IsEnabled = false };

public MainWindow()
{
InitializeComponent();
Expand Down Expand Up @@ -225,39 +221,9 @@ private void OnLoaded(object sender, RoutedEventArgs _)
_viewModel.LastQuerySelected = true;
}

if (_viewModel.ProgressBarVisibility == Visibility.Visible &&
isProgressBarStoryboardPaused)
{
_progressBarStoryboard.Begin(ProgressBar, true);
isProgressBarStoryboardPaused = false;
}

if (_settings.UseAnimation)
WindowAnimator();
}
else if (!isProgressBarStoryboardPaused)
{
_progressBarStoryboard.Stop(ProgressBar);
isProgressBarStoryboardPaused = true;
}
});
break;
}
case nameof(MainViewModel.ProgressBarVisibility):
{
Dispatcher.Invoke(() =>
{
if (_viewModel.ProgressBarVisibility == Visibility.Hidden && !isProgressBarStoryboardPaused)
{
_progressBarStoryboard.Stop(ProgressBar);
isProgressBarStoryboardPaused = true;
}
else if (_viewModel.MainWindowVisibilityStatus &&
isProgressBarStoryboardPaused)
{
_progressBarStoryboard.Begin(ProgressBar, true);
isProgressBarStoryboardPaused = false;
}
});
break;
}
Expand Down Expand Up @@ -365,7 +331,6 @@ private void InitializeNotifyIcon()
Icon = Constant.Version == "1.0.0" ? Properties.Resources.dev : Properties.Resources.app,
Visible = !_settings.HideNotifyIcon
};

var openIcon = new FontIcon { Glyph = "\ue71e" };
var open = new MenuItem
{
Expand All @@ -376,7 +341,8 @@ private void InitializeNotifyIcon()
var gamemodeIcon = new FontIcon { Glyph = "\ue7fc" };
var gamemode = new MenuItem
{
Header = InternationalizationManager.Instance.GetTranslation("GameMode"), Icon = gamemodeIcon
Header = InternationalizationManager.Instance.GetTranslation("GameMode"),
Icon = gamemodeIcon
};
var positionresetIcon = new FontIcon { Glyph = "\ue73f" };
var positionreset = new MenuItem
Expand All @@ -393,7 +359,8 @@ private void InitializeNotifyIcon()
var exitIcon = new FontIcon { Glyph = "\ue7e8" };
var exit = new MenuItem
{
Header = InternationalizationManager.Instance.GetTranslation("iconTrayExit"), Icon = exitIcon
Header = InternationalizationManager.Instance.GetTranslation("iconTrayExit"),
Icon = exitIcon
};

open.Click += (o, e) => _viewModel.ToggleFlowLauncher();
Expand Down Expand Up @@ -460,17 +427,50 @@ private async void PositionReset()

private void InitProgressbarAnimation()
{
var progressBarStoryBoard = new Storyboard();

var da = new DoubleAnimation(ProgressBar.X2, ActualWidth + 100,
new Duration(new TimeSpan(0, 0, 0, 0, 1600)));
var da1 = new DoubleAnimation(ProgressBar.X1, ActualWidth + 0,
new Duration(new TimeSpan(0, 0, 0, 0, 1600)));
Storyboard.SetTargetProperty(da, new PropertyPath("(Line.X2)"));
Storyboard.SetTargetProperty(da1, new PropertyPath("(Line.X1)"));
_progressBarStoryboard.Children.Add(da);
_progressBarStoryboard.Children.Add(da1);
_progressBarStoryboard.RepeatBehavior = RepeatBehavior.Forever;
progressBarStoryBoard.Children.Add(da);
progressBarStoryBoard.Children.Add(da1);
progressBarStoryBoard.RepeatBehavior = RepeatBehavior.Forever;

da.Freeze();
da1.Freeze();

const string progressBarAnimationName = "ProgressBarAnimation";
var beginStoryboard = new BeginStoryboard
{
Name = progressBarAnimationName, Storyboard = progressBarStoryBoard
};

var stopStoryboard = new StopStoryboard()
{
BeginStoryboardName = progressBarAnimationName
};

var trigger = new Trigger
{
Property = VisibilityProperty, Value = Visibility.Visible
};
trigger.EnterActions.Add(beginStoryboard);
trigger.ExitActions.Add(stopStoryboard);


var progressStyle = new Style(typeof(System.Windows.Shapes.Line))
{
BasedOn = FindResource("PendingLineStyle") as Style
};
progressStyle.RegisterName(progressBarAnimationName, beginStoryboard);
progressStyle.Triggers.Add(trigger);

ProgressBar.Style = progressStyle;

_viewModel.ProgressBarVisibility = Visibility.Hidden;
isProgressBarStoryboardPaused = true;
}

public void WindowAnimator()
Expand Down
Loading