IWxView.SetBackgroundImage

Syntax

SetBackgroundImage(Rect: IGxRect; BackgroundBitmap: IGxBitmap);

SetBackgroundImage(Rect: Prognoz.Platform.Interop.Drawing.GxRect; BackgroundBitmap: Prognoz.Platform.Interop.Drawing.GxBitmap);

Parameters

Rect. Rectangle that defines the part of the image to be set as the background.

BackgroundBitmap. The image to be set as the background.

Description

The SetBackgroundImage method sets the specified part of the image as the background for the workspace.

Comments

Use the IWxView.AutoScroll method to put an image to the center of the workspace without changing zoom.

Example

Executing the example requires a form with the Button1 button, the WorkspaceBox component with the WorkspaceBox1 identifier and the UiWorkspaceOblect component with the UiWorkspaceOblect1 identifier. Set UiWorkspaceOblect1 as a data source for the WorkspaceBox1 component. The example is the OnClick event handler for the Button1 component. It is also required to have the ConnectedCPs.gif image.

Add links to the Andy, Drawing system assemblies.

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

    Rect: IGxRect;
    Bmp: IGxBitmap;
Begin
    
// Get workspace for editing
    ws := UiWorkspace1.WxWorkspace;
    view := ws.CreateView;
    view := ws.Views.Item(
0);
    Rect := New GxRect.Create(00, WorkspaceBox1.ClientWidth, WorkspaceBox1.ClientHeight);
    Bmp := GxBitmap.FromFile(
"C:\ConnectedCPs.gif"As IGxBitmap;
    view.BeginUpdate;
    view.SetBackgroundImage(Rect, Bmp);
    view.EndUpdate;

End Sub Button1OnClick;
Imports Prognoz.Platform.Interop.Andy;
Imports Prognoz.Platform.Interop.Drawing;

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

    GxRectCls: GxRectClass = New GxRectClass();
    GxBitmapCls: GxBitmapClassClass = 
New GxBitmapClassClass();
    Bmp: GxBitmap;
Begin
    
// Get workspace for editing
    ws := uiWorkspaceNet1.WxWorkspace;
    view := ws.CreateView();
    view := ws.Views.Item[
0];
    GxRectCls.Create(00, WorkspaceBoxNet1.CtrlBox.ClientWidth, WorkspaceBoxNet1.CtrlBox.ClientHeight);
    Bmp := 
New GxBitmapClass_2();
    Bmp := GxBitmapCls.FromFile(
"C:\ConnectedCPs.gif"As GxBitmap;
    view.BeginUpdate();
    view.SetBackgroundImage(GxRectCls, Bmp);
    view.EndUpdate();

End Sub;

On clicking the button the selected image is set as the background for the workspace. Size of the image part, which is set as the background, corresponds to client-based size of the WorkspaceBox1 component.

See also:

IWxView