コード例 #1
0
        private void CreateHeartRateAnimationGlyphs(IDynamicGlyphFactory2 dynamicGlyphFactory)
        {
            IColor whiteTransparentColor = (IColor)ESRI.ArcGIS.ADF.Connection.Local.Converter.ToRGBColor(Color.FromArgb(255, 255, 255));

            m_heartRateGlyph = new IDynamicGlyph[5];
            string heartRateIcon;
            string heartIconBaseName = "Icons.valentine-heart";
            Bitmap bitmap            = null;
            int    imagesize         = 16;

            for (int i = 0; i < 5; i++)
            {
                heartRateIcon       = heartIconBaseName + imagesize + ".bmp";
                bitmap              = new Bitmap(GetType(), heartRateIcon);
                m_heartRateGlyph[i] = dynamicGlyphFactory.CreateDynamicGlyphFromBitmap(esriDynamicGlyphType.esriDGlyphMarker, bitmap.GetHbitmap().ToInt32(), false, whiteTransparentColor);
                m_heartRateGlyph[i].SetAnchor(20.0f, -40.0f);
                imagesize += 2;
            }
        }
コード例 #2
0
        /// <summary>
        /// create the layer's glyphs used to set the symbol of the dynamic-layer items
        /// </summary>
        /// <param name="pDynamicGlyphFactory"></param>
        private void CreateDynamicSymbols(IDynamicGlyphFactory2 pDynamicGlyphFactory)
        {
            try
            {
                //set the background color
                IColor color = ESRI.ArcGIS.ADF.Connection.Local.Converter.ToRGBColor(Color.FromArgb(255, 255, 255)) as IColor;

                // Create Character Marker Symbols glyph
                // --------------------------------------
                ICharacterMarkerSymbol characterMarkerSymbol = new CharacterMarkerSymbolClass();
                characterMarkerSymbol.Color          = color as IColor;
                characterMarkerSymbol.Font           = ESRI.ArcGIS.ADF.Connection.Local.Converter.ToStdFont(new Font("ESRI Environmental & Icons", 32));
                characterMarkerSymbol.Size           = 40;
                characterMarkerSymbol.Angle          = 0;
                characterMarkerSymbol.CharacterIndex = 36;

                //create the glyph from the marker symbol
                m_markerGlyphs[0] = pDynamicGlyphFactory.CreateDynamicGlyph(characterMarkerSymbol as ISymbol);

                characterMarkerSymbol.Size           = 32;
                characterMarkerSymbol.CharacterIndex = 224;

                //create the glyph from the marker symbol
                m_markerGlyphs[1] = pDynamicGlyphFactory.CreateDynamicGlyph(characterMarkerSymbol as ISymbol);

                // Create the glyph from embedded bitmap
                // -----------------------------------
                // Sets the transparency color
                IColor transparentColor = ESRI.ArcGIS.ADF.Connection.Local.Converter.ToRGBColor(Color.FromArgb(255, 255, 255)) as IColor;

                Bitmap bitmap = new Bitmap(GetType(), "B2.bmp");
                m_markerGlyphs[2] = pDynamicGlyphFactory.CreateDynamicGlyphFromBitmap(esriDynamicGlyphType.esriDGlyphMarker, bitmap.GetHbitmap().ToInt32(), false, transparentColor);

                // Create a glyph for the labels text, use the first 'internal' text glyph
                // ------------------------------------------------------------------------
                m_textGlyph = pDynamicGlyphFactory.get_DynamicGlyph(1, esriDynamicGlyphType.esriDGlyphText, 1);
            }
            catch (Exception ex)
            {
                System.Diagnostics.Trace.WriteLine(ex.Message);
            }
        }
コード例 #3
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);
        }
コード例 #4
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;
    }
