IWxView.ConvertPtToView

Syntax

ConvertPtToView(Pt: IGxPoint): IGxPointF;

ConvertPtToView(Pt: Prognoz.Platform.Interop.Drawing.IGxPoint): Prognoz.Platform.Interop.Drawing.IGxPointF;

Parameters

Pt. Point in pixels.

Description

The ConvertPtToView method converts the defined point in pixels into a point in millimeters.

Example

Executing the example requires a form with the WorkspaceBox component named WorkspaceBox1 and a data source for WorkspaceBox1.

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

Sub WorkspaceBox1OnClick(Sender: Object; Args: IMouseEventArgs);
Var
    WS: IWxWorkspace;
    View: IWxView;
    Point: IGxPointF;
    Ellipse: IWxEllipse;
Begin
    WS := UiWorkspace1.WxWorkspace;
    View := WS.Views.Item(
0);
    View.Id := 
"MyView";
    View.Scale := 
0.5;
    View.Size := 
New GxSizeF.Create(100.55,100.66);
    Point := View.ConvertPtToView(
New GxPoint.Create(Args.pPoint.X, Args.pPoint.Y));
    Ellipse := WS.CreateEllipse;
    Ellipse.PinPosition := View.ViewToWorkspace(Point);
    
//Coordiantes
    Debug.WriteLine(Args.pPoint.X.ToString + " " + Args.pPoint.Y.ToString);
    Debug.WriteLine(Point.X.ToString + 
" " + Point.Y.ToString);
    Debug.WriteLine(Ellipse.PinPosition.X.ToString + 
" " + Ellipse.PinPosition.Y.ToString);
End Sub WorkspaceBox1OnClick;
Imports Prognoz.Platform.Interop.Andy;
Imports Prognoz.Platform.Interop.Drawing;
Imports Prognoz.Platform.Interop.Workspace;

 
Private Sub workspaceBoxNet1_Click(sender: System.Object; e: System.EventArgs);
Var
    WS: IWxWorkspace;
    View: IWxView;
    pPoint: Point;
    gxPoint: GxPointF;
    Ellipse: IWxEllipse;
    OutSize: GxSizeF = 
New GxSizeFClass();
    OutPoint: GxPoint = 
New GxPointClass();
Begin
    WS := uiWorkspaceNet1.WxWorkspace;
    View := WS.Views.Item[
0];
    View.Id := 
"MyView";
    View.Scale := 
0.5;
    OutSize.Create(
100.55,100.66);
    View.Size := OutSize;
    pPoint := WorkspaceBoxNet1.PointToClient(Cursor.Position);
    OutPoint.Create(pPoint.X, pPoint.Y);
    gxPoint := View.ConvertPtToView(OutPoint);
    Ellipse := WS.CreateEllipse();
    Ellipse.PinPosition := View.ViewToWorkspace(gxPoint);
    
//Coordiantes
    System.Diagnostics.Debug.WriteLine(pPoint.X.ToString() + " " + pPoint.Y.ToString());
    System.Diagnostics.Debug.WriteLine(gxPoint.X.ToString() + 
" " + gxPoint.Y.ToString());
    System.Diagnostics.Debug.WriteLine(Ellipse.PinPosition.X.ToString() + 
" " + Ellipse.PinPosition.Y.ToString());
End Sub;

After executing the example the workspace view will be created and parameters will be set, clicking the button will also display an ellipse.

See also:

IWxView