FunctionEditorBase

References
public sealed class FunctionEditorBase : IResponsive
Base control for editing functions.

Constructors

FunctionEditorBase

#
Create a new editor.
public FunctionEditorBase()

FunctionEditorBase

#
Create a new editor.
public FunctionEditorBase(
frame
)

Fields

AxisLabelFillColour

#
Default fill colour used by DrawAxisLabels(Context, Color, Color) callers that don't specify one (e.g. the pop-out editor). The mapper's attributes override this by calling the method with skin-derived shade colours.
public Color AxisLabelFillColour

AxisLabelSize

#
Pixel size of the square X / Y axis label boxes.
public const float AxisLabelSize = 14

AxisLabelTextColour

#
Default text colour used by DrawAxisLabels(Context, Color, Color) callers that don't specify one.
public Color AxisLabelTextColour

Properties

All

#
Get all functions.
public FunctionUi[] All { get; }

AllowCreate

#
Gets or sets whether the user can add new functions or replace the ones already hosted. If this property is false, existing functions can be edited or deleted.
public bool AllowCreate { get; set; }

AllowDelete

#
Gets or sets whether the user can delete functions.
public bool AllowDelete { get; set; }

Constraints

#
Gets or sets the axis-lock and ratio constraints for this editor. Changes take effect on the next SetFrameBoundary(RectangleF) call and also fire ConstraintsChanged so external observers can react.
public GraphConstraints Constraints { get; set; }

Count

#
Gets the number of functions in this editor.
public int Count { get; }

Frame

#
Gets or sets the frame projection for this editor.
public FrameF Frame { get; set; }

Responder

#
public Responses Responder { get; }
Responder

ShowGrips

#
Gets or sets whether functions with grips on actually show and respond to their grips. Hiding keeps the per-function grip state intact for a view which cannot display it.
public bool ShowGrips { get; set; }

SnapToGrid

#
Gets whether grip dragging is snapped to the visible grid.
public bool SnapToGrid { get; set; }

SnapToGrips

#
Gets whether grip dragging is snapped to the unselected grips.
public bool SnapToGrips { get; set; }

UnitsPerPixel

#
Gets the units in graph space per units in frame space. Since the horizontal and vertical scaling should always be equal, this value is the average of the units in both x and y directions.
public double UnitsPerPixel { get; }

XLabelBox

#
Rectangle for the X axis label, centred on the bottom edge of the current frame boundary and sitting just inside it.
public RectangleF XLabelBox { get; }

YLabelBox

#
Rectangle for the Y axis label, centred on the left edge of the current frame boundary and sitting just inside it.
public RectangleF YLabelBox { get; }

Indexers

this[]

#
Gets the UI with the given identifier.
public FunctionUi this[
id
] { get; }

this[]

#
Gets the UI at the given index.
public FunctionUi this[
index
] { get; }

Methods

Add

#
Add multiple functions to this editor.
public void Add(
params FunctionUi[]
functions
)

AdoptProjection

#
Adopt another view's projection. Two views of the same functions rarely have the same pixel bounds, so copying the limits across verbatim leaves them showing different X:Y ratios - the same numbers stretched over a different aspect. The visible ratio and the X range are copied instead and the Y range is derived from this view's own boundary, so both views draw the same grid squares even though they show different amounts of graph vertically.
public void AdoptProjection(
other
Frame to adopt, boundary included.
)

ApplyConstraints

#
Assign new constraints as a single user gesture. Unlike the Constraints setter this brackets the change so an owner can record a coalescing undo checkpoint via AxisChanged. Use this for user-initiated constraint edits (input panel, menu); use the plain setter for programmatic / internal changes that shouldn't be undoable in their own right.
public void ApplyConstraints(
constraints
)

CancelRatioSnap

#
Advance the ratio-snap animation (if one is running) and adjust the frame so the visible ratio matches the interpolated value. Called at the start of drawing from both the on-canvas mapper and the pop-out editor.
Cancel any in-flight ratio-snap animation. Called when the frame is restored from undo so a lingering animation can't overwrite it.
public void CancelRatioSnap()

Clear

#
Remove all functions from this editor.
public void Clear()

CreateSnapSpace

#
Create the combined snapping space for grips and the grid, based on snapping properties.
public SnapSpace CreateSnapSpace()

CursorAt

#
Cursor appropriate for a given content-space point when interacting with axis labels, scalar link grips and referent fields. Returns null (default cursor) when the point is over none of those. Shared between the on-canvas mapper's ICursorAwareAttributes implementation and the pop-out editor's mouse-move handler so both give the same hover feedback.
public Cursor CursorAt(
PointF
contentLocation
)

DeleteSelection

#
public void DeleteSelection()

Draw

#
public void Draw(
context,
WindowSelectionFill,
WindowSelectionEdge
)

Draw

#
public void Draw(
context
)

DrawAxisLabels

#
Draw the two axis-label pills. Shared between the pop-out editor (via Draw(Context, Action, Action)) and the on-canvas mapper (which calls this method directly with its own skin-derived colours). The X pill is centred on the bottom edge of the frame boundary with a rounded top; the Y pill mirrors that on the left edge with a rounded right.
public void DrawAxisLabels(
context,
Color
fillColour,
Color
textColour
)