コード例 #5
0
		private IDynamicGlyph GetDynamicGlyph(IDynamicGlyphFactory2 dynamicGlyphFactory, int iconCode, DataRow dbr, out int originalIconSize)
		{
      originalIconSize = 0;

      if (dynamicGlyphFactory == null)
				return null;
			
			string iconPath;
			int iconWidth, iconHeight;
			Bitmap bitmap = null;
			IDynamicGlyph dynamicGlyph = null;

			//search for an existing symbol in the table
			DataRow r = m_symbolTable.Rows.Find(iconCode);
			if (r == null)
			{
				iconPath = Convert.ToString(dbr[7]);
				bitmap = DownloadIcon(iconPath, out iconWidth, out iconHeight);
				if (bitmap != null)
				{
          originalIconSize = iconWidth;

          dynamicGlyph = dynamicGlyphFactory.CreateDynamicGlyphFromBitmap(esriDynamicGlyphType.esriDGlyphMarker,
																						 bitmap.GetHbitmap().ToInt32(),
																						 false,
																						 (IColor)ESRI.ArcGIS.ADF.Connection.Local.Converter.ToRGBColor(Color.FromArgb(255, 255, 255))
																						 );

					
          //update the symbol table
					r = m_symbolTable.NewRow();
					lock (m_symbolTable)
					{
						r[1] = iconCode;
						r[3] = iconWidth;
						r[4] = iconHeight;
						r[5] = dynamicGlyph;
						r[6] = bitmap;
						m_symbolTable.Rows.Add(r);
					}
				}
			}
			else
			{
				if (r[5] is DBNull)
				{
					if (r[6] is DBNull)
					{
						iconPath = Convert.ToString(dbr[7]);
						bitmap = DownloadIcon(iconPath, out iconWidth, out iconHeight);
						if (bitmap == null)
							return null;

            originalIconSize = iconWidth;

						lock (m_symbolTable)
						{
              r[3] = iconWidth;
              r[4] = iconHeight;
              r[6] = bitmap;
						}
					}
					else
					{
            originalIconSize = Convert.ToInt32(r[3]);
            bitmap = (Bitmap)r[6];
					}
					dynamicGlyph = dynamicGlyphFactory.CreateDynamicGlyphFromBitmap(esriDynamicGlyphType.esriDGlyphMarker,
																						 bitmap.GetHbitmap().ToInt32(),
																						 false,
																						 (IColor)ESRI.ArcGIS.ADF.Connection.Local.Converter.ToRGBColor(Color.FromArgb(255, 255, 255))
																						 );

					lock (m_symbolTable)
					{
						r[5] = dynamicGlyph;
					}
				}
				else
				{
          originalIconSize = Convert.ToInt32(r[3]);
					dynamicGlyph = (IDynamicGlyph)r[5];
				}
			}

			return dynamicGlyph;
		}
コード例 #6
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);
    }
