HypernovaDesktop Components · docs
Binarymission
WinForms › Project Management › PertChart

PertChart

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

A PERT chart: a plan's tasks as a network of boxes joined in the order the work has to happen, each box carrying its earliest and latest dates and its float, with the critical path emphasised.

public partial class PertChart : Control

Inherits from / implements: Control

Remarks

Give it the same Tasks and Links as a GanttChart or a TaskBoard and the three show one plan: a change made in either of the others is drawn here at once. Summary tasks are structure, not work, so they are not boxes; a link to or from a summary is drawn to the subtasks at its edges. The chart is for reading. Click or use the arrow keys to select a box, press Enter or double-click to raise TaskActivated, drag the background to pan, use the wheel to scroll (with Shift, sideways) and Ctrl with the wheel, or Ctrl with Plus, Minus and 0, to zoom.

Members at a glance

PertChartCreates an empty PERT chart. Give it Tasks and Links.
BoxBackColorThe fill of a box. Empty follows BackColor.
BoxBorderColorThe border and grid of a box that is not critical. Empty is a shade between BackColor and ForeColor.
ColumnGapThe space between columns of boxes, in logical units. At least 24.
ConnectorColorThe arrows between boxes that are not critical. Empty is a shade between BackColor and ForeColor.
CriticalColorThe border of a critical box and the colour of a critical arrow.
HolidaysDates that are not worked. Never null: setting null gives an empty collection. An observable collection is watched.
LinksThe links between tasks. Never null: setting null gives an empty collection. Watched as Tasks is.
NodeHeightThe height of a box, in logical units. At least 48.
NodeWidthThe width of a box, in logical units (1/96 inch). At least 80.
ProgressColorThe bar along the bottom of a box that shows how far the task has got.
ProjectStartThe first day work can happen. Null uses the earliest planned start in the plan.
RowGapThe space between rows of boxes, in logical units. At least 8.
SelectedTaskThe task whose box is selected, or null when none is. Setting a task that has no box - a summary, or a task not in the plan - clears the selection.
ShowCriticalPathWhether the critical path is drawn in CriticalColor with heavier lines.
TasksThe tasks to chart, as a flat list with parent references. Never null: setting null gives an empty collection.
TodayThe date the charts treat as today; null for the computer's date.
WorkingWeekThe days of the week that are worked.
ZoomFactorHow large the network is drawn: 1 is its natural size, 0.25 the smallest and 3 the largest. Values outside that range are clamped.
CreateAccessibilityInstanceCreates the accessible object that presents the boxes to assistive technology.
DisposeStops watching the plan and releases the fonts and the tooltip.
EnsureScheduleThe plan as last scheduled: every task's dates and float, the critical path, and anything in the input that could not be used. Scheduled again first when something has changed.
ExportImageDraws the whole network, at 96 DPI and a zoom of one, into a new image. The selection is not drawn: the image is a record of the plan, not of the screen.
IsInputKeyMakes the arrows, Home, End and the page keys the chart's own, and Enter while a box is selected, so a dialog's default button keeps Enter otherwise.
OnDpiChangedAfterParentRebuilds everything measured in device pixels when the control moves to a display with a different scale: the fonts, the scroll bars and the scroll range.
OnFontChangedRebuilds the fonts the boxes are written in.
OnGotFocusRedraws the focus cue and says which box has the focus.
OnHandleCreatedFits the scroll bars once the window exists, when the display's scale is first known for certain.
OnHandleDestroyedForgets a refresh posted to a window that is going away; the next window posts again.
OnKeyDownThe keys: arrows follow the work (PertLayout), Home and End go to the first and last box, Enter activates, the page keys scroll, and Ctrl with Plus, Minus or 0 zooms.
OnLostFocusRemoves the focus cue.
OnMouseCaptureChangedEnds a pan if the mouse is taken away mid-drag, by a message box or a switch of window.
OnMouseDoubleClickA double-click on a box raises TaskActivated.
OnMouseDownA press on a box selects it; a press on the background starts a pan.
OnMouseLeaveHides the tooltip when the pointer leaves.
OnMouseMovePans while the background is dragged; otherwise keeps the tooltip and cursor on the box under the pointer.
OnMouseUpEnds a pan.
OnMouseWheelThe wheel scrolls, sideways with Shift, and zooms about the pointer with Ctrl.
OnPaintPaints the chart. Never throws: a fault is reported and the paint abandoned.
OnResizeFits the scroll bars and the view to the new size.
OnRightToLeftChangedLays the network out again, mirrored, when the reading direction changes.
OnScheduleChangedRaises ScheduleChanged.
OnSelectedTaskChangedRaises SelectedTaskChanged.
OnTaskActivatedRaises TaskActivated.
OnZoomFactorChangedRaises ZoomFactorChanged.
RescheduleSchedules the plan again now and raises ScheduleChanged. Needed only after changing a plain list, which cannot be watched.
ScrollToTaskScrolls the chart until a task's box is in view. Does nothing for a task that has no box.
ZoomToFitSets ZoomFactor so the whole network fits the control, and scrolls to its start.
ScheduleChangedRaised after the plan has been scheduled again because something changed: a task, a link, a collection, a calendar setting, or a call to Reschedule.
SelectedTaskChangedRaised when the selected box changes, by the reader or by SelectedTask.
TaskActivatedRaised when the reader double-clicks a box or presses Enter on the selected one.
ZoomFactorChangedRaised when ZoomFactor changes.

