private void InitializeUi() { _currentCount = _Manager.Count(); _currentFocus = _Manager.GetCurrent(); ActivateHotkeys(); IDictionary <int, Image> images = new Dictionary <int, Image>(); if (_config.Buttons.ButtonType == ButtonTypeEnum.DisplayGraphic) { var w = SystemInformation.VirtualScreen.Width; var h = SystemInformation.VirtualScreen.Height; var fakeRect = new Rectangle(0, 0, w, h); double scale = ((double)_config.Application.ApplicationHeight / (double)h); double imageScale = scale * 0.9; //var imageRect = DesktopVisualManager.ScaleRectangle(fakeRect, imageScale); var buttonRect = DesktopVisualManager.ScaleRectangle(fakeRect, imageScale); _config.Buttons.MinimumButtonWidth = buttonRect.Width; //images = DesktopVisualManager.LoadAllDesktopImages(fakeRect, // ColorTranslator.FromHtml(_config.InactiveDesktopColors.Border), // ColorTranslator.FromHtml(_config.InactiveDesktopColors.Background), // ColorTranslator.FromHtml(_config.ActiveDesktopColors.Background), // imageRect.Height, // imageRect.Width); } for (var i = 1; i <= _config.Application.MaxDesktops; i++) { //DrawButton(i, _config.Buttons.ButtonType, images); DrawButton(i, _config.Buttons.ButtonType); } if (_config.Buttons.ButtonType == ButtonTypeEnum.DisplayGraphic) { QueueIconRefresh(); } DrawGripperButton(); AdjustApplicationSizeAndColor(); //PatchButtonSizes(); StartRefreshTimer(); SetTopMost(); SetStartLocation(); //Process process = Process.GetCurrentProcess(); //_manager.PinWindow(process.Handle); }
private async void QueueIconRefresh() { if (_IsRefreshingIcons) { return; } lock (_IconRefreshLock) { _IsRefreshingIcons = true; } Task.Run(() => { var w = SystemInformation.VirtualScreen.Width; var h = SystemInformation.VirtualScreen.Height; var fakeRect = new Rectangle(0, 0, w, h); double scale = ((double)_config.Application.ApplicationHeight / (double)h); double imageScale = scale * 0.9; var imageRect = DesktopVisualManager.ScaleRectangle(fakeRect, imageScale); var images = DesktopVisualManager.LoadAllDesktopImages(fakeRect, ColorTranslator.FromHtml(_config.InactiveDesktopColors.Border), ColorTranslator.FromHtml(_config.InactiveDesktopColors.Background), ColorTranslator.FromHtml(_config.ActiveDesktopColors.Background), imageRect.Height, imageRect.Width); foreach (var btnKvp in _Buttons) { Image newIcon; if (images.TryGetValue(btnKvp.Key - 1, out newIcon)) { btnKvp.Value.BackgroundImage = newIcon; } } lock (_IconRefreshLock) { _IsRefreshingIcons = false; } }); }
private void QueueIconRefresh(int desktopIndex) { Task.Run(() => { var w = SystemInformation.VirtualScreen.Width; var h = SystemInformation.VirtualScreen.Height; var fakeRect = new Rectangle(0, 0, w, h); double scale = ((double)_config.Application.ApplicationHeight / (double)h); double imageScale = scale * 0.9; var imageRect = DesktopVisualManager.ScaleRectangle(fakeRect, imageScale); var image = DesktopVisualManager.LoadDesktopImage(fakeRect, desktopIndex - 1, ColorTranslator.FromHtml(_config.InactiveDesktopColors.Border), ColorTranslator.FromHtml(_config.InactiveDesktopColors.Background), ColorTranslator.FromHtml(_config.ActiveDesktopColors.Background), imageRect.Height, imageRect.Width); _Buttons[desktopIndex].BackgroundImage = image; }); }