Пример #1
0
        private bool getShowInTaskbar()
        {
            // EnumWindows and ShellHook return UWP app windows that are 'cloaked', which should not be visible in the taskbar.
            if (EnvironmentHelper.IsWindows8OrBetter)
            {
                int cbSize = Marshal.SizeOf(typeof(uint));
                NativeMethods.DwmGetWindowAttribute(Handle, NativeMethods.DWMWINDOWATTRIBUTE.DWMWA_CLOAKED, out var cloaked, cbSize);

                if (cloaked > 0)
                {
                    ShellLogger.Debug($"ApplicationWindow: Cloaked ({cloaked}) window ({Title}) hidden from taskbar");
                    return(false);
                }

                // UWP shell windows that are not cloaked should be hidden from the taskbar, too.
                StringBuilder cName = new StringBuilder(256);
                NativeMethods.GetClassName(Handle, cName, cName.Capacity);
                string className = cName.ToString();
                if (className == "ApplicationFrameWindow" || className == "Windows.UI.Core.CoreWindow")
                {
                    if ((ExtendedWindowStyles & (int)NativeMethods.ExtendedWindowStyles.WS_EX_WINDOWEDGE) == 0)
                    {
                        ShellLogger.Debug($"ApplicationWindow: Hiding UWP non-window {Title}");
                        return(false);
                    }
                }
                else if (!EnvironmentHelper.IsWindows10OrBetter && (className == "ImmersiveBackgroundWindow" || className == "SearchPane" || className == "NativeHWNDHost" || className == "Shell_CharmWindow" || className == "ImmersiveLauncher") && WinFileName.ToLower().Contains("explorer.exe"))
                {
                    ShellLogger.Debug($"ApplicationWindow: Hiding immersive shell window {Title}");
                    return(false);
                }
            }

            return(CanAddToTaskbar);
        }
        private bool GetAutoTrayEnabled()
        {
            int enableAutoTray = 1;

            try
            {
                RegistryKey explorerKey = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer", false);

                if (explorerKey != null)
                {
                    var enableAutoTrayValue = explorerKey.GetValue("EnableAutoTray");

                    if (enableAutoTrayValue != null)
                    {
                        enableAutoTray = Convert.ToInt32(enableAutoTrayValue);
                    }
                }
            }
            catch (Exception e)
            {
                ShellLogger.Debug($"ExplorerTrayService: Unable to get EnableAutoTray setting: {e.Message}");
            }

            return(enableAutoTray == 1);
        }
Пример #3
0
        private IntPtr pathToRelPidl(string path)
        {
            IntPtr pidl;
            uint   pchEaten = 0;

            ShellFolders.SFGAO pdwAttributes = 0;

            string file = Path.GetFileName(path);

            if (parentShellFolder != null)
            {
                int result = parentShellFolder.ParseDisplayName(IntPtr.Zero, IntPtr.Zero, file, ref pchEaten, out pidl, ref pdwAttributes);

                if (pidl == IntPtr.Zero)
                {
                    ShellLogger.Debug("HRESULT " + result + " retrieving pidl for " + path);
                }

                return(pidl);
            }
            else
            {
                ShellLogger.Debug("Parent IShellFolder for " + path + " is null");
                return(IntPtr.Zero);
            }
        }
Пример #4
0
        private void RegisterTrayWnd()
        {
            ushort trayClassReg = RegisterWndClass(TrayWndClass);

            if (trayClassReg == 0)
            {
                ShellLogger.Info($"TrayService: Error registering {TrayWndClass} class ({Marshal.GetLastWin32Error()})");
            }

            HwndTray = CreateWindowEx(
                ExtendedWindowStyles.WS_EX_TOPMOST |
                ExtendedWindowStyles.WS_EX_TOOLWINDOW, trayClassReg, "",
                WindowStyles.WS_POPUP | WindowStyles.WS_CLIPCHILDREN |
                WindowStyles.WS_CLIPSIBLINGS, 0, 0, GetSystemMetrics(0),
                (int)(23 * DpiHelper.DpiScale), IntPtr.Zero, IntPtr.Zero, hInstance, IntPtr.Zero);

            if (HwndTray == IntPtr.Zero)
            {
                ShellLogger.Info($"TrayService: Error creating {TrayWndClass} window ({Marshal.GetLastWin32Error()})");
            }
            else
            {
                ShellLogger.Debug($"TrayService: Created {TrayWndClass}");
            }
        }
