Create Process Statement Labels by Code

Hello,

is there a possibility to create labels like the Process Statement Labels by code (.NET)?

image

Thank you very much!

For your own purposes? I don’t think so.
The flow editor has its own special UI overlay which implements those dots and labels. You would probably need to implement your own overlay from scratch.

Okay, thank you for your fast replay!

It’s not easy to create the same functionalities as PM.
Simple stuff would be OK.

ShowNames

Sample code for from scratch.

public void Initialize()
{    
    app = IoC.Get<IApplication>();
    window = app.ActiveWindow;
    render = IoC.Get<IRenderService>();
   
    render.OnRequestRender += Render_OnRequestRender;
    
    var viewport = IoC.Get<IDirect3DViewportViewModel>();
    grid = viewport.ControlGrid;
    if (grid != null)
    {
        grid.SizeChanged += Grid_SizeChanged;
        canvas = new Canvas
        {
            // Background = media.Brushes.DeepSkyBlue,
            Width = grid.ActualWidth,
            Height = grid.ActualHeight,
            HorizontalAlignment = HorizontalAlignment.Right,
            VerticalAlignment = VerticalAlignment.Bottom,
            Margin = new Thickness(0, 0, 0, 0)                    
        };
        grid.Children.Add(canvas);               
    }
}

private void Render_OnRequestRender(object sender, EventArgs e)
{
    canvas.Children.Clear();            
    foreach (var component in app.World.Components)
    {
        var matrix = component.TransformationInWorld;
        var vector = new Vector3();
        window.ProjectWorldPointToScreenSpace(ref matrix, out vector);
        var x = vector.X;
        var y = vector.Y;
        
        var rectangle = new Rectangle
        {
            Opacity = 0.5,
            Width = component.Name.Length*10.0,
            Height = 10.0,
            Fill = media.Brushes.Cyan                                      
        };
        canvas.Children.Add(rectangle);
        Canvas.SetTop(rectangle, y + 15.0);
        Canvas.SetLeft(rectangle, x);
        
        var textBlock = new TextBlock
        {
            Text = component.Name,
            Foreground = media.Brushes.Red,
            FontSize = 20.0
        };
        canvas.Children.Add(textBlock);
        Canvas.SetTop(textBlock, y);
        Canvas.SetLeft(textBlock, x);
    }
}

private void Grid_SizeChanged(object sender, SizeChangedEventArgs e)
{
    canvas.Width = grid.ActualWidth;
    canvas.Height = grid.ActualHeight;
}
3 Likes