using System;
using System.Collections.Generic;
using System.Text;
using OSGeo.MapGuide;
using System.Drawing;
using System.ComponentModel;
using System.Collections.ObjectModel;
using System.Windows.Forms;
namespace OSGeo.MapGuide.Viewer
{
///
/// A callback for circle digitization
///
/// The X coordinate of the circle's center
/// The Y coordinate of the circle's center
/// The circle's radius
public delegate void CircleDigitizationCallback(double x, double y, double radius);
///
/// A callback for line digitization
///
/// The X coordinate of the line's first point
/// The Y coordinate of the line's first point
/// The X coordinate of the line's second point
/// The Y coordinate of the line's second point
public delegate void LineDigitizationCallback(double x1, double y1, double x2, double y2);
///
/// A callback for point digitization
///
/// The X coordinate of the point
/// The Y coordinate of the point
public delegate void PointDigitizationCallback(double x, double y);
///
/// A callback for polygon digitization
///
/// A n by 2 array of polygon coordinates, where n is the number of vertices
public delegate void PolygonDigitizationCallback(double[,] coordinates);
///
/// A callback for line string digitization
///
/// A n by 2 array of line string coordinates, where n is the number of vertices
public delegate void LineStringDigitizationCallback(double[,] coordinates);
///
/// A callback for rectangle digitization
///
/// The X coordinate of the rectangle's lower left point
/// The Y coordinate of the rectangle's lower left point
/// The X coordinate of the rectangle's upper right point
/// The Y coordinate of the rectangle's upper right point
public delegate void RectangleDigitizationCallback(double llx, double lly, double urx, double ury);
///
/// A map viewer component
///
public interface IMapViewer : IMapViewerComponent, INotifyPropertyChanged, IMapComponent
{
///
/// Clears the current selection
///
void ClearSelection();
///
/// Starts the digitization process for a circle
///
/// The callback to be invoked when the digitization process completes
void DigitizeCircle(CircleDigitizationCallback callback);
///
/// Starts the digitization process for a line
///
/// The callback to be invoked when the digitization process completes
void DigitizeLine(LineDigitizationCallback callback);
///
/// Starts the digitization process for a point
///
/// The callback to be invoked when the digitization process completes
void DigitizePoint(PointDigitizationCallback callback);
///
/// Starts the digitization process for a polygon
///
/// The callback to be invoked when the digitization process completes
void DigitizePolygon(PolygonDigitizationCallback callback);
///
/// Starts the digitization process for a line string (polyline)
///
/// The callback to be invoked when the digitization process completes
void DigitizeLineString(LineStringDigitizationCallback callback);
///
/// Starts the digitization process for a line string (polyline)
///
/// The callback to be invoked when the digitization process completes
/// The callback to be invoked when a new segment of the current line string is digitized
void DigitizeLineString(LineStringDigitizationCallback callback, LineDigitizationCallback segmentDigitized);
///
/// Starts the digitization process for a rectangle
///
/// The callback to be invoked when the digitization process completes
void DigitizeRectangle(RectangleDigitizationCallback callback);
///
/// Starts the digitization process for a circle
///
/// The callback to be invoked when the digitization process completes
/// The custom prompt to use for the tracking tooltip
void DigitizeCircle(CircleDigitizationCallback callback, string customPrompt);
///
/// Starts the digitization process for a line
///
/// The callback to be invoked when the digitization process completes
/// The custom prompt to use for the tracking tooltip
void DigitizeLine(LineDigitizationCallback callback, string customPrompt);
///
/// Starts the digitization process for a point
///
/// The callback to be invoked when the digitization process completes
/// The custom prompt to use for the tracking tooltip
void DigitizePoint(PointDigitizationCallback callback, string customPrompt);
///
/// Starts the digitization process for a polygon
///
/// The callback to be invoked when the digitization process completes
/// The custom prompt to use for the tracking tooltip
void DigitizePolygon(PolygonDigitizationCallback callback, string customPrompt);
///
/// Starts the digitization process for a line string (polyline)
///
/// The callback to be invoked when the digitization process completes
/// The custom prompt to use for the tracking tooltip
void DigitizeLineString(LineStringDigitizationCallback callback, string customPrompt);
///
/// Starts the digitization process for a line string (polyline)
///
/// The callback to be invoked when the digitization process completes
/// The callback to be invoked when a new segment of the current line string is digitized
/// The custom prompt to use for the tracking tooltip
void DigitizeLineString(LineStringDigitizationCallback callback, LineDigitizationCallback segmentDigitized, string customPrompt);
///
/// Starts the digitization process for a rectangle
///
/// The callback to be invoked when the digitization process completes
/// The custom prompt to use for the tracking tooltip
void DigitizeRectangle(RectangleDigitizationCallback callback, string customPrompt);
///
/// Gets the current runtime map
///
///
MgMapBase GetMap();
///
/// Gets the selection set of the runtime map
///
///
MgSelectionBase GetSelection();
///
/// Gets the coordinate system of the runtime map
///
MgCoordinateSystem CoordinateSystem { get; }
///
/// Gets or sets the color used to render selected features
///
Color SelectionColor { get; set; }
///
/// Gets or sets the active tool
///
MapActiveTool ActiveTool { get; set; }
///
/// Gets the map viewer provider for this control
///
///
MgMapViewerProvider GetProvider();
///
/// Gets or sets the minimum allowed zoom scale for this viewer
///
int MinScale { get; set; }
///
/// Gets or sets the maximum allowed zoom scale for this viewer
///
int MaxScale { get; set; }
///
/// The amount of time (in ms) to wait to re-render after a mouse wheel scroll
///
int MouseWheelDelayRenderInterval { get; set; }
///
/// Gets or sets the factor by which to multiply the scale to zoom in
///
double ZoomInFactor { get; set; }
///
/// Gets or sets the factor by which to multiply the scale to zoom out
///
double ZoomOutFactor { get; set; }
///
/// Gets or sets whether feature tooltips are enabled. If set to true, tooltip queries are
/// executed at the current mouse position if the active tool is Pan or Select
///
bool FeatureTooltipsEnabled { get; set; }
///
/// Gets whether the viewer has any active rendering operations
///
bool IsBusy { get; }
///
/// Gets the type of object being currently digitized. If the digitization type is None, then
/// the viewer is not currently digitizing
///
MapDigitizationType DigitizingType { get; }
///
/// Gets the currently rendered image
///
///
System.Drawing.Image GetCurrentImage();
///
/// Copies the image of the current map to the clipboard
///
void CopyMap();
///
/// Refreshes the current map view
///
void RefreshMap();
///
/// Raised when the map has been refreshed
///
event EventHandler MapRefreshed;
///
/// Pans the view left by a pre-defined distance
///
///
void PanLeft(bool refresh);
///
/// Pans the view up by a pre-defined distance
///
///
void PanUp(bool refresh);
///
/// Pans the view right by a pre-defined distance
///
///
void PanRight(bool refresh);
///
/// Pans the view down by a pre-defined distance
///
///
void PanDown(bool refresh);
///
/// Updates the rendered selection. Call this method if you have manipulated the selection
/// set outside of the viewer
///
///
/// If you have modified the selection as a result of calling , calling
/// this method is not necessary as it will have automatically do this.
///
void UpdateSelection();
///
/// Updates the rendered selection. Call this method if you have manipulated the selection
/// set outside of the viewer
///
/// Indicates if the event should be raised as well
///
/// If you have modified the selection as a result of calling , calling
/// this method is not necessary as it will have automatically do this.
///
void UpdateSelection(bool raise);
///
/// Selects features from all selectable layers that intersects the given geometry
///
/// The geometry to perform intersection tests against
///
/// This method will automatically trigger selection updates. Calling is not necessary if
/// you are calling this method
///
void SelectByGeometry(MgGeometry geom);
///
/// Selects features from all selectable layers that intersects the given geometry up to the specified number
///
/// The geometry to perform intersection tests against
/// The maximum number of features to select. Specify -1 for all features
///
/// This method will automatically trigger selection updates. Calling is not necessary if
/// you are calling this method
///
void SelectByGeometry(MgGeometry geom, int maxFeatures);
///
/// Selects features from all selectable layers that intersects the given geometry up to the specified number
///
/// The geometry to perform intersection tests against
/// The maximum number of features to select. Specify -1 for all features
/// An optional handler method that is invoked upon change of selection
///
/// If a selection handler is passed to this method two things will happen:
///
/// - The event is not raised upon change of selection. Existing subscribers will not be notified of any selection change caused by this method
/// - The handler will be called with a object passed to it. If this query results in nothing selected, null is passed to this handler
///
/// The handler is responsible for the selection given to it. You may call on this selection if desired when your handler is done with it
///
void SelectByGeometry(MgGeometry geom, int maxFeatures, Action selectionHandler);
///
/// Zooms to the initial map view
///
void InitialMapView();
///
/// Zooms to the specified map view
///
///
///
///
///
void ZoomToView(double x, double y, double scale, bool refresh);
///
/// Raised when the scale of the current runtime map has changed
///
event EventHandler MapScaleChanged;
///
/// Raised when the selection has changed. Note that programmatic selection modifications
/// will not raise this event.
///
event EventHandler SelectionChanged;
///
/// Raised when the viewer has been initialized
///
event EventHandler MapLoaded;
///
/// Raised when the map cursor position has changed
///
event EventHandler MouseMapPositionChanged;
///
/// Zooms to the view defined by the specified extent
///
///
///
///
///
void ZoomToExtents(double llx, double lly, double urx, double ury);
///
/// Gets or sets whether to show vertex coordinates when digitizing
///
bool ShowVertexCoordinatesWhenDigitizing { get; set; }
///
/// Gets or sets whether to convert tiled layers to non-tiled layers. This is a workaround
/// setting for tiled maps to be displayed as viewer support for tiled layers is still not
/// implemented.
///
/// If is set
/// to true, this property has no effect.
///
///
/// As of 2.5, images from RenderDynamicOverlay will include any base layers by default. Using this property
/// as a workaround is no longer required. This property remains for compatibility purposes.
///
bool ConvertTiledGroupsToNonTiled { get; set; }
///
/// Gets whether to use the RenderMap API instead of RenderDynamicOverlay if the map has tiled
/// layers. RenderMap includes tiled layers as part of the output image, but will not take advantage
/// of any tile caching mechanisms. Setting this property to true nullifies any effect of the
/// property
///
///
/// As of 2.5, images from RenderDynamicOverlay will include any base layers by default. Setting this property to true is no longer required
/// unless you still require map images to be rendered with a pre-filled background (which RenderMap() does). This property remains
/// for compatibility purposes.
///
bool UseRenderMapIfTiledLayersExist { get; set; }
///
/// Gets whether to respect the list of finite display scales in a map being viewed if there are any defined.
/// If true, all zooms will "snap" to the nearest finite display scale
///
bool RespectFiniteDisplayScales { get; set; }
///
/// Gets whether this viewer has a map loaded into it
///
bool HasLoadedMap { get; }
///
/// Gets or sets the amount of pixels to buffer out by when doing point-based selections with the Select tool
///
int PointPixelBuffer { get; set; }
///
/// Navigates to the previous view in the history stack
///
void PreviousView();
///
/// Navigates to the next view in the history stack
///
void NextView();
///
/// Gets the current index in the view history stack
///
int ViewHistoryIndex { get; }
///
/// Gets the view history stack. The first item being the earliest and the last item being the most recent.
///
ReadOnlyCollection ViewHistory { get; }
///
/// Cancels the active digitization process. Does nothing if is MapDigitizationType.None
///
void CancelDigitization();
///
/// Raised before map rendering begins in the control's Paint method. This allows you to do custom rendering before the
/// map image is rendered. Depending on whatever map/layer transparency settings, content rendered by your handler may
/// be obscured by the map image that is rendered afterwards. If you need to do custom rendering on top of a rendered map
/// image, consider doing the rendering on the event
/// instead.
///
///
/// The object attached to the
/// that is passed to your handler will already have any scale/translate transforms applied as a result of user panning or
/// transitional zooming.
///
/// Also note that any such custom rendrered content will not appear in any custom rendering or plotting output through
/// MapGuide's APIs as it has no knowledge of the your custom rendered content here.
///
event PaintEventHandler PreMapRender;
///
/// Raised after map render has completed in the control's Paint method. This allows you to do custom rendering after the
/// map image is rendered
///
///
/// The object attached to the
/// that is passed to your handler will already have any scale/translate transforms applied as a result of user panning or
/// transitional zooming.
///
/// Also note that any such custom rendrered content will not appear in any custom rendering or plotting output through
/// MapGuide's APIs as it has no knowledge of the your custom rendered content here.
///
event PaintEventHandler PostMapRender;
///
/// Gets the width of this control
///
int ControlWidth { get; }
///
/// Gets the height of this control
///
int ControlHeight { get; }
///
/// Converts the given coordinate in screen units to map units
///
/// The x coordinate in screen space
/// The y coordinate in screen space
///
PointF ScreenToMapUnits(double x, double y);
///
/// Converts the given coordinate in map-space to coordinates in screen space. This is the inverse of
///
///
/// The x coordinate in map space
/// The y coordinate in map space
///
Point MapToScreenUnits(double x, double y);
}
///
/// Defines a map view location already visited
///
public class MgMapViewHistoryEntry
{
///
/// Constructor
///
///
///
///
public MgMapViewHistoryEntry(double x, double y, double scale)
{
this.X = x;
this.Y = y;
this.Scale = scale;
}
///
/// The view location X coordinate
///
public double X { get; private set; }
///
/// The view location Y coordinate
///
public double Y { get; private set; }
///
/// The view scale
///
public double Scale { get; private set; }
}
///
/// Contains data of a MouseMapPositionChanged event
///
public class MapPointEventArgs : EventArgs
{
///
/// Gets the X coordinate
///
public readonly double X;
///
/// Gets the Y coordinate
///
public readonly double Y;
///
///
///
///
///
public MapPointEventArgs(double x, double y)
{
this.X = x;
this.Y = y;
}
}
///
/// The type of digitization in progress
///
public enum MapDigitizationType
{
///
/// No digitization in progress
///
None,
///
/// A point digitization is in progress
///
Point,
///
/// A line digitization is in progress
///
Line,
///
/// A line string digitization is in progress
///
LineString,
///
/// A rectangle digitization is in progress
///
Rectangle,
///
/// A polygon digitization is in progress
///
Polygon,
///
/// A circle digitization is in progress
///
Circle
}
///
/// The active viewer tool
///
public enum MapActiveTool
{
///
/// Zoom In command
///
ZoomIn,
///
/// Zoom Out command
///
ZoomOut,
///
/// Pan command
///
Pan,
///
/// Select command
///
Select,
///
/// No active command
///
None
}
}