Пример #5
0
        private void btnBrowse_Click(object sender, RoutedEventArgs e)
        {
            string filter = "Programs and shortcuts|";

            foreach (string ext in AppGrabberService.ExecutableExtensions)
            {
                filter += $"*{ext};";
            }

            filter = filter.Substring(0, filter.Length - 2);

            using (OpenFileDialog dlg = new OpenFileDialog
            {
                Filter = filter
            })
            {
                if (dlg.SafeShowDialog() == System.Windows.Forms.DialogResult.OK && ShellHelper.Exists(dlg.FileName))
                {
                    ApplicationInfo customApp = AppGrabberService.PathToApp(dlg.FileName, true, true);
                    if (!ReferenceEquals(customApp, null))
                    {
                        if (!programsMenuAppsCollection.Contains(customApp) && !(InstalledAppsView.ItemsSource as ObservableCollection <ApplicationInfo>).Contains(customApp))
                        {
                            programsMenuAppsCollection.Add(customApp);
                        }
                        else
                        {
                            // disallow adding a duplicate
                            ShellLogger.Debug("Excluded duplicate item: " + customApp.Name + ": " + customApp.Target);
                        }
                    }
                }
            }
        }
Пример #6
0
        private bool haveDisplaysChanged()
        {
            resetScreenCache();

            if (_screenState.Count == Screen.AllScreens.Length)
            {
                bool same = true;
                for (int i = 0; i < Screen.AllScreens.Length; i++)
                {
                    Screen current = Screen.AllScreens[i];
                    if (!(_screenState[i].Bounds == current.Bounds && _screenState[i].DeviceName == current.DeviceName && _screenState[i].Primary == current.Primary))
                    {
                        same = false;
                        break;
                    }
                }

                if (same)
                {
                    ShellLogger.Debug("WindowManager: No display changes");
                    return(false);
                }
            }

            return(true);
        }
Пример #7
0
        public void IconMouseUp(MouseButton button, uint mouse, int doubleClickTime)
        {
            ShellLogger.Debug($"NotifyIcon: {button} mouse button clicked: {Title}");

            if (button == MouseButton.Left)
            {
                if (handleClickOverride(true))
                {
                    return;
                }

                SendMessage((uint)WM.LBUTTONUP, mouse);

                // This is documented as version 4, but Explorer does this for version 3 as well
                if (Version >= 3)
                {
                    SendMessage((uint)NIN.SELECT, mouse);
                }

                _lastLClick = DateTime.Now;
            }
            else if (button == MouseButton.Right)
            {
                SendMessage((uint)WM.RBUTTONUP, mouse);

                // This is documented as version 4, but Explorer does this for version 3 as well
                if (Version >= 3)
                {
                    SendMessage((uint)WM.CONTEXTMENU, mouse);
                }

                _lastRClick = DateTime.Now;
            }
        }
        public static ApplicationInfo PathToApp(string file, bool allowNonApps, bool allowExcludedNames)
        {
            ApplicationInfo ai      = new ApplicationInfo();
            string          fileExt = Path.GetExtension(file);

            if (allowNonApps || ExecutableExtensions.Contains(fileExt, StringComparer.OrdinalIgnoreCase))
            {
                try
                {
                    ai.Name = ShellHelper.GetDisplayName(file);
                    ai.Path = file;
                    string target = string.Empty;

                    if (fileExt.Equals(".lnk", StringComparison.OrdinalIgnoreCase))
                    {
                        Shell.Link link = new Shell.Link(file);
                        target = link.Target;
                    }
                    else
                    {
                        target = file;
                    }

                    ai.Target = target;

                    // remove items that we can't execute.
                    if (!allowNonApps)
                    {
                        if (!string.IsNullOrEmpty(target) && !ExecutableExtensions.Contains(Path.GetExtension(target), StringComparer.OrdinalIgnoreCase))
                        {
                            ShellLogger.Debug("Not an app: " + file + ": " + target);
                            return(null);
                        }

                        // remove things that aren't apps (help, uninstallers, etc)
                        if (!allowExcludedNames)
                        {
                            foreach (string word in excludedNames)
                            {
                                if (ai.Name.ToLower().Contains(word))
                                {
                                    ShellLogger.Debug("Excluded item: " + file + ": " + target);
                                    return(null);
                                }
                            }
                        }
                    }

                    return(ai);
                }
                catch (Exception ex)
                {
                    ShellLogger.Error("Error creating ApplicationInfo object in appgrabber. " + ex.Message, ex);
                    return(null);
                }
            }

            return(null);
        }
