IUiWorkspaceBaseEventArgs.UiWs

Syntax

UiWs: IUiWorkspaceObject;

Description

The UiWs property returns the object containing the UiWorkspaceObject component that generated the event.

Example

Executing the example requires that the repository contains a form and a workspace with WORKSPACE identifier. Place on the form the components: Button, WorkspaceBox, UiWorkspaceObject named Button1 WorkspaceBox1, UiWorkspaceObject1, respectively.

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

Class TESTForm: Form
    Button1: Button;
    WorkspaceBox1: WorkspaceBox;
    UiWorkspaceObject1: UiWorkspaceObject;

    Sub TESTFormOnCreate(Sender: Object; Args: IEventArgs);
    Var
        Mb: IMetabase;
        Workspace: IMetabaseObjectDescriptor;
    Begin
        // Get workspace
        Mb := MetabaseClass.Active;
        Workspace := Mb.ItemById("WORKSPACE").Edit;
        // Set object opening parameters on form
        UiWorkspaceObject1.Active := True;
        UiWorkspaceObject1.Object := Workspace;
        UiWorkspaceObject1.OperationMode := UiMetabaseObjectOperationMode.Edit;
        WorkspaceBox1.Source := UiWorkspaceObject1 As IWorkspaceSource;
    End Sub TESTFormOnCreate;

    // Add a shape to workspace on button click
    Sub Button1OnClick(Sender: Object; Args: IMouseEventArgs);
    Var
        Workspace: IWxWorkspace;
    Begin
        Workspace := UiWorkspaceObject1.Workspace As IWxWorkspace;
        Workspace.CreateEllipse;
    End Sub Button1OnClick;

    // Set up the event that will occur after adding a shape
    Sub UiWorkspaceObject1OnAfterCreateShape(Sender: Object; Args: IUiWorkspaceShapeEventArgs);
    Var
        Arg: IUiWorkspaceBaseEventArgs;
        Object: IUiWorkspaceObject;
        Workspace: IWxWorkspace;
        Shapes: IWxShapes;
        Shape: IWxShape;
        Style: IWxStyle;
        Count: Integer;
    Begin
        Arg := Args As IUiWorkspaceBaseEventArgs;
        // Get the object containing the UiWorkspaceObject component
        Object := Arg.UiWs;
        // Get workspace
        Workspace := Object.Workspace As IWxWorkspace;
        Workspace.BeginUpdate;
        // Get collection of shapes and their number
        Shapes := Workspace.Shapes;
        Count := Shapes.Count;
        // Set red fill color for added shape
        Shape := Workspace.Shapes.Item(Count - 1);
        Style := Shape.Style;
        Style.BackgroundBrushForeColor := GxColor.FromName("Red");
        Workspace.EndUpdate;
    End Sub UiWorkspaceObject1OnAfterCreateShape;
End Class TESTForm;

After executing the example, clicking the button adds an ellipsis to the workspace. When the shape is added, the event is executed that adds red fill color.

See also:

IUiWorkspaceBaseEventArgs