GanttChart
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
GanttChart | Creates a Gantt chart with an empty plan. |
BarBrush | Gets or sets the fill of a task bar and a milestone. A calm blue by default. |
BaselineBrush | Gets or sets the fill of the baseline drawn under a bar. A light grey by default. |
Columns | Gets or sets which columns the task list shows. The name is always shown. |
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 | Gets or sets the colour of the lines between rows, columns and header ticks. |
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 | Gets or sets the tint behind the column and timeline headers. |
Holidays | Gets or sets the dates that are not worked. Never null: setting null gives an empty list. An ObservableCollection{T} is watched. |
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 | Gets or sets the colour of the links between bars. A mid grey by default. |
Links | Gets or sets the links between the tasks. Never null: setting null gives an empty list. |
LogicalChildren | — |
NonWorkingBrush | Gets or sets the tint behind weekends and holidays. Shown at Day and Week zoom. |
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 | Gets or sets the first day work can happen. Null, the default, takes it from the tasks' own dates. |
RowHeight | Gets or sets the height of a row in logical units (1/96 inch). 28 by default, at least 16. |
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 | Gets or sets the task the reader has chosen, or null when there is none. |
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 | Gets or sets whether each task's baseline is drawn under its bar. False by default. |
ShowCriticalPath | Gets or sets whether the critical path is drawn in CriticalBrush. True by default. |
ShowLinks | Gets or sets whether the links between tasks are drawn. True by default. |
ShowToday | Gets or sets whether a line is drawn down the timeline at today. True by default. |
SummaryBrush | Gets or sets the colour of a summary task's bracket. A slate grey by default. |
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. |
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 | Gets or sets the colour of the today line. A clear green by default. |
VisualChildrenCount | — |
WeekStart | Gets or sets the day weeks start on in the timeline's headers. Monday by default. |
WorkingWeek | Gets or sets the days of the week that are worked. Monday to Friday by default. |
Zoom | Gets or sets how much time the timeline shows. Week by default. |
ArrangeOverride | — |
CollapseAll | Closes every summary task. |
ExpandAll | Opens every summary task. |
ExportImage | 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. |
GetVisualChild | — |
IsExpanded | Whether a summary task is open, showing its subtasks. |
MeasureOverride | — |
OnCreateAutomationPeer | — |
OnDpiChanged | — |
OnIsKeyboardFocusedChanged | — |
OnKeyDown | — |
OnLinksChanged | Raises LinksChanged. |
OnLinksChanging | Raises LinksChanging. |
OnLostMouseCapture | — |
OnMouseLeave | — |
OnMouseLeftButtonDown | — |
OnMouseLeftButtonUp | — |
OnMouseMove | — |
OnMouseRightButtonDown | — |
OnMouseWheel | — |
OnPropertyChanged | — |
OnQueryCursor | — |
OnRender | — |
OnScheduleChanged | Raises ScheduleChanged. |
OnSelectedTaskChanged | Raises SelectedTaskChanged. |
OnTaskActivated | Raises TaskActivated. |
OnTaskChanged | Raises TaskChanged. |
OnTaskChanging | Raises TaskChanging. |
OnTaskToggled | Raises TaskToggled. |
OnZoomChanged | Raises ZoomChanged. |
Print | 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. |
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 | 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. |
ScrollToToday | Scrolls the timeline so that today is in view, a third of the way across. |
SetExpanded | Opens or closes a summary task. Does nothing for a task that has no subtasks. |
ZoomIn | Opens the timeline one step finer: Year, Quarter, Month, Week, Day. |
ZoomOut | Closes the timeline one step coarser: Day, Week, Month, Quarter, Year. |
ZoomToFit | Chooses the finest zoom at which the whole plan fits the timeline pane, and scrolls to the plan's first day. |
LinksChanged | Raised after a reader's edit has changed Links. |
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 | Raised after the plan has been scheduled again because something in it changed. |
SelectedTaskChanged | Raised when SelectedTask changes. |
TaskActivated | Raised when a reader double-clicks a task, or presses Enter or Space on it. |
TaskChanged | Raised after a reader's edit has changed a task. |
TaskChanging | Raised before a reader's edit changes a task. Cancel it to refuse the edit. |
TaskToggled | Raised when a summary task is opened or closed. |
ZoomChanged | Raised when Zoom changes. |
BarBrushProperty | Identifies the BarBrush dependency property. |
BaselineBrushProperty | Identifies the BaselineBrush dependency property. |
ColumnsProperty | Identifies the Columns dependency property. |
CriticalBrushProperty | Identifies the CriticalBrush dependency property. |
GridLineBrushProperty | Identifies the GridLineBrush dependency property. |
GridWidthProperty | Identifies the GridWidth dependency property. |
HeaderBrushProperty | Identifies the HeaderBrush dependency property. |
HolidaysProperty | Identifies the Holidays dependency property. |
IsReadOnlyProperty | Identifies the IsReadOnly dependency property. |
LinkBrushProperty | Identifies the LinkBrush dependency property. |
LinksProperty | Identifies the Links dependency property. |
NonWorkingBrushProperty | Identifies the NonWorkingBrush dependency property. |
ProgressBrushProperty | Identifies the ProgressBrush dependency property. |
ProjectStartProperty | Identifies the ProjectStart dependency property. |
RowHeightProperty | Identifies the RowHeight dependency property. |
SelectedTaskProperty | Identifies the SelectedTask dependency property. |
SelectionBrushProperty | Identifies the SelectionBrush dependency property. |
ShowBaselinesProperty | Identifies the ShowBaselines dependency property. |
ShowCriticalPathProperty | Identifies the ShowCriticalPath dependency property. |
ShowLinksProperty | Identifies the ShowLinks dependency property. |
ShowTodayProperty | Identifies the ShowToday dependency property. |
SummaryBrushProperty | Identifies the SummaryBrush dependency property. |
TasksProperty | Identifies the Tasks dependency property. |
TodayBrushProperty | Identifies the TodayBrush dependency property. |
TodayProperty | Identifies the Today dependency property. |
WeekStartProperty | Identifies the WeekStart dependency property. |
WorkingWeekProperty | Identifies the WorkingWeek dependency property. |
ZoomProperty | Identifies the Zoom dependency property. |
Constructors
GanttChart
Creates a Gantt chart with an empty plan.
Properties
BarBrush
Gets or sets the fill of a task bar and a milestone. A calm blue by default.
BaselineBrush
Gets or sets the fill of the baseline drawn under a bar. A light grey by default.
Columns
Gets or sets which columns the task list shows. The name is always shown.
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
Gets or sets the colour of the lines between rows, columns and header ticks.
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
Gets or sets the tint behind the column and timeline headers.
Holidays
Gets or sets the dates that are not worked. Never null: setting null gives an empty list. An ObservableCollection{T} is watched.
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
Gets or sets the colour of the links between bars. A mid grey by default.
Links
Gets or sets the links between the tasks. Never null: setting null gives an empty list.
LogicalChildren
No summary in the source yet.
NonWorkingBrush
Gets or sets the tint behind weekends and holidays. Shown at Day and Week zoom.
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
Gets or sets the first day work can happen. Null, the default, takes it from the tasks' own dates.
RowHeight
Gets or sets the height of a row in logical units (1/96 inch). 28 by default, at least 16.
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
Gets or sets the task the reader has chosen, or null when there is none.
Tasks is not selected.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
Gets or sets whether each task's baseline is drawn under its bar. False by default.
ShowCriticalPath
Gets or sets whether the critical path is drawn in CriticalBrush. True by default.
ShowLinks
Gets or sets whether the links between tasks are drawn. True by default.
ShowToday
Gets or sets whether a line is drawn down the timeline at today. True by default.
SummaryBrush
Gets or sets the colour of a summary task's bracket. A slate grey by default.
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.
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
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
Gets or sets the colour of the today line. A clear green by default.
VisualChildrenCount
No summary in the source yet.
WeekStart
Gets or sets the day weeks start on in the timeline's headers. Monday by default.
WorkingWeek
Gets or sets the days of the week that are worked. Monday to Friday by default.
Zoom
Gets or sets how much time the timeline shows. Week by default.
Methods
ArrangeOverride
No summary in the source yet.
CollapseAll
Closes every summary task.
ExpandAll
Opens every summary task.
ExportImage
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
dpiis not a positive number.
dpi that fits; its DpiX says which.GetVisualChild
No summary in the source yet.
IsExpanded
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
No summary in the source yet.
OnCreateAutomationPeer
No summary in the source yet.
OnDpiChanged
No summary in the source yet.
OnIsKeyboardFocusedChanged
No summary in the source yet.
OnKeyDown
No summary in the source yet.
OnLinksChanged
Raises LinksChanged.
- e
- Empty event data.
OnLinksChanging
Raises LinksChanging.
- e
- The proposed change.
OnLostMouseCapture
No summary in the source yet.
OnMouseLeave
No summary in the source yet.
OnMouseLeftButtonDown
No summary in the source yet.
OnMouseLeftButtonUp
No summary in the source yet.
OnMouseMove
No summary in the source yet.
OnMouseRightButtonDown
No summary in the source yet.
OnMouseWheel
No summary in the source yet.
OnPropertyChanged
No summary in the source yet.
OnQueryCursor
No summary in the source yet.
OnRender
No summary in the source yet.
OnScheduleChanged
Raises ScheduleChanged.
- e
- Empty event data.
OnSelectedTaskChanged
Raises SelectedTaskChanged.
- e
- Empty event data.
OnTaskActivated
Raises TaskActivated.
- e
- The task that was activated.
OnTaskChanged
Raises TaskChanged.
- e
- The task that changed.
OnTaskChanging
Raises TaskChanging.
- e
- The proposed change.
OnTaskToggled
Raises TaskToggled.
- e
- The summary task that was opened or closed.
OnZoomChanged
Raises ZoomChanged.
- e
- Empty event data.
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
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
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
Scrolls the timeline so that today is in view, a third of the way across.
SetExpanded
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
Opens the timeline one step finer: Year, Quarter, Month, Week, Day.
ZoomOut
Closes the timeline one step coarser: Day, Week, Month, Quarter, Year.
ZoomToFit
Chooses the finest zoom at which the whole plan fits the timeline pane, and scrolls to the plan's first day.
Events
LinksChanged
Raised after a reader's edit has changed Links.
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
Raised after the plan has been scheduled again because something in it changed.
SelectedTaskChanged
Raised when SelectedTask changes.
TaskActivated
Raised when a reader double-clicks a task, or presses Enter or Space on it.
TaskChanged
Raised after a reader's edit has changed a task.
TaskChanging
Raised before a reader's edit changes a task. Cancel it to refuse the edit.
TaskToggled
Raised when a summary task is opened or closed.
ZoomChanged
Raised when Zoom changes.
Fields
BarBrushProperty
Identifies the BarBrush dependency property.
BaselineBrushProperty
Identifies the BaselineBrush dependency property.
ColumnsProperty
Identifies the Columns dependency property.
CriticalBrushProperty
Identifies the CriticalBrush dependency property.
GridLineBrushProperty
Identifies the GridLineBrush dependency property.
GridWidthProperty
Identifies the GridWidth dependency property.
HeaderBrushProperty
Identifies the HeaderBrush dependency property.
HolidaysProperty
Identifies the Holidays dependency property.
IsReadOnlyProperty
Identifies the IsReadOnly dependency property.
LinkBrushProperty
Identifies the LinkBrush dependency property.
LinksProperty
Identifies the Links dependency property.
NonWorkingBrushProperty
Identifies the NonWorkingBrush dependency property.
ProgressBrushProperty
Identifies the ProgressBrush dependency property.
ProjectStartProperty
Identifies the ProjectStart dependency property.
RowHeightProperty
Identifies the RowHeight dependency property.
SelectedTaskProperty
Identifies the SelectedTask dependency property.
SelectionBrushProperty
Identifies the SelectionBrush dependency property.
ShowBaselinesProperty
Identifies the ShowBaselines dependency property.
ShowCriticalPathProperty
Identifies the ShowCriticalPath dependency property.
ShowLinksProperty
Identifies the ShowLinks dependency property.
ShowTodayProperty
Identifies the ShowToday dependency property.
SummaryBrushProperty
Identifies the SummaryBrush dependency property.
TasksProperty
Identifies the Tasks dependency property.
TodayBrushProperty
Identifies the TodayBrush dependency property.
TodayProperty
Identifies the Today dependency property.
WeekStartProperty
Identifies the WeekStart dependency property.
WorkingWeekProperty
Identifies the WorkingWeek dependency property.
ZoomProperty
Identifies the Zoom dependency property.