Пример #1
0
        private void SaveExcludedTasks()
        {
            // copy to array
            ExcludedWindow[] ExcludedTasks = new ExcludedWindow[this.TasksListPanel.Controls.Count];
            int i = 0;

            while (i < ExcludedTasks.Length)
            {
                TaskItemControl tic = (TaskItemControl)this.TasksListPanel.Controls[i];
                ExcludedTasks[i] = new ExcludedWindow(tic.ClassName, tic.ProcessName);
                i++;
            }

            // save
            WindowsTaskManager.SaveExcludedClassWindows(System.IO.Path.Combine(System.IO.Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath), @"profiles\" + System.Environment.UserName + @"\ExcludedTasks.xml"), ExcludedTasks);
        }
Пример #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++;
            }
        }