コード例 #7
0
        /// <summary>
        /// The dynamic layer draw method
        /// </summary>
        /// <param name="DynamicDrawPhase">the current drawphase of the dynamic drawing</param>
        /// <param name="Display">the ActiveView's display</param>
        /// <param name="DynamicDisplay">the ActiveView's dynamic display</param>
        public override void DrawDynamicLayer(ESRI.ArcGIS.Display.esriDynamicDrawPhase DynamicDrawPhase, ESRI.ArcGIS.Display.IDisplay Display, ESRI.ArcGIS.Display.IDynamicDisplay DynamicDisplay)
        {
            try
            {
                //make sure that the display is valid as well as that the layer is visible
                if (null == DynamicDisplay || null == Display || !this.m_visible)
                {
                    return;
                }

                //make sure that the current drawphase is immediate. In this sample there is no use of the
                //compiled drawPhase. Use the esriDDPCompiled drawPhase in order to draw semi-static items (items
                //which have update rate lower than the display update rate).
                if (DynamicDrawPhase != esriDynamicDrawPhase.esriDDPImmediate)
                {
                    return;
                }

                if (m_bOnce)
                {
                    //cast the DynamicDisplay into DynamicGlyphFactory
                    m_dynamicGlyphFactory = DynamicDisplay.DynamicGlyphFactory as IDynamicGlyphFactory2;
                    //cast the DynamicDisplay into DynamicSymbolProperties
                    m_dynamicSymbolProps = DynamicDisplay as IDynamicSymbolProperties;
                    //cast the compound marker symbol
                    m_dynamicCompoundMarker = DynamicDisplay as IDynamicCompoundMarker;

                    IntializeLayerData(Display.DisplayTransformation);

                    GetLayerExtent();

                    m_bOnce = false;
                }

                //get the display fitted bounds
                m_extentMaxX = Display.DisplayTransformation.FittedBounds.XMax;
                m_extentMaxY = Display.DisplayTransformation.FittedBounds.YMax;
                m_extentMinX = Display.DisplayTransformation.FittedBounds.XMin;
                m_extentMinY = Display.DisplayTransformation.FittedBounds.YMin;

                //create the dynamic symbols for the layer
                if (!m_bDynamicGlyphsCreated)
                {
                    this.CreateDynamicSymbols(m_dynamicGlyphFactory);
                    m_bDynamicGlyphsCreated = true;
                }

                double X, Y, heading;
                int    type;
                //iterate through the layers' items
                foreach (DataRow r in m_table.Rows)
                {
                    if (r[1] is DBNull || r[2] is DBNull)
                    {
                        continue;
                    }

                    //get the item's coordinate, heading and type
                    X       = Convert.ToDouble(r[1]);
                    Y       = Convert.ToDouble(r[2]);
                    heading = Convert.ToDouble(r[5]);
                    type    = Convert.ToInt32(r[6]);

                    //assign the items' coordinate to the cached point
                    m_point.PutCoords(X, Y);

                    //set the symbol's properties
                    switch (type)
                    {
                    case 0:
                        //set the heading of the current symbols' text
                        m_dynamicSymbolProps.set_Heading(esriDynamicSymbolType.esriDSymbolText, 0.0f);
                        m_dynamicSymbolProps.set_Heading(esriDynamicSymbolType.esriDSymbolMarker, 0.0f);

                        //set the symbol alignment so that it will align with the screen
                        m_dynamicSymbolProps.set_RotationAlignment(esriDynamicSymbolType.esriDSymbolMarker, esriDynamicSymbolRotationAlignment.esriDSRAScreen);

                        //set the text alignment so that it will also align with the screen
                        m_dynamicSymbolProps.set_RotationAlignment(esriDynamicSymbolType.esriDSymbolText, esriDynamicSymbolRotationAlignment.esriDSRAScreen);

                        //scale the item
                        m_dynamicSymbolProps.SetScale(esriDynamicSymbolType.esriDSymbolMarker, 0.8f, 0.8f);
                        //set the items' color (blue)
                        m_dynamicSymbolProps.SetColor(esriDynamicSymbolType.esriDSymbolMarker, 0.0f, 0.0f, 1.0f, 1.0f); // Blue
                        //assign the item's glyph to the dynamic-symbol
                        m_dynamicSymbolProps.set_DynamicGlyph(esriDynamicSymbolType.esriDSymbolMarker, m_markerGlyphs[0]);
                        //set the labels text glyph
                        m_dynamicSymbolProps.set_DynamicGlyph(esriDynamicSymbolType.esriDSymbolText, m_textGlyph);
                        //set the color of the text
                        m_dynamicSymbolProps.SetColor(esriDynamicSymbolType.esriDSymbolText, 1.0f, 1.0f, 0.0f, 1.0f); // Yellow

                        //draw the item as a compound marker. This means that you do not have to draw the items and their
                        //accompanying labels separately, and thus allow you to write less code as well as get better
                        //performance.
                        m_dynamicCompoundMarker.DrawCompoundMarker4
                            (m_point,
                            //"TOP",
                            //"BOTTOM",
                            "Item " + Convert.ToString(r[0]),
                            heading.ToString("###.##"),
                            m_point.X.ToString("###.#####"),
                            m_point.Y.ToString("###.#####"));
                        break;

                    case 1:
                        //set the heading of the current symbol
                        m_dynamicSymbolProps.set_Heading(esriDynamicSymbolType.esriDSymbolMarker, (float)heading);

                        //set the symbol alignment so that it will align with towards the symbol heading
                        m_dynamicSymbolProps.set_RotationAlignment(esriDynamicSymbolType.esriDSymbolMarker, esriDynamicSymbolRotationAlignment.esriDSRANorth);

                        m_dynamicSymbolProps.SetScale(esriDynamicSymbolType.esriDSymbolMarker, 1.0f, 1.0f);
                        m_dynamicSymbolProps.SetColor(esriDynamicSymbolType.esriDSymbolMarker, 0.0f, 1.0f, 0.6f, 1.0f); // GREEN
                        m_dynamicSymbolProps.set_DynamicGlyph(esriDynamicSymbolType.esriDSymbolMarker, m_markerGlyphs[1]);

                        //draw the current location
                        DynamicDisplay.DrawMarker(m_point);
                        break;

                    case 2:
                        //set the heading of the current symbol
                        m_dynamicSymbolProps.set_Heading(esriDynamicSymbolType.esriDSymbolMarker, (float)heading);

                        //set the symbol alignment so that it will align with towards the symbol heading
                        m_dynamicSymbolProps.set_RotationAlignment(esriDynamicSymbolType.esriDSymbolMarker, esriDynamicSymbolRotationAlignment.esriDSRANorth);

                        m_dynamicSymbolProps.SetScale(esriDynamicSymbolType.esriDSymbolMarker, 1.1f, 1.1f);
                        m_dynamicSymbolProps.SetColor(esriDynamicSymbolType.esriDSymbolMarker, 1.0f, 1.0f, 1.0f, 1.0f); // WHITE
                        m_dynamicSymbolProps.set_DynamicGlyph(esriDynamicSymbolType.esriDSymbolMarker, m_markerGlyphs[2]);

                        //draw the current location
                        DynamicDisplay.DrawMarker(m_point);
                        break;
                    }
                }

                // by setting immediate flag to false, we signal the dynamic display that the layer is current.
                base.m_bIsImmediateDirty = false;
            }
            catch (Exception ex)
            {
                System.Diagnostics.Trace.WriteLine(ex.Message);
            }
        }
