HypernovaDesktop Components · docs
Binarymission
WPF › Project Management › GanttChart

GanttChart

class.NET 6 / 8 / 10.NET Framework 4.8Binarymission.WPF.Controls.ProjectManagement

A Gantt chart: a task list beside a timeline of bars, links, milestones and the critical path, which a reader can scroll, zoom and edit with the mouse or the keyboard alone.

public partial class GanttChart : Control

Inherits from / implements: Control

Remarks

Give it a plan through Tasks and Links. The dates are worked out by the critical-path method on the working calendar set by WorkingWeek, Holidays and ProjectStart; the result is in Schedule. Every edit a reader makes is offered first through TaskChanging or LinksChanging, which the application can cancel, and is then made to the task or link object itself. Set IsReadOnly to allow viewing only.

Members at a glance

GanttChartCreates a Gantt chart with an empty plan.
BarBrushGets or sets the fill of a task bar and a milestone. A calm blue by default.
BaselineBrushGets or sets the fill of the baseline drawn under a bar. A light grey by default.
ColumnsGets or sets which columns the task list shows. The name is always shown.
CriticalBrushGets or sets the fill of the bars, milestones and links on the critical path, when ShowCriticalPath is set. A red-orange by default.
GridLineBrushGets or sets the colour of the lines between rows, columns and header ticks.
GridWidthGets or sets the width of the task list in logical units (1/96 inch). 420 by default. The reader changes it by dragging the splitter between the panes.
HeaderBrushGets or sets the tint behind the column and timeline headers.
HolidaysGets or sets the dates that are not worked. Never null: setting null gives an empty list. An ObservableCollection{T} is watched.
IsReadOnlyGets or sets whether the reader can only look: no dragging, no drawing links, no typing into cells and no keyboard edits. Selecting, scrolling and zooming still work.
LinkBrushGets or sets the colour of the links between bars. A mid grey by default.
LinksGets or sets the links between the tasks. Never null: setting null gives an empty list.
LogicalChildren—
NonWorkingBrushGets or sets the tint behind weekends and holidays. Shown at Day and Week zoom.
ProgressBrushGets or sets what is painted over the finished part of a bar. A translucent black by default, which darkens whatever colour the bar is, critical or not.
ProjectStartGets or sets the first day work can happen. Null, the default, takes it from the tasks' own dates.
RowHeightGets or sets the height of a row in logical units (1/96 inch). 28 by default, at least 16.
ScheduleGets the plan as scheduled: every task's dates and float, the links that were honoured, the critical path, and anything in the input that could not be used. Never null.
SelectedTaskGets or sets the task the reader has chosen, or null when there is none.
SelectionBrushGets or sets the fill behind the selected row. Null, the default, uses the system highlight colour, lightened so the row's text stays readable in Foreground.
ShowBaselinesGets or sets whether each task's baseline is drawn under its bar. False by default.
ShowCriticalPathGets or sets whether the critical path is drawn in CriticalBrush. True by default.
ShowLinksGets or sets whether the links between tasks are drawn. True by default.
ShowTodayGets or sets whether a line is drawn down the timeline at today. True by default.
SummaryBrushGets or sets the colour of a summary task's bracket. A slate grey by default.
TasksGets or sets the tasks, as a flat list in outline order with parent references. Never null: setting null gives the chart a new empty list.
TodayGets or sets which day the today line is drawn on. Null, the default, is the computer's date. It changes nothing but the line.
TodayBrushGets or sets the colour of the today line. A clear green by default.
VisualChildrenCount—
WeekStartGets or sets the day weeks start on in the timeline's headers. Monday by default.
WorkingWeekGets or sets the days of the week that are worked. Monday to Friday by default.
ZoomGets or sets how much time the timeline shows. Week by default.
ArrangeOverride—
CollapseAllCloses every summary task.
ExpandAllOpens every summary task.
ExportImageDraws the whole chart as an image: every task, open or not, beside the whole timeline, with the task list at its full width. Selection, focus and scroll position are not drawn.
GetVisualChild—
IsExpandedWhether a summary task is open, showing its subtasks.
MeasureOverride—
OnCreateAutomationPeer—
OnDpiChanged—
OnIsKeyboardFocusedChanged—
OnKeyDown—
OnLinksChangedRaises LinksChanged.
OnLinksChangingRaises LinksChanging.
OnLostMouseCapture—
OnMouseLeave—
OnMouseLeftButtonDown—
OnMouseLeftButtonUp—
OnMouseMove—
OnMouseRightButtonDown—
OnMouseWheel—
OnPropertyChanged—
OnQueryCursor—
OnRender—
OnScheduleChangedRaises ScheduleChanged.
OnSelectedTaskChangedRaises SelectedTaskChanged.
OnTaskActivatedRaises TaskActivated.
OnTaskChangedRaises TaskChanged.
OnTaskChangingRaises TaskChanging.
OnTaskToggledRaises TaskToggled.
OnZoomChangedRaises ZoomChanged.
PrintAsks the reader for a printer and prints the whole chart on one page, as ExportImage draws it, shrunk to fit the printable area when it is larger.
RescheduleSchedules the plan again now. Only needed after changing a plain list that does not say when it changes; observable collections and the tasks in them are watched.
ScrollToTaskBrings a task into view: opens the summaries above it, scrolls its row into view and scrolls the timeline to its bar. The selection does not change.
ScrollToTodayScrolls the timeline so that today is in view, a third of the way across.
SetExpandedOpens or closes a summary task. Does nothing for a task that has no subtasks.
ZoomInOpens the timeline one step finer: Year, Quarter, Month, Week, Day.
ZoomOutCloses the timeline one step coarser: Day, Week, Month, Quarter, Year.
ZoomToFitChooses the finest zoom at which the whole plan fits the timeline pane, and scrolls to the plan's first day.
LinksChangedRaised after a reader's edit has changed Links.
LinksChangingRaised before a reader's edit changes the links into a task: a link drawn between two bars, or the Predecessors cell typed. Cancel it to refuse the edit.
ScheduleChangedRaised after the plan has been scheduled again because something in it changed.
SelectedTaskChangedRaised when SelectedTask changes.
TaskActivatedRaised when a reader double-clicks a task, or presses Enter or Space on it.
TaskChangedRaised after a reader's edit has changed a task.
TaskChangingRaised before a reader's edit changes a task. Cancel it to refuse the edit.
TaskToggledRaised when a summary task is opened or closed.
ZoomChangedRaised when Zoom changes.
BarBrushPropertyIdentifies the BarBrush dependency property.
BaselineBrushPropertyIdentifies the BaselineBrush dependency property.
ColumnsPropertyIdentifies the Columns dependency property.
CriticalBrushPropertyIdentifies the CriticalBrush dependency property.
GridLineBrushPropertyIdentifies the GridLineBrush dependency property.
GridWidthPropertyIdentifies the GridWidth dependency property.
HeaderBrushPropertyIdentifies the HeaderBrush dependency property.
HolidaysPropertyIdentifies the Holidays dependency property.
IsReadOnlyPropertyIdentifies the IsReadOnly dependency property.
LinkBrushPropertyIdentifies the LinkBrush dependency property.
LinksPropertyIdentifies the Links dependency property.
NonWorkingBrushPropertyIdentifies the NonWorkingBrush dependency property.
ProgressBrushPropertyIdentifies the ProgressBrush dependency property.
ProjectStartPropertyIdentifies the ProjectStart dependency property.
RowHeightPropertyIdentifies the RowHeight dependency property.
SelectedTaskPropertyIdentifies the SelectedTask dependency property.
SelectionBrushPropertyIdentifies the SelectionBrush dependency property.
ShowBaselinesPropertyIdentifies the ShowBaselines dependency property.
ShowCriticalPathPropertyIdentifies the ShowCriticalPath dependency property.
ShowLinksPropertyIdentifies the ShowLinks dependency property.
ShowTodayPropertyIdentifies the ShowToday dependency property.
SummaryBrushPropertyIdentifies the SummaryBrush dependency property.
TasksPropertyIdentifies the Tasks dependency property.
TodayBrushPropertyIdentifies the TodayBrush dependency property.
TodayPropertyIdentifies the Today dependency property.
WeekStartPropertyIdentifies the WeekStart dependency property.
WorkingWeekPropertyIdentifies the WorkingWeek dependency property.
ZoomPropertyIdentifies the Zoom dependency property.

