Click here to Skip to main content
15,396,032 members
Articles / Desktop Programming / Windows Forms
Posted 1 Jan 2010


228 bookmarked

Task Manager

Rate me:
Please Sign up or sign in to vote.
4.90/5 (105 votes)
1 Jan 2010CPOL4 min read
Manage your daily tasks and To-Do list using some exciting features of Windows 7.

Image 1


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.

Image 2

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

Image 3

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.

Image 4

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.

Image 5

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.

Image 6

Image 7

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.

Image 8

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:

Image 9

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
Chief Technology Officer
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

My Linked-In Profile

Comments and Discussions

SuggestionSuggestions Pin
kiquenet.com2-Apr-17 23:49
professionalkiquenet.com2-Apr-17 23:49 
PraiseGreat post Pin
Member 1275014430-Oct-16 16:23
MemberMember 1275014430-Oct-16 16:23 
QuestionNice post Pin
Tridip Bhattacharjee12-Dec-13 23:05
professionalTridip Bhattacharjee12-Dec-13 23:05 
QuestionEntityException Pin
Meysam Toluie10-Oct-13 7:34
MemberMeysam Toluie10-Oct-13 7:34 
QuestionEntityException was unhandled Pin
Member 1012125322-Jun-13 2:55
professionalMember 1012125322-Jun-13 2:55 
AnswerRe: EntityException was unhandled Pin
Member 1077984116-Nov-14 19:09
MemberMember 1077984116-Nov-14 19:09 
QuestionError Pin
Member 88308513-Sep-12 17:25
MemberMember 88308513-Sep-12 17:25 
QuestionRe: Windows 7 Crash Pin
JimZ19-Aug-12 10:08
MemberJimZ19-Aug-12 10:08 
GeneralMy vote of 5 Pin
EtherealMonkey19-Apr-12 5:32
MemberEtherealMonkey19-Apr-12 5:32 
GeneralMy vote of 5 Pin
Filip D'haene16-Jun-11 21:35
MemberFilip D'haene16-Jun-11 21:35 
GeneralBe sure to call _jumpList.Refresh() otherwise it will not show up Pin
webridges10-Jun-11 5:36
Memberwebridges10-Jun-11 5:36 
QuestionShakeel, How can I get in touch with you in Islamabad? Pin
mango_lier26-Jan-11 13:58
Membermango_lier26-Jan-11 13:58 
GeneralNamespace Error Pin
Deepak Gharge22-Jun-10 22:50
MemberDeepak Gharge22-Jun-10 22:50 
GeneralRe: Namespace Error Pin
Shakeel Iqbal23-Jun-10 2:07
MemberShakeel Iqbal23-Jun-10 2:07 
GeneralRe: Namespace Error Pin
Deepak Gharge23-Jun-10 2:19
MemberDeepak Gharge23-Jun-10 2:19 
GeneralRe: Namespace Error Pin
Rai Shahid7-Dec-10 1:30
MemberRai Shahid7-Dec-10 1:30 
Generalgood job Pin
regupathi30-Jan-10 19:07
Memberregupathi30-Jan-10 19:07 
GeneralRe: good job Pin
Shakeel Iqbal30-Jan-10 23:38
MemberShakeel Iqbal30-Jan-10 23:38 
GeneralRe: good job Pin
regupathi2-Feb-10 23:35
Memberregupathi2-Feb-10 23:35 
GeneralRe: good job Pin
regupathi2-Feb-10 23:35
Memberregupathi2-Feb-10 23:35 
QuestionDownload error Pin
regupathi29-Jan-10 22:18
Memberregupathi29-Jan-10 22:18 
GeneralMy vote is 5 Pin
Dianyang Wu8-Jan-10 3:00
MemberDianyang Wu8-Jan-10 3:00 
GeneralGood Job [modified] Pin
hackcat8-Jan-10 2:13
Memberhackcat8-Jan-10 2:13 
GeneralRe: Good Job Pin
Shakeel Iqbal8-Jan-10 6:47
MemberShakeel Iqbal8-Jan-10 6:47 
GeneralRe: Good Job Pin
hackcat8-Jan-10 14:56
Memberhackcat8-Jan-10 14:56 

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.