コード例 #8
0
    private void CreateHeartRateAnimationGlyphs(IDynamicGlyphFactory2 dynamicGlyphFactory)
    {
        IColor whiteTransparentColor = (IColor)ESRI.ArcGIS.ADF.Connection.Local.Converter.ToRGBColor(Color.FromArgb(255, 255, 255));

      m_heartRateGlyph = new IDynamicGlyph[5];
      string heartRateIcon;
      string heartIconBaseName = "Icons.valentine-heart";
      Bitmap bitmap = null;
      int imagesize = 16;
      for (int i = 0; i < 5; i++)
      {
        heartRateIcon = heartIconBaseName + imagesize + ".bmp";
        bitmap = new Bitmap(GetType(), heartRateIcon);
        m_heartRateGlyph[i] = dynamicGlyphFactory.CreateDynamicGlyphFromBitmap(esriDynamicGlyphType.esriDGlyphMarker, bitmap.GetHbitmap().ToInt32(), false, whiteTransparentColor);
        m_heartRateGlyph[i].SetAnchor(20.0f, -40.0f);
        imagesize += 2;
      }
    }
コード例 #9
0
    /// <summary>
    /// The dynamic layer draw method
    /// </summary>
    /// <param name="DynamicDrawPhase">the current drawphase of the dynamic drawing</param>
    /// <param name="Display">the ActiveView's display</param>
    /// <param name="DynamicDisplay">the ActiveView's dynamic display</param>
    public override void DrawDynamicLayer(ESRI.ArcGIS.Display.esriDynamicDrawPhase DynamicDrawPhase, ESRI.ArcGIS.Display.IDisplay Display, ESRI.ArcGIS.Display.IDynamicDisplay DynamicDisplay)
    {
      try
      {
        //make sure that the display is valid as well as that the layer is visible
        if (null == DynamicDisplay || null == Display || !this.m_visible)
          return;

        //make sure that the current drawphase is immediate. In this sample there is no use of the
        //compiled drawPhase. Use the esriDDPCompiled drawPhase in order to draw semi-static items (items
        //which have update rate lower than the display update rate).
				if (DynamicDrawPhase != esriDynamicDrawPhase.esriDDPImmediate)
          return;

        if (m_bOnce)
        {
          //cast the DynamicDisplay into DynamicGlyphFactory
          m_dynamicGlyphFactory = DynamicDisplay.DynamicGlyphFactory as IDynamicGlyphFactory2;
          //cast the DynamicDisplay into DynamicSymbolProperties
          m_dynamicSymbolProps = DynamicDisplay as IDynamicSymbolProperties;
          //cast the compound marker symbol
          m_dynamicCompoundMarker = DynamicDisplay as IDynamicCompoundMarker;

					IntializeLayerData (Display.DisplayTransformation);

          GetLayerExtent();

          m_bOnce = false;
        }

        //get the display fitted bounds
        m_extentMaxX = Display.DisplayTransformation.FittedBounds.XMax;
        m_extentMaxY = Display.DisplayTransformation.FittedBounds.YMax;
        m_extentMinX = Display.DisplayTransformation.FittedBounds.XMin;
        m_extentMinY = Display.DisplayTransformation.FittedBounds.YMin;

        //create the dynamic symbols for the layer
        if (!m_bDynamicGlyphsCreated)
        {
          this.CreateDynamicSymbols(m_dynamicGlyphFactory);
          m_bDynamicGlyphsCreated = true;
        }

        double X, Y, heading;
        int type;
        //iterate through the layers' items
        foreach (DataRow r in m_table.Rows)
        {
          if (r[1] is DBNull || r[2] is DBNull)
            continue;

          //get the item's coordinate, heading and type
          X = Convert.ToDouble(r[1]);
          Y = Convert.ToDouble(r[2]);
          heading = Convert.ToDouble(r[5]);
          type = Convert.ToInt32(r[6]);

          //assign the items' coordinate to the cached point
          m_point.PutCoords(X, Y);

          //set the symbol's properties
          switch (type)
          {
            case 0:
              //set the heading of the current symbols' text
              m_dynamicSymbolProps.set_Heading(esriDynamicSymbolType.esriDSymbolText, 0.0f);
              m_dynamicSymbolProps.set_Heading(esriDynamicSymbolType.esriDSymbolMarker, 0.0f);

              //set the symbol alignment so that it will align with the screen
              m_dynamicSymbolProps.set_RotationAlignment(esriDynamicSymbolType.esriDSymbolMarker, esriDynamicSymbolRotationAlignment.esriDSRAScreen);

              //set the text alignment so that it will also align with the screen
              m_dynamicSymbolProps.set_RotationAlignment(esriDynamicSymbolType.esriDSymbolText, esriDynamicSymbolRotationAlignment.esriDSRAScreen);

              //scale the item
              m_dynamicSymbolProps.SetScale(esriDynamicSymbolType.esriDSymbolMarker, 0.8f, 0.8f);
              //set the items' color (blue)
              m_dynamicSymbolProps.SetColor(esriDynamicSymbolType.esriDSymbolMarker, 0.0f, 0.0f, 1.0f, 1.0f); // Blue
              //assign the item's glyph to the dynamic-symbol
              m_dynamicSymbolProps.set_DynamicGlyph(esriDynamicSymbolType.esriDSymbolMarker, m_markerGlyphs[0]);
              //set the labels text glyph
              m_dynamicSymbolProps.set_DynamicGlyph(esriDynamicSymbolType.esriDSymbolText, m_textGlyph);
              //set the color of the text
              m_dynamicSymbolProps.SetColor(esriDynamicSymbolType.esriDSymbolText, 1.0f, 1.0f, 0.0f, 1.0f); // Yellow

              //draw the item as a compound marker. This means that you do not have to draw the items and their
              //accompanying labels separately, and thus allow you to write less code as well as get better
              //performance.  
              m_dynamicCompoundMarker.DrawCompoundMarker4
                (m_point,
                //"TOP",
                //"BOTTOM",
                "Item " + Convert.ToString(r[0]),
                heading.ToString("###.##"),
                m_point.X.ToString("###.#####"),
                m_point.Y.ToString("###.#####"));
              break;
            case 1:
              //set the heading of the current symbol
              m_dynamicSymbolProps.set_Heading(esriDynamicSymbolType.esriDSymbolMarker, (float)heading);

              //set the symbol alignment so that it will align with towards the symbol heading
              m_dynamicSymbolProps.set_RotationAlignment(esriDynamicSymbolType.esriDSymbolMarker, esriDynamicSymbolRotationAlignment.esriDSRANorth);

              m_dynamicSymbolProps.SetScale(esriDynamicSymbolType.esriDSymbolMarker, 1.0f, 1.0f);
              m_dynamicSymbolProps.SetColor(esriDynamicSymbolType.esriDSymbolMarker, 0.0f, 1.0f, 0.6f, 1.0f); // GREEN
              m_dynamicSymbolProps.set_DynamicGlyph(esriDynamicSymbolType.esriDSymbolMarker, m_markerGlyphs[1]);

              //draw the current location
              DynamicDisplay.DrawMarker(m_point);
              break;
            case 2:
              //set the heading of the current symbol
              m_dynamicSymbolProps.set_Heading(esriDynamicSymbolType.esriDSymbolMarker, (float)heading);

              //set the symbol alignment so that it will align with towards the symbol heading
              m_dynamicSymbolProps.set_RotationAlignment(esriDynamicSymbolType.esriDSymbolMarker, esriDynamicSymbolRotationAlignment.esriDSRANorth);

              m_dynamicSymbolProps.SetScale(esriDynamicSymbolType.esriDSymbolMarker, 1.1f, 1.1f);
              m_dynamicSymbolProps.SetColor(esriDynamicSymbolType.esriDSymbolMarker, 1.0f, 1.0f, 1.0f, 1.0f); // WHITE
              m_dynamicSymbolProps.set_DynamicGlyph(esriDynamicSymbolType.esriDSymbolMarker, m_markerGlyphs[2]);

              //draw the current location
              DynamicDisplay.DrawMarker(m_point);
              break;
          }
        }

       // by setting immediate flag to false, we signal the dynamic display that the layer is current.
        base.m_bIsImmediateDirty = false;
				
      }     
      catch (Exception ex)
      {
        System.Diagnostics.Trace.WriteLine(ex.Message);
      }
    }
