Creating Objects, Their Styles and a Link between Them

Executing the example requires that repository contains a workspace with the WSP identifier.

Add links to the Andy, Drawing, Metabase, Workspace system assemblies.

Sub UserProc;
Var
    MB: IMetabase;
    ws: IWxWorkspace;
    Rect: IWxRectangle;
    Ellipse: IWxEllipse;
    Style: IWxStyle;
    Link: IWxLink;
Begin
    Mb := MetabaseClass.Active;
    ws := Mb.ItemById("WSP").Edit As IWxWorkspace;
    ws.BeginUpdate;
    // Create a rectangle
    Rect := ws.CreateRectangle;
    Rect.PinPosition := New GxPointF.Create(2010);
    Rect.Text := "Rectangle";
    Style := ws.CreateStyle;
    Style.Id := "MyStyle";
    Style.BackgroundBrushForeColor := New GxColor.CreateRGB(153204255);
    Style.BackgroundBrushForeTransparent := 10;
    Style.ShadowBrushForeColor := GxColor.FromName("White");
    Style.ShadowBrushBackColor := New GxColor.CreateRGB(204153255);
    Style.ShadowBrushPattern := GxBrushPattern.Gradient;
    Style.TextFontSize := 9;
    Style.TextFontBrushColor := GxColor.FromName("Blue");
    Rect.Style := Style;
    // Create an ellipse
    Ellipse := ws.CreateEllipse;
    Ellipse.PinPosition := New GxPointF.Create(8060);
    Ellipse.Text := "Ellipse";
    Ellipse.Style := ws.Styles.FindById("MyStyle");
    // Create a link between objects
    Link := ws.CreateLink;
    Link.Text := "Link";
    Link.TextVertOffset := -10;
    Style := ws.CreateStyle;
    Style.LinePenBeginWxCap := WxLineCap.ArrowRoundedFilled;
    Style.LinePenColor := New GxColor.CreateRGB(1280255);
    Style.LinePenWidth := 0.5;
    Link.Style := Style;
    ws.GlueConnectionPoints(Rect, 3, Link, 0);
    ws.GlueConnectionPoints(Ellipse, 0, Link, 1);
    ws.EndUpdate;
    (ws As IMetabaseObject).Save;
End Sub UserProc;

After executing the example a rectangle, an ellipse and a link between them are created in a workspace, and the specified style is applied for each of these objects:

See also:

Examples