At.FF.Krems.FullscreenBrowser.ScreenRefresher.Initialize C# (CSharp) Method

Initialize() private method

Initializes this instance.
private Initialize ( bool force = false ) : void
force bool Force initialization, even if already initialized.
return void
        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();
            }
        }