コード例 #1
0
        /// <summary>
        /// draw the numbers (azimuth) in the HUD
        /// </summary>
        /// <param name="deviceFrame"></param>
        /// <param name="angle"></param>
        private void DrawAzimuths(tagRECT deviceFrame, float angle)
        {
            //need to draw the current azimuth
            m_dynamicSymbolProps.SetColor(esriDynamicSymbolType.esriDSymbolText, 0.0f, 0.8f, 0.0f, 1.0f); // Green
            //assign the item's glyph to the dynamic-symbol
            m_dynamicSymbolProps.set_DynamicGlyph(esriDynamicSymbolType.esriDSymbolText, m_textGlyph);

            //get the floor of the azimuth
            float azimuth = 180.0f - angle;

            if (azimuth > 360)
            {
                azimuth -= 360;
            }
            else if (azimuth < 0)
            {
                azimuth += 360;
            }

            float  floorAzi = (int)(azimuth / 10.0f) * 10.0f;
            double deltaAzi = (angle - (float)((int)(angle / 10.0f) * 10.0f)) * 6.0; //(the shift to the X axis)

            double xmin    = (double)deviceFrame.left;
            double xmax    = (double)deviceFrame.right;
            double ymin    = (double)deviceFrame.top;
            double xmiddle = (xmax + xmin) / 2.0;

            double x = xmiddle - 150.0 + deltaAzi;

            double dAzStartMiddle = (150.0 - 2.0 * deltaAzi) / 6.0;

            dAzStartMiddle = (int)(dAzStartMiddle / 60.0) * 60.0 + 10.0;
            int    azi   = (int)(floorAzi - dAzStartMiddle) - 5;
            double delta = 60.0;

            m_dynamicSymbolProps.set_Heading(esriDynamicSymbolType.esriDSymbolText, 0.0f);
            m_dynamicSymbolProps.set_RotationAlignment(esriDynamicSymbolType.esriDSymbolText, esriDynamicSymbolRotationAlignment.esriDSRAScreen);
            for (int i = 0; i < 5; i++)
            {
                m_point.PutCoords(x, ymin + 28.0);

                if (azi > 360)
                {
                    azi -= 360;
                }
                else if (azi < 0)
                {
                    azi += 360;
                }
                m_dynamicDrawScreen.DrawScreenText(m_point, azi.ToString());

                azi += 10;
                x   += delta;
            }

            //need to draw the current azimuth
            m_dynamicSymbolProps.SetColor(esriDynamicSymbolType.esriDSymbolText, 0.0f, 0.0f, 0.0f, 1.0f); // Black
            m_point.PutCoords(xmiddle, ymin + 95.0);
            m_dynamicDrawScreen.DrawScreenText(m_point, azimuth.ToString("###"));
        }
コード例 #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);
        }
コード例 #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);
            }
        }