Пример #9
0
        public static ApplicationInfo PathToApp(string filePath, string fileDisplayName, bool allowNonApps, bool allowExcludedNames)
        {
            ApplicationInfo ai      = new ApplicationInfo();
            string          fileExt = Path.GetExtension(filePath);

            if (allowNonApps || ExecutableExtensions.Contains(fileExt, StringComparer.OrdinalIgnoreCase))
            {
                try
                {
                    ai.Name = fileDisplayName;
                    ai.Path = filePath;
                    string target;

                    if (fileExt.Equals(".lnk", StringComparison.OrdinalIgnoreCase))
                    {
                        Link link = new Link(filePath);
                        target = link.Target;
                    }
                    else
                    {
                        target = filePath;
                    }

                    ai.Target = target;

                    // remove items that we can't execute.
                    if (!allowNonApps)
                    {
                        if (!string.IsNullOrEmpty(target) && !ExecutableExtensions.Contains(Path.GetExtension(target), StringComparer.OrdinalIgnoreCase))
                        {
                            ShellLogger.Debug($"AppGrabberService: Not an app: {filePath}: {target}");
                            return(null);
                        }

                        // remove things that aren't apps (help, uninstallers, etc)
                        if (!allowExcludedNames)
                        {
                            foreach (string word in excludedNames)
                            {
                                if (ai.Name.ToLower().Contains(word))
                                {
                                    ShellLogger.Debug($"AppGrabberService: Excluded item: {filePath}: {target}");
                                    return(null);
                                }
                            }
                        }
                    }

                    return(ai);
                }
                catch (Exception ex)
                {
                    ShellLogger.Error($"AppGrabberService: Error creating ApplicationInfo object: {ex.Message}");
                    return(null);
                }
            }

            return(null);
        }
Пример #10
0
        internal void Initialize()
        {
            if (IsInitialized)
            {
                return;
            }

            try
            {
                ShellLogger.Debug("TasksService: Starting");

                // create window to receive task events
                _HookWin = new NativeWindowEx();
                _HookWin.CreateHandle(new CreateParams());

                // prevent other shells from working properly
                SetTaskmanWindow(_HookWin.Handle);

                // register to receive task events
                RegisterShellHookWindow(_HookWin.Handle);
                WM_SHELLHOOKMESSAGE         = RegisterWindowMessage("SHELLHOOK");
                WM_TASKBARCREATEDMESSAGE    = RegisterWindowMessage("TaskbarCreated");
                TASKBARBUTTONCREATEDMESSAGE = RegisterWindowMessage("TaskbarButtonCreated");
                _HookWin.MessageReceived   += ShellWinProc;

                if (EnvironmentHelper.IsWindows8OrBetter)
                {
                    // set event hook for uncloak events
                    uncloakEventProc = UncloakEventCallback;

                    if (uncloakEventHook == IntPtr.Zero)
                    {
                        uncloakEventHook = SetWinEventHook(
                            EVENT_OBJECT_UNCLOAKED,
                            EVENT_OBJECT_UNCLOAKED,
                            IntPtr.Zero,
                            uncloakEventProc,
                            0,
                            0,
                            WINEVENT_OUTOFCONTEXT | WINEVENT_SKIPOWNPROCESS);
                    }
                }

                // set window for ITaskbarList
                setTaskbarListHwnd(_HookWin.Handle);

                // adjust minimize animation
                SetMinimizedMetrics();

                // enumerate windows already opened and set active window
                getInitialWindows();

                IsInitialized = true;
            }
            catch (Exception ex)
            {
                ShellLogger.Info("TasksService: Unable to start: " + ex.Message);
            }
        }
