/// <summary> /// DynamicMap AfterDynamicDraw event handler method /// </summary> /// <param name="DynamicMapDrawPhase"></param> /// <param name="Display"></param> /// <param name="dynamicDisplay"></param> private void OnAfterDynamicDraw(esriDynamicMapDrawPhase DynamicMapDrawPhase, IDisplay Display, IDynamicDisplay dynamicDisplay) { try { if (DynamicMapDrawPhase != esriDynamicMapDrawPhase.esriDMDPDynamicLayers) { return; } //make sure that the display is valid as well as that the layer is visible if (null == dynamicDisplay || null == Display) { return; } tagRECT rect = Display.DisplayTransformation.get_DeviceFrame(); float rotation = (float)Display.DisplayTransformation.Rotation; if (m_bOnce) { //need to cache all the DynamicDisplay stuff m_dynamicGlyphFactory = dynamicDisplay.DynamicGlyphFactory; m_dynamicDrawScreen = (IDynamicDrawScreen)dynamicDisplay; m_dynamicSymbolProps = (IDynamicSymbolProperties)dynamicDisplay; //set the screen coordinates of the char symbol m_point = new ESRI.ArcGIS.Geometry.PointClass(); CreateDynamicGlyphs(m_dynamicGlyphFactory); m_bOnce = false; } //draw the OpenGL compass GL.glPushMatrix(); GL.glLoadIdentity(); //use OpenGL to do the drawings DrawTicks(rect, rotation); GL.glPopMatrix(); //please note that while you are rotating the map, the numbers showing in the HUD are //different than the number reported by the rotation tool. The reason for that is that //the reported map rotation is the mathematical angle while the HUD shows the angle from //the north (the map's azimuth). DrawAzimuths(rect, rotation); } catch (Exception ex) { System.Windows.Forms.MessageBox.Show(ex.Message, "ERROR", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); } }
/// <summary> /// Creates the dynamic glyph used to draw the numbers in the HUD /// </summary> /// <param name="pDynamicGlyphFactory"></param> private void CreateDynamicGlyphs(IDynamicGlyphFactory pDynamicGlyphFactory) { try { //create the text glyph using a text symbol ITextSymbol textSymbol = new TextSymbolClass(); textSymbol.Size = 15.0; textSymbol.Angle = 0.0; textSymbol.VerticalAlignment = esriTextVerticalAlignment.esriTVACenter; textSymbol.HorizontalAlignment = esriTextHorizontalAlignment.esriTHACenter; textSymbol.Font = ESRI.ArcGIS.ADF.Connection.Local.Converter.ToStdFont(new Font("Arial", 15.0f, FontStyle.Regular)); m_textGlyph = pDynamicGlyphFactory.CreateDynamicGlyph((ISymbol)textSymbol); } catch (Exception ex) { System.Diagnostics.Trace.WriteLine(ex.Message); } }
private void DrawDynamicLogo(IDynamicDisplay dynamicDisplay) { if (m_bOnce) { //cast the DynamicDisplay into DynamicGlyphFactory m_dynamicGlyphFactory = dynamicDisplay.DynamicGlyphFactory; //cast the DynamicDisplay into DynamicSymbolProperties m_dynamicSymbolProps = dynamicDisplay as IDynamicSymbolProperties; m_dynamicDrawScreen = dynamicDisplay as IDynamicDrawScreen; //create the dynamic glyph for the logo m_logoGlyph = m_dynamicGlyphFactory.CreateDynamicGlyphFromFile(esriDynamicGlyphType.esriDGlyphMarker, m_logoPath, ESRI.ArcGIS.ADF.Connection.Local.Converter.ToRGBColor(Color.White)); m_point = new PointClass(); m_point.PutCoords(120, 160); m_bOnce = false; } m_dynamicSymbolProps.set_DynamicGlyph(esriDynamicSymbolType.esriDSymbolMarker, m_logoGlyph); m_dynamicSymbolProps.SetScale(esriDynamicSymbolType.esriDSymbolMarker, .435f, .435f); m_dynamicDrawScreen.DrawScreenMarker(m_point); }
private void DrawDynamicLogo(IDynamicDisplay dynamicDisplay) { if (m_bOnce) { //cast the DynamicDisplay into DynamicGlyphFactory m_dynamicGlyphFactory = dynamicDisplay.DynamicGlyphFactory; //cast the DynamicDisplay into DynamicSymbolProperties m_dynamicSymbolProps = dynamicDisplay as IDynamicSymbolProperties; m_dynamicDrawScreen = dynamicDisplay as IDynamicDrawScreen; //create the dynamic glyph for the logo m_logoGlyph = m_dynamicGlyphFactory.CreateDynamicGlyphFromFile(esriDynamicGlyphType.esriDGlyphMarker, m_logoPath, ESRI.ArcGIS.ADF.Connection.Local.Converter.ToRGBColor(Color.White)); m_point = new PointClass(); m_point.PutCoords(120, 160); m_bOnce = false; } m_dynamicSymbolProps.set_DynamicGlyph(esriDynamicSymbolType.esriDSymbolMarker, m_logoGlyph); m_dynamicSymbolProps.SetScale(esriDynamicSymbolType.esriDSymbolMarker, .435f, .435f); m_dynamicDrawScreen.DrawScreenMarker(m_point); }
public override void DrawDynamicLayer(esriDynamicDrawPhase DynamicDrawPhase, IDisplay Display, IDynamicDisplay DynamicDisplay) { if (DynamicDrawPhase != esriDynamicDrawPhase.esriDDPImmediate) { return; } if (!m_bValid || !m_visible) { return; } IEnvelope visibleExtent = Display.DisplayTransformation.FittedBounds; if (m_bOnce) { IDynamicGlyphFactory dynamicGlyphFactory = DynamicDisplay.DynamicGlyphFactory; m_dynamicSymbolProps = DynamicDisplay as IDynamicSymbolProperties2; ICharacterMarkerSymbol markerSymbol = new CharacterMarkerSymbolClass(); markerSymbol.Font = ESRI.ArcGIS.ADF.Connection.Local.Converter.ToStdFont(new Font("ESRI Default Marker", 25.0f, FontStyle.Bold)); markerSymbol.Size = 25.0; // set the symbol color to white markerSymbol.Color = (IColor)ESRI.ArcGIS.ADF.Connection.Local.Converter.ToRGBColor(Color.FromArgb(255, 255, 255)); markerSymbol.CharacterIndex = 92; // create the dynamic glyph m_myGlyph = dynamicGlyphFactory.CreateDynamicGlyph((ISymbol)markerSymbol); Random r = new Random(); double X = visibleExtent.XMin + r.NextDouble() * visibleExtent.Width; double Y = visibleExtent.YMin + r.NextDouble() * visibleExtent.Height; m_point = new PointClass(); m_point.PutCoords(X, Y); m_stepX = visibleExtent.Width / 250; m_stepY = visibleExtent.Height / 250; // start the update timer m_updateTimer.Enabled = true; m_bOnce = false; } // draw the marker m_dynamicSymbolProps.set_DynamicGlyph(esriDynamicSymbolType.esriDSymbolMarker, m_myGlyph); m_dynamicSymbolProps.SetColor(esriDynamicSymbolType.esriDSymbolMarker, 1.0f, 0.0f, 0.0f, 1.0f); m_dynamicSymbolProps.SetScale(esriDynamicSymbolType.esriDSymbolMarker, 1.0f, 1.0f); DynamicDisplay.DrawMarker(m_point); // update the point location for the next draw cycle m_point.X += m_stepX; m_point.Y += m_stepY; // make sure that the point fall within the visible extent if (m_point.X > visibleExtent.XMax) { m_stepX = -Math.Abs(m_stepX); } if (m_point.X < visibleExtent.XMin) { m_stepX = Math.Abs(m_stepX); } if (m_point.Y > visibleExtent.YMax) { m_stepY = -Math.Abs(m_stepY); } if (m_point.Y < visibleExtent.YMin) { m_stepY = Math.Abs(m_stepY); } // set the dirty flag to false since drawing is done. base.m_bIsImmediateDirty = false; }