HypernovaDesktop Components · docs
Binarymission
WPF › Project Management › PertChart

PertChart

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

A PERT chart: the plan as a network of boxes, one for each piece of work, joined by arrows in the order the work has to happen, with the dates the critical-path method gives each task.

public partial class PertChart : Control

Inherits from / implements: Control

Remarks

Give the chart the same Tasks and Links as a Gantt chart or a task board and the three agree: they schedule the same objects with the same arithmetic, and a change made in any of them is seen by all. Each box shows the task's name, then its earliest start, duration and earliest finish, then its latest start, total float and latest finish. A summary task is not a box: a PERT chart shows the work, not the outline it is filed in. The chart is one tab stop. The arrow keys move between boxes - Right to the nearest task that follows, Left to the nearest it follows, Up and Down along a column - Home and End go to the first and last box, and Enter raises TaskActivated. Drag the background to pan, use the wheel to scroll, and hold Ctrl with the wheel, or with Plus and Minus, to zoom.

Members at a glance

PertChartCreates an empty PERT chart.
ColumnGapThe space between columns of boxes, in logical units, where the connectors turn. 64 by default, and never less than 24.
CriticalBrushThe outline of a critical box, the connectors along the critical path and a critical task's float. A red-orange by default.
HolidaysDates that are not worked, beside the days WorkingWeek leaves out. Never null; an observable collection is watched.
LinkBrushThe connectors that are not on the critical path. A grey by default.
LinksThe links between tasks. Never null; setting null gives the chart an empty list of its own.
NodeBackgroundBrushThe fill of a box. Null, the default, fills boxes with the chart's Background, so that they follow a light or a dark theme.
NodeBorderBrushThe outline of a box and the lines inside it. A mid grey by default, which reads on light and dark alike.
NodeHeightThe height of a box, in logical units. 92 by default; a box is never drawn shorter than 48, the least that holds its three rows of text.
NodeWidthThe width of a box, in logical units (1/96 inch). 188 by default; a box is never drawn narrower than 80, the least that holds three short dates side by side.
ProgressBrushThe progress bar along the bottom of a box. A calm blue by default.
ProjectStartThe first day work can happen. Null starts the plan at its earliest planned date, or today when no task has one.
RowGapThe space between rows of boxes, in logical units, where connectors that skip a column run. 28 by default, and never less than 8.
ScheduleThe plan as last scheduled: every task's early and late dates, its float, and the critical path. Scheduled again first when anything has changed.
SelectedTaskThe selected task, which is also the box the arrow keys move from; null when none is. A task that is not a box of this chart - a summary, or one not in Tasks - selects nothing.
SelectionBrushThe ring round the selected box and the connectors into and out of it. Null, the default, uses the system's highlight colour.
ShowCriticalPathDraws the critical tasks and the links between them in CriticalBrush. True by default.
TasksThe tasks: a flat list in outline order, each naming its parent. Never null; setting null gives the chart an empty list of its own.
TodayThe date the charts treat as today; null for the computer's own date. The Gantt chart draws its today line here. A PERT chart has no timeline and draws nothing for it; the property is here so that one set of settings can be given to all three charts alike.
VisualChildrenCountThe children are the two scroll bars; everything else is drawn.
WorkingWeekThe days of the week that are worked. Monday to Friday by default.
ZoomFactorHow large the network is drawn: 1 is its own size, 0.25 the smallest and 3 the largest. Ctrl and the mouse wheel change it about the pointer.
ArrangeOverridePlaces the scroll bars, which appear only when the network is larger than the chart.
ExportImageDraws the whole chart as a picture, at its own size and zoom 1, whatever part of it is in view and whatever is selected.
GetEnumeratorThe scroll bars, as logical children, so that they inherit the chart's resources and font.
GetVisualChildReturns a scroll bar.
MeasureOverrideAsks for the network's size at the current zoom, or the space available when that is less.
OnCreateAutomationPeerGives UI Automation the chart as a list of boxes.
OnDpiChangedThe scene and the text in it were drawn for a different screen density; draw them again.
OnGotKeyboardFocusShows the focus cue and tells a screen reader which box is current.
OnKeyDownThe arrows, Home and End move between boxes; Enter activates the selected one; the page keys scroll; Ctrl with Plus, Minus or 0 zooms.
OnLostKeyboardFocusTakes the focus cue away when the chart loses the keyboard.
OnLostMouseCaptureA pan ends if something else takes the mouse, such as a window coming to the front.
OnMouseLeaveHides the tooltip when the pointer leaves the chart.
OnMouseLeftButtonDownSelects the box under the pointer, or starts panning from the background.
OnMouseLeftButtonUpEnds a pan.
OnMouseMovePans while the background is dragged; otherwise follows the pointer for the tooltip and cursor.
OnMouseWheelScrolls down and up; with Shift, across; with Ctrl, zooms about the pointer.
OnPropertyChangedDrops what was drawn from the inherited text and colour settings - the font, the foreground, the background, the language, the reading direction and the text formatting mode - when one changes.
OnQueryCursorA hand over a box, which can be chosen; a four-way arrow while panning.
OnRenderDraws the chart: the scene under the view's transform, then the selection and focus over it.
RescheduleSchedules the plan again now and redraws. Needed only after changing a plain list that does not say when it changes, or a task in one.
ScrollToTaskScrolls the view, as little as it needs to, so that a task's box is in it. Nothing happens for a task that is not a box of this chart.
ZoomInDraws the network larger, keeping the middle of the view where it is.
ZoomOutDraws the network smaller, keeping the middle of the view where it is.
ZoomToFitChooses the zoom at which the whole network fits the chart, within the zoom's limits, and scrolls to its start. A chart not yet laid out does this as soon as it is.
ScheduleChangedRaised after the plan has been scheduled again because something changed: a task, a link, a collection, or one of the scheduling settings.
SelectedTaskChangedRaised when SelectedTask changes, by the reader or by the application.
TaskActivatedRaised when the reader double-clicks a box, or presses Enter on the selected one.
ZoomFactorChangedRaised when ZoomFactor changes, by the reader or by the application.
ColumnGapPropertyIdentifies the ColumnGap dependency property.
CriticalBrushPropertyIdentifies the CriticalBrush dependency property.
HolidaysPropertyIdentifies the Holidays dependency property.
LinkBrushPropertyIdentifies the LinkBrush dependency property.
LinksPropertyIdentifies the Links dependency property.
NodeBackgroundBrushPropertyIdentifies the NodeBackgroundBrush dependency property.
NodeBorderBrushPropertyIdentifies the NodeBorderBrush dependency property.
NodeHeightPropertyIdentifies the NodeHeight dependency property.
NodeWidthPropertyIdentifies the NodeWidth dependency property.
ProgressBrushPropertyIdentifies the ProgressBrush dependency property.
ProjectStartPropertyIdentifies the ProjectStart dependency property.
RowGapPropertyIdentifies the RowGap dependency property.
SelectedTaskPropertyIdentifies the SelectedTask dependency property.
SelectionBrushPropertyIdentifies the SelectionBrush dependency property.
ShowCriticalPathPropertyIdentifies the ShowCriticalPath dependency property.
TasksPropertyIdentifies the Tasks dependency property.
TodayPropertyIdentifies the Today dependency property.
WorkingWeekPropertyIdentifies the WorkingWeek dependency property.
ZoomFactorPropertyIdentifies the ZoomFactor dependency property.