Пример #11
0
        public void InsertByPath(string[] fileNames, int index, AppCategoryType categoryType)
        {
            int count = 0;

            foreach (string fileName in fileNames)
            {
                if (!ShellHelper.Exists(fileName))
                {
                    continue;
                }

                ApplicationInfo customApp = PathToApp(fileName, false, true);
                if (ReferenceEquals(customApp, null))
                {
                    continue;
                }

                Category category;

                if (categoryType == AppCategoryType.Uncategorized || categoryType == AppCategoryType.Standard)
                {
                    // if type is standard, drop in uncategorized
                    category = CategoryList.GetSpecialCategory(AppCategoryType.Uncategorized);
                    if (CategoryList.FlatList.Contains(customApp))
                    {
                        // disallow duplicates within all programs menu categories
                        ShellLogger.Debug($"AppGrabberService: Excluded duplicate item: {customApp.Name}: {customApp.Target}");
                        continue;
                    }
                }
                else
                {
                    category = CategoryList.GetSpecialCategory(categoryType);
                    if (category.Contains(customApp))
                    {
                        // disallow duplicates within the category
                        ShellLogger.Debug($"AppGrabberService: Excluded duplicate item: {customApp.Name}: {customApp.Target}");
                        continue;
                    }
                }

                if (index >= 0)
                {
                    category.Insert(index, customApp);
                }
                else
                {
                    category.Add(customApp);
                }
                count++;
            }

            if (count > 0)
            {
                Save();
            }
        }
Пример #12
0
 private void keyboardListener_OnKeyPressed(object sender, Common.KeyEventArgs e)
 {
     if (e.Key == Key.LWin || e.Key == Key.RWin)
     {
         ShellLogger.Debug(e.Key.ToString() + " Key Pressed");
         ToggleProgramsMenu();
         e.Handled = true;
     }
 }
Пример #13
0
 public void CloseWindow(ApplicationWindow window)
 {
     if (window.DoClose() != IntPtr.Zero)
     {
         ShellLogger.Debug($"TasksService: Removing window {window.Title} from collection due to no response");
         window.Dispose();
         Windows.Remove(window);
     }
 }
Пример #14
0
        private void openTaskbar(AppBarScreen screen)
        {
            ShellLogger.Debug($"WindowManager: Opening taskbar on screen {screen.DeviceName}");
            Taskbar taskbar = new Taskbar(this, _shellManager, _startMenuMonitor, _updater, screen, (AppBarEdge)Settings.Instance.Edge);

            taskbar.Show();

            _taskbars.Add(taskbar);
        }
Пример #15
0
        private IntPtr pathToFullPidl(string path)
        {
            IntPtr pidl = ShellFolders.ILCreateFromPath(path);

            if (pidl == IntPtr.Zero)
            {
                ShellLogger.Debug("Unable to get pidl for " + path);
            }

            return(pidl);
        }
Пример #16
0
        private void SendTaskbarCreated()
        {
            int msg = RegisterWindowMessage("TaskbarCreated");

            if (msg > 0)
            {
                ShellLogger.Debug("TrayService: Sending TaskbarCreated message");
                SendNotifyMessage(HWND_BROADCAST,
                                  (uint)msg, UIntPtr.Zero, IntPtr.Zero);
            }
        }
Пример #17
0
        private void closeTaskbars()
        {
            ShellLogger.Debug($"WindowManager: Closing all taskbars");

            foreach (var taskbar in _taskbars)
            {
                taskbar.AllowClose = true;
                taskbar.Close();
            }

            _taskbars.Clear();
        }
Пример #18
0
        private void loadWeather()
        {
            string apiKey = Properties.Settings.Default.ApiKey;

            if (string.IsNullOrEmpty(apiKey))
            {
                State = ForecastState.ApiKeyError;
            }
            else if (State == ForecastState.ApiKeyError)
            {
                State = ForecastState.Loading;
            }

            Thread weatherThread = new Thread(() =>
            {
                if (LocationState == LocationApiState.Ok && State != ForecastState.ApiKeyError)
                {
                    using (WebClient webClient = new WebClient())
                    {
                        try
                        {
                            // set units
                            string units = "metric";
                            if (!RegionInfo.CurrentRegion.IsMetric)
                            {
                                units = "imperial";
                            }

                            // fetch weather
                            string url = string.Format(RequestUrl, latitude, longitude, units, apiKey);
                            parseWeather(webClient.DownloadString(url));
                        }
                        catch (Exception e)
                        {
                            ShellLogger.Debug("Error fetching weather: " + e.Message);

                            if (State == ForecastState.Loading)
                            {
                                State = ForecastState.FetchError;
                                OnWeatherChanged();
                            }
                        }
                    }
                }
                else
                {
                    OnWeatherChanged();
                }
            });

            weatherThread.Start();
        }
