Table of Contents

Class CommentElement

Namespace
FlowGraph.Core.Elements.Shapes
Assembly
FlowGraph.Core.dll

A sticky note style comment element for annotations on the canvas.

public class CommentElement : ShapeElement, ICanvasElement, INotifyPropertyChanged
Inheritance
CommentElement
Implements
Inherited Members

Examples

// Create a sticky note comment
var comment = new CommentElement("comment-1")
{
    Position = new Point(200, 150),
    Width = 200,
    Height = 100,
    Text = "TODO: Refactor this section",
    BackgroundColor = "#FFF9C4", // Light yellow
    TextColor = "#5D4037",
    CornerRadius = 4
};
graph.AddElement(comment);

// Create a warning annotation
var warning = new CommentElement("warning-1")
{
    Position = new Point(400, 200),
    Text = "⚠️ Deprecated API",
    BackgroundColor = "#FFCDD2", // Light red
    TextColor = "#C62828",
    ShowShadow = true
};

Remarks

CommentElement provides a styled annotation with: - Background fill with optional transparency - Corner radius for rounded appearance - Padding for text inset - Optional shadow effect - Resizable bounds

By default, comments render in a foreground layer (above nodes) using ZIndexComments (400), making them ideal for overlay annotations.

Constructors

CommentElement()

Creates a new comment element with a generated ID.

public CommentElement()

CommentElement(string)

Creates a new comment element with the specified ID.

public CommentElement(string id)

Parameters

id string

The unique identifier for this comment.

Fields

ZIndexComments

Default Z-index for comment elements (above nodes).

public const int ZIndexComments = 400

Field Value

int

Properties

BackgroundColor

Gets or sets the background color of the comment.

public string BackgroundColor { get; set; }

Property Value

string

Remarks

Common sticky note colors:

  • Yellow: #FFF9C4
  • Blue: #BBDEFB
  • Green: #C8E6C9
  • Pink: #F8BBD9
  • Orange: #FFE0B2

BorderColor

Gets or sets the border color.

public string BorderColor { get; set; }

Property Value

string

CornerRadius

Gets or sets the corner radius for rounded corners.

public double CornerRadius { get; set; }

Property Value

double

FontFamily

Gets or sets the font family name.

public string FontFamily { get; set; }

Property Value

string

FontSize

Gets or sets the font size in points.

public double FontSize { get; set; }

Property Value

double

FontWeight

Gets or sets the font weight.

public FontWeight FontWeight { get; set; }

Property Value

FontWeight

IsEditing

Gets or sets whether the comment is currently being edited.

public bool IsEditing { get; set; }

Property Value

bool

Remarks

When true, the renderer should show an editable text area.

Padding

Gets or sets the padding between the border and text.

public double Padding { get; set; }

Property Value

double

ShadowBlur

Gets or sets the shadow blur radius.

public double ShadowBlur { get; set; }

Property Value

double

ShadowColor

Gets or sets the shadow color.

public string ShadowColor { get; set; }

Property Value

string

ShadowOffsetX

Gets or sets the shadow X offset.

public double ShadowOffsetX { get; set; }

Property Value

double

ShadowOffsetY

Gets or sets the shadow Y offset.

public double ShadowOffsetY { get; set; }

Property Value

double

ShowShadow

Gets or sets whether to show a drop shadow.

public bool ShowShadow { get; set; }

Property Value

bool

Style

Gets or sets the visual style of the comment.

public CommentStyle Style { get; set; }

Property Value

CommentStyle

Text

Gets or sets the text content of the comment.

public string Text { get; set; }

Property Value

string

TextColor

Gets or sets the text color.

public string TextColor { get; set; }

Property Value

string

Type

Gets the type identifier for this element.

public override string Type { get; }

Property Value

string

Remarks

Used by renderer registries to select the appropriate renderer. For nodes, this typically comes from the node definition's Type property. For shapes, this identifies the shape type (line, rectangle, text, etc.).

Methods

Clone()

Creates a copy of this comment element with a new ID.

public CommentElement Clone()

Returns

CommentElement

A new CommentElement with copied properties.