InsertNewFunction

#
Insert a new function based on the [IoId] of a function type.
public bool InsertNewFunction(
id
IoId of a Function type.
)

InsertNewFunction

#
Insert a new function based on type.
public bool InsertNewFunction(
type
Type of a Function.
)

PopulateAxisMenu

#
Populate the axis-options context menu with the standard items: Set domain / codomain (as dialogs), Lock domain / codomain toggles, Set X:Y ratio and Reset ratio. Called by the on-canvas mapper when the user right- clicks an axis label, and by PopulateMenu(PointF, ContextMenu) when the pop-out editor's context-menu machinery lands on a label.
public void PopulateAxisMenu(
ContextMenu
menu
)

PopulateMenu

#
public void PopulateMenu(
PointF
location,
ContextMenu
menu
)

ProjectLimits

#
The single function that maps GraphConstraints onto a set of frame limits. Callers supply their preferred midpoint and range on each axis; this function overrides both when constraints demand it. Rules, in order:
  • A locked axis uses its locked interval; the caller's midpoint and range for that axis are ignored.
  • When enforceRatio is true and both axes aren't locked, the visible ratio is forced to equal GraphConstraints.Ratio by rescaling one axis's range around its midpoint. The chosen axis is Y unless Y is locked (in which case X is chosen instead).
  • When both axes are locked, both intervals are used verbatim and the visible ratio drifts with the boundary.
Ratio enforcement is on by default because boundary changes (resize) and explicit ratio changes want it. Pan/zoom gestures pass false so the user can actively rescale one axis while the other stays locked.
public static (double xMin, double xMax, double yMin, double yMax) ProjectLimits(
RectangleF
boundary,
c,
xMid,
xRange,
yMid,
yRange,
enforceRatio = true
)

Remove

#
Remove a ui from this editor.
public void Remove(
function
)

ReplaceAll

#
Replace the entire function collection in a single operation, raising just one FunctionsChanged. Restores a snapshot (e.g. a pop-out undo) without the transient-empty flicker of Clear() followed by Add(FunctionUi[]).
public void ReplaceAll(
params FunctionUi[]
functions
)

Reproject

#
Reproject the current frame through ProjectLimits(RectangleF, GraphConstraints, double, double, double, double, bool). Used after pan/zoom/gesture to enforce locks; ratio is deliberately not enforced so nav gestures can rescale the unlocked axis freely. Public so external nav callers (e.g. INestedNavigation on the on-canvas attributes) can invoke it after directly assigning Frame.
public void Reproject()

SetFrameBoundary

#
Change the boundary of the frame. On a resize (that is, when the previous boundary was non-empty and the caller isn't setting fresh limits) the domain is rescaled to preserve units-per-pixel on both axes independently, so a user-established X:Y ratio survives the resize. Whatever ratio is in place only changes via SetFrameLimits(double, double, double, double).
public void SetFrameBoundary(
RectangleF
boundary
)

SetFrameLimits

#
Same as SetFrameLimits(double, double, double, double) but with explicit control over the "fresh" flag. Pass markFresh=false when the new limits already reflect the current boundary (e.g. after adopting a computed aspect ratio) - the next boundary change will then rescale the limits normally instead of adopting the new boundary verbatim.
public void SetFrameLimits(
x0,
x1,
y0,
y1,
markFresh
)

SetFrameLimits

#
Assign new limits to this frame. The limits are used verbatim; the next SetFrameBoundary(RectangleF) call will adopt the new boundary without rescaling these limits.
public void SetFrameLimits()

ShowAxisTooltipAt

#
If the given content-space point is over an X or Y axis label, pop a tooltip describing the label and return true. Callers use this to give both the on-canvas mapper and the pop-out editor identical hover tooltips over the label pills.
public bool ShowAxisTooltipAt(
PointF
contentLocation
)

TickRatioSnap

#
public void TickRatioSnap(
context
)

WindowSelectionHandler

#
public void WindowSelectionHandler()

Events

AxisChanged

#
Raised once per user-driven axis gesture, after the gesture completes, carrying the pre-gesture frame and constraints. Owners subscribe to record a single undo step; successive gestures are meant to coalesce.

BeginEdit

#
Raised at the start of a user interaction that edits the function collection, before the first mutation. This includes grip-drags, but also addition of new functions or removal of existing functions.
public event EventHandler BeginEdit

CompleteEdit

#
Raised at the end of a function interaction.
public event EventHandler CompleteEdit

ConstraintsChanged

#
Raised whenever Constraints is changed.
public event EventHandler ConstraintsChanged

DisplayChanged

#
public event EventHandler<EventArgs> DisplayChanged

FunctionsChanged

#
public event EventHandler<FunctionsChangedEventArgs> FunctionsChanged

SnappingContextChanged

#
Raised whenever the SnapToGrid or SnapToGrips properties are changed.
public event EventHandler<EventArgs> SnappingContextChanged