Giter Site home page Giter Site logo

jakesee / ganttchart Goto Github PK

View Code? Open in Web Editor NEW
172.0 23.0 76.0 182 KB

The Winforms Gantt Chart is the .NET Winforms control originally hosted on CodePlex (http://ganttchart.codeplex.com)

Home Page: https://jakesee.sg/net-c-winforms-gantt-chart-control/

License: MIT License

C# 100.00%
winforms winforms-controls dotnet dotnet-framework gantt-chart gantt chart

ganttchart's Introduction

.NET C# Winforms Gantt Chart Control

This .NET class library project provides a C# Winforms UserControl that draws a gantt chart using native GDI+.

Getting Started

The project is written with Microsoft Visual Studio 2017, simply download the latest source code from the master branch and build the library with the IDE.

Prerequisites

No pre-requisites other than the .NET Framework.

Installing

The project builds into a class library with example applications.

Running the tests

The source code includes a test project GanttChartTests which you can load and run within Microsoft Visual Studio 2017 from the test menu.

Features

  • Support time units Weeks, Days (default), Hours out-of-the-box, can be modified to support other time resolutions.
  • Single tasks, grouped tasks, precedent/dependant tasks, split tasks, tagged resources
  • Printing respects page margin, orientation and multiple pages per page
  • Percentage complete property for each task
  • Various mouse events for customising UI experience directly on the chart.
  • Comes with default mouse commands that can be overridden through inheritance.
  • Determines critical path and slack

Documentation

Jump directly to the doxygen documentation, or visit my blog for more information. (Please make sure you are reading the updated versions while I try to keep up, thanks.)

Basic Usage

Create Chart and Adding Tasks

public Form1()
{
    InitializeComponents();
    var manager = new ProjectManager();
    var task = new Task() { Name = "Hello World" };
    manager.Add(task);
    var chart = new Chart();
    chart.Init(manage);
    
    this.Controls.Add(chart);

    this.AutoScroll = true; // this is no longer required
}

Common Task Manipulation

You can manipulate the task through code using various methods in the ProjectManager:

// Set task durations
_mManager.SetDuration(wake, 3);
// Give the Tasks some organisation, setting group and
// precedents e.g. make "wake" task a subtask under "work"
_mManager.Group(work, wake);
// Setting task dependencies e.g. make "wake" task a precedent of "brush teeth" task
_mManager.Relate(wake, teeth);
// Assigning Resources e.g. add "jake" resource to "wake" task
_mManager.Assign(wake, jake);
// splitting a tasks e.g. split the "pack up" task into 2 new tasks
_mManager.Split(pack, new MyTask(_mManager), new MyTask(_mManager), 2);
// set some tooltips to show the resources in each task
// e.g. set a tooltip on the "wake" task
_mChart.SetToolTip(wake, string.Join(", ", _mManager.ResourcesOf(wake).Select(x => (x as MyResource).Name)));

Custom Task Data: Different colors for every tasks

You can change the default task appearance for all task, or as in here change individual task color as a demo for adding custom business data to tasks.

public partial class ExampleSimple : Form
{
  ProjectManager _mProject;
  public ExampleSimple()
  {
    InitializeComponent();
    _mProject = new ProjectManager();
    _mProject.Add(new Task() { Name = "New Task" });
    _mProject.Add(new ColoredTask() { Name = "Purple Task", Color = Color.Purple });
    _mProject.Add(new ColoredTask() { Name = "Gold Task", Color = Color.Gold });
    _mChart.Init(_mProject);
    // Custom behavior on paint task
    _mChart.PaintTask += (s, e) =>
    {
        ColoredTask ctask = e.Task as ColoredTask;
        if (ctask != null)
        {
            var format = new TaskFormat();
            format = e.Format;
            format.BackFill = new SolidBrush(ctask.Color);
            e.Format = format;
        }
    };
		
    // Grab custom data for tasks
    _mChart.TaskSelected += (s, e) =>
    {
        ColoredTask ctask = e.Task as ColoredTask;
        if (ctask != null)
        {
            MessageBox.Show("Selected " + ctask.Color.ToString());
        }
    };
  }
}

// Custom task with business data
public class ColoredTask : Task
{
    public ColoredTask() : base() {}
    public Color Color { get; set; }
}

License

This project is licensed under the MIT License - see the LICENSE.md file for details

ganttchart's People

Contributors

jakesee avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ganttchart's Issues

Make event firing thread-safe

Hi, Possibly a minor point, but the event firing could be more thread-safe by copying the handler to a local variable and then firing the local variable. This prevents potential issues where while the task is firing a separate thread adds or removes more handlers before the event is complete. It's an edge case, but as nobody can know how this control may be used anything is possible. For example, OnTaskMouseDoubleClick would look like:

private void OnTaskMouseDoubleClick(TaskMouseEventArgs e)
{
	EventHandler<TaskMouseEventArgs> locum = TaskMouseDoubleClick;
	if(locum != null)
	{
		locum(this, e);
	}
}

Add Baseline functionality

Need the ability to display current schedule and baseline schedule simultaneously so visually display project status as compared to original.

Change property AllowTaskDragDrop to ReadOnly

Someone suggested AllowTaskDragDrop is better named ReadOnly. There must be a reason why I named it this way in the first place. I will have to confirm the implications and make the change if required.

Feature-Request: Group tasks by their resources

It would be awesome if it would be possible to group the tasks by their resources. Currently every task will be shown underneath, even if they are done by the same resource.

E.g.
1 row for "Jake" with the tasks: wake, teeth
1 row for "Peter" with the tasks: wake
1 row for "John" with the tasks: wake, shower

So I can see directly, which resource got free capacity (= empty space) or which resource is overloaded (full of bars). Like in other planning tools.

In my example, the task "packaging" will be done by the logistics guy. It would be great if both tasks would be in the same row:
grafik
grafik

Add Calendar Function to Chart

Need to add functionality to assign a calendar with non-working days so that bar size is correct relative to the number of work days required to complete a task.

Fix selecting and deselecting tasks on chart

Expected:
Shift+left click to deselect tasks.
When task part is selected, Chart.SelectedTasks will contain task part.
Chart.SelectedTasks will not contain split tasks.
User can listen to PaintTask event to draw selected tasks differently.

Hover over text outside control

For entries with large amounts of text, I can't find a way to all the textl when hovering over the entry - part of the text ends up outside the control. Could scroll bars/mousewheel be used to view it?

Business Hours and Days

Hello, i dont know if there is any way to setup the business day or business hours.

Thanks

Timeline view

Is there any way to show hours and minutes on timeline (except of date\weekdays)?

操作数据库

将任务数据从数据库中读取并显示的功能我已经实现了,但是如何将修改后的数据提交的数据库中还未实现。程序中所有的时间都是timespan类型,而要保存的数据都是DateTime类型的。有没有什么好的方法可以实现修改的数据能提交的数据库中呢?

Change days in header2 and tick

Hello,
thanks for this great project. I really like it!
But i want to make some changes.

  1. I want to change the days from MTWTFSS, to MDMDFSS, and the tick from S to M, so the first day in the week is monday here.

How can i do that?

Thanks

Add Chart Scroll event

A Chart scrolling event can help users to synchronise scrolling with complementary UI such as a datagridview containing information with respect to each task on each row.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.