private void DrawGPSInfo(IDynamicDisplay dynamicDisplay, IPoint gpsPosition) { // altitude is already available string course; string speed; lock (m_bikePositionInfo) { course = string.Format("Course {0} DEG", m_bikePositionInfo.course.ToString("###.##")); speed = string.Format("Speed {0} MPH", m_bikePositionInfo.speed.ToString("###.##")); } string gpsInfo = string.Format("{0}\n{1}\n{2}", course, speed, m_altitudeString); m_textGlyph.SetAnchor(-35.0f, -47.0f); m_dynamicSymbolProperties.set_DynamicGlyph(esriDynamicSymbolType.esriDSymbolText, m_textGlyph); m_dynamicSymbolProperties.TextBoxUseDynamicFillSymbol = true; m_dynamicSymbolProperties.set_Heading(esriDynamicSymbolType.esriDSymbolText, 0.0f); m_dynamicSymbolProperties.SetColor(esriDynamicSymbolType.esriDSymbolText, 0.0f, 0.8f, 0.0f, 1.0f); m_dynamicSymbolProperties.SetScale(esriDynamicSymbolType.esriDSymbolText, 1.0f, 1.0f); m_dynamicSymbolProperties.SetColor(esriDynamicSymbolType.esriDSymbolFill, 0.0f, 0.0f, 0.0f, 0.6f); m_dynamicSymbolProperties.TextBoxHorizontalAlignment = esriTextHorizontalAlignment.esriTHALeft; dynamicDisplay.DrawText(m_gpsPosition, gpsInfo); m_dynamicSymbolProperties.set_DynamicGlyph(esriDynamicSymbolType.esriDSymbolMarker, m_gpsGlyph); m_dynamicSymbolProperties.SetColor(esriDynamicSymbolType.esriDSymbolMarker, 1.0f, 1.0f, 1.0f, 1.0f); m_dynamicSymbolProperties.SetScale(esriDynamicSymbolType.esriDSymbolMarker, m_gpsSymbolScale, m_gpsSymbolScale); m_dynamicSymbolProperties.set_RotationAlignment(esriDynamicSymbolType.esriDSymbolMarker, esriDynamicSymbolRotationAlignment.esriDSRANorth); m_dynamicSymbolProperties.set_Heading(esriDynamicSymbolType.esriDSymbolMarker, (float)(m_heading - 90)); dynamicDisplay.DrawMarker(m_gpsPosition); if (m_drawCycles % 5 == 0) { // increment the symbol size m_gpsSymbolScale += 0.05f; if (m_gpsSymbolScale > 1.2f) { m_gpsSymbolScale = 0.8f; } } m_drawCycles++; if (m_drawCycles == 5) { m_drawCycles = 0; } }
void OnAfterDynamicDraw(esriDynamicMapDrawPhase DynamicMapDrawPhase, IDisplay Display, IDynamicDisplay dynamicDisplay) { if (DynamicMapDrawPhase != esriDynamicMapDrawPhase.esriDMDPDynamicLayers) { return; } if (m_bDrawOnce) { //cast the DynamicDisplay into DynamicGlyphFactory m_dynamicGlyphFactory = dynamicDisplay.DynamicGlyphFactory as IDynamicGlyphFactory2; //cast the DynamicDisplay into DynamicSymbolProperties m_dynamicSymbolProps = dynamicDisplay as IDynamicSymbolProperties2; //create the VW dynamic marker glyph from the embedded bitmap resource Bitmap bitmap = new Bitmap(GetType(), "VW.bmp"); //get bitmap handler int hBmp = bitmap.GetHbitmap().ToInt32(); //set white transparency color IColor whiteTransparencyColor = ESRI.ArcGIS.ADF.Connection.Local.Converter.ToRGBColor(Color.FromArgb(0, 0, 0)) as IColor; //get the VM dynamic marker glyph m_VWmarkerGlyph = m_dynamicGlyphFactory.CreateDynamicGlyphFromBitmap(esriDynamicGlyphType.esriDGlyphMarker, hBmp, false, whiteTransparencyColor); m_bDrawOnce = false; } //set the symbol alignment so that it will align with towards the symbol heading m_dynamicSymbolProps.set_RotationAlignment(esriDynamicSymbolType.esriDSymbolMarker, esriDynamicSymbolRotationAlignment.esriDSRANorth); //set the symbol's properties m_dynamicSymbolProps.set_DynamicGlyph(esriDynamicSymbolType.esriDSymbolMarker, m_VWmarkerGlyph); m_dynamicSymbolProps.SetScale(esriDynamicSymbolType.esriDSymbolMarker, 1.3f, 1.3f); m_dynamicSymbolProps.SetColor(esriDynamicSymbolType.esriDSymbolMarker, 1.0f, 1.0f, 0.0f, 1.0f); // yellow //set the heading of the current symbol m_dynamicSymbolProps.set_Heading(esriDynamicSymbolType.esriDSymbolMarker, (float)m_navigationData.Azimuth); //draw the current location dynamicDisplay.DrawMarker(m_point); }
private void DrawHeartRateAnimation(IDynamicDisplay dynamicDisplay, IPoint bikePoint) { m_dynamicSymbolProperties.set_DynamicGlyph(esriDynamicSymbolType.esriDSymbolMarker, m_heartRateGlyph[m_heartRateCounter]); m_dynamicSymbolProperties.SetColor(esriDynamicSymbolType.esriDSymbolMarker, 1.0f, 1.0f, 1.0f, 1.0f); m_dynamicSymbolProperties.SetScale(esriDynamicSymbolType.esriDSymbolMarker, 1.0f, 1.0f); m_dynamicSymbolProperties.set_RotationAlignment(esriDynamicSymbolType.esriDSymbolMarker, esriDynamicSymbolRotationAlignment.esriDSRAScreen); m_dynamicSymbolProperties.set_Heading(esriDynamicSymbolType.esriDSymbolMarker, 0.0f); dynamicDisplay.DrawMarker(bikePoint); m_textGlyph.SetAnchor(-35.0f, -50.0f); m_dynamicSymbolProperties.set_DynamicGlyph(esriDynamicSymbolType.esriDSymbolText, m_textGlyph); m_dynamicSymbolProperties.TextBoxUseDynamicFillSymbol = true; m_dynamicSymbolProperties.SetColor(esriDynamicSymbolType.esriDSymbolText, 0.0f, 0.8f, 0.0f, 1.0f); m_dynamicSymbolProperties.SetColor(esriDynamicSymbolType.esriDSymbolFill, 0.0f, 0.0f, 0.0f, 1.0f); m_dynamicSymbolProperties.TextBoxHorizontalAlignment = esriTextHorizontalAlignment.esriTHALeft; dynamicDisplay.DrawText(bikePoint, m_heartRateString); m_textGlyph.SetAnchor(-20.0f, -30.0f); m_dynamicSymbolProperties.set_DynamicGlyph(esriDynamicSymbolType.esriDSymbolText, m_textGlyph); dynamicDisplay.DrawText(bikePoint, m_altitudeString); if (m_drawCycles % 5 == 0) { m_heartRateCounter++; if (m_heartRateCounter > 4) { m_heartRateCounter = 0; } } m_drawCycles++; if (m_drawCycles == 5) { m_drawCycles = 0; } }
/// <summary> /// Draw the layer while in dynamic mode /// </summary> /// <param name="DynamicDrawPhase"></param> /// <param name="Display"></param> /// <param name="DynamicDisplay"></param> public override void DrawDynamicLayer(esriDynamicDrawPhase DynamicDrawPhase, IDisplay Display, IDynamicDisplay DynamicDisplay) { if (DynamicDrawPhase != esriDynamicDrawPhase.esriDDPCompiled) return; if (!m_bValid || !m_visible) return; if (m_bDDOnce) { m_dynamicGlyphFactory = DynamicDisplay.DynamicGlyphFactory as IDynamicGlyphFactory2; m_dynamicSymbolProperties = DynamicDisplay as IDynamicSymbolProperties2; m_dynamicCompoundMarker = DynamicDisplay as IDynamicCompoundMarker2; m_textGlyph = m_dynamicGlyphFactory.get_DynamicGlyph(1, esriDynamicGlyphType.esriDGlyphText, 1); // create glyph for the selection symbol if (m_selectionSymbol == null) InitializeSelectionSymbol(); m_selectionGlyph = m_dynamicGlyphFactory.CreateDynamicGlyph(m_selectionSymbol); m_bDDOnce = false; } m_display = Display; double lat, lon; int iconCode; int iconWidth = 0; bool selected; IDynamicGlyph dynamicGlyph = null; float symbolSized; string citiName = string.Empty; string temperature = string.Empty; //loop through the rows. Draw each row that has a shape foreach (DataRow row in m_table.Rows) { //get the Lat/Lon of the item lat = Convert.ToDouble(row[3]); lon = Convert.ToDouble(row[4]); //get the icon ID iconCode = Convert.ToInt32(row[8]); // get citiname and temperature citiName = Convert.ToString(row[2]); temperature = string.Format("{0} F", row[5]); //get the selection state of the item selected = Convert.ToBoolean(row[13]); //search for the symbol in the symbology table dynamicGlyph = GetDynamicGlyph(m_dynamicGlyphFactory, iconCode, row, out iconWidth); if (null == dynamicGlyph) continue; m_point.X = lon; m_point.Y = lat; m_point.SpatialReference = m_spatialRef; //reproject the point to the DataFrame's spatial reference if (null != m_spatialRef && m_mapSpatialRef.FactoryCode != m_layerSRFactoryCode) m_point.Project(m_mapSpatialRef); symbolSized = 1.35f * (float)(m_symbolSize / (double)iconWidth); // draw the weather item // 1. set the whether symbol properties m_dynamicSymbolProperties.set_DynamicGlyph(esriDynamicSymbolType.esriDSymbolMarker, dynamicGlyph); m_dynamicSymbolProperties.set_RotationAlignment(esriDynamicSymbolType.esriDSymbolMarker, esriDynamicSymbolRotationAlignment.esriDSRAScreen); m_dynamicSymbolProperties.set_Heading(esriDynamicSymbolType.esriDSymbolMarker, 0.0f); m_dynamicSymbolProperties.SetColor(esriDynamicSymbolType.esriDSymbolMarker, 1.0f, 1.0f, 1.0f, 1.0f); m_dynamicSymbolProperties.SetScale(esriDynamicSymbolType.esriDSymbolMarker, symbolSized, symbolSized); m_dynamicSymbolProperties.set_Smooth(esriDynamicSymbolType.esriDSymbolMarker, false); // 2. set the text properties m_dynamicSymbolProperties.set_DynamicGlyph(esriDynamicSymbolType.esriDSymbolText, m_textGlyph); m_dynamicSymbolProperties.set_RotationAlignment(esriDynamicSymbolType.esriDSymbolMarker, esriDynamicSymbolRotationAlignment.esriDSRAScreen); m_dynamicSymbolProperties.set_Heading(esriDynamicSymbolType.esriDSymbolText, 0.0f); m_dynamicSymbolProperties.SetColor(esriDynamicSymbolType.esriDSymbolText, 0.0f, 0.85f, 0.0f, 1.0f); m_dynamicSymbolProperties.SetScale(esriDynamicSymbolType.esriDSymbolText, 1.0f, 1.0f); m_dynamicSymbolProperties.set_Smooth(esriDynamicSymbolType.esriDSymbolText, false); m_dynamicSymbolProperties.TextBoxUseDynamicFillSymbol = false; m_dynamicSymbolProperties.TextBoxHorizontalAlignment = esriTextHorizontalAlignment.esriTHACenter; m_dynamicSymbolProperties.TextRightToLeft = false; // draw both the icon and the text as a compound marker m_dynamicCompoundMarker.DrawCompoundMarker2(m_point, temperature, citiName); if (selected) // draw the selected symbol { m_dynamicSymbolProperties.SetColor(esriDynamicSymbolType.esriDSymbolMarker, 0.0f, 1.0f, 1.0f, 1.0f); m_dynamicSymbolProperties.set_DynamicGlyph(esriDynamicSymbolType.esriDSymbolMarker, m_selectionGlyph); DynamicDisplay.DrawMarker(m_point); } } base.m_bIsCompiledDirty = false; }
void OnAfterDynamicDraw(esriDynamicMapDrawPhase DynamicMapDrawPhase, IDisplay Display, IDynamicDisplay dynamicDisplay) { if (DynamicMapDrawPhase != esriDynamicMapDrawPhase.esriDMDPDynamicLayers) return; if (m_bDrawOnce) { //cast the DynamicDisplay into DynamicGlyphFactory m_dynamicGlyphFactory = dynamicDisplay.DynamicGlyphFactory as IDynamicGlyphFactory2; //cast the DynamicDisplay into DynamicSymbolProperties m_dynamicSymbolProps = dynamicDisplay as IDynamicSymbolProperties2; //create the VW dynamic marker glyph from the embedded bitmap resource Bitmap bitmap = new Bitmap(GetType(), "VW.bmp"); //get bitmap handler int hBmp = bitmap.GetHbitmap().ToInt32(); //set white transparency color IColor whiteTransparencyColor = ESRI.ArcGIS.ADF.Connection.Local.Converter.ToRGBColor(Color.FromArgb(0, 0, 0)) as IColor; //get the VM dynamic marker glyph m_VWmarkerGlyph = m_dynamicGlyphFactory.CreateDynamicGlyphFromBitmap(esriDynamicGlyphType.esriDGlyphMarker, hBmp, false, whiteTransparencyColor); m_bDrawOnce = false; } //set the symbol alignment so that it will align with towards the symbol heading m_dynamicSymbolProps.set_RotationAlignment(esriDynamicSymbolType.esriDSymbolMarker, esriDynamicSymbolRotationAlignment.esriDSRANorth); //set the symbol's properties m_dynamicSymbolProps.set_DynamicGlyph(esriDynamicSymbolType.esriDSymbolMarker, m_VWmarkerGlyph); m_dynamicSymbolProps.SetScale(esriDynamicSymbolType.esriDSymbolMarker, 1.3f, 1.3f); m_dynamicSymbolProps.SetColor(esriDynamicSymbolType.esriDSymbolMarker, 1.0f, 1.0f, 0.0f, 1.0f); // yellow //set the heading of the current symbol m_dynamicSymbolProps.set_Heading(esriDynamicSymbolType.esriDSymbolMarker, (float)m_navigationData.Azimuth); //draw the current location dynamicDisplay.DrawMarker(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; }
private void DrawGPSInfo(IDynamicDisplay dynamicDisplay, IPoint gpsPosition) { // altitude is already available string course; string speed; lock (m_bikePositionInfo) { course = string.Format("Course {0} DEG", m_bikePositionInfo.course.ToString("###.##")); speed = string.Format("Speed {0} MPH", m_bikePositionInfo.speed.ToString("###.##")); } string gpsInfo = string.Format("{0}\n{1}\n{2}", course, speed, m_altitudeString); m_textGlyph.SetAnchor(-35.0f, -47.0f); m_dynamicSymbolProperties.set_DynamicGlyph(esriDynamicSymbolType.esriDSymbolText, m_textGlyph); m_dynamicSymbolProperties.TextBoxUseDynamicFillSymbol = true; m_dynamicSymbolProperties.set_Heading(esriDynamicSymbolType.esriDSymbolText, 0.0f); m_dynamicSymbolProperties.SetColor(esriDynamicSymbolType.esriDSymbolText, 0.0f, 0.8f, 0.0f, 1.0f); m_dynamicSymbolProperties.SetScale(esriDynamicSymbolType.esriDSymbolText, 1.0f, 1.0f); m_dynamicSymbolProperties.SetColor(esriDynamicSymbolType.esriDSymbolFill, 0.0f, 0.0f, 0.0f, 0.6f); m_dynamicSymbolProperties.TextBoxHorizontalAlignment = esriTextHorizontalAlignment.esriTHALeft; dynamicDisplay.DrawText(m_gpsPosition, gpsInfo); m_dynamicSymbolProperties.set_DynamicGlyph(esriDynamicSymbolType.esriDSymbolMarker, m_gpsGlyph); m_dynamicSymbolProperties.SetColor(esriDynamicSymbolType.esriDSymbolMarker, 1.0f, 1.0f, 1.0f, 1.0f); m_dynamicSymbolProperties.SetScale(esriDynamicSymbolType.esriDSymbolMarker, m_gpsSymbolScale, m_gpsSymbolScale); m_dynamicSymbolProperties.set_RotationAlignment(esriDynamicSymbolType.esriDSymbolMarker, esriDynamicSymbolRotationAlignment.esriDSRANorth); m_dynamicSymbolProperties.set_Heading(esriDynamicSymbolType.esriDSymbolMarker, (float)(m_heading - 90)); dynamicDisplay.DrawMarker(m_gpsPosition); if (m_drawCycles % 5 == 0) { // increment the symbol size m_gpsSymbolScale += 0.05f; if (m_gpsSymbolScale > 1.2f) m_gpsSymbolScale = 0.8f; } m_drawCycles++; if (m_drawCycles == 5) m_drawCycles = 0; }
private void DrawHeartRateAnimation(IDynamicDisplay dynamicDisplay, IPoint bikePoint) { m_dynamicSymbolProperties.set_DynamicGlyph(esriDynamicSymbolType.esriDSymbolMarker, m_heartRateGlyph[m_heartRateCounter]); m_dynamicSymbolProperties.SetColor(esriDynamicSymbolType.esriDSymbolMarker, 1.0f, 1.0f, 1.0f, 1.0f); m_dynamicSymbolProperties.SetScale(esriDynamicSymbolType.esriDSymbolMarker, 1.0f, 1.0f); m_dynamicSymbolProperties.set_RotationAlignment(esriDynamicSymbolType.esriDSymbolMarker, esriDynamicSymbolRotationAlignment.esriDSRAScreen); m_dynamicSymbolProperties.set_Heading(esriDynamicSymbolType.esriDSymbolMarker, 0.0f); dynamicDisplay.DrawMarker(bikePoint); m_textGlyph.SetAnchor(-35.0f, -50.0f); m_dynamicSymbolProperties.set_DynamicGlyph(esriDynamicSymbolType.esriDSymbolText, m_textGlyph); m_dynamicSymbolProperties.TextBoxUseDynamicFillSymbol = true; m_dynamicSymbolProperties.SetColor(esriDynamicSymbolType.esriDSymbolText, 0.0f, 0.8f, 0.0f, 1.0f); m_dynamicSymbolProperties.SetColor(esriDynamicSymbolType.esriDSymbolFill, 0.0f, 0.0f, 0.0f, 1.0f); m_dynamicSymbolProperties.TextBoxHorizontalAlignment = esriTextHorizontalAlignment.esriTHALeft; dynamicDisplay.DrawText(bikePoint, m_heartRateString); m_textGlyph.SetAnchor(-20.0f, -30.0f); m_dynamicSymbolProperties.set_DynamicGlyph(esriDynamicSymbolType.esriDSymbolText, m_textGlyph); dynamicDisplay.DrawText(bikePoint, m_altitudeString); if (m_drawCycles % 5 == 0) { m_heartRateCounter++; if (m_heartRateCounter > 4) m_heartRateCounter = 0; } m_drawCycles++; if (m_drawCycles == 5) m_drawCycles = 0; }
private void OnAfterDynamicDraw(esriDynamicMapDrawPhase DynamicMapDrawPhase, IDisplay Display, IDynamicDisplay dynamicDisplay) { if (DynamicMapDrawPhase != esriDynamicMapDrawPhase.esriDMDPDynamicLayers) return; // initialize symbology for dynamic drawing if (m_bOnce) { // create the glyphs for the bike position as well as for the route IDynamicGlyphFactory2 dynamicGlyphFactory = dynamicDisplay.DynamicGlyphFactory as IDynamicGlyphFactory2; IColor whiteTransparentColor = (IColor)ESRI.ArcGIS.ADF.Connection.Local.Converter.ToRGBColor(Color.FromArgb(255, 255, 255)); Bitmap bitmap = new Bitmap(GetType(), "Icons.bicycle-icon.bmp"); m_bikeGlyph = dynamicGlyphFactory.CreateDynamicGlyphFromBitmap(esriDynamicGlyphType.esriDGlyphMarker, bitmap.GetHbitmap().ToInt32(), false, whiteTransparentColor); bitmap = new Bitmap(GetType(), "Icons.cat.bmp"); m_catGlyph = dynamicGlyphFactory.CreateDynamicGlyphFromBitmap(esriDynamicGlyphType.esriDGlyphMarker, bitmap.GetHbitmap().ToInt32(), false, whiteTransparentColor); bitmap = new Bitmap(GetType(), "Icons.gps.png"); m_gpsGlyph = dynamicGlyphFactory.CreateDynamicGlyphFromBitmap(esriDynamicGlyphType.esriDGlyphMarker, bitmap.GetHbitmap().ToInt32(), false, whiteTransparentColor); ISymbol routeSymbol = CreateBikeRouteSymbol(); m_bikeRouteGlyph = dynamicGlyphFactory.CreateDynamicGlyph(routeSymbol); // create the heart rate glyphs series CreateHeartRateAnimationGlyphs(dynamicGlyphFactory); // get the default internal text glyph m_textGlyph = dynamicGlyphFactory.get_DynamicGlyph(1, esriDynamicGlyphType.esriDGlyphText, 1); // do one time casting m_dynamicSymbolProperties = dynamicDisplay as IDynamicSymbolProperties2; m_dynamicCompoundMarker = dynamicDisplay as IDynamicCompoundMarker2; m_dynamicScreenDisplay = dynamicDisplay as IDynamicScreenDisplay; m_bOnce = false; } // draw the trail m_dynamicSymbolProperties.set_DynamicGlyph(esriDynamicSymbolType.esriDSymbolLine, m_bikeRouteGlyph); m_dynamicSymbolProperties.SetColor(esriDynamicSymbolType.esriDSymbolLine, 1.0f, 1.0f, 1.0f, 1.0f); m_dynamicSymbolProperties.SetScale(esriDynamicSymbolType.esriDSymbolLine, 1.0f, 1.0f); m_dynamicSymbolProperties.LineContinuePattern = true; dynamicDisplay.DrawPolyline(m_bikeRouteGeometry); if (m_playbackFormat == GPSPlaybackFormat.HST) { // adjust the bike lap additional info point to draw at the top left corner of the window m_additionalInfoPoint.Y = Display.DisplayTransformation.get_DeviceFrame().bottom - 70; // draw additional lap information DrawLapInfo(dynamicDisplay); // draw the heart-rate and altitude DrawHeartRateAnimation(dynamicDisplay, m_gpsPosition); // draw the current position as a marker glyph m_dynamicSymbolProperties.set_DynamicGlyph(esriDynamicSymbolType.esriDSymbolMarker, m_bikeGlyph); m_dynamicSymbolProperties.SetColor(esriDynamicSymbolType.esriDSymbolMarker, 1.0f, 1.0f, 1.0f, 1.0f); m_dynamicSymbolProperties.SetScale(esriDynamicSymbolType.esriDSymbolMarker, 1.2f, 1.2f); m_dynamicSymbolProperties.set_RotationAlignment(esriDynamicSymbolType.esriDSymbolMarker, esriDynamicSymbolRotationAlignment.esriDSRANorth); m_dynamicSymbolProperties.set_Heading(esriDynamicSymbolType.esriDSymbolMarker, (float)(m_heading - 90)); dynamicDisplay.DrawMarker(m_gpsPosition); } else { DrawGPSInfo(dynamicDisplay, m_gpsPosition); } }
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; }
private void OnAfterDynamicDraw(esriDynamicMapDrawPhase DynamicMapDrawPhase, IDisplay Display, IDynamicDisplay dynamicDisplay) { if (DynamicMapDrawPhase != esriDynamicMapDrawPhase.esriDMDPDynamicLayers) { return; } // initialize symbology for dynamic drawing if (m_bOnce) { // create the glyphs for the bike position as well as for the route IDynamicGlyphFactory2 dynamicGlyphFactory = dynamicDisplay.DynamicGlyphFactory as IDynamicGlyphFactory2; IColor whiteTransparentColor = (IColor)ESRI.ArcGIS.ADF.Connection.Local.Converter.ToRGBColor(Color.FromArgb(255, 255, 255)); Bitmap bitmap = new Bitmap(GetType(), "Icons.bicycle-icon.bmp"); m_bikeGlyph = dynamicGlyphFactory.CreateDynamicGlyphFromBitmap(esriDynamicGlyphType.esriDGlyphMarker, bitmap.GetHbitmap().ToInt32(), false, whiteTransparentColor); bitmap = new Bitmap(GetType(), "Icons.cat.bmp"); m_catGlyph = dynamicGlyphFactory.CreateDynamicGlyphFromBitmap(esriDynamicGlyphType.esriDGlyphMarker, bitmap.GetHbitmap().ToInt32(), false, whiteTransparentColor); bitmap = new Bitmap(GetType(), "Icons.gps.png"); m_gpsGlyph = dynamicGlyphFactory.CreateDynamicGlyphFromBitmap(esriDynamicGlyphType.esriDGlyphMarker, bitmap.GetHbitmap().ToInt32(), false, whiteTransparentColor); ISymbol routeSymbol = CreateBikeRouteSymbol(); m_bikeRouteGlyph = dynamicGlyphFactory.CreateDynamicGlyph(routeSymbol); // create the heart rate glyphs series CreateHeartRateAnimationGlyphs(dynamicGlyphFactory); // get the default internal text glyph m_textGlyph = dynamicGlyphFactory.get_DynamicGlyph(1, esriDynamicGlyphType.esriDGlyphText, 1); // do one time casting m_dynamicSymbolProperties = dynamicDisplay as IDynamicSymbolProperties2; m_dynamicCompoundMarker = dynamicDisplay as IDynamicCompoundMarker2; m_dynamicScreenDisplay = dynamicDisplay as IDynamicScreenDisplay; m_bOnce = false; } // draw the trail m_dynamicSymbolProperties.set_DynamicGlyph(esriDynamicSymbolType.esriDSymbolLine, m_bikeRouteGlyph); m_dynamicSymbolProperties.SetColor(esriDynamicSymbolType.esriDSymbolLine, 1.0f, 1.0f, 1.0f, 1.0f); m_dynamicSymbolProperties.SetScale(esriDynamicSymbolType.esriDSymbolLine, 1.0f, 1.0f); m_dynamicSymbolProperties.LineContinuePattern = true; dynamicDisplay.DrawPolyline(m_bikeRouteGeometry); if (m_playbackFormat == GPSPlaybackFormat.HST) { // adjust the bike lap additional info point to draw at the top left corner of the window m_additionalInfoPoint.Y = Display.DisplayTransformation.get_DeviceFrame().bottom - 70; // draw additional lap information DrawLapInfo(dynamicDisplay); // draw the heart-rate and altitude DrawHeartRateAnimation(dynamicDisplay, m_gpsPosition); // draw the current position as a marker glyph m_dynamicSymbolProperties.set_DynamicGlyph(esriDynamicSymbolType.esriDSymbolMarker, m_bikeGlyph); m_dynamicSymbolProperties.SetColor(esriDynamicSymbolType.esriDSymbolMarker, 1.0f, 1.0f, 1.0f, 1.0f); m_dynamicSymbolProperties.SetScale(esriDynamicSymbolType.esriDSymbolMarker, 1.2f, 1.2f); m_dynamicSymbolProperties.set_RotationAlignment(esriDynamicSymbolType.esriDSymbolMarker, esriDynamicSymbolRotationAlignment.esriDSRANorth); m_dynamicSymbolProperties.set_Heading(esriDynamicSymbolType.esriDSymbolMarker, (float)(m_heading - 90)); dynamicDisplay.DrawMarker(m_gpsPosition); } else { DrawGPSInfo(dynamicDisplay, m_gpsPosition); } }