private void Initialize(bool force = false)
{
if ((this.initializeCalled && !force) || !Bootstrapper.GetInstance<IBrowserConfiguration>().Config.ScreenRefresher.Enabled)
{
return;
}
if (!this.initializeCalled)
{
this.timer.Elapsed += (sender, args) => this.ShowScreenRefresher();
this.eventHook = Bootstrapper.GetInstance<IEventHook>();
this.eventHook.Setup(WinEvents.EventSystemForeground);
this.eventHook.EventFired +=
(hook, type, hwnd, idObject, child, thread, time) =>
this.Dispatcher.BeginInvoke(
new Action(() =>
NativeMethods.SetWindowPos(
new WindowInteropHelper(this).Handle,
NativeMethods.HwndTopmost,
0,
0,
0,
0,
NativeMethods.TopmostFlags)));
}
this.initializeCalled = true;
this.config = Bootstrapper.GetInstance<IBrowserConfiguration>().Config.ScreenRefresher;
Canvas.SetTop(this.RectangleAnimation, this.config.Height * -1);
this.RectangleAnimation.Height = this.config.Height;
if (this.config.RunAtStartup)
{
this.ShowScreenRefresher();
}
else
{
this.StartTimer();
}
}