Пример #19
0
        public int RegisterBar(AppBarWindow abWindow, double width, double height, AppBarEdge edge = AppBarEdge.Top)
        {
            lock (appBarLock)
            {
                APPBARDATA abd = new APPBARDATA();
                abd.cbSize = Marshal.SizeOf(typeof(APPBARDATA));
                abd.hWnd   = abWindow.Handle;

                if (!AppBars.Contains(abWindow))
                {
                    if (!EnvironmentHelper.IsAppRunningAsShell)
                    {
                        uCallBack            = RegisterWindowMessage("AppBarMessage");
                        abd.uCallbackMessage = uCallBack;

                        SHAppBarMessage((int)ABMsg.ABM_NEW, ref abd);
                    }

                    AppBars.Add(abWindow);

                    ShellLogger.Debug($"AppBarManager: Created AppBar for handle {abWindow.Handle}");

                    if (!EnvironmentHelper.IsAppRunningAsShell)
                    {
                        ABSetPos(abWindow, width, height, edge, true);
                    }
                    else
                    {
                        SetWorkArea(abWindow.Screen);
                    }
                }
                else
                {
                    if (!EnvironmentHelper.IsAppRunningAsShell)
                    {
                        SHAppBarMessage((int)ABMsg.ABM_REMOVE, ref abd);
                    }

                    AppBars.Remove(abWindow);
                    ShellLogger.Debug($"AppBarManager: Removed AppBar for handle {abWindow.Handle}");

                    if (EnvironmentHelper.IsAppRunningAsShell)
                    {
                        SetWorkArea(abWindow.Screen);
                    }

                    return(0);
                }
            }

            return(uCallBack);
        }
Пример #20
0
        private void FullscreenCheck_Tick(object sender, EventArgs e)
        {
            IntPtr hWnd = GetForegroundWindow();

            List <FullScreenApp> removeApps = new List <FullScreenApp>();
            bool skipAdd = false;

            // first check if this window is already in our list. if so, remove it if necessary
            foreach (FullScreenApp app in FullScreenApps)
            {
                FullScreenApp appCurrentState = getFullScreenApp(app.hWnd);

                if (app.hWnd == hWnd && appCurrentState != null && app.screen.DeviceName == appCurrentState.screen.DeviceName)
                {
                    // this window, still same screen, do nothing
                    skipAdd = true;
                    continue;
                }

                if (appCurrentState != null && app.hWnd != hWnd &&
                    app.screen.DeviceName == appCurrentState.screen.DeviceName &&
                    Screen.FromHandle(hWnd).DeviceName != appCurrentState.screen.DeviceName)
                {
                    // if the full-screen window is no longer foreground, keep it
                    // as long as the foreground window is on a different screen.
                    continue;
                }

                removeApps.Add(app);
            }

            // remove any changed windows we found
            if (removeApps.Count > 0)
            {
                ShellLogger.Debug("Removing full screen app(s)");
                foreach (FullScreenApp existingApp in removeApps)
                {
                    FullScreenApps.Remove(existingApp);
                }
            }

            // check if this is a new full screen app
            if (!skipAdd)
            {
                FullScreenApp appNew = getFullScreenApp(hWnd);
                if (appNew != null)
                {
                    ShellLogger.Debug("Adding full screen app");
                    FullScreenApps.Add(appNew);
                }
            }
        }
Пример #21
0
        private void GetTrayItems()
        {
            IntPtr toolbarHwnd = FindExplorerTrayToolbarHwnd();

            if (toolbarHwnd == IntPtr.Zero)
            {
                return;
            }

            int count = GetNumTrayIcons(toolbarHwnd);

            if (count < 1)
            {
                return;
            }

            GetWindowThreadProcessId(toolbarHwnd, out var processId);
            IntPtr hProcess = OpenProcess(ProcessAccessFlags.All, false, (int)processId);
            IntPtr hBuffer  = VirtualAllocEx(hProcess, IntPtr.Zero, (uint)Marshal.SizeOf(new TBBUTTON()), AllocationType.Commit,
                                             MemoryProtection.ReadWrite);

            for (int i = 0; i < count; i++)
            {
                TrayItem trayItem = GetTrayItem(i, hBuffer, hProcess, toolbarHwnd);

                if (trayItem.hWnd == IntPtr.Zero || !IsWindow(trayItem.hWnd))
                {
                    ShellLogger.Debug($"ExplorerTrayService: Ignored notify icon {trayItem.szIconText} due to invalid handle");
                    continue;
                }

                SafeNotifyIconData nid = GetTrayItemIconData(trayItem);

                if (trayDelegate != null)
                {
                    if (!trayDelegate((uint)NIM.NIM_ADD, nid))
                    {
                        ShellLogger.Debug("ExplorerTrayService: Ignored notify icon message");
                    }
                }
                else
                {
                    ShellLogger.Debug("ExplorerTrayService: trayDelegate is null");
                }
            }

            VirtualFreeEx(hProcess, hBuffer, 0, AllocationType.Release);

            CloseHandle((int)hProcess);
        }
