ArcGIS Explorer Component Help |
GeometryOperations..::.Scale Method (Geometry, Double, Point) |
GeometryOperations Class Example See Also |
Returns a new Geometry which is a copy of the input Geometry scaled by the specified factor along both the x and y axis,
using the specified Point of origin.
Namespace:
ESRI.ArcGISExplorer.GeometryAssembly: ESRI.ArcGISExplorer (in ESRI.ArcGISExplorer.dll) Version: 2.0.0.1500 (2.0.0.1500)
Syntax
C# |
---|
public static Geometry Scale( Geometry inputGeometry, double scale, Point origin ) |
Visual Basic (Declaration) |
---|
Public Shared Function Scale ( _ inputGeometry As Geometry, _ scale As Double, _ origin As Point _ ) As Geometry |
Parameters
- inputGeometry
- Type: ESRI.ArcGISExplorer.Geometry..::.Geometry
The Geometry to copy and scale.
- scale
- Type: System..::.Double
The factor by which to scale the geometry.
- origin
- Type: ESRI.ArcGISExplorer.Geometry..::.Point
A Point to use as the origin of the scale operation.
Return Value
A new Geometry of the same type as the inputGeometry, scaled by the scale factor.Remarks
You can use this overload of the Scale method to resize a geometry and maintain the original aspect ratio; the geometry is stretched equally along both the x and y axis. You can use the Scale(Geometry, Double, Double, Point) overloads to scale a geometry around a specific point of origin and change the aspect ratio.
Examples
The code below gets the Note currently selected, and uses the GeometryOperations class to
scale the Geometry of the Graphic of the Note by a factor of 2 using the bottom-left corner of the
geometry's extent as the origin of the operation; this means the minimum X and Y coordinates of the
geometry remain the same and the maximum X and Y coordinates change.
The code assumes you have using statements for the Application, Geometry and Mapping namespaces.
CopyC#
SelectedItemsCollection selItems = ESRI.ArcGISExplorer.Application.Application.SelectedItems; if ((selItems.Count == 1) && (selItems[0] is Note)) { Note selected = selItems[0] as Note; // Get the bottom-left corner of the geometry. Geometry geom = selected.Graphic.Geometry; Envelope env = geom.GetEnvelope(); ESRI.ArcGISExplorer.Geometry.Point bottomLeft = new ESRI.ArcGISExplorer.Geometry.Point(env.XMin, env.YMin); // Scale the geometry maintaining the aspect ratio, and using the bottom-left point as the origin Geometry scaled = GeometryOperations.Scale(geom, 2, bottomLeft); // Alternatively, scale with different x and y factors to change the aspect ratio. // Geometry scaled = GeometryOperations.Scale(geom, 2, 1, bottomLeft); // Update the geometry of the graphic. selected.Graphic.Geometry = scaled; }
CopyVB.NET
Dim selItems As SelectedItemsCollection = ESRI.ArcGISExplorer.Application.Application.SelectedItems If selItems.Count = 1 AndAlso TypeOf selItems(0) Is Note Then Dim selected As Note = selItems(0) ' Get the bottom-left corner of the geometry. Dim geom As Geometry = selected.Graphic.Geometry Dim env As Envelope = geom.GetEnvelope() Dim bottomLeft As ESRI.ArcGISExplorer.Geometry.Point = New ESRI.ArcGISExplorer.Geometry.Point(env.XMin, env.YMin) ' Scale the geometry maintaining the aspect ratio, and using the bottom-left point as the origin Dim scaled As Geometry = GeometryOperations.Scale(geom, 2, bottomLeft) ' Alternatively, scale with different x and y factors to change the aspect ratio. ' Dim scaled As Geometry = GeometryOperations.Scale(geom, 2, 1, bottomLeft) ' Update the geometry of the graphic. selected.Graphic.Geometry = scaled End If