IWxView.DrawOnGraphics

Syntax

DrawOnGraphics(Graphics: IGxGraphics);

DrawOnGraphics(Graphics: Prognoz.Platform.Interop.Drawing.IGxGraphics);

Parameters

Graphics. Graphical context.

Description

The DrawOnGraphics method draws a workspace within a graphical context.

Example

Executing the example requires a form with the Button1 button, the WorkspaceBox component named WorkspaceBox1 and a data source for the WorkspaceBox1. The file system must contain the C:\WSP.pngĀ» image.

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

Sub Button1OnClick(Sender: Object; Args: IMouseEventArgs);
Var
    ws: IWxWorkspace;
    view: IWxView;

    ellipse: IWxEllipse;
    Img: IGxImage;
    Graph: IGxGraphics;
Begin
    
// Get workspace for editing
    ws := UiWorkspace1.WxWorkspace;
    view := ws.CreateView;

    ellipse := ws.CreateEllipse;
    view.AutoScaleAndScroll;
    Img := GxBitmap.CreateNew(
300300, GxPixelFormat.Format32bppArgb);
    Graph := GxGraphicsClass.FromImage(Img);
    View.DrawOnGraphics(Graph);
    Img.SaveToFileEncoded(
"C:\WSP.png", GxImageFormats.Png);
End Sub Button1OnClick;
Imports Prognoz.Platform.Interop.Andy;
Imports Prognoz.Platform.Interop.Workspace;
Imports Prognoz.Platform.Interop.Drawing;

 
Private Sub button1_Click(sender: System.Object; e: System.EventArgs);
Var
    ws: IWxWorkspace;
    view: IWxView;
    ellipse: IWxEllipse;

    GxImageFormats: GxImageFormatsClass = New GxImageFormatsClass();
    Graph: GxGraphics;
    BmpCls: GxBitmapClass = 
New GxBitmapClass();
    Bmp: GxBitmap;
    GraphCls: GxGraphicsClass = 
New GxGraphicsClassClass();
Begin
    
// Get workspace for editing
    ws := uiWorkspaceNet1.WxWorkspace;
    view := ws.CreateView();
    view := ws.Views.Item[
0];
    ellipse := ws.CreateEllipse();
    view.AutoScaleAndScroll();
    Bmp := BmpCls.CreateNew(
300300, GxPixelFormat.pifFormat32bppArgb);
    Graph := GraphCls.FromImage(Bmp);
    view.DrawOnGraphics(Graph);
    Bmp.SaveToFileEncoded(
"C:\WSP.png", GxImageFormats.Png);
End Sub;

 

After executing the example the part of workspace image of defined size is saved to the file.

See also:

IWxView