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;
Imports Prognoz.Platform.Interop.Andy;
Imports Prognoz.Platform.Interop.Drawing;
Imports Prognoz.Platform.Interop.Workspace;

 
Public Shared Sub Main(Params: StartParams);
Var
    MB: IMetabase;
    ws: IWxWorkspace;
    Rect: IWxRectangle;
    Ellipse: IWxEllipse;
    Style: IWxStyle;
    Link: IWxLink;
    vGxColor: GxColorClass_2 = 
New GxColorClass_2();
    GxColorCls: GxColorClass = 
New GxColorClassClass();
    OutPoint: GxPointF = 
New GxPointFClass();
Begin
    Mb := Params.Metabase;
    ws := Mb.ItemById[
"WSP"].Edit() As IWxWorkspace;
    ws.BeginUpdate();
    
// Create a rectangle
    Rect := ws.CreateRectangle();
    OutPoint.Create(
2010);
    Rect.PinPosition := OutPoint;
    Rect.Text := 
"Rectangle";
    Style := ws.CreateStyle();
    Style.Id := 
"MyStyle";
    vGxColor.CreateRGB(
153204255);
    Style.BackgroundBrushForeColor := vGxColor;
    Style.BackgroundBrushForeTransparent := 
10;
    Style.ShadowBrushForeColor := GxColorCls.FromName(
"White");
    vGxColor.CreateRGB(
204153255);
    Style.ShadowBrushBackColor := vGxColor;
    Style.ShadowBrushPattern := GxBrushPattern.wbpGradient;
    Style.TextFontSize := 
9;
    Style.TextFontBrushColor := GxColorCls.FromName(
"Blue");
    Rect.Style := Style;
    
// Create an ellipse
    Ellipse := ws.CreateEllipse();
    OutPoint.Create(
8060);
    Ellipse.PinPosition := OutPoint;
    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.wlcArrowRoundedFilled;
    vGxColor.CreateRGB(
1280255);
    Style.LinePenColor := vGxColor;
    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;

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