Constructors

PertChart

public PertChart()

Creates an empty PERT chart.

Properties

ColumnGap

public double ColumnGap

The space between columns of boxes, in logical units, where the connectors turn. 64 by default, and never less than 24.

CriticalBrush

public Brush CriticalBrush

The outline of a critical box, the connectors along the critical path and a critical task's float. A red-orange by default.

Holidays

public IList<DateTime> Holidays

Dates that are not worked, beside the days WorkingWeek leaves out. Never null; an observable collection is watched.

LinkBrush

public Brush LinkBrush

The connectors that are not on the critical path. A grey by default.

NodeBackgroundBrush

public Brush NodeBackgroundBrush

The fill of a box. Null, the default, fills boxes with the chart's Background, so that they follow a light or a dark theme.

NodeBorderBrush

public Brush NodeBorderBrush

The outline of a box and the lines inside it. A mid grey by default, which reads on light and dark alike.

NodeHeight

public double NodeHeight

The height of a box, in logical units. 92 by default; a box is never drawn shorter than 48, the least that holds its three rows of text.

NodeWidth

public double NodeWidth

The width of a box, in logical units (1/96 inch). 188 by default; a box is never drawn narrower than 80, the least that holds three short dates side by side.

ProgressBrush

public Brush ProgressBrush

The progress bar along the bottom of a box. A calm blue by default.

ProjectStart

public DateTime? ProjectStart

The first day work can happen. Null starts the plan at its earliest planned date, or today when no task has one.

