Click here to Skip to main content
11,928,605 members (54,996 online)
Click here to Skip to main content
Add your own
alternative version


216 bookmarked

Task Manager

, 1 Jan 2010 CPOL
Rate this:
Please Sign up or sign in to vote.
Manage your daily tasks and To-Do list using some exciting features of Windows 7.


Task Manager is a tool for managing your daily tasks/To-Do list. You can easily manage your tasks using some exciting Windows 7 features. Task manager provides a functionality to set the task title, detail, start date, end date, priority, color tag and flag etc.

Window 7 provides a very nice and managed task bar as compared to the previous versions of Windows. So, I used some new features like JumpList, TabbedThumbnail etc., introduced by Windows 7 in this application. With the help of these new features, Task Manager is a more interactive application. This article will explain how to use these features in the application and will also give teach you to use the ComboBox and DataGridView in an advanced manner.

Task Manager also has a separate version for those who do not have Windows 7.

Jump List

Task Manager provides an easy way to view/edit tasks using the Windows 7 jump list. You can easily set your jump list view using the Settings window of the Task Manager.

The Settings window provides you three ways to group your jump list, by Priority, Color Category, or Flag.

It is very easy to manage the Jump list using the Windows API Code Pack. Call the JumpList.CreateJumpList() method to create a jump list for your application.

private JumpList _jumpList;

private void InitTaskJumpList()
    _jumpList = JumpList.CreateJumpList();

Here is an example to create a jump list for the color category. Create the JumpListCustomCategory object and add it to the jump list object.

private void ShowJumpListByColorCategory(IQueryable<task> tasks)
    string[] colorCategories = Enum.GetNames(typeof(TaskCategory));

    foreach (string catName in colorCategories)
        // Get task by color category
        IQueryable<Task> colorTask = tasks.Where(t => t.ColorCategory == catName);

        if (colorTask.Count() > 0)
            // Create jump list custom category
            JumpListCustomCategory customList = new JumpListCustomCategory(catName);

            // Add jump list category in list

            // Add tasks in custom category
            foreach (Task task in colorTask)
                string imagePath = "Resources\\" + catName + "_Category.ico";
                AddTask(customList, task.Title, task.TaskID.ToString(), imagePath);

Add JumpListLink to the JumpListCustomCategory collection using the AddJumpListItems() method, for creating a jump list link.

private void AddTask(JumpListCustomCategory customCategory, 
                     string text, string argument, string imagePath)
    // Get executable file path
    string path = Path.GetDirectoryName(Application.ExecutablePath);

    // Creat jump list link
    JumpListLink jumpListLink = 
      new JumpListLink(Assembly.GetExecutingAssembly().Location, text);
    jumpListLink.Arguments = argument;
    jumpListLink.IconReference = 
      new IconReference(Path.Combine(path, imagePath), 0);

    // Add link in category

JumpListLink gets the path of the application executable and its open windows on each click. But Task Manager opens an edit task window of the same application on a link click. You can achieve this functionality using a Mutex class. Mutex is used in a multi threaded environment for synchronization mechanisms to ensure that only one thread at a time uses a resource. The SingleInstanceChecker class checks the running instance of the application.

using (SingleInstanceChecker singleInstance = 
         new SingleInstanceChecker("TaskManager"))

    if (!singleInstance.IsSingle)

        TaskManagerMainForm taskManagerMainForm = new TaskManagerMainForm();


If SingleInstanceChecker sets IsSingle to false, it means the application is already running; handle it using the HandleJumpListCommand() method. If this event is because of a jump list item, then this method sends a window message to the TaskManagerMainForm form. TaskManagerMainForm handles this message by overriding the WndProc method to handle window messages.

protected override void WndProc(ref Message m)
    if (m.Msg == WindowMessageHelper.JumplistEvent)
        int taskID = m.WParam.ToInt32();


    base.WndProc(ref m);

Tabbed Thumbnail

You can easily navigate your incomplete tasks using Tabbed Thumbnail of Windows 7. The Task Manager provides allows you to move forward and back your tasks using the Thumbnail, and you can also edit/view your task details using an Edit button.

The Windows 7 API Code Pack also provides you an easy way to add Tabbed Thumbnail Preview. Just create a TabbedThumbnail object and add it using the TaskbarManager.Instance.TabbedThumbnail.AddThumbnailPreview() method. You can also add buttons in it by using the ThumbnailToolbarButton class. Create an object of this class and add it to the thumbnail using the TaskbarManager.Instance.ThumbnailToolbars.AddButtons() method. Register the click event of the button for the appropriate action on button click.