Пример #22
0
        public ImageSource GetIconImageSource(IconSize size)
        {
            string iconPath;

            switch (size)
            {
            case IconSize.Small:
                iconPath = SmallIconPath;
                break;

            case IconSize.Medium:
                iconPath = MediumIconPath;
                break;

            case IconSize.ExtraLarge:
                iconPath = ExtraLargeIconPath;
                break;

            case IconSize.Jumbo:
                iconPath = JumboIconPath;
                break;

            default:
                iconPath = LargeIconPath;
                break;
            }

            if (string.IsNullOrEmpty(iconPath))
            {
                return(GetShellItemImageSource(size));
            }

            try
            {
                BitmapImage img = new BitmapImage();
                img.BeginInit();
                img.UriSource   = new Uri(iconPath, UriKind.Absolute);
                img.CacheOption = BitmapCacheOption.OnLoad;
                img.EndInit();
                img.Freeze();

                return(img);
            }
            catch (Exception e)
            {
                ShellLogger.Debug($"StoreApp: Unable to load icon by path for {DisplayName}: {e.Message}");
                return(GetShellItemImageSource(size));
            }
        }
Пример #23
0
 public void Dispose()
 {
     if (sysTrayObject != null)
     {
         try
         {
             Guid sso = new Guid(CGID_SHELLSERVICEOBJECT);
             sysTrayObject.Exec(ref sso, OLECMDID_SAVE, OLECMDEXECOPT_DODEFAULT, IntPtr.Zero, IntPtr.Zero);
         }
         catch
         {
             ShellLogger.Debug("ShellServiceObject: Unable to stop");
         }
     }
 }
Пример #24
0
        public void Dispose()
        {
            if (IsInitialized)
            {
                ShellLogger.Debug("TasksService: Deregistering hooks");
                DeregisterShellHookWindow(_HookWin.Handle);
                if (uncloakEventHook != IntPtr.Zero)
                {
                    UnhookWinEvent(uncloakEventHook);
                }
                _HookWin.DestroyHandle();
                setTaskbarListHwnd(IntPtr.Zero);
            }

            TaskCategoryProvider?.Dispose();
        }
Пример #25
0
        private void DestroyWindows()
        {
            if (HwndNotify != IntPtr.Zero)
            {
                DestroyWindow(HwndNotify);
                UnregisterClass(NotifyWndClass, hInstance);
                ShellLogger.Debug($"TrayService: Unregistered {NotifyWndClass}");
            }

            if (HwndTray != IntPtr.Zero)
            {
                DestroyWindow(HwndTray);
                UnregisterClass(TrayWndClass, hInstance);
                ShellLogger.Debug($"TrayService: Unregistered {TrayWndClass}");
            }
        }
