Ejemplo n.º 1
0
        /// <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);
            }
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
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);
            }
        }
    /// <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);
      }
    }
    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);
    }