public void ExtentTest() { Envelope mapEnvelope = new Envelope(123.0, 456.0, 78.0, 91.0); SolidColorBrush color = new SolidColorBrush(Colors.Green); GhostFrame target = new GhostFrame(backgroundMap, mapEnvelope, color); Envelope actual; actual = target.Extent; Assert.AreEqual(actual, target.Extent); }
public void GhostFrameConstructorTest() { Envelope mapEnvelope = new Envelope(123.0, 456.0, 78.0, 98.0); SolidColorBrush color = new SolidColorBrush(Colors.Red); GhostFrame target = new GhostFrame(backgroundMap, mapEnvelope, color); //Make sure we have the same color Assert.AreEqual(color, target.Color); //Make sure the map envelope is the same Assert.AreEqual(mapEnvelope, target.Extent); }
/// <summary> /// Adds a new MapFrame to the layer via the /// two map points from the map. /// /// A MapFrame is created where the extent are defined /// by the two points (one for upper left corner and the /// other for lower right corner). /// /// The position of the MapFrame on the screen is also defined /// by the 2 Points value (one for upper left corner and another /// for lower right corner). /// </summary> /// <param name="mapPoint1"></param> /// <param name="mapPoint2"></param> /// <param name="screenPoint1"></param> /// <param name="screenPoint2"></param> public MapFrame CreateMapFrame(MapPoint mapPoint1, MapPoint mapPoint2, Point screenPoint1, Point screenPoint2) { SolidColorBrush randomColor = GetRandomColor(); ArcGisMap BackgroundMap = BackgroundMapLayer.Instance.getBackgroundMap(); GhostFrame gFrame = new GhostFrame(BackgroundMap, new Envelope(mapPoint1, mapPoint2), randomColor); MapFrame mFrame = new MapFrame(gFrame, mapPoint1, mapPoint2, randomColor); /* create new delegates instances and bind them to MapFrame's MapLayer managment methods */ /*MapLayersManager.MapLayerAddedDelegate delegate1 = new MapLayersManager.MapLayerAddedDelegate(mFrame.MapLayerAdded.ID); MapLayersManager.MapLayerDeletedDelegate delegate2 = new MapLayersManager.MapLayerDeletedDelegate(mFrame.MapLayerDeleted); MapLayersManager.Instance.MapLayerAdded += delegate1; MapLayersManager.Instance.MapLayerDeleted += delegate2;*/ mFrame.Orientation = 0.0; var xDiff = Math.Abs(screenPoint1.X - screenPoint2.X); var yDiff = Math.Abs(screenPoint1.Y - screenPoint2.Y); if (screenPoint1.X < screenPoint2.X && screenPoint1.Y < screenPoint2.Y) { mFrame.Orientation = 0.0; mFrame.Height = yDiff; mFrame.Width = xDiff; mFrame.Center = new System.Windows.Point(screenPoint1.X + xDiff / 2, screenPoint1.Y + yDiff / 2); } else if (screenPoint1.X > screenPoint2.X && screenPoint1.Y < screenPoint2.Y) { mFrame.Orientation = 90.0; mFrame.Height = yDiff; mFrame.Width = xDiff; mFrame.Center = new System.Windows.Point(screenPoint1.X - xDiff / 2, screenPoint1.Y + yDiff / 2); } else if (screenPoint1.X > screenPoint2.X && screenPoint1.Y > screenPoint2.Y) { mFrame.Orientation = 180.0; mFrame.Height = yDiff; mFrame.Width = xDiff; mFrame.Center = new System.Windows.Point(screenPoint1.X - xDiff / 2, screenPoint1.Y - yDiff / 2); } else if (screenPoint1.X < screenPoint2.X && screenPoint1.Y > screenPoint2.Y) { mFrame.Orientation = 270.0; mFrame.Height = yDiff; mFrame.Width = xDiff; mFrame.Center = new System.Windows.Point(screenPoint1.X + xDiff / 2, screenPoint1.Y - yDiff / 2); } return mFrame; }
/// <summary> /// Constructor of Map Frame /// </summary> /// <param name="relatedGhostFrame">GhostFrame object corresponding to this map frame</param> /// <param name="p1">First map point - map location for the first corner of the map</param> /// <param name="p2">Second map point - map location for the second corner of the map</param> public MapFrame(GhostFrame relatedGhostFrame, MapPoint p1, MapPoint p2) { InitializeComponent(); linkedGhostFrame = relatedGhostFrame; linkedGhostFrame.LinkedMapFrame = this; MainMap.Map.Loaded += new RoutedEventHandler(MainMap_Loaded); // Initialize the map InitializeMap(); LoadMap(p1, p2); UpdateVisibilityOfAnnotationButtons(); }
/// <summary> /// Constructor for MapFrame /// </summary> /// <param name="relatedGhostFrame">GhostFrame object corresponding to this map frame</param> /// <param name="env">Map envelope representing the location of the map inside the frame</param> /// <param name="color">Color of the map frame</param> public MapFrame(GhostFrame relatedGhostFrame, Envelope env, SolidColorBrush color) { InitializeComponent(); linkedGhostFrame = relatedGhostFrame; linkedGhostFrame.LinkedMapFrame = this; glassFrame1.Background = color; glassFrame2.Background = color; glassFrame3.Background = color; glassFrame4.Background = color; MainMap.Map.Loaded += new RoutedEventHandler(MainMap_Loaded); // Initialize the map InitializeMap(); LoadMap(env); UpdateVisibilityOfAnnotationButtons(); }
public void setLinkedGhostFrameTest() { ArcGisMap target = new ArcGisMap(); GhostFrame gf = new GhostFrame(BackgroundMapLayer.Instance.getBackgroundMap(), target.Extent, new SolidColorBrush(Colors.Red)); target.LinkedGhostFrame = gf; Assert.AreEqual(gf, target.LinkedGhostFrame); }
/// <summary> /// Adds a new MapFrame to the layer via the BookmarkPins. /// /// The position of the MapFrame (centre) is the same as the related BookmarkPin. /// The orientation of the frame is also defined. The map extent of the frame is the same as the related Bookmark. /// </summary> /// <param name="bookmark">Related Bookmark</param> /// <param name="centerPt">Center point to place the map frame on the screen</param> /// <param name="orientation">Orientation of the map frame</param> /// <param name="fromBookmarkList">true if the map frame is created from the Bookmark list, false otherwise</param> /// <returns></returns> public MapFrame CreateMapFrame(Bookmark bookmark, Point centerPt, double orientation, bool fromBookmarkList) { /* if it is already open, dont open again */ if (bookmark.MapFrameCurrentlyOpen == true) { BackgroundMapLayer.Instance.BringMapFrameToFront(bookmark); return null; } Envelope mapExtent = new Envelope(); double frameHeight = 270; double frameWidth = 270; Point frameCenter = centerPt; double frameOri = orientation; // TODO: Check if this makes a difference or if it is not needed if (fromBookmarkList) { mapExtent = bookmark.MapFrameEnvelope; frameOri = orientation + 90; } if (bookmark.MapFramePreviouslyOpen == true) { /* Do we really want to open the map frame from it's previous position? */ //mapExtent = bookmark.MapFrameEnvelope; //frameHeight = bookmark.MapFrameHeight; //frameWidth = bookmark.MapFrameWidth; //frameCenter = bookmark.MapFrameCenter; //frameOri = bookmark.MapFrameOrientation; } else { mapExtent = bookmark.MapFrameEnvelope; //frameHeight = height; //frameWidth = width; frameCenter = centerPt; } SolidColorBrush randomColor = GetRandomColor(); ArcGisMap BackgroundMap = BackgroundMapLayer.Instance.getBackgroundMap(); GhostFrame gFrame = new GhostFrame(BackgroundMap, mapExtent, randomColor); MapFrame mFrame = new MapFrame(gFrame, mapExtent, randomColor); /* create new delegates instances and bind them to MapFrame's MapLayer managment methods */ /*MapLayersManager.MapLayerAddedDelegate delegate1 = new MapLayersManager.MapLayerAddedDelegate(mFrame.MapLayerAdded); MapLayersManager.MapLayerDeletedDelegate delegate2 = new MapLayersManager.MapLayerDeletedDelegate(mFrame.MapLayerDeleted); MapLayersManager.Instance.MapLayerAdded += delegate1; MapLayersManager.Instance.MapLayerDeleted += delegate2;*/ mFrame.RelatedBookmark = bookmark; mFrame.Orientation = frameOri; mFrame.Height = frameHeight; mFrame.Width = frameWidth; mFrame.Center = frameCenter; bookmark.MapFrameCurrentlyOpen = true; return mFrame; }
public void UpdatePositionTest() { Envelope mapEnvelope = new Envelope(123.0, 456.0, 78.0, 91.0); SolidColorBrush color = new SolidColorBrush(Colors.Pink); GhostFrame target = new GhostFrame(backgroundMap, mapEnvelope, color); Envelope newEnvelope = new Envelope(987.0, 654.0, 32.0, 10.0); target.UpdatePosition(newEnvelope); Assert.AreEqual(newEnvelope.XMax, target.Extent.XMax); Assert.AreEqual(newEnvelope.YMax, target.Extent.YMax); Assert.AreEqual(newEnvelope.XMin, target.Extent.XMin); Assert.AreEqual(newEnvelope.YMin, target.Extent.YMin); }