Esempio n. 1
0
        private void ShowHideBoundaries()
        {
            var anim = _showBoundaries ? _showButtonsAnimation : _hideButtonsAnimation;

            Dispatcher?.InvokeAsync(() =>
            {
                BoundaryRef?.BeginAnimation(OpacityProperty, anim);
                ButtonsRef?.BeginAnimation(OpacityProperty, anim);
                OnClickThruModeChanged();
            });
        }
        protected void Init(WindowSettings settings, bool ignoreSize = true)
        {
            _settings   = settings;
            _ignoreSize = ignoreSize;

            _opacityAnimation = new DoubleAnimation()
            {
                Duration = TimeSpan.FromMilliseconds(250)
            };

            Topmost = true;
            Left    = settings.X * SettingsManager.ScreenW;
            Top     = settings.Y * SettingsManager.ScreenH;

            if (!ignoreSize)
            {
                if (settings.H != 0)
                {
                    Height = settings.H;
                }
                if (settings.W != 0)
                {
                    Width = settings.W;
                }
            }

            _settings.EnabledChanged       += OnEnabledChanged;
            _settings.ClickThruModeChanged += OnClickThruModeChanged;
            _settings.VisibilityChanged    += OnWindowVisibilityChanged;

            Loaded  += OnLoaded;
            Closing += (_, args) =>
            {
                //args.Cancel = true;
                //Hide();
            };
            SizeChanged += OnSizeChanged;

            WindowManager.ForegroundManager.VisibilityChanged += OnVisibilityChanged;
            WindowManager.ForegroundManager.DimChanged        += OnDimChanged;
            WindowManager.ForegroundManager.ClickThruChanged  += OnClickThruModeChanged;
            FocusManager.FocusTimer.Elapsed += OnFocusTick;

            if (_settings.Enabled)
            {
                Show();
            }
            OnClickThruModeChanged();
            OnVisibilityChanged();
            OnWindowVisibilityChanged();

            FocusManager.MakeUnfocusable(Handle);


            if (ButtonsRef == null)
            {
                MouseLeftButtonDown += Drag;
                return;
            }
            _hideButtons  = new DoubleAnimation(0, TimeSpan.FromMilliseconds(1000));
            _showButtons  = new DoubleAnimation(1, TimeSpan.FromMilliseconds(150));
            _buttonsTimer = new DispatcherTimer {
                Interval = TimeSpan.FromSeconds(2)
            };
            _buttonsTimer.Tick += OnButtonsTimerTick;

            MouseEnter += (_, __) => ButtonsRef.BeginAnimation(OpacityProperty, _showButtons);
            MouseLeave += (_, __) => _buttonsTimer.Start();
            ButtonsRef.MouseLeftButtonDown += Drag;
        }
Esempio n. 3
0
        protected void Init(WindowSettings settings, bool ignoreSize = true, bool undimOnFlyingGuardian = true, bool perClassPosition = true)
        {
            settings.PerClassPosition = perClassPosition;
            WindowSettings            = settings;
            _ignoreSize            = ignoreSize;
            _undimOnFlyingGuardian = undimOnFlyingGuardian;

            _opacityAnimation = new DoubleAnimation {
                Duration = TimeSpan.FromMilliseconds(100)
            };

            MainContent.Opacity = 0;
            Topmost             = true;
            Left = settings.X * WindowManager.ScreenSize.Width * WindowManager.ScreenCorrection.Width;
            Top  = settings.Y * WindowManager.ScreenSize.Height * WindowManager.ScreenCorrection.Height;
            CheckBounds();
            if (!ignoreSize)
            {
                if (settings.H != 0)
                {
                    Height = settings.H;
                }
                if (settings.W != 0)
                {
                    Width = settings.W;
                }
            }

            WindowSettings.EnabledChanged       += OnEnabledChanged;
            WindowSettings.ClickThruModeChanged += OnClickThruModeChanged;
            WindowSettings.VisibilityChanged    += OnWindowVisibilityChanged;
            WindowSettings.ResetToCenter        += ResetToCenter;

            Loaded      += OnLoaded;
            SizeChanged += OnSizeChanged;

            WindowManager.ForegroundManager.VisibilityChanged += OnVisibilityChanged;
            WindowManager.ForegroundManager.DimChanged        += OnDimChanged;
            WindowManager.ForegroundManager.ClickThruChanged  += OnClickThruModeChanged;
            FocusManager.FocusTick += OnFocusTick;

            //if (WindowSettings.Enabled) Show();
            OnClickThruModeChanged();
            OnVisibilityChanged();
            OnWindowVisibilityChanged();

            FocusManager.MakeUnfocusable(Handle);


            if (ButtonsRef == null)
            {
                if (CanMove)
                {
                    MouseLeftButtonDown += Drag;
                }
                return;
            }

            _hideButtons  = new DoubleAnimation(0, TimeSpan.FromMilliseconds(1000));
            _showButtons  = new DoubleAnimation(1, TimeSpan.FromMilliseconds(150));
            _buttonsTimer = new DispatcherTimer {
                Interval = TimeSpan.FromSeconds(2)
            };
            _buttonsTimer.Tick += OnButtonsTimerTick;

            MouseEnter += (_, __) =>
            {
                if (!SettingsHolder.HideHandles)
                {
                    ButtonsRef.BeginAnimation(OpacityProperty, _showButtons);
                }
            };
            MouseLeave += (_, __) => _buttonsTimer.Start();
            if (CanMove)
            {
                ButtonsRef.MouseLeftButtonDown += Drag;
            }
        }