private void InitializeThumbnail()
    if (!HasThumbnailControl(_controlToShow))

        // Back Button
        _btnBack = new ThumbnailToolbarButton(Properties.Resources.Back, 
                                              "Previous Task");
        _btnBack.Click += 
          new EventHandler<thumbnailbuttonclickedeventargs>(_btnBack_Click);

        // Forwaard
        _btnForward = new ThumbnailToolbarButton(Properties.Resources.Forward, 
                                                 "Next Task");
        _btnForward.Click += new 

        // Edit
        _btnEdit = new ThumbnailToolbarButton(
          Properties.Resources.edit_Icon, "Edit Task");
        _btnEdit.Click += new 
        TabbedThumbnail thumbnail = 
           new TabbedThumbnail(_parentHandle, _controlToShow);
        thumbnail.DisplayFrameAroundBitmap = true;
        thumbnail.Title = "Task Manager";
        thumbnail.Tooltip = "Task Manager";
        thumbnail.TabbedThumbnailClosed += new 
        thumbnail.TabbedThumbnailActivated += 
          new EventHandler<TabbedThumbnailEventArgs>(
        // Add Buttons in the tool bar
          _controlToShow.Handle, _btnBack, _btnForward, _btnEdit);

        // Add Tabbed preview

        // Set active tab

        // Set Thumnail preview

The SetThumbnail() method sets the preview image of the current task. It sets the image using the SetImage() method.

private void SetThumbnail()
    TabbedThumbnail preview = 
    if (preview != null)
        Task task = null;
        string toolTip = "Task Manager";
        if (_taskList.Count > _selectedIndex)
            task = _taskList[_selectedIndex];
            toolTip = task.Title;

        preview.Tooltip = toolTip;

        Bitmap bitmap = new Bitmap(_controlToShow.Width, _controlToShow.Height);
        bitmap = _controlToShow.Image;


Progress Bar

The Task Manager also shows the task completed percentage in a progress bar using the Windows 7 Code Pack feature. You can easily set the value of the progress bar.

public static void SetProgressValue(int value)
    TaskbarProgressBarState state = TaskbarProgressBarState.Normal;

    TaskbarManager.Instance.SetProgressValue(value, 100);

Overlay Icon

Icon overlay is the best feature of Windows 7. You can easily see the state of an application with just one look at the task bar. Task Manager also shows two icons on the task bar: one for error and another for confirmation/question.

public static void SetTaskBarIcon(Icon icon)
    TaskbarManager.Instance.SetOverlayIcon(icon, "icon");

Gantt Chart

You can also see the Gantt view of your tasks in the Task Manager. This Gantt chart shows the day view only. The Gantt chart grid shows weekend days (Saturday, Sunday) cells in gray color and shows a green line for current day cells. You can see the busy days with a red bar and it also shows the tooltip with task detail on mouse over on a busy cell.

The GanttChart class is inherited from DataGridView because the Gantt chart view is like a grid. The GanttChart class overrides some methods of DataGridview to change the default behavior.

protected override void OnCellPainting(DataGridViewCellPaintingEventArgs e)
    // Draw row selector header
    if (e.ColumnIndex < 0)
        DrawCellColor(e.Graphics, e.CellBounds, Color.SteelBlue, Color.Black);
    /// Draw Header Cell
    else if (e.RowIndex < 0 && e.ColumnIndex >= 0)
    /// Draw Cell

    // set true to set it is handled
    e.Handled = true;

The OnCellPainting method executes for each cell drawing, and overrides the cell draw method according to its data and type. If the cell is a header, then it draws the day header, and if the cell is data, then the cell is drawn according to its data. The OnPaint method handles the drawing of the year header.

protected override void OnPaint(PaintEventArgs e)

The OnPaint method simply draws the year header and calls the base class OnPaint(e) method.

Image in Combo Box

The Task Manager show images in combo boxes for priority, color category, and Flag. .NET provides an easy way to add images in a combo box. Here is the code sample of a priority combo box:

public static void BindTaskPriorityCombo(ComboBox priorityCombo, bool addEmpty)
    priorityCombo.DrawMode = DrawMode.OwnerDrawVariable;
    priorityCombo.DrawItem += new DrawItemEventHandler(priorityCombo_DrawItem);

    if (addEmpty)

    foreach (TaskPriority priority in Enum.GetValues(typeof(TaskPriority)))