Constructors

PertChart

public PertChart()

Creates an empty PERT chart. Give it Tasks and Links.

Properties

BoxBackColor

public Color BoxBackColor

The fill of a box. Empty follows BackColor.

BoxBorderColor

public Color BoxBorderColor

The border and grid of a box that is not critical. Empty is a shade between BackColor and ForeColor.

ColumnGap

public int ColumnGap

The space between columns of boxes, in logical units. At least 24.

ConnectorColor

public Color ConnectorColor

The arrows between boxes that are not critical. Empty is a shade between BackColor and ForeColor.

CriticalColor

public Color CriticalColor

The border of a critical box and the colour of a critical arrow.

Holidays

public IList<DateTime> Holidays

Dates that are not worked. Never null: setting null gives an empty collection. An observable collection is watched.

NodeHeight

public int NodeHeight

The height of a box, in logical units. At least 48.

NodeWidth

public int NodeWidth

The width of a box, in logical units (1/96 inch). At least 80.

ProgressColor

public Color ProgressColor

The bar along the bottom of a box that shows how far the task has got.

ProjectStart

public DateTime? ProjectStart

The first day work can happen. Null uses the earliest planned start in the plan.

RowGap

public int RowGap

The space between rows of boxes, in logical units. At least 8.

SelectedTask

public ProjectTask SelectedTask

The task whose box is selected, or null when none is. Setting a task that has no box - a summary, or a task not in the plan - clears the selection.

ShowCriticalPath

public bool ShowCriticalPath

Whether the critical path is drawn in CriticalColor with heavier lines.

Tasks

public IList<ProjectTask> Tasks

The tasks to chart, as a flat list with parent references. Never null: setting null gives an empty collection.

An ObservableCollection{T} or a BindingList{T} is watched, and so is every task in it, so changes are drawn as they happen. 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 date.

The Gantt chart draws its today line from this. A network has no time axis to draw a line on, so the PERT chart draws nothing from it; it is here so that one set of plan settings can be given to all three charts alike.

WorkingWeek

public WorkingWeek WorkingWeek

The days of the week that are worked.

ZoomFactor

public double ZoomFactor

How large the network is drawn: 1 is its natural size, 0.25 the smallest and 3 the largest. Values outside that range are clamped.

Methods

CreateAccessibilityInstance

protected override AccessibleObject CreateAccessibilityInstance()

Creates the accessible object that presents the boxes to assistive technology.

Returns. The chart's accessible object.

Dispose

protected override void Dispose(bool disposing)

Stops watching the plan and releases the fonts and the tooltip.

disposing
True when called from Dispose.

EnsureSchedule

public ProjectSchedule Schedule

The plan as last scheduled: every task's dates and float, the critical path, and anything in the input that could not be used. Scheduled again first when something has changed.

ExportImage

public Bitmap ExportImage()

Draws the whole network, at 96 DPI and a zoom of one, into a new image. The selection is not drawn: the image is a record of the plan, not of the screen.

Returns. The image. The caller disposes it.

A very large network makes a very large image, and GDI+ refuses a bitmap much beyond a few hundred million pixels; an image of such a network is better taken in parts by the application, from Schedule.

IsInputKey

protected override bool IsInputKey(Keys keyData)

