예제 #1
0
        public void Initialize()
        {
            FlyoutWindow = new FlyoutWindow();
            CreateWndProc();

            UIManager = new UIManager();
            UIManager.Initialize(FlyoutWindow);

            DUIHook = new DUIHook();
            DUIHook.Hook();
            DUIHook.DUIShown     += DUIShown;
            DUIHook.DUIDestroyed += DUIDestroyed;
            rehooktimer           = new DispatcherTimer()
            {
                Interval = TimeSpan.FromSeconds(3), IsEnabled = false
            };
            rehooktimer.Tick += (_, __) => TryRehook();

            KeyboardHook = new KeyboardHook();

            #region App Data

            var adEnabled   = AppDataHelper.AudioModuleEnabled;
            var apmdEnabled = AppDataHelper.AirplaneModeModuleEnabled;
            var lkkyEnabled = AppDataHelper.LockKeysModuleEnabled;
            var brEnabled   = AppDataHelper.BrightnessModuleEnabled;

            DefaultFlyout = AppDataHelper.DefaultFlyout;

            TopBarEnabled         = AppDataHelper.TopBarEnabled;
            DefaultFlyoutPosition = AppDataHelper.DefaultFlyoutPosition;

            async void getStartupStatus()
            {
                RunAtStartup = await StartupHelper.GetRunAtStartupEnabled();
            }

            getStartupStatus();

            #endregion

            #region Initiate Helpers

            AudioFlyoutHelper = new AudioFlyoutHelper()
            {
                IsEnabled = adEnabled
            };
            AirplaneModeFlyoutHelper = new AirplaneModeFlyoutHelper()
            {
                IsEnabled = apmdEnabled
            };
            LockKeysFlyoutHelper = new LockKeysFlyoutHelper()
            {
                IsEnabled = lkkyEnabled
            };
            BrightnessFlyoutHelper = new BrightnessFlyoutHelper()
            {
                IsEnabled = brEnabled
            };

            AudioFlyoutHelper.ShowFlyoutRequested        += ShowFlyout;
            AirplaneModeFlyoutHelper.ShowFlyoutRequested += ShowFlyout;
            LockKeysFlyoutHelper.ShowFlyoutRequested     += ShowFlyout;
            BrightnessFlyoutHelper.ShowFlyoutRequested   += ShowFlyout;

            #endregion

            HasInitialized = true;
            Initialized?.Invoke(null, null);
        }
예제 #2
0
        public void Initialize()
        {
            DUIHandler.ForceFindDUIAndHide();

            FlyoutWindow = new FlyoutWindow();
            CreateWndProc();

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

            DUIHook = new DUIHook();
            DUIHook.Hook();
            DUIHook.DUIShown     += DUIShown;
            DUIHook.DUIDestroyed += DUIDestroyed;
            rehooktimer           = new DispatcherTimer()
            {
                Interval = TimeSpan.FromSeconds(3), IsEnabled = false
            };
            rehooktimer.Tick += (_, __) => TryRehook();

            KeyboardHook = new KeyboardHook();

            #region Load Settings

            var adEnabled           = AppDataHelper.AudioModuleEnabled;
            var apmdEnabled         = AppDataHelper.AirplaneModeModuleEnabled;
            var lkkyEnabled         = AppDataHelper.LockKeysModuleEnabled;
            var brEnabled           = AppDataHelper.BrightnessModuleEnabled;
            var defaultFlyoutString = AppDataHelper.DefaultFlyout;

            if (Enum.TryParse(defaultFlyoutString, true, out DefaultFlyout _defaultFlyout))
            {
                DefaultFlyout = _defaultFlyout;
            }
            else
            {
                AppDataHelper.DefaultFlyout = DefaultFlyout.ToString();
            }

            TopBarEnabled         = AppDataHelper.TopBarEnabled;
            DefaultFlyoutPosition = AppDataHelper.DefaultFlyoutPosition;

            async void getStartupStatus()
            {
                RunAtStartup = await StartupHelper.GetRunAtStartupEnabled();
            }

            getStartupStatus();

            #endregion

            #region Initiate Helpers

            AudioFlyoutHelper = new AudioFlyoutHelper()
            {
                IsEnabled = adEnabled
            };
            AirplaneModeFlyoutHelper = new AirplaneModeFlyoutHelper()
            {
                IsEnabled = apmdEnabled
            };
            LockKeysFlyoutHelper = new LockKeysFlyoutHelper()
            {
                IsEnabled = lkkyEnabled
            };
            BrightnessFlyoutHelper = new BrightnessFlyoutHelper()
            {
                IsEnabled = brEnabled
            };

            AudioFlyoutHelper.ShowFlyoutRequested        += ShowFlyout;
            AirplaneModeFlyoutHelper.ShowFlyoutRequested += ShowFlyout;
            LockKeysFlyoutHelper.ShowFlyoutRequested     += ShowFlyout;
            BrightnessFlyoutHelper.ShowFlyoutRequested   += ShowFlyout;

            #endregion

            HasInitialized = true;
            Initialized?.Invoke(null, null);
        }