static void priorityCombo_DrawItem(object sender, DrawItemEventArgs e)
    if (e.Index >= 0)
        ComboBox cmbPriority = sender as ComboBox;
        string text = cmbPriority.Items[e.Index].ToString();

        if (text.Length > 0)
            TaskPriority priority = 
              (TaskPriority)Enum.Parse(typeof(TaskPriority), text);
            Image img = GetTaskPriorityImage(priority);

            if (img != null)
                e.Graphics.DrawImage(img, e.Bounds.X, e.Bounds.Y, 15, 15);

        e.Graphics.DrawString(text, cmbPriority.Font,
            new RectangleF(e.Bounds.X + 15, e.Bounds.Y, 
                           e.Bounds.Width, e.Bounds.Height));


For adding an image to a combo box, you need to set the DrawMode of the combobox: DrawMode = DrawMode.OwnerDrawVariable. Then, you need to override the DrawItem event of the combo box where you can draw the item as you want.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Shakeel Iqbal
Software Developer (Senior) TEO
Pakistan Pakistan
Passion and positive dedication is essential part of success. I believe on hardworking and sharing knowledge with others. I always try to be a better than I am and think positive for positive result.

My Blogs

You may also be interested in...

Comments and Discussions

QuestionNice post Pin
Tridip Bhattacharjee13-Dec-13 0:05
memberTridip Bhattacharjee13-Dec-13 0:05 
QuestionEntityException Pin
Meysam Tolouee10-Oct-13 8:34
memberMeysam Tolouee10-Oct-13 8:34 
QuestionEntityException was unhandled Pin
Member 1012125322-Jun-13 3:55
memberMember 1012125322-Jun-13 3:55 
AnswerRe: EntityException was unhandled Pin
Member 1077984116-Nov-14 20:09
memberMember 1077984116-Nov-14 20:09 
QuestionError Pin
Member 88308513-Sep-12 18:25
memberMember 88308513-Sep-12 18:25 
QuestionRe: Windows 7 Crash Pin
JimZ19-Aug-12 11:08
memberJimZ19-Aug-12 11:08 
Not sure if this has been addressed or not, but if you are having a problem with the app crashing under Win 7, I think I found the cause --

When TabbedThumbnailProxyWindow initializes, it calls:

TabbedThumbnailNativeMethods.GetWindowText(proxyingFor, text, text.Capacity);

which causes the window message to enter DispatchMessage in TaskbarWindowManager,
where it ends up at

if (!buttonsAdded)

The problem is that all of the initialization is not complete when GetWindowText is called, the logic fails in TaskBarWindow.WindowToTellTaskbarAbout and it returns a
new IntPtr(), dooming all that follows.