Пример #26
0
 public void Start()
 {
     if (EnvironmentHelper.IsAppRunningAsShell)
     {
         try
         {
             sysTrayObject = (IOleCommandTarget) new SysTrayObject();
             Guid sso = new Guid(CGID_SHELLSERVICEOBJECT);
             sysTrayObject.Exec(ref sso, OLECMDID_NEW, OLECMDEXECOPT_DODEFAULT, IntPtr.Zero, IntPtr.Zero);
         }
         catch
         {
             ShellLogger.Debug("ShellServiceObject: Unable to start");
         }
     }
 }
        private void TextBlock_Drop(object sender, DragEventArgs e)
        {
            TextBlock dropBlock    = sender as TextBlock;
            Category  dropCategory = dropBlock.DataContext as Category;

            if (e.Data.GetDataPresent(typeof(Category)))
            {
                ShellLogger.Debug(e.Data.GetData(typeof(Category)).ToString());
                Category dropData = e.Data.GetData(typeof(Category)) as Category;

                CategoryList parent       = dropCategory.ParentCategoryList;
                int          initialIndex = parent.IndexOf(dropData);
                int          dropIndex    = parent.IndexOf(dropCategory);
                parent.Move(initialIndex, dropIndex);
            }
            else if (e.Data.GetDataPresent(typeof(ApplicationInfo)))
            {
                ApplicationInfo dropData = e.Data.GetData(typeof(ApplicationInfo)) as ApplicationInfo;
                if (dropCategory.Type == AppCategoryType.QuickLaunch)
                {
                    e.Effects = DragDropEffects.Copy;

                    // Do not duplicate entries
                    if (!dropCategory.Contains(dropData))
                    {
                        ApplicationInfo dropClone = dropData.Clone();
                        dropCategory.Add(dropClone);
                        dropClone.Icon     = null; // icon may differ depending on category
                        dropClone.IconPath = null;
                    }
                }
                else if (sourceView != null)
                {
                    e.Effects = DragDropEffects.Move;

                    (sourceView.ItemsSource as Category).Remove(dropData);
                    if ((sourceView.ItemsSource as Category).Type != AppCategoryType.QuickLaunch)
                    {
                        dropCategory.Add(dropData);
                    }
                }

                sourceView = null;
            }

            isDragging = false;
        }
Пример #28
0
        private Brush GetCairoBackgroundBrush_Windows()
        {
            string wallpaper          = string.Empty;
            CairoWallpaperStyle style = CairoWallpaperStyle.Stretch;

            try
            {
                wallpaper = Registry.GetValue(@"HKEY_CURRENT_USER\Control Panel\Desktop", "Wallpaper", "") as string;
                string regWallpaperStyle = Registry.GetValue(@"HKEY_CURRENT_USER\Control Panel\Desktop", "WallpaperStyle", "") as string;
                string regTileWallpaper  = Registry.GetValue(@"HKEY_CURRENT_USER\Control Panel\Desktop", "TileWallpaper", "") as string;

                // https://docs.microsoft.com/en-us/windows/desktop/Controls/themesfileformat-overview
                switch ($"{regWallpaperStyle}{regTileWallpaper}")
                {
                case "01":     // Tiled { WallpaperStyle = 0; TileWallpaper = 1 }
                    style = CairoWallpaperStyle.Tile;
                    break;

                case "00":     // Centered { WallpaperStyle = 0; TileWallpaper = 0 }
                    style = CairoWallpaperStyle.Center;
                    break;

                case "60":     // Fit { WallpaperStyle = 6; TileWallpaper = 0 }
                    style = CairoWallpaperStyle.Fit;
                    break;

                case "100":     // Fill { WallpaperStyle = 10; TileWallpaper = 0 }
                    style = CairoWallpaperStyle.Fill;
                    break;

                case "220":     // Span { WallpaperStyle = 22; TileWallpaper = 0 }
                    style = CairoWallpaperStyle.Span;
                    break;

                case "20":     // Stretched { WallpaperStyle = 2; TileWallpaper = 0 }
                default:
                    style = CairoWallpaperStyle.Stretch;
                    break;
                }
            }
            catch (Exception ex)
            {
                ShellLogger.Debug("Problem loading Windows background", ex);
            }

            return(GetCairoBackgroundBrush_Image(wallpaper, style) ?? GetCairoBackgroundBrush_Color());
        }
Пример #29
0
        private void TrayMonitor_Tick(object sender, EventArgs e)
        {
            if (HwndTray == IntPtr.Zero)
            {
                return;
            }

            IntPtr taskbarHwnd = FindWindow(TrayWndClass, "");

            if (taskbarHwnd == HwndTray)
            {
                return;
            }

            ShellLogger.Debug("TrayService: Raising Shell_TrayWnd");
            MakeTrayTopmost();
        }
Пример #30
0
        private List <StartupEntry> GetAppsFromEntry(StartupLocation location)
        {
            switch (location.Type)
            {
            case StartupEntryType.Directory:
                return(GetAppsFromDirectory(location));

            case StartupEntryType.RegistryKey:
                return(GetAppsFromRegistryKey(location));

            default:
                ShellLogger.Debug("StartupRunner: Unknown startup location type");
                break;
            }

            return(new List <StartupEntry>());
        }