Constructors

GanttChart

public GanttChart()

Creates a Gantt chart with an empty plan.

Properties

BarBrush

public Brush BarBrush

Gets or sets the fill of a task bar and a milestone. A calm blue by default.

BaselineBrush

public Brush BaselineBrush

Gets or sets the fill of the baseline drawn under a bar. A light grey by default.

Columns

public GanttColumns Columns

Gets or sets which columns the task list shows. The name is always shown.

CriticalBrush

public Brush CriticalBrush

Gets or sets the fill of the bars, milestones and links on the critical path, when ShowCriticalPath is set. A red-orange by default.

GridLineBrush

public Brush GridLineBrush

Gets or sets the colour of the lines between rows, columns and header ticks.

GridWidth

public double GridWidth

Gets or sets the width of the task list in logical units (1/96 inch). 420 by default. The reader changes it by dragging the splitter between the panes.

HeaderBrush

public Brush HeaderBrush

Gets or sets the tint behind the column and timeline headers.

Holidays

public IList<DateTime> Holidays

Gets or sets the dates that are not worked. Never null: setting null gives an empty list. An ObservableCollection{T} is watched.

IsReadOnly

public bool IsReadOnly

Gets or sets whether the reader can only look: no dragging, no drawing links, no typing into cells and no keyboard edits. Selecting, scrolling and zooming still work.