RowGap

public double RowGap

The space between rows of boxes, in logical units, where connectors that skip a column run. 28 by default, and never less than 8.

Schedule

public ProjectSchedule Schedule

The plan as last scheduled: every task's early and late dates, its float, and the critical path. Scheduled again first when anything has changed.

SelectedTask

public ProjectTask SelectedTask

The selected task, which is also the box the arrow keys move from; null when none is. A task that is not a box of this chart - a summary, or one not in Tasks - selects nothing.

SelectionBrush

public Brush SelectionBrush

The ring round the selected box and the connectors into and out of it. Null, the default, uses the system's highlight colour.

ShowCriticalPath

public bool ShowCriticalPath

Draws the critical tasks and the links between them in CriticalBrush. True by default.

Tasks

public IList<ProjectTask> Tasks

The tasks: a flat list in outline order, each naming its parent. Never null; setting null gives the chart an empty list of its own.

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

Today

public DateTime? Today

The date the charts treat as today; null for the computer's own date. The Gantt chart draws its today line here. A PERT chart has no timeline and draws nothing for it; the property is here so that one set of settings can be given to all three charts alike.

VisualChildrenCount

protected override int VisualChildrenCount

The children are the two scroll bars; everything else is drawn.

WorkingWeek

public WorkingWeek WorkingWeek

The days of the week that are worked. Monday to Friday by default.

ZoomFactor

public double ZoomFactor

How large the network is drawn: 1 is its own size, 0.25 the smallest and 3 the largest. Ctrl and the mouse wheel change it about the pointer.

Methods

ArrangeOverride

protected override Size ArrangeOverride(Size arrangeBounds)

Places the scroll bars, which appear only when the network is larger than the chart.

arrangeBounds
The size the chart has been given.

Returns. The size used: all of it.

ExportImage

