/// <summary> Populates the snap-to points list with one or more snappable points /// </summary> /// <param name="pMapView">current map view /// </param> /// <param name="x">x-coordinate of the cursor position relative to the upper-left corner of the view /// </param> /// <param name="y">y-coordinate of the cursor position relative to the upper-left corner of the view /// </param> /// <param name="pSnapToPointsList"> List of points that can be snapped to at the specified location. /// </param> /// <seealso cref="SNAPTOPOINTSLISTSERVERLib.SnapToPointsListClass"/> public void GetSnappablePoints(FalconViewOverlayLib.IFvMapView pMapView, int x, int y, object pSnapToPointsList) { if (m_DummyItem.Contains(x, y)) { SNAPTOPOINTSLISTSERVERLib.ISnapToPointsList theItemList = (SNAPTOPOINTSLISTSERVERLib.ISnapToPointsList)pSnapToPointsList; SNAPTOPOINTSLISTSERVERLib.ISnapToPointsList2 theItemList2 = (SNAPTOPOINTSLISTSERVERLib.ISnapToPointsList2)pSnapToPointsList; MAPENGINELib.ISettableMapProj theMapProj = (MAPENGINELib.ISettableMapProj)pMapView.CurrentMapProj; double Lat, Lon; int result; theMapProj.surface_to_geo(m_DummyItem.X + (m_DummyItem.Width / 2), m_DummyItem.Y + (m_DummyItem.Height / 2), out Lat, out Lon, out result); if (result == SUCCESS) { theItemList.m_dLatitude = Lat; theItemList.m_dLongitude = Lon; theItemList2.m_overlayDescGuid = this.OverlayDescGuid; theItemList2.m_bstrOverlayName = OverlayFriendlyName; theItemList2.m_bstrTooltip = "Dummy snap to point"; theItemList2.m_bstrKey = ""; theItemList.AddToList(); } } }
/// <summary> Performs a "hit test" on the overlay for snappable points /// </summary> /// <param name="pMapView">current map view /// </param> /// <param name="x">x-coordinate of the cursor position relative to the upper-left corner of the view /// </param> /// <param name="y">y-coordinate of the cursor position relative to the upper-left corner of the view /// </param> /// <returns> /// Returns TRUE if a snappable point exists in the given view at the given screen coordinates. /// </returns> public int CanSnapTo(FalconViewOverlayLib.IFvMapView pMapView, int x, int y) { if (GetScaleDenominator((MAPENGINELib.ISettableMapProj)pMapView.CurrentMapProj) > m_HideAbove) return FALSE; if (m_DummyItem.Contains(x, y)) return TRUE; return FALSE; }
/// <summary> Optional interface that can be implemented to support rendering your overlay. /// OnDraw is called by the framework to render your overlay to a surface (screen, printer, or DIB). /// </summary> /// <param name="pMapView">current map view that the overlay is being drawn to. This is the /// currently displayed map (which may not have been drawn). Overlays should reference /// the CurrentMapProj from the IActiveMapProj as the map they will draw to. /// </param> /// <param name="pActiveMap">IActiveMapProj interface created by the map rendering engine /// </param> public void OnDraw(FalconViewOverlayLib.IFvMapView pMapView, object pActiveMap) { MAPENGINELib.IActiveMapProj theActiveMap = pActiveMap as MAPENGINELib.IActiveMapProj; MAPENGINELib.ISettableMapProj theSettableMapProj = null; MAPENGINELib.IGraphicsContext theGC = null; try { // Insure that the overlay can be seen theActiveMap.GetSettableMapProj(out theSettableMapProj); if (theSettableMapProj == null) // can't draw yet without a map reference return; double scaleDenominator = GetScaleDenominator(theSettableMapProj); m_OverlayHidden = (scaleDenominator > m_HideAbove); if (m_OverlayHidden) return; // Some common items to retrieve,... double Lat, Lon; double LLLat, LLLon, URLat, URLon; int result; theSettableMapProj.actual_center_lat(out Lat); theSettableMapProj.actual_center_lon(out Lon); theSettableMapProj.get_vmap_bounds(out LLLat, out LLLon, out URLat, out URLon, out result, MAPENGINELib.VirtualSurfaceEnum.EQUALARC_VSURFACE); double rotation; theSettableMapProj.actual_rotation(out rotation); int zoom; theSettableMapProj.actual_zoom_percent(out zoom); // Draw the overlay according to user preferences theActiveMap.GetGraphicsContext(out theGC); if (theGC != null) { int hdc, hAttribDC; theGC.GetDC(out hdc, out hAttribDC); DRAWING.Graphics mapGraphics = DRAWING.Graphics.FromHdc(new IntPtr(hdc), new IntPtr(hAttribDC)); bool isPrtDC; theGC.IsPrinting(out isPrtDC); if (isPrtDC) mapGraphics.PageUnit = System.Drawing.GraphicsUnit.Pixel; DRAWING.SizeF strSize; if (m_ShowBanner) { int width, height; theSettableMapProj.get_surface_size(out width, out height, out result); int centerX = width / 2; string displayTitle = OverlayFriendlyName; DRAWING.Rectangle theBannerRect = new DRAWING.Rectangle(); strSize = mapGraphics.MeasureString(displayTitle, m_Font_Large); theBannerRect.X = centerX - (int)strSize.Width / 2 - 10; theBannerRect.Y = 10; theBannerRect.Width = (int)strSize.Width + 20; theBannerRect.Height = (int)strSize.Height + 20; // just an example of decluttering if (scaleDenominator <= m_HideLabelsAbove) { mapGraphics.FillRectangle(DRAWING.Brushes.Aquamarine, theBannerRect); mapGraphics.DrawRectangle(DRAWING.Pens.Blue, theBannerRect); } mapGraphics.DrawString(displayTitle, m_Font_Large, DRAWING.Brushes.Blue, centerX - (strSize.Width / 2), 15); FalconViewOverlayLib.IFvOverlayPersistence theFileOverlay = this as FalconViewOverlayLib.IFvOverlayPersistence; if (theFileOverlay != null) { // Draw the file name for the overlay (if we have one) strSize = mapGraphics.MeasureString(theFileOverlay.FileSpecification, m_Font_Small); mapGraphics.DrawString(theFileOverlay.FileSpecification, m_Font_Small, DRAWING.Brushes.Blue, centerX - (strSize.Width / 2), 55); } } // Draw the data item //DRAWING.SolidBrush theBrush = new DRAWING.SolidBrush(m_UseColor); //mapGraphics.FillRectangle(theBrush, m_DummyItem); //// Draw a title name for the item (new name can be pasted from the clipboard if support added) //strSize = mapGraphics.MeasureString(m_DummyItemName, m_Font_Small); //mapGraphics.DrawString(m_DummyItemName, m_Font_Small, DRAWING.Brushes.Blue, // (m_DummyItem.X + m_DummyItem.Width / 2) - (strSize.Width / 2), // (m_DummyItem.Y + m_DummyItem.Height * 0.8f) - (strSize.Height / 2)); //Austen: Working fvw.Layer myLayer = new fvw.Layer(); //fvw.IGPS myGPS = new fvw.GPSClass(); // myGPS.AddPoint(GetConnectedHandle(), 46.5452, 29.2538, 0, 0, 0, 0, DateTime.Now); // Draw FingDraw = new Draw(); // FingDraw.FingDrawEllipse(); DRAWING.SolidBrush lineBrush = new DRAWING.SolidBrush(DRAWING.Color.Red); DRAWING.Point Point1 = new DRAWING.Point(200, 200); DRAWING.Point Point2 = new DRAWING.Point(400, 400); DRAWING.Pen Pen1 = new DRAWING.Pen(lineBrush, 3); mapGraphics.DrawLine(Pen1, Point1, Point2); //FalconViewOverlayLib.IFvOverlay curOverlay = this as FalconViewOverlayLib.IFvOverlay // Draw something to exercise the time sensitive nature of the overlay // // This section draws the display time from the Playback dialog on the map // if the wizard implemented the IFvPlaybackEventsObserver interface on the overlay. // // IMPORTANT:: Overlays should use the m_DisplayTime member variable rather than // this "long" method of determining the current time on the overlay. This is a // convenience for the wizard only FalconViewOverlayLib.IFvPlaybackEventsObserver thisOverlay = this as FalconViewOverlayLib.IFvPlaybackEventsObserver; if (thisOverlay != null) { DateTime theDisplayTime; // TODO: Simplify this line // bool UsePlaybackTime = m_TheOverlay.m_UsePlaybackTime; System.Reflection.FieldInfo fi = thisOverlay.GetType().GetField("m_UsePlaybackTime"); bool UsePlaybackTime = (bool)fi.GetValue(this); if (UsePlaybackTime) { fi = thisOverlay.GetType().GetField("m_DisplayTime"); theDisplayTime = (DateTime)fi.GetValue(this); } else { theDisplayTime = DateTime.Now; } string displayTime = theDisplayTime.ToShortTimeString(); strSize = mapGraphics.MeasureString(displayTime, m_Font_Small); mapGraphics.DrawString(displayTime, m_Font_Small, DRAWING.Brushes.Blue, (m_DummyItem.X + m_DummyItem.Width / 2) - (strSize.Width / 2), (m_DummyItem.Y + m_DummyItem.Height / 5) - (strSize.Height / 2)); } } } catch (Exception) { // Block exceptions from being passed on to FalconView } finally { // Clean up any items aquired during the draw theActiveMap = null; theSettableMapProj = null; theGC = null; } }
/// <summary> Called whenever the user clicks on one of the toolbar buttons on the toolbar returned by ActivateEditor /// </summary> /// <param name="pMapView">the current map view /// </param> /// <param name="lButtonCommandId">lButtonCommandId zero-based index of the button that was clicked /// </param> /// <remarks> /// If a toolbar "object" is used rather than implemented on "this", then prefer the OnButtonPressed event /// of the IFvToolbarEvents interface on that object /// </remarks> public void OnToolbarButtonClick(FalconViewOverlayLib.IFvMapView pMapView, int lButtonCommandId) { // TODO: Respond to the toolbar button press if (lButtonCommandId == m_SelectionButton) { m_EditorState = EditorState.VIEWDATA; } else if (lButtonCommandId == m_DropPointsButton) { m_EditorState = EditorState.ADDPOINTS; } else if (lButtonCommandId == m_QueryButton) { m_EditorState = EditorState.AOI_SELECT; } else if (lButtonCommandId == m_EraseButton) { m_EditorState = EditorState.DELETEMODE; } // Then Set the UI state of the toolbar SetButtonStates(); }
/// <summary> Called when the user leaves this editor mode /// </summary> /// <param name="pMapView"> pMapView the current map view /// </param> public void DeactivateEditor(FalconViewOverlayLib.IFvMapView pMapView) { FvOverlay.CurrentEditor = null; FvOverlay.EditMode = false; }
/// <summary> Called when the editor mode is activated. /// </summary> /// <param name="pMapView"> pMapView the current map view /// </param> public void ActivateEditor(FalconViewOverlayLib.IFvMapView pMapView) { FvOverlay.CurrentEditor = this; FvOverlay.EditMode = true; }
/// <summary> Called when the property page is created by the overlay options dialog. /// </summary> /// <param name="propertyPageGuid"> uid specifed in the property pages config file /// </param> /// <param name="pMapView"> The Current Map View object /// </param> /// <param name="hWndParent"> the HWND of the parent window in the overlay options /// dialog box. The property page should be created as a child of this window /// </param> /// <param name="pEvents"> can implement IMapChangeNotifyEvents, IDisplayChangeNotifyEvents, and IFvPropertyPageEvents /// </param> public void OnCreate(Guid propertyPageGuid, FalconViewOverlayLib.IFvMapView pMapView, int hWndParent, object pEvents) { // The GUID of the property page that is being requested. i.e. "this" provides several configurations of the // property control (itself). // Save aside the callback objects for use m_MapView = pMapView; m_MapChangeNotifyEvents = pEvents as FalconViewOverlayLib.IMapChangeNotifyEvents; m_DisplayChangeNotifyEvents = pEvents as FalconViewOverlayLib.IDisplayChangeNotifyEvents; m_PropertyPageNotifyEvents = pEvents as FalconViewOverlayLib.IPropertyPageNotifyEvents; // Critical step to get the draw notification SetParent(Handle, new IntPtr(hWndParent)); int OverlayOnTop = m_MapView.OverlayManager.SelectByOverlayDescGuid(new Guid("f9109e69-faa5-4144-9b74-aaf6fd933d7d")); if (OverlayOnTop == 1) { m_TheOverlay = m_MapView.OverlayManager.CurrentOverlay as FvOverlay; } else { do { int result = m_MapView.OverlayManager.MoveNext(); if (result == 0) break; m_TheOverlay = m_MapView.OverlayManager.CurrentOverlay as FvOverlay; } while (m_TheOverlay == null); } PreferenceClass thePrefs = null; if (m_TheOverlay != null) thePrefs = PreferenceClass.CreateFromString(m_TheOverlay.GetPreferences()); else thePrefs = new PreferenceClass(); SetSelectedItem(thePrefs.m_HideAbove, m_HideAboveCB); SetSelectedItem(thePrefs.m_HideLabelsAbove, m_HideLabelsAboveCB); m_OverlayBannerCk.Checked = thePrefs.m_ShowBanner; RBBlueIcons.Checked = thePrefs.m_UseBlueIcons; RBRedIcons.Checked = !thePrefs.m_UseBlueIcons; }