コード例 #1
0
 private void TryRehook()
 {
     if (DUIHandler.GetAllInfos())
     {
         rehooktimer.Stop();
         DUIHook.Rehook();
     }
 }
コード例 #2
0
 private void TryRehook()
 {
     (IntPtr Host, int processid) = DUIHandler.GetAll();
     if (Host != IntPtr.Zero && processid != 0)
     {
         rehooktimer.Stop();
         DUIHook.Rehook(Host, (uint)processid);
     }
 }
コード例 #3
0
        private void OnDefaultFlyoutChanged()
        {
            if (defaultFlyout != DefaultFlyout.ModernFlyouts)
            {
                FlyoutWindow.Visible = false;
            }
            if (defaultFlyout != DefaultFlyout.WindowsDefault)
            {
                DUIHandler.FindDUIAndHide();
            }

            AppDataHelper.DefaultFlyout = defaultFlyout;
        }
コード例 #4
0
        static void Main(string[] args)
        {
            AppLifecycleManager.StartApplication(args, () =>
            {
                AppDataMigration.Perform();

                DUIHandler.ForceFindDUIAndHide(false);

                LocalizationHelper.Initialize();

                var app = new App();
                app.Run();
            });
        }
コード例 #5
0
        private void OnDefaultFlyoutChanged()
        {
            if (defaultFlyout != DefaultFlyout.ModernFlyouts)
            {
                FlyoutWindow.Visible = false;
            }
            if (defaultFlyout != DefaultFlyout.WindowsDefault)
            {
                DUIHandler.FindDUIAndHide();
            }

            Properties.Settings.Default.DefaultFlyout = defaultFlyout.ToString();
            Properties.Settings.Default.Save();
        }
コード例 #6
0
 private void DUIShown()
 {
     if (DefaultFlyout == DefaultFlyout.ModernFlyouts && Handled())
     {
         DUIHandler.FindDUIAndHide();
     }
     else if (DefaultFlyout == DefaultFlyout.None)
     {
         DUIHandler.FindDUIAndHide();
     }
     else
     {
         DUIHandler.FindDUIAndShow();
     }
 }
コード例 #7
0
ファイル: Program.cs プロジェクト: disman-52/ModernFlyouts
        internal static void RunCommand(RunCommandType runCommandType)
        {
            switch (runCommandType)
            {
            case RunCommandType.ShowSettings:
            {
                if (FlyoutHandler.HasInitialized)
                {
                    FlyoutHandler.ShowSettingsWindow();
                }
                else
                {
                    FlyoutHandler.Initialized += (_, __) => FlyoutHandler.ShowSettingsWindow();
                }
                break;
            }

            case RunCommandType.RestoreDefault:
            {
                if (!DUIHandler.IsDUIAvailable())
                {
                    DUIHandler.GetAllInfos();
                }
                FlyoutHandler.SafelyExitApplication();
                break;
            }

            case RunCommandType.SafeExit:
            {
                FlyoutHandler.SafelyExitApplication();
                break;
            }

            case RunCommandType.AppUpdated:
            {
                if (AppLifecycleManager.IsBuildBetaChannel)
                {
                    MessageBox.Show("App update successfully!", AppName);
                }

                break;
            }

            default:
                break;
            }
        }
コード例 #8
0
        private void DUIShown()
        {
            Debug.WriteLine(nameof(DUIHook) + ": DUI Shown!");

            if (DefaultFlyout == DefaultFlyout.ModernFlyouts && Handled())
            {
                DUIHandler.FindDUIAndHide();
            }
            else if (DefaultFlyout == DefaultFlyout.None)
            {
                DUIHandler.FindDUIAndHide();
            }
            else
            {
                DUIHandler.FindDUIAndShow();
            }
        }
