Beispiel #1
0
        private void BuildTaskBarItems()
        {
            Dispatcher.BeginInvoke(new Action(() =>
            {
                Dictionary <string, TaskBarItem> items = new Dictionary <string, TaskBarItem>();
                int Position = 0;
                foreach (string linkPath in TaskbarPinnedItems.GetPinnedTaskBarItems())
                {
                    ShellFile link = ShellFile.FromFilePath(linkPath);
                    if (!link.IsLink)
                    {
                        link.Dispose();
                        continue;
                    }

                    string displayName = link.GetDisplayName(DisplayNameType.Default);
                    string path        = link.Properties.System.Link.TargetParsingPath.Value;
                    if (System.IO.File.Exists(path))
                    {
                        items.Add(path, new TaskBarItem(path, null, displayName, Imaging.ExtractIcon(path, IntPtr.Zero), Position++));
                    }
                    else
                    {
                        items.Add(EXPLORER_PATH, new TaskBarItem(EXPLORER_PATH, null, "File Explorer", Imaging.ExtractIcon(EXPLORER_PATH, IntPtr.Zero), Position++));
                    }
                    link.Dispose();
                }
                foreach (var win in WindowsTasksService.Windows.Where((w) => w.Enabled && w.ClassName != "Progman"))
                {
                    if (!items.ContainsKey(win.Process.MainModule.FileName))
                    {
                        items.Add(win.Process.MainModule.FileName, new TaskBarItem(win.Process.MainModule.FileName, null, win.Title, win.Icon, Position++));
                    }
                    items[win.Process.MainModule.FileName]._openWindows.Add(win);
                }
                foreach (var itm in items.Values)
                {
                    TaskBarItem existingWindow = null;
                    if ((existingWindow = TaskBarItems.FirstOrDefault((esw) => esw.FullPath == itm.FullPath)) != null)
                    {
                        itm.CopyFrom(existingWindow);
                    }
                }
                TaskBarItems.Clear();
                foreach (var itm in items.Values.OrderByDescending((itm) => - 1 * itm.Position))
                {
                    TaskBarItems.Add(itm);
                }
            }));
        }
 internal void CopyFrom(TaskBarItem existingWindow)
 {
     Position = existingWindow.Position;
 }
Beispiel #3
0
 internal void CopyFrom(TaskBarItem existingWindow)
 {
     Position = existingWindow.Position;
 }