FunctionEditorBase

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

Constructors

FunctionEditorBase

#
public FunctionEditorBase()
Create a new editor.

FunctionEditorBase

#
public FunctionEditorBase(FrameF frame)
Create a new editor.
frame (FrameF)

Fields

AxisLabelFillColour

#
public Color 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.

AxisLabelSize

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

AxisLabelTextColour

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

Properties

All

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

AllowCreate

#
public bool AllowCreate { get; set; }
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.

AllowDelete

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

Constraints

#
public GraphConstraints Constraints { get; set; }
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.

Count

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

Frame

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

Responder

#
public Responses Responder { get; }
Responder

ShowGrips

#
public bool ShowGrips { get; set; }
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.

SnapToGrid

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

SnapToGrips

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

UnitsPerPixel

#
public double UnitsPerPixel { get; }
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.

XLabelBox

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

YLabelBox

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

Indexers

this[]

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

this[]

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

Methods

Add

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

AdoptProjection

#
public void AdoptProjection(FrameF other)
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.
other (FrameF)Frame to adopt, boundary included.

ApplyConstraints

#
public void ApplyConstraints(GraphConstraints constraints)
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.
constraints (GraphConstraints)

CancelRatioSnap

#
public void 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.

Clear

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

CreateSnapSpace

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

CursorAt

#
public Cursor CursorAt(PointF contentLocation)
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.
contentLocation (PointF)

DeleteSelection

#
public void DeleteSelection()

Draw

#
public void Draw(Context context, Action WindowSelectionFill, Action WindowSelectionEdge)
context (Context)
WindowSelectionFill (Action)
WindowSelectionEdge (Action)

Draw

#
public void Draw(Context context)
context (Context)

DrawAxisLabels

#
public void DrawAxisLabels(Context context, Color fillColour, Color textColour)
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.
context (Context)
fillColour (Color)
textColour (Color)

InsertNewFunction

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

InsertNewFunction

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

PopulateAxisMenu

#
public void PopulateAxisMenu(ContextMenu menu)
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.
menu (ContextMenu)

PopulateMenu

#
public void PopulateMenu(PointF location, ContextMenu menu)
location (PointF)
menu (ContextMenu)

ProjectLimits

#
public static (double xMin, double xMax, double yMin, double yMax) ProjectLimits(RectangleF boundary, GraphConstraints c, double xMid, double xRange, double yMid, double yRange, bool enforceRatio = true)
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.
boundary (RectangleF)
c (GraphConstraints)
xMid (double)
xRange (double)
yMid (double)
yRange (double)
enforceRatio (bool = true)

Remove

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

ReplaceAll

#
public void ReplaceAll(params FunctionUi[] functions)
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[]).
functions (params FunctionUi[])

Reproject

#
public void 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.

SetFrameBoundary

#
public void SetFrameBoundary(RectangleF boundary)
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).
boundary (RectangleF)

SetFrameLimits

#
public void SetFrameLimits(double x0, double x1, double y0, double y1, bool markFresh)
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.
x0 (double)
x1 (double)
y0 (double)
y1 (double)
markFresh (bool)

SetFrameLimits

#
public void SetFrameLimits(double x0, double x1, double y0, double y1)
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.
x0 (double)
x1 (double)
y0 (double)
y1 (double)

ShowAxisTooltipAt

#
public bool ShowAxisTooltipAt(PointF contentLocation)
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.
contentLocation (PointF)

TickRatioSnap

#
public void TickRatioSnap(Context context)
context (Context)

WindowSelectionHandler

#
public void WindowSelectionHandler(WindowSelectionEventArgs e)

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

#
public event EventHandler 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.

CompleteEdit

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

ConstraintsChanged

#
public event EventHandler ConstraintsChanged
Raised whenever Constraints is changed.

DisplayChanged

#
public event EventHandler<EventArgs> DisplayChanged

FunctionsChanged

#
public event EventHandler<FunctionsChangedEventArgs> FunctionsChanged

SnappingContextChanged

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