public BitmapSource ExportImage(double dpi

Draws the whole chart as a picture, at its own size and zoom 1, whatever part of it is in view and whatever is selected.

dpi
Dots per inch of the image; 96 is one pixel per logical unit.

Returns. The image, frozen so that it can be used on any 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.

GetEnumerator

protected override IEnumerator LogicalChildren

The scroll bars, as logical children, so that they inherit the chart's resources and font.

GetVisualChild

protected override Visual GetVisualChild(int index)

Returns a scroll bar.

index
0 for the vertical bar, 1 for the horizontal.

Returns. The scroll bar.

MeasureOverride

protected override Size MeasureOverride(Size constraint)

Asks for the network's size at the current zoom, or the space available when that is less.

constraint
The space available.

Returns. The size wanted.

OnCreateAutomationPeer

protected override AutomationPeer OnCreateAutomationPeer()

Gives UI Automation the chart as a list of boxes.

Returns. The chart's automation peer.

OnDpiChanged

protected override void OnDpiChanged(DpiScale oldDpi, DpiScale newDpi)

The scene and the text in it were drawn for a different screen density; draw them again.

oldDpi
The density before.
newDpi
The density now.

OnGotKeyboardFocus

protected override void OnGotKeyboardFocus(KeyboardFocusChangedEventArgs e)

Shows the focus cue and tells a screen reader which box is current.

e
The event data.

OnKeyDown

protected override void OnKeyDown(KeyEventArgs e)

The arrows, Home and End move between boxes; Enter activates the selected one; the page keys scroll; Ctrl with Plus, Minus or 0 zooms.

e
The key.

OnLostKeyboardFocus

protected override void OnLostKeyboardFocus(KeyboardFocusChangedEventArgs e)

Takes the focus cue away when the chart loses the keyboard.

e
The event data.

OnLostMouseCapture

protected override void OnLostMouseCapture(MouseEventArgs e)

A pan ends if something else takes the mouse, such as a window coming to the front.

e
The event data.

OnMouseLeave

protected override void OnMouseLeave(MouseEventArgs e)

Hides the tooltip when the pointer leaves the chart.

e
The event data.

OnMouseLeftButtonDown

protected override void OnMouseLeftButtonDown(MouseButtonEventArgs e)

Selects the box under the pointer, or starts panning from the background.

e
The press.

OnMouseLeftButtonUp

protected override void OnMouseLeftButtonUp(MouseButtonEventArgs e)

Ends a pan.

e
The release.

OnMouseMove

protected override void OnMouseMove(MouseEventArgs e)

Pans while the background is dragged; otherwise follows the pointer for the tooltip and cursor.

e
The move.

OnMouseWheel

protected override void OnMouseWheel(MouseWheelEventArgs e)

Scrolls down and up; with Shift, across; with Ctrl, zooms about the pointer.

e
The wheel turn.

OnPropertyChanged

protected override void OnPropertyChanged(DependencyPropertyChangedEventArgs e)

Drops what was drawn from the inherited text and colour settings - the font, the foreground, the background, the language, the reading direction and the text formatting mode - when one changes.

e
The property that changed.

OnQueryCursor

protected override void OnQueryCursor(QueryCursorEventArgs e)

A hand over a box, which can be chosen; a four-way arrow while panning.

e
The event data.

OnRender

protected override void OnRender(DrawingContext drawingContext)

Draws the chart: the scene under the view's transform, then the selection and focus over it.

drawingContext
Where to draw.

Reschedule

public void Reschedule()

Schedules the plan again now and redraws. Needed only after changing a plain list that does not say when it changes, or a task in one.

ScrollToTask

public void ScrollToTask(ProjectTask task)

Scrolls the view, as little as it needs to, so that a task's box is in it. Nothing happens for a task that is not a box of this chart.

task
The task to show.

ZoomIn

public void ZoomIn()

Draws the network larger, keeping the middle of the view where it is.

ZoomOut

public void ZoomOut()

Draws the network smaller, keeping the middle of the view where it is.

ZoomToFit

public void ZoomToFit()

Chooses the zoom at which the whole network fits the chart, within the zoom's limits, and scrolls to its start. A chart not yet laid out does this as soon as it is.

Events

ScheduleChanged

public event EventHandler ScheduleChanged

Raised after the plan has been scheduled again because something changed: a task, a link, a collection, or one of the scheduling settings.

SelectedTaskChanged

public event EventHandler SelectedTaskChanged

Raised when SelectedTask changes, by the reader or by the application.

TaskActivated

public event EventHandler<TaskEventArgs> TaskActivated

Raised when the reader double-clicks a box, or presses Enter on the selected one.

ZoomFactorChanged

public event EventHandler ZoomFactorChanged

Raised when ZoomFactor changes, by the reader or by the application.

Fields

ColumnGapProperty

public static readonly DependencyProperty ColumnGapProperty

Identifies the ColumnGap dependency property.

CriticalBrushProperty

public static readonly DependencyProperty CriticalBrushProperty

Identifies the CriticalBrush dependency property.

HolidaysProperty

public static readonly DependencyProperty HolidaysProperty

Identifies the Holidays dependency property.

LinkBrushProperty

public static readonly DependencyProperty LinkBrushProperty

Identifies the LinkBrush dependency property.

LinksProperty

public static readonly DependencyProperty LinksProperty

Identifies the Links dependency property.

NodeBackgroundBrushProperty

public static readonly DependencyProperty NodeBackgroundBrushProperty

Identifies the NodeBackgroundBrush dependency property.

NodeBorderBrushProperty

public static readonly DependencyProperty NodeBorderBrushProperty

Identifies the NodeBorderBrush dependency property.

NodeHeightProperty

public static readonly DependencyProperty NodeHeightProperty

Identifies the NodeHeight dependency property.

NodeWidthProperty

public static readonly DependencyProperty NodeWidthProperty

Identifies the NodeWidth dependency property.

ProgressBrushProperty

public static readonly DependencyProperty ProgressBrushProperty

Identifies the ProgressBrush dependency property.

ProjectStartProperty

public static readonly DependencyProperty ProjectStartProperty

Identifies the ProjectStart dependency property.

RowGapProperty

public static readonly DependencyProperty RowGapProperty

Identifies the RowGap dependency property.

SelectedTaskProperty

public static readonly DependencyProperty SelectedTaskProperty

Identifies the SelectedTask dependency property.

SelectionBrushProperty

public static readonly DependencyProperty SelectionBrushProperty

Identifies the SelectionBrush dependency property.

ShowCriticalPathProperty

public static readonly DependencyProperty ShowCriticalPathProperty

Identifies the ShowCriticalPath dependency property.

TasksProperty

public static readonly DependencyProperty TasksProperty

Identifies the Tasks dependency property.

TodayProperty

public static readonly DependencyProperty TodayProperty

Identifies the Today dependency property.

WorkingWeekProperty

public static readonly DependencyProperty WorkingWeekProperty

Identifies the WorkingWeek dependency property.

ZoomFactorProperty

public static readonly DependencyProperty ZoomFactorProperty

Identifies the ZoomFactor dependency property.