Class MagnetElementBase<TConstraintType>
- Namespace
- Nalu.MagnetLayout
- Assembly
- Nalu.Maui.Layouts.dll
Base class for elements that can be part of a magnet layout stage.
public abstract class MagnetElementBase<TConstraintType> : BindableObject, INotifyPropertyChanged, IMagnetElement, IMagnetElementBase where TConstraintType : struct, Enum
Type Parameters
TConstraintTypeEnum type defining all the possible constraints applied by the element.
- Inheritance
-
MagnetElementBase<TConstraintType>
- Implements
- Derived
- Inherited Members
- Extension Methods
Fields
IdProperty
Bindable property for Id.
public static readonly BindableProperty IdProperty
Field Value
Properties
Id
Gets or sets the unique identifier for this element.
public string Id { get; set; }
Property Value
Methods
ApplyConstraints()
Applies all the constraints to the solver.
public void ApplyConstraints()
ApplyConstraints(IMagnetStage)
Applies the constraints for the element.
protected virtual void ApplyConstraints(IMagnetStage stage)
Parameters
stageIMagnetStage
DetectChanges()
Detects eventual changes and notifies dependent elements.
public void DetectChanges()
DetectChanges(IMagnetStage)
Detects eventual changes and notifies dependent elements.
protected virtual void DetectChanges(IMagnetStage stage)
Parameters
stageIMagnetStage
EnsureConstraintsFactory(TConstraintType, ConstraintsFactory)
Sets the constraintsFactory for the specified constraintType and invalidates the stage
only if the ConstraintsFactory on the constraintType is not already set to the same value.
protected void EnsureConstraintsFactory(TConstraintType constraintType, ConstraintsFactory constraintsFactory)
Parameters
constraintTypeTConstraintTypeconstraintsFactoryConstraintsFactory
FinalizeConstraints()
Eventually adds more constraints, or changes editable variables to complete the layout process.
public void FinalizeConstraints()
FinalizeConstraints(IMagnetStage)
Eventually adds more constraints, or changes editable variables to complete the layout process.
protected virtual void FinalizeConstraints(IMagnetStage stage)
Parameters
stageIMagnetStage
GetEditableVariables()
Gets the editable variables for the element.
protected virtual (Variable Variable, double Strength)[] GetEditableVariables()
Returns
InvalidateStage()
Invalidates the stage (if any).
protected void InvalidateStage()
RemoveConstraints(TConstraintType)
Removes all constraints of the specified type.
protected void RemoveConstraints(TConstraintType constraintType)
Parameters
constraintTypeTConstraintType
SetStage(IMagnetStage?)
Sets or unsets the magnet layout context for this element.
public void SetStage(IMagnetStage? stage)
Parameters
stageIMagnetStage
Remarks
This method is called when the element is added or removed from the magnet layout. Constraints should be added or removed in this method. It's not necessary to invoke Invalidate() here, as it is implicit.
SetVariableNames(string)
Initializes the variables for the element given the chosen element identifier.
protected abstract void SetVariableNames(string id)
Parameters
idstring
UpdateConstraints(TConstraintType, ConstraintsFactory?)
Sets the constraintsFactory for the specified constraintType and invalidates the stage.
protected void UpdateConstraints(TConstraintType constraintType, ConstraintsFactory? constraintsFactory)
Parameters
constraintTypeTConstraintTypeconstraintsFactoryConstraintsFactory