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);
      }

      

    }
    /// <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;
    }
Esempio n. 3
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);
            }
        }