LinkBrush

public Brush LinkBrush

Gets or sets the colour of the links between bars. A mid grey by default.

LogicalChildren

protected override IEnumerator LogicalChildren

No summary in the source yet.

NonWorkingBrush

public Brush NonWorkingBrush

Gets or sets the tint behind weekends and holidays. Shown at Day and Week zoom.

ProgressBrush

public Brush ProgressBrush

Gets or sets what is painted over the finished part of a bar. A translucent black by default, which darkens whatever colour the bar is, critical or not.

ProjectStart

public DateTime? ProjectStart

Gets or sets the first day work can happen. Null, the default, takes it from the tasks' own dates.

RowHeight

public double RowHeight

Gets or sets the height of a row in logical units (1/96 inch). 28 by default, at least 16.

Schedule

public ProjectSchedule Schedule

Gets the plan as scheduled: every task's dates and float, the links that were honoured, the critical path, and anything in the input that could not be used. Never null.

SelectedTask

public ProjectTask SelectedTask

Gets or sets the task the reader has chosen, or null when there is none.

Setting a task inside a closed summary opens the summaries above it and scrolls it into view. A task that is not in Tasks is not selected.

SelectionBrush

public Brush SelectionBrush

Gets or sets the fill behind the selected row. Null, the default, uses the system highlight colour, lightened so the row's text stays readable in Foreground.

ShowBaselines

public bool ShowBaselines

Gets or sets whether each task's baseline is drawn under its bar. False by default.

ShowCriticalPath

public bool ShowCriticalPath

Gets or sets whether the critical path is drawn in CriticalBrush. True by default.

ShowToday

public bool ShowToday

Gets or sets whether a line is drawn down the timeline at today. True by default.

SummaryBrush

public Brush SummaryBrush

Gets or sets the colour of a summary task's bracket. A slate grey by default.

Tasks

public IList<ProjectTask> Tasks

Gets or sets the tasks, as a flat list in outline order with parent references. Never null: setting null gives the chart a new empty list.

An ObservableCollection{T} or a BindingList is watched, and so is every task in it; a plain list is read when it is assigned, and after changing one call Reschedule.

Today

public DateTime? Today

Gets or sets which day the today line is drawn on. Null, the default, is the computer's date. It changes nothing but the line.

TodayBrush

public Brush TodayBrush

Gets or sets the colour of the today line. A clear green by default.

VisualChildrenCount

protected override int VisualChildrenCount

No summary in the source yet.

WeekStart

public DayOfWeek WeekStart

Gets or sets the day weeks start on in the timeline's headers. Monday by default.

WorkingWeek

public WorkingWeek WorkingWeek

Gets or sets the days of the week that are worked. Monday to Friday by default.

Zoom

public GanttZoom Zoom

Gets or sets how much time the timeline shows. Week by default.

Methods

ArrangeOverride

protected override Size ArrangeOverride(Size arrangeSize)

No summary in the source yet.

CollapseAll

public void CollapseAll()

Closes every summary task.

ExpandAll

public void ExpandAll()

Opens every summary task.

ExportImage