コード例 #10
0
    /// <summary>
    /// create the layer's glyphs used to set the symbol of the dynamic-layer items
    /// </summary>
    /// <param name="pDynamicGlyphFactory"></param>
    private void CreateDynamicSymbols(IDynamicGlyphFactory2 pDynamicGlyphFactory)
    {
      try
      {
        //set the background color
				IColor color = ESRI.ArcGIS.ADF.Connection.Local.Converter.ToRGBColor (Color.FromArgb (255, 255, 255)) as IColor;

        // Create Character Marker Symbols glyph
        // --------------------------------------
				ICharacterMarkerSymbol characterMarkerSymbol = new CharacterMarkerSymbolClass ();
				characterMarkerSymbol.Color = color as IColor;
                characterMarkerSymbol.Font = ESRI.ArcGIS.ADF.Connection.Local.Converter.ToStdFont(new Font("ESRI Environmental & Icons", 32));
				characterMarkerSymbol.Size = 40;
				characterMarkerSymbol.Angle = 0;
				characterMarkerSymbol.CharacterIndex = 36;

        //create the glyph from the marker symbol
        m_markerGlyphs[0] = pDynamicGlyphFactory.CreateDynamicGlyph(characterMarkerSymbol as ISymbol);

        characterMarkerSymbol.Size = 32;
        characterMarkerSymbol.CharacterIndex = 224;

        //create the glyph from the marker symbol
        m_markerGlyphs[1] = pDynamicGlyphFactory.CreateDynamicGlyph(characterMarkerSymbol as ISymbol);

        // Create the glyph from embedded bitmap
        // -----------------------------------
        // Sets the transparency color
        IColor transparentColor = ESRI.ArcGIS.ADF.Connection.Local.Converter.ToRGBColor(Color.FromArgb(255, 255, 255)) as IColor;

				Bitmap bitmap = new Bitmap (GetType (), "B2.bmp");
				m_markerGlyphs[2] = pDynamicGlyphFactory.CreateDynamicGlyphFromBitmap(esriDynamicGlyphType.esriDGlyphMarker, bitmap.GetHbitmap ().ToInt32 (), false, transparentColor);
     
        // Create a glyph for the labels text, use the first 'internal' text glyph 
        // ------------------------------------------------------------------------
        m_textGlyph = pDynamicGlyphFactory.get_DynamicGlyph(1, esriDynamicGlyphType.esriDGlyphText, 1);

      }
      catch (Exception ex)
      {
        System.Diagnostics.Trace.WriteLine(ex.Message);
      }
    }
コード例 #11
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);
            }
        }