(yes, this took a while to track down, so I don't blame the author) Wink | ;)

The quickest fix that seems to work so far (CAUTION: I have NOT completely tested this, but it gets past the initial crash cause) is:

Modify TaskbarWindowManager.DispatchMessage, and insert at the very top a check for a WM_GETTEXT message (the int value is 13) and if it is, simply return false, signalling the window message was not handled.

internal bool DispatchMessage(ref Message m, TaskbarWindow taskbarWindow)
// Exit on WM_GETTEXT message
if (m.Msg == (int)13)
return false;

if (taskbarWindow.EnableThumbnailToolbars)
..... rest of code

Hope this helps! Smile | :)
GeneralMy vote of 5 Pin
EtherealMonkey19-Apr-12 6:32
memberEtherealMonkey19-Apr-12 6:32 
GeneralMy vote of 5 Pin
Filip D'haene16-Jun-11 22:35
memberFilip D'haene16-Jun-11 22:35 
GeneralBe sure to call _jumpList.Refresh() otherwise it will not show up Pin
webridges10-Jun-11 6:36
memberwebridges10-Jun-11 6:36 
QuestionShakeel, How can I get in touch with you in Islamabad? Pin
mango_lier26-Jan-11 14:58
membermango_lier26-Jan-11 14:58 
GeneralNamespace Error Pin
deepakgharge22-Jun-10 23:50
memberdeepakgharge22-Jun-10 23:50 
GeneralRe: Namespace Error Pin
Shakeel Iqbal23-Jun-10 3:07
memberShakeel Iqbal23-Jun-10 3:07 
GeneralRe: Namespace Error Pin
deepakgharge23-Jun-10 3:19
memberdeepakgharge23-Jun-10 3:19 
GeneralRe: Namespace Error Pin
Rai Shahid7-Dec-10 2:30
memberRai Shahid7-Dec-10 2:30 
Generalgood job Pin
regupathi30-Jan-10 20:07
memberregupathi30-Jan-10 20:07 
GeneralRe: good job Pin
Shakeel Iqbal31-Jan-10 0:38
memberShakeel Iqbal31-Jan-10 0:38 
GeneralRe: good job Pin
regupathi3-Feb-10 0:35
memberregupathi3-Feb-10 0:35 
GeneralRe: good job Pin
regupathi3-Feb-10 0:35
memberregupathi3-Feb-10 0:35 
QuestionDownload error Pin
regupathi29-Jan-10 23:18
memberregupathi29-Jan-10 23:18 
GeneralMy vote is 5 Pin
Dianyang Wu8-Jan-10 4:00
memberDianyang Wu8-Jan-10 4:00 
GeneralGood Job [modified] Pin
hackcat8-Jan-10 3:13
memberhackcat8-Jan-10 3:13 
GeneralRe: Good Job Pin
Shakeel Iqbal8-Jan-10 7:47
memberShakeel Iqbal8-Jan-10 7:47 
GeneralRe: Good Job Pin
hackcat8-Jan-10 15:56
memberhackcat8-Jan-10 15:56 
Generalhappy new year Pin
konikula6-Jan-10 20:44
memberkonikula6-Jan-10 20:44 
GeneralMy Vote is 5 Pin
R-O-C-K-Y6-Jan-10 6:58
memberR-O-C-K-Y6-Jan-10 6:58 
GeneralMy vote of 2 Pin
radink6-Jan-10 4:19
memberradink6-Jan-10 4:19 
GeneralRe: My vote of 2 Pin
Shakeel Iqbal6-Jan-10 6:03
memberShakeel Iqbal6-Jan-10 6:03 
GeneralRe: My vote of 2 Pin
JimZ19-Aug-12 12:19
memberJimZ19-Aug-12 12:19 
QuestionEntity Exception Pin
Doncp5-Jan-10 11:48
memberDoncp5-Jan-10 11:48 
AnswerRe: Entity Exception Pin
Gary Lutchanksy5-Jan-10 14:44
memberGary Lutchanksy5-Jan-10 14:44 
GeneralRe: Entity Exception Pin
Doncp6-Jan-10 8:44
memberDoncp6-Jan-10 8:44 
GeneralRe: Entity Exception Pin
Gary Lutchanksy6-Jan-10 14:31
memberGary Lutchanksy6-Jan-10 14:31 
AnswerRe: Entity Exception Pin
Shakeel Iqbal5-Jan-10 20:05
memberShakeel Iqbal5-Jan-10 20:05 
GeneralRe: Entity Exception Pin
Doncp6-Jan-10 8:32
memberDoncp6-Jan-10 8:32 
GeneralExcellent work Pin
Haris Munawar5-Jan-10 4:17
memberHaris Munawar5-Jan-10 4:17 
GeneralNice Work Pin
Bilal Haider4-Jan-10 21:13
memberBilal Haider4-Jan-10 21:13 
GeneralI like it .... Pin
Programm3r4-Jan-10 19:41
memberProgramm3r4-Jan-10 19:41 
GeneralVery informative Pin
Zaid Naeem4-Jan-10 19:05
memberZaid Naeem4-Jan-10 19:05 
GeneralGreat ;) Pin
M Jan4-Jan-10 9:08
memberM Jan4-Jan-10 9:08 
GeneralExcellent Article! Pin
M Ijaz Shoaib4-Jan-10 8:47
memberM Ijaz Shoaib4-Jan-10 8:47 
GeneralGreate Pin
jszczur3-Jan-10 23:30
memberjszczur3-Jan-10 23:30 
Generalgood one.. Pin
Rajesh Pillai2-Jan-10 18:11
memberRajesh Pillai2-Jan-10 18:11 
GeneralVery Good article Pin
i_islamian1-Jan-10 23:32
memberi_islamian1-Jan-10 23:32 
GeneralVery good job Pin
Sacha Barber1-Jan-10 22:47
mvpSacha Barber1-Jan-10 22:47 
GeneralRe: Very good job Pin
Shakeel Iqbal1-Jan-10 22:53
memberShakeel Iqbal1-Jan-10 22:53 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.151126.1 | Last Updated 2 Jan 2010
Article Copyright 2010 by Shakeel Iqbal
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid