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