public BitmapSource ExportImage(double dpi

Draws the whole chart as an image: every task, open or not, beside the whole timeline, with the task list at its full width. Selection, focus and scroll position are not drawn.

dpi
The image's resolution in dots per inch; 96 draws one pixel per logical unit.

Returns. The image, frozen, so it can be handed to another thread.

ArgumentOutOfRangeException
dpi is not a positive number.
An image that would be wider or taller than 16,384 pixels, or larger than 128 megapixels, is made at the highest resolution below dpi that fits; its DpiX says which.

GetVisualChild

protected override Visual GetVisualChild(int index)

No summary in the source yet.

IsExpanded

public bool IsExpanded(ProjectTask task)

Whether a summary task is open, showing its subtasks.

task
The task.

Returns. True for an open summary; false for a closed one, a task with no subtasks, or a task not in the plan.

MeasureOverride

protected override Size MeasureOverride(Size constraint)

No summary in the source yet.

OnCreateAutomationPeer

protected override AutomationPeer OnCreateAutomationPeer()

No summary in the source yet.

OnDpiChanged

protected override void OnDpiChanged(DpiScale oldDpi, DpiScale newDpi)

No summary in the source yet.

OnIsKeyboardFocusedChanged

protected override void OnIsKeyboardFocusedChanged(DependencyPropertyChangedEventArgs e)

No summary in the source yet.

OnKeyDown

protected override void OnKeyDown(KeyEventArgs e)

No summary in the source yet.

OnLinksChanged

protected virtual void OnLinksChanged(EventArgs e)

Raises LinksChanged.

e
Empty event data.

OnLinksChanging

protected virtual void OnLinksChanging(LinksChangingEventArgs e)

Raises LinksChanging.

e
The proposed change.

OnLostMouseCapture

protected override void OnLostMouseCapture(MouseEventArgs e)

No summary in the source yet.

OnMouseLeave

protected override void OnMouseLeave(MouseEventArgs e)

No summary in the source yet.

OnMouseLeftButtonDown

protected override void OnMouseLeftButtonDown(MouseButtonEventArgs e)

No summary in the source yet.

OnMouseLeftButtonUp

protected override void OnMouseLeftButtonUp(MouseButtonEventArgs e)

No summary in the source yet.

OnMouseMove

protected override void OnMouseMove(MouseEventArgs e)

No summary in the source yet.

OnMouseRightButtonDown

protected override void OnMouseRightButtonDown(MouseButtonEventArgs e)

No summary in the source yet.

OnMouseWheel

protected override void OnMouseWheel(MouseWheelEventArgs e)

No summary in the source yet.

OnPropertyChanged

protected override void OnPropertyChanged(DependencyPropertyChangedEventArgs e)

No summary in the source yet.

OnQueryCursor

protected override void OnQueryCursor(QueryCursorEventArgs e)

No summary in the source yet.

OnRender

protected override void OnRender(DrawingContext drawingContext)

No summary in the source yet.

OnScheduleChanged

protected virtual void OnScheduleChanged(EventArgs e)

Raises ScheduleChanged.

e
Empty event data.

OnSelectedTaskChanged

protected virtual void OnSelectedTaskChanged(EventArgs e)

Raises SelectedTaskChanged.

e
Empty event data.

OnTaskActivated

protected virtual void OnTaskActivated(TaskEventArgs e)

Raises TaskActivated.

e
The task that was activated.

OnTaskChanged

protected virtual void OnTaskChanged(TaskEventArgs e)

Raises TaskChanged.

e
The task that changed.

OnTaskChanging

protected virtual void OnTaskChanging(TaskChangingEventArgs e)

Raises TaskChanging.

e
The proposed change.

OnTaskToggled

protected virtual void OnTaskToggled(TaskEventArgs e)

Raises TaskToggled.

e
The summary task that was opened or closed.

OnZoomChanged

protected virtual void OnZoomChanged(EventArgs e)

Raises ZoomChanged.

e
Empty event data.

Print

public void Print(string description)

Asks the reader for a printer and prints the whole chart on one page, as ExportImage draws it, shrunk to fit the printable area when it is larger.

description
What the print job is called in the printer's queue; null or empty for "Gantt chart".

Reschedule

public void Reschedule()

Schedules the plan again now. Only needed after changing a plain list that does not say when it changes; observable collections and the tasks in them are watched.

ScrollToTask

public void ScrollToTask(ProjectTask task)

Brings a task into view: opens the summaries above it, scrolls its row into view and scrolls the timeline to its bar. The selection does not change.

task
The task. Nothing happens for null or a task not in the plan.

ScrollToToday

public void ScrollToToday()

Scrolls the timeline so that today is in view, a third of the way across.

SetExpanded

public void SetExpanded(ProjectTask task, bool expanded)

Opens or closes a summary task. Does nothing for a task that has no subtasks.

task
The summary task.
expanded
True to show its subtasks, false to hide them.

ZoomIn

public void ZoomIn()

Opens the timeline one step finer: Year, Quarter, Month, Week, Day.

ZoomOut

public void ZoomOut()

Closes the timeline one step coarser: Day, Week, Month, Quarter, Year.

ZoomToFit

public void ZoomToFit()

Chooses the finest zoom at which the whole plan fits the timeline pane, and scrolls to the plan's first day.

Events

LinksChanged

public event EventHandler LinksChanged

Raised after a reader's edit has changed Links.

LinksChanging

public event EventHandler<LinksChangingEventArgs> LinksChanging

Raised before a reader's edit changes the links into a task: a link drawn between two bars, or the Predecessors cell typed. Cancel it to refuse the edit.

ScheduleChanged

public event EventHandler ScheduleChanged

Raised after the plan has been scheduled again because something in it changed.

SelectedTaskChanged

public event EventHandler SelectedTaskChanged

Raised when SelectedTask changes.

TaskActivated

public event EventHandler<TaskEventArgs> TaskActivated

Raised when a reader double-clicks a task, or presses Enter or Space on it.

TaskChanged

public event EventHandler<TaskEventArgs> TaskChanged

Raised after a reader's edit has changed a task.

TaskChanging

public event EventHandler<TaskChangingEventArgs> TaskChanging

Raised before a reader's edit changes a task. Cancel it to refuse the edit.

TaskToggled

public event EventHandler<TaskEventArgs> TaskToggled

Raised when a summary task is opened or closed.

ZoomChanged

public event EventHandler ZoomChanged

Raised when Zoom changes.

Fields

BarBrushProperty

public static readonly DependencyProperty BarBrushProperty

Identifies the BarBrush dependency property.

BaselineBrushProperty

public static readonly DependencyProperty BaselineBrushProperty

Identifies the BaselineBrush dependency property.

ColumnsProperty

public static readonly DependencyProperty ColumnsProperty

Identifies the Columns dependency property.

CriticalBrushProperty

public static readonly DependencyProperty CriticalBrushProperty

Identifies the CriticalBrush dependency property.

GridLineBrushProperty

public static readonly DependencyProperty GridLineBrushProperty

Identifies the GridLineBrush dependency property.

GridWidthProperty

public static readonly DependencyProperty GridWidthProperty

Identifies the GridWidth dependency property.

HeaderBrushProperty

public static readonly DependencyProperty HeaderBrushProperty

Identifies the HeaderBrush dependency property.

HolidaysProperty

public static readonly DependencyProperty HolidaysProperty

Identifies the Holidays dependency property.

IsReadOnlyProperty

public static readonly DependencyProperty IsReadOnlyProperty

Identifies the IsReadOnly dependency property.

LinkBrushProperty

public static readonly DependencyProperty LinkBrushProperty

Identifies the LinkBrush dependency property.

LinksProperty

public static readonly DependencyProperty LinksProperty

Identifies the Links dependency property.

NonWorkingBrushProperty

public static readonly DependencyProperty NonWorkingBrushProperty

Identifies the NonWorkingBrush dependency property.

ProgressBrushProperty

public static readonly DependencyProperty ProgressBrushProperty

Identifies the ProgressBrush dependency property.

ProjectStartProperty

public static readonly DependencyProperty ProjectStartProperty

Identifies the ProjectStart dependency property.

RowHeightProperty

public static readonly DependencyProperty RowHeightProperty

Identifies the RowHeight dependency property.

SelectedTaskProperty

public static readonly DependencyProperty SelectedTaskProperty

Identifies the SelectedTask dependency property.

SelectionBrushProperty

public static readonly DependencyProperty SelectionBrushProperty

Identifies the SelectionBrush dependency property.

ShowBaselinesProperty

public static readonly DependencyProperty ShowBaselinesProperty

Identifies the ShowBaselines dependency property.

ShowCriticalPathProperty

public static readonly DependencyProperty ShowCriticalPathProperty

Identifies the ShowCriticalPath dependency property.

ShowLinksProperty

public static readonly DependencyProperty ShowLinksProperty

Identifies the ShowLinks dependency property.

ShowTodayProperty

public static readonly DependencyProperty ShowTodayProperty

Identifies the ShowToday dependency property.

SummaryBrushProperty

public static readonly DependencyProperty SummaryBrushProperty

Identifies the SummaryBrush dependency property.

TasksProperty

public static readonly DependencyProperty TasksProperty

Identifies the Tasks dependency property.

TodayBrushProperty

public static readonly DependencyProperty TodayBrushProperty

Identifies the TodayBrush dependency property.

TodayProperty

public static readonly DependencyProperty TodayProperty

Identifies the Today dependency property.

WeekStartProperty

public static readonly DependencyProperty WeekStartProperty

Identifies the WeekStart dependency property.

WorkingWeekProperty

public static readonly DependencyProperty WorkingWeekProperty

Identifies the WorkingWeek dependency property.

ZoomProperty

public static readonly DependencyProperty ZoomProperty

Identifies the Zoom dependency property.