コード例 #9
0
        private void ShowFlyout(HelperBase helper)
        {
            if (DefaultFlyout != DefaultFlyout.ModernFlyouts || !helper.IsEnabled)
            {
                return;
            }

            FlyoutWindow.StopHideTimer();

            if (helper.AlwaysHandleDefaultFlyout)
            {
                DUIHandler.FindDUIAndHide();
            }

            FlyoutWindow.DataContext = helper;
            FlyoutWindow.Visible     = true;
            FlyoutWindow.StartHideTimer();
        }
コード例 #10
0
ファイル: Program.cs プロジェクト: yume-chan/ModernFlyouts
        static void Main(string[] args)
        {
            if (mutex.WaitOne(TimeSpan.Zero, true))
            {
                ProcessCommandLineArgs(args);

                CreateRemoteService(AppName);

                DUIHandler.ForceFindDUIAndHide(false);

                var app = new App();
                app.Run();
            }
            else
            {
                SignalFirstInstance(AppName);
            }
        }
コード例 #11
0
ファイル: Program.cs プロジェクト: disman-52/ModernFlyouts
        private static void Main(string[] args)
        {
            AppLifecycleManager.StartApplication(args, () =>
            {
                InitializePrivateUseClasses();

#if RELEASE
                Microsoft.AppCenter.AppCenter.Start("26393d67-ab03-4e26-a6db-aa76bf989c21",
                                                    typeof(Microsoft.AppCenter.Analytics.Analytics), typeof(Microsoft.AppCenter.Crashes.Crashes));
#endif

                AppDataMigration.Perform();

                DUIHandler.ForceFindDUIAndHide(false);

                LocalizationHelper.Initialize();

                var app = new App();
                app.Run();
            });
        }
コード例 #12
0
ファイル: App.xaml.cs プロジェクト: xyfx666/ModernFlyouts
        public static void ProcessCommandLineArgs(IList <string> args, bool isFirstInstance = true)
        {
            string arg = string.Empty;

            if ((isFirstInstance && args?.Count > 0) || (!isFirstInstance && args?.Count > 1))
            {
                arg = isFirstInstance ? args[0] : args[1];
            }

            if (arg == string.Empty)
            {
                if (!isFirstInstance)
                {
                    FlyoutHandler.ShowSettingsWindow();
                }
            }
            else if (arg.ToLowerInvariant() == arg_settings)
            {
                if (FlyoutHandler.HasInitialized)
                {
                    FlyoutHandler.ShowSettingsWindow();
                }
                else
                {
                    FlyoutHandler.Initialized += (_, __) => FlyoutHandler.ShowSettingsWindow();
                }
            }
            else if (arg.ToLowerInvariant() == arg_restore)
            {
                if (!DUIHandler.IsDUIAvailable())
                {
                    DUIHandler.GetAllInfos();
                }
                FlyoutHandler.SafelyExitApplication();
            }
            else if (arg.ToLowerInvariant() == arg_exit)
            {
                FlyoutHandler.SafelyExitApplication();
            }
        }
コード例 #13
0
        internal static void RunCommand(RunCommandType runCommandType)
        {
            switch (runCommandType)
            {
            case RunCommandType.ShowSettings:
            {
                if (FlyoutHandler.HasInitialized)
                {
                    FlyoutHandler.ShowSettingsWindow();
                }
                else
                {
                    FlyoutHandler.Initialized += (_, __) => FlyoutHandler.ShowSettingsWindow();
                }
                break;
            }

            case RunCommandType.RestoreDefault:
            {
                if (!DUIHandler.IsDUIAvailable())
                {
                    DUIHandler.GetAllInfos();
                }
                FlyoutHandler.SafelyExitApplication();
                break;
            }

            case RunCommandType.SafeExit:
            {
                FlyoutHandler.SafelyExitApplication();
                break;
            }

            default:
                break;
            }
        }
コード例 #14
0
 public static void SafelyExitApplication()
 {
     DUIHandler.FindDUIAndShow();
     Environment.Exit(0);
 }
コード例 #15
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
        }
コード例 #16
0
 public static void SafelyExitApplication()
 {
     DUIHandler.FindDUIAndShow();
     Application.Current.Shutdown();
 }
コード例 #17
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);
        }