Example #1
0
        /// <summary>
        /// Gets all the running tasks as OrbitItems
        /// </summary>
        /// <param name="device">Direct3D Device to load resources to</param>
        /// <returns>An array of OrbitItems</returns>
        public static OrbitItem[] GetTasks(Device device)
        {
            ExcludedWindow[] ExclusionList = LoadExcludedClassWindows();
            IntPtr[]         TasksList     = WindowsTaskManager.GetWindowHandles(ExclusionList);
            if (TasksList == null)
            {
                return new OrbitItem[] { new EmptyItem(device) }
            }
            ;

            // actually catalog them
            OrbitItem[] ItemRegistry = new OrbitItem[TasksList.Length];

            int a = 0;

            foreach (IntPtr Handle in TasksList)
            {
                ItemRegistry[a] = new TaskItem(device, new WindowInformation(WindowsTaskManager.GetWindowText(Handle), Handle));

                if (ItemRegistry[a] != null)
                {
                    ItemRegistry[a].Parent = "Orbit";
                    ItemRegistry[a].Line   = 0;
                }
                a++;
            }

            return(ItemRegistry);
        }
Example #2
0
        private void LoadExcludedTasks()
        {
            // load the exclusion list
            ExcludedWindow[] ExclusionList = WindowsTaskManager.LoadExcludedClassWindows(System.IO.Path.Combine(System.IO.Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath), @"profiles\" + System.Environment.UserName + @"\ExcludedTasks.xml"));

            if (ExclusionList == null)
            {
                return;
            }

            // actually catalog them
            int i = 0;

            foreach (ExcludedWindow window in ExclusionList)
            {
                TaskItemControl tic = new TaskItemControl();

                tic.ProcessName = window.ProcessName;
                tic.ClassName   = window.ClassName;

                // try to find a currently running window that matches this spec
                IntPtr FoundWindow = FindFirstWindowLike(window);
                if (FoundWindow != IntPtr.Zero)
                {
                    tic.WindowTitle = WindowsTaskManager.GetWindowText(FoundWindow);
                    using (Bitmap shot = WindowsTaskManager.GetWindowBitmap(FoundWindow))
                    {
                        tic.WindowScreenshot = ImageHelper.GetAspectThumbnail(shot, new Size(64, 64));
                    }
                }
                else
                {
                    tic.WindowTitle = System.IO.Path.GetFileNameWithoutExtension(window.ProcessName);
                }

                // set this properties
                tic.Width   = this.TasksListPanel.Width;
                tic.Anchor |= AnchorStyles.Right;
                tic.Top     = tic.Height * i;

                // hook up events
                tic.RemoveLinkClicked += new EventHandler(tic_RemoveLinkClicked);

                this.TasksListPanel.Controls.Add(tic);
                i++;
            }
        }