Makes the arrows, Home, End and the page keys the chart's own, and Enter while a box is selected, so a dialog's default button keeps Enter otherwise.

keyData
The key, with its modifiers.

Returns. True for a key the chart handles.

OnDpiChangedAfterParent

protected override void OnDpiChangedAfterParent(EventArgs e)

Rebuilds everything measured in device pixels when the control moves to a display with a different scale: the fonts, the scroll bars and the scroll range.

e
The event data.

OnFontChanged

protected override void OnFontChanged(EventArgs e)

Rebuilds the fonts the boxes are written in.

e
The event data.

OnGotFocus

protected override void OnGotFocus(EventArgs e)

Redraws the focus cue and says which box has the focus.

e
The event data.

OnHandleCreated

protected override void OnHandleCreated(EventArgs e)

Fits the scroll bars once the window exists, when the display's scale is first known for certain.

e
The event data.

OnHandleDestroyed

protected override void OnHandleDestroyed(EventArgs e)

Forgets a refresh posted to a window that is going away; the next window posts again.

e
The event data.

OnKeyDown

protected override void OnKeyDown(KeyEventArgs e)

The keys: arrows follow the work (PertLayout), Home and End go to the first and last box, Enter activates, the page keys scroll, and Ctrl with Plus, Minus or 0 zooms.

e
The key data.

OnLostFocus

protected override void OnLostFocus(EventArgs e)

Removes the focus cue.

e
The event data.

OnMouseCaptureChanged

protected override void OnMouseCaptureChanged(EventArgs e)

Ends a pan if the mouse is taken away mid-drag, by a message box or a switch of window.

e
The event data.

OnMouseDoubleClick

protected override void OnMouseDoubleClick(MouseEventArgs e)

A double-click on a box raises TaskActivated.

e
The mouse data.

OnMouseDown

protected override void OnMouseDown(MouseEventArgs e)

A press on a box selects it; a press on the background starts a pan.

e
The mouse data.

OnMouseLeave

protected override void OnMouseLeave(EventArgs e)

Hides the tooltip when the pointer leaves.

e
The event data.

OnMouseMove

protected override void OnMouseMove(MouseEventArgs e)

Pans while the background is dragged; otherwise keeps the tooltip and cursor on the box under the pointer.

e
The mouse data.

OnMouseUp

protected override void OnMouseUp(MouseEventArgs e)

Ends a pan.

e
The mouse data.

OnMouseWheel

protected override void OnMouseWheel(MouseEventArgs e)

The wheel scrolls, sideways with Shift, and zooms about the pointer with Ctrl.

e
The mouse data.

OnPaint

protected override void OnPaint(PaintEventArgs e)

Paints the chart. Never throws: a fault is reported and the paint abandoned.

e
The paint data.

OnResize

protected override void OnResize(EventArgs e)

Fits the scroll bars and the view to the new size.

e
The event data.

OnRightToLeftChanged

protected override void OnRightToLeftChanged(EventArgs e)

Lays the network out again, mirrored, when the reading direction changes.

e
The event data.

OnScheduleChanged

protected virtual void OnScheduleChanged(EventArgs e)

Raises ScheduleChanged.

e
The event data.

OnSelectedTaskChanged

protected virtual void OnSelectedTaskChanged(EventArgs e)

Raises SelectedTaskChanged.

e
The event data.

OnTaskActivated

protected virtual void OnTaskActivated(TaskEventArgs e)

Raises TaskActivated.

e
The task that was activated.

OnZoomFactorChanged

protected virtual void OnZoomFactorChanged(EventArgs e)

Raises ZoomFactorChanged.

e
The event data.

Reschedule

public void Reschedule()

Schedules the plan again now and raises ScheduleChanged. Needed only after changing a plain list, which cannot be watched.

ScrollToTask

public void ScrollToTask(ProjectTask task)

Scrolls the chart until a task's box is in view. Does nothing for a task that has no box.

task
The task to show.

ZoomToFit

public void ZoomToFit()

Sets ZoomFactor so the whole network fits the control, and scrolls to its start.

Events

ScheduleChanged

public event EventHandler ScheduleChanged

Raised after the plan has been scheduled again because something changed: a task, a link, a collection, a calendar setting, or a call to Reschedule.

SelectedTaskChanged

public event EventHandler SelectedTaskChanged

Raised when the selected box changes, by the reader or by SelectedTask.

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.