Controls
The Matrix Framework provides a set of controls that serve both as visual components and middleware prototypes.
Custom Controls
TaskComponent Example
<UserControl x:Class="Matrix.Controls.TaskComponent"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<!-- Control implementation -->
</UserControl>Usage:
<TaskComponent Name="Task1" Priority="High" />When to Use Custom Controls
-
Complex Elements
- Rich templates
- Custom input fields
- Complex visualizations
-
Reusable Components
- MQTTConnector
- JWTAuthorizationComponent
- Terminal components
Component Distribution
NuGet Package
Our controls are distributed via NuGet for several reasons:
-
Reusable Component Library
- Immediate access to controls
- TreePanel, HeapPanel, TaskComponent
- Ready-to-use middleware components
-
Complete Encapsulation
- Controls and panels
- Attached properties
- Routing strategies
- XAML parsers
-
Professional Distribution
- Version management
- Dependency handling
- Documentation integration
Implementation Features
| Feature | Implementation | Middleware Runtime |
|---|---|---|
| Geometries | TreePanel, HeapPanel as custom panels | TreeGeometry, HeapPriorityGeometry |
| Routing Strategies | Attached properties (RoutingProperties) | Dynamic strategies (Bubble, Tunnel) |
| Node Metadata | Attached properties (Priority, Path) | Reactive properties in CoreElement |
| Event Handling | Declarative (onEventName=“Handler”) | EventRouter routes dynamically |
| Prototyping | Visual debugging via controls | Translates to runtime logic |
| Remote Monitoring | Live visualization (bindings) | Runtime state changes |
Implementation Steps
1. Custom Controls
public class TreePanel : Panel
{
// Dependency Properties
public static readonly DependencyProperty RoutingStrategyProperty =
DependencyProperty.Register(
"RoutingStrategy",
typeof(string),
typeof(TreePanel));
// Implementation
protected override Size MeasureOverride(Size availableSize)
{
// Tree layout measurement logic
}
protected override Size ArrangeOverride(Size finalSize)
{
// Tree layout arrangement logic
}
}2. XAML Parsing
public class XamlParser
{
public static RuntimeGeometry ParseGeometry(FrameworkElement element)
{
var geometry = new RuntimeGeometry();
// Extract routing strategies
var strategy = TreePanel.GetRoutingStrategy(element);
geometry.SetRoutingStrategy(strategy);
// Parse child nodes
foreach (var child in LogicalTreeHelper.GetChildren(element))
{
geometry.AddNode(ParseNode(child));
}
return geometry;
}
}3. Reactive Properties
public class ReactiveProperty<T> : INotifyPropertyChanged
{
private T _value;
public T Value
{
get => _value;
set
{
_value = value;
PropertyChanged?.Invoke(this,
new PropertyChangedEventArgs(nameof(Value)));
}
}
public event PropertyChangedEventHandler PropertyChanged;
}