Exemplo n.º 1
0
 private void TryRehook()
 {
     (IntPtr Host, int processid) = DUIHandler.GetAll();
     if (Host != IntPtr.Zero && processid != 0)
     {
         rehooktimer.Stop();
         DUIHook.Rehook(Host, (uint)processid);
     }
 }
Exemplo n.º 2
0
        public void Initialize()
        {
            DUIHandler.ForceFindDUIAndHide();

            FlyoutWindow = new FlyoutWindow();
            FlyoutWindow.SourceInitialized += FlyoutWindow_SourceInitialized;

            SystemTheme.SystemThemeChanged += OnSystemThemeChange;
            SystemTheme.Initialize();

            (IntPtr Host, int processid) = DUIHandler.GetAll();
            DUIHook = new DUIHook();
            DUIHook.Hook(Host, (uint)processid);
            DUIHook.DUIShown     += DUIShown;
            DUIHook.DUIDestroyed += DUIDestroyed;
            rehooktimer           = new DispatcherTimer()
            {
                Interval = TimeSpan.FromSeconds(3), IsEnabled = false
            };
            rehooktimer.Tick += (_, __) => TryRehook();

            KeyboardHook          = new KeyboardHook();
            KeyboardHook.KeyDown += KeyboardHook_KeyDown;

            #region Load Settings

            var adEnabled           = Properties.Settings.Default.AudioModuleEnabled;
            var apmdEnabled         = Properties.Settings.Default.AirplaneModeModuleEnabled;
            var lkkyEnabled         = Properties.Settings.Default.LockKeysModuleEnabled;
            var brEnabled           = Properties.Settings.Default.BrightnessModuleEnabled;
            var defaultFlyoutString = Properties.Settings.Default.DefaultFlyout;

            if (Enum.TryParse(defaultFlyoutString, true, out DefaultFlyout _defaultFlyout))
            {
                DefaultFlyout = _defaultFlyout;
            }
            else
            {
                Properties.Settings.Default.DefaultFlyout = DefaultFlyout.ToString();
                Properties.Settings.Default.Save();
            }

            TopBarEnabled = Properties.Settings.Default.TopBarEnabled;

            #endregion

            #region Initiate Helpers

            AudioHelper = new AudioHelper()
            {
                IsEnabled = adEnabled
            };
            AirplaneModeHelper = new AirplaneModeHelper()
            {
                IsEnabled = apmdEnabled
            };
            LockKeysHelper = new LockKeysHelper()
            {
                IsEnabled = lkkyEnabled
            };
            BrightnessHelper = new BrightnessHelper()
            {
                IsEnabled = brEnabled
            };

            AudioHelper.ShowFlyoutRequested        += ShowFlyout;
            AirplaneModeHelper.ShowFlyoutRequested += ShowFlyout;
            LockKeysHelper.ShowFlyoutRequested     += ShowFlyout;
            BrightnessHelper.ShowFlyoutRequested   += ShowFlyout;

            #endregion
        }