/// <summary>
        /// Start all functions.
        /// </summary>
        public void StartAllFunctions()
        {
            Logger.Write("Starting functions...");
            Logger.Write("Creating MainService...");
            _mainService = new MainService(_hwndSource);

            Logger.Write("Creating OSD window...");
            if (SettingManager.OsdStyle == 1)
            {
                _osdWindow = new DefaultOsdWindow();
            }
            else if (SettingManager.OsdStyle == 2)
            {
                _osdWindow = new CirculaOsdWindow();
            }

            if (_taskbarIcon == null && SettingManager.TrayIconId > 0)
            {
                Logger.Write("Creating TrayIcon...");
                var icon    = System.Drawing.Icon.ExtractAssociatedIcon(_currentExeFilePath);
                var iconUri = @"pack://application:,,,/"
                              + Assembly.GetExecutingAssembly().GetName().Name
                              + ";component/"
                              + $"Resources/TrayIcon{SettingManager.TrayIconId}.png";
                try
                {
                    var iconImageUri = new Uri(iconUri, UriKind.Absolute);
                    var image        = new BitmapImage(iconImageUri);
                    var iconBitmap   = ImageToBitmap(image);
                    icon = System.Drawing.Icon.FromHandle(iconBitmap.GetHicon());
                    iconBitmap.Dispose();
                }
                catch (Exception ex)
                {
                    Logger.Write($"GetIcon from {iconUri} failed, error:{ex}");
                }

                var settingCommand       = new TaskbarIconMenuCommand(ShowSettingWindow);
                var exitCommand          = new TaskbarIconMenuCommand(Close);
                var taskbarIconViewModel = new TaskbarIconViewModel(settingCommand, exitCommand);
                _taskbarIcon = new TaskbarIcon
                {
                    DataContext = taskbarIconViewModel,
                    ContextMenu = Application.Current.TryFindResource("SysTrayMenu") as ContextMenu,
                    TrayToolTip = Application.Current.TryFindResource("SysTrayToolTip") as Border,
                    Icon        = icon
                };
                _taskbarIcon.TrayMouseDoubleClick += OnTrayIconDoubleClick;
                var backlightService = ServiceManager.GetService <IBacklightService>();
                backlightService.BrightnessChanged += OnBrightnessChanged;
                OnBrightnessChanged(backlightService, EventArgs.Empty);
            }

            Logger.Write("All functions started.");
        }
 /// <summary>
 /// Close all functions.
 /// </summary>
 public void StopAllFunctions()
 {
     Logger.Write("Stopping functions...");
     if (_taskbarIcon != null)
     {
         _taskbarIcon.TrayMouseDoubleClick -= OnTrayIconDoubleClick;
         var backlightService = ServiceManager.GetService <IBacklightService>();
         backlightService.BrightnessChanged -= OnBrightnessChanged;
         _taskbarIcon.Dispose();
         _taskbarIcon = null;
     }
     if (_osdWindow != null)
     {
         _osdWindow.Close();
         _osdWindow = null;
     }
     if (_mainService != null)
     {
         _mainService.Close();
         _mainService = null;
     }
     Logger.Write("All functions stopped.");
 }