Beispiel #1
0
        private IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
        {
            if (msg == WM_MOUSEACTIVATE)
            {
                handled = true;
                return(new IntPtr(MA_NOACTIVATE));
            }

            if (msg == messageShellHookId)
            {
                if (wParam == (IntPtr)55)
                {
                    //Brightness
                    BrightnessFlyoutHelper?.OnExternalUpdated();
                }
                else if (wParam == (IntPtr)12)
                {
                    //Volume
                    AudioFlyoutHelper?.OnExternalUpdated(
                        (int)lParam == (int)HookMessageEnum.HOOK_MEDIA_NEXT ||
                        (int)lParam == (int)HookMessageEnum.HOOK_MEDIA_PREVIOUS ||
                        (int)lParam == (int)HookMessageEnum.HOOK_MEDIA_PLAYPAUSE ||
                        (int)lParam == (int)HookMessageEnum.HOOK_MEDIA_STOP);
                }
            }

            if (msg == WM_EXITSIZEMOVE)
            {
                FlyoutWindow.SaveFlyoutPosition();
            }

            return(IntPtr.Zero);
        }
Beispiel #2
0
        public void Initialize(FlyoutWindow flyoutWindow)
        {
            _flyoutWindow = flyoutWindow;

            themeResources = (ThemeResources)App.Current.Resources.MergedDictionaries.FirstOrDefault(x => x is ThemeResources);
            lightResources = themeResources.ThemeDictionaries["Light"];
            darkResources  = themeResources.ThemeDictionaries["Dark"];

            FlyoutBackgroundOpacity = AppDataHelper.FlyoutBackgroundOpacity;
            UseColoredTrayIcon      = AppDataHelper.UseColoredTrayIcon;

            SystemTheme.SystemThemeChanged += OnSystemThemeChange;
            SystemTheme.Initialize();
        }
Beispiel #3
0
        private IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
        {
            if (msg == WM_MOUSEACTIVATE)
            {
                handled = true;
                return(new IntPtr(MA_NOACTIVATE));
            }

            if (msg == messageShellHookId)
            {
                if (wParam == (IntPtr)55)
                {
                    //Brightness
                    BrightnessFlyoutHelper?.OnExternalUpdated();
                }
                else if (wParam == (IntPtr)12)
                {
                    switch ((long)lParam)
                    {
                    case (long)HookMessageEnum.HOOK_MEDIA_NEXT:
                    case (long)HookMessageEnum.HOOK_MEDIA_PREVIOUS:
                    case (long)HookMessageEnum.HOOK_MEDIA_PLAYPAUSE:
                    case (long)HookMessageEnum.HOOK_MEDIA_STOP:
                        //Media
                        AudioFlyoutHelper?.OnExternalUpdated(true);
                        break;

                    case (long)HookMessageEnum.HOOK_MEDIA_VOLMINUS:
                    case (long)HookMessageEnum.HOOK_MEDIA_VOLMUTE:
                    case (long)HookMessageEnum.HOOK_MEDIA_VOLPLUS:
                        //Volume
                        AudioFlyoutHelper?.OnExternalUpdated(false);
                        break;

                    default:
                        //Ignore mouse side buttons and other keyboard special keys
                        break;
                    }
                }
            }

            if (msg == WM_EXITSIZEMOVE)
            {
                FlyoutWindow.SaveFlyoutPosition();
            }

            return(IntPtr.Zero);
        }
        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();
        }
Beispiel #5
0
        private IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
        {
#if DEBUG
            System.Diagnostics.Debug.WriteLine($"msg={msg}, wParam={wParam}, lParam={lParam}");
#endif
            if (msg == WM_MOUSEACTIVATE)
            {
                handled = true;
                return(new IntPtr(MA_NOACTIVATE));
            }

            if (msg == messageShellHookId || msg == 13)
            {
                if (wParam == (IntPtr)55)
                {
                    //Brightness
                    BrightnessFlyoutHelper?.OnExternalUpdated();
                }
                else if (wParam == (IntPtr)12 || wParam == (IntPtr)512)
                {
                    //Volume
                    AudioFlyoutHelper?.OnExternalUpdated(
                        (long)lParam == (long)HookMessageEnum.HOOK_MEDIA_NEXT ||
                        (long)lParam == (long)HookMessageEnum.HOOK_MEDIA_PREVIOUS ||
                        (long)lParam == (long)HookMessageEnum.HOOK_MEDIA_PLAYPAUSE ||
                        (long)lParam == (long)HookMessageEnum.HOOK_MEDIA_HEADSET_VOLPLUS ||
                        (long)lParam == (long)HookMessageEnum.HOOK_MEDIA_STOP);
                }
            }

            if (msg == WM_EXITSIZEMOVE)
            {
                FlyoutWindow.SaveFlyoutPosition();
            }

            return(IntPtr.Zero);
        }
Beispiel #6
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);
        }
Beispiel #7
0
        public void Initialize(FlyoutWindow flyoutWindow)
        {
            _flyoutWindow = flyoutWindow;

            FlyoutTimeout = AppDataHelper.FlyoutTimeout;
            MaxVerticalSessionControlsCount = AppDataHelper.MaxVerticalSessionControlsCount;
            SessionsPanelOrientation        = AppDataHelper.SessionsPanelOrientation;

            themeResources = (ThemeResources)App.Current.Resources.MergedDictionaries.FirstOrDefault(x => x is ThemeResources);
            lightResources = themeResources.ThemeDictionaries["Light"];
            darkResources  = themeResources.ThemeDictionaries["Dark"];

            FlyoutBackgroundOpacity = AppDataHelper.FlyoutBackgroundOpacity;

            #region Setup TaskbarIcon

            var settingsItem = new MenuItem()
            {
                Header  = Properties.Strings.SettingsItem,
                ToolTip = Properties.Strings.SettingsItemDescription,
                Icon    = new SymbolIcon()
                {
                    Symbol = Symbol.Setting
                }
            };
            settingsItem.Click += (_, __) => FlyoutHandler.ShowSettingsWindow();

            var exitItem = new MenuItem()
            {
                Header  = Properties.Strings.ExitItem,
                ToolTip = Properties.Strings.ExitItemDescription,
                Icon    = new FontIcon()
                {
                    Glyph = CommonGlyphs.PowerButton
                }
            };
            exitItem.Click += (_, __) => FlyoutHandler.SafelyExitApplication();

            TaskbarIconContextMenu = new ContextMenu()
            {
                Items = { settingsItem, exitItem }
            };

            TaskbarIconToolTip = new ToolTip()
            {
                Content = Program.AppName
            };

            TaskbarIcon = new TaskbarIcon()
            {
                TrayToolTip = TaskbarIconToolTip,
                ContextMenu = TaskbarIconContextMenu
            };
            TaskbarIcon.TrayMouseDoubleClick += (_, __) => FlyoutHandler.ShowSettingsWindow();

            #endregion

            UseColoredTrayIcon = AppDataHelper.UseColoredTrayIcon;

            SystemTheme.SystemThemeChanged += OnSystemThemeChange;
            SystemTheme.Initialize();
        }
Beispiel #8
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);
        }
        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
        }