public static void FlashGeometry(IScreenDisplay display, IEnumerable <IGeometry> geometries) { IRgbColor color = new RgbColor(); color.Green = color.Blue = 0; color.Red = 255; short cacheId = display.AddCache(); display.StartDrawing(display.hDC, cacheId); geometries.ToList().ForEach(geometry => { if (symbolsToFlash.ContainsKey(geometry.GeometryType)) { var symbol = symbolsToFlash[geometry.GeometryType].Invoke(color); display.SetSymbol(symbol); actionToFlash[geometry.GeometryType].Invoke(display, geometry); } else { throw new KeyNotFoundException("{0} cannot be found in the Symbol dictionary".InvariantFormat(geometry.GeometryType)); } }); display.FinishDrawing(); tagRECT rect = new tagRECT(); display.DrawCache(display.hDC, cacheId, ref rect, ref rect); System.Threading.Thread.Sleep(300); display.Invalidate(rect: null, erase: true, cacheIndex: cacheId); display.RemoveCache(cacheId); }
protected override void OnPaint(PaintEventArgs e) { #region old //e.Graphics.SmoothingMode = m_smoothingMode; //Rectangle cliprectangle = e.ClipRectangle; //if (m_staticImage == null) //{ // cliprectangle = ClientRectangle; // m_staticImage = new Bitmap(ClientRectangle.Width, ClientRectangle.Height); // // m_staticImage.Save("D:\\a.png", ImageFormat.Png); // m_staticDirty = true; //} ////绘制在背景图片上 //Graphics BitMapGc = Graphics.FromImage(m_staticImage); //BitMapGc.SmoothingMode = m_smoothingMode; ////this.BackgroundLayer.Draw(dcStatic, r); ////if (m_model.GridLayer.Enabled) //// m_model.GridLayer.Draw(dcStatic, r); ////绘制十字丝 //RPoint rCenterPoint = new RPoint(0, 0, 0); //PointF nullPoint = Transform.ToScreen(rCenterPoint, this); //BitMapGc.DrawLine(Pens.Blue, nullPoint.X - 10, nullPoint.Y, nullPoint.X + 10, nullPoint.Y); //BitMapGc.DrawLine(Pens.Blue, nullPoint.X, nullPoint.Y - 10, nullPoint.X, nullPoint.Y + 10); //if (m_staticDirty) //{ // m_staticDirty = false; // List<ILayer> layers = mMap.Layers; // for (int layerindex = layers.Count - 1; layerindex >= 0; layerindex--) // { // if (layers[layerindex].Visible) // layers[layerindex].Draw(mScreenDisplay); // } // BitMapGc.Dispose(); //} ////绘制背景图片 //e.Graphics.DrawImage(m_staticImage, cliprectangle, cliprectangle, GraphicsUnit.Pixel); #endregion e.Graphics.SmoothingMode = m_smoothingMode; mScreenDisplay.StartDrawing(this); mScreenDisplay.FinishDrawing(e.Graphics); if (mScreenDisplay.IsCacheDirty) { mScreenDisplay.StartRecording(); mScreenDisplay.StopRecording(); } else { mScreenDisplay.DrawCache(); } }
///<summary>Flash geometry on the display.</summary> ///<param name="geometry"> The input IGeometry to flash. Supported geometry types are GeometryBag, Polygon, Polyline, Point and Multipoint.</param> ///<param name="screenDisplay">An IScreenDisplay reference</param> ///<param name="delay">An integer that is the time in milliseconds to wait.</param> public static void FlashGeometry(IGeometry geometry, IScreenDisplay screenDisplay, int delay, int times) { if (geometry == null || screenDisplay == null) { return; } bool continueFlashing = true; using (ComReleaser comReleaser = new ComReleaser()) { ITrackCancel cancelTracker = new CancelTrackerClass(); comReleaser.ManageLifetime(cancelTracker); screenDisplay.CancelTracker = cancelTracker; short cacheID = screenDisplay.AddCache(); int cacheMemDC = screenDisplay.get_CacheMemDC(cacheID); IRgbColor fillColor = new RgbColorClass(); comReleaser.ManageLifetime(fillColor); fillColor.Green = 128; IRgbColor lineColor = new RgbColorClass(); comReleaser.ManageLifetime(lineColor); screenDisplay.StartDrawing(cacheMemDC, cacheID); DrawGeometry(geometry, fillColor, lineColor, (IDisplay)screenDisplay, cancelTracker); ESRI.ArcGIS.esriSystem.tagRECT RECT = new tagRECT(); screenDisplay.FinishDrawing(); for (int j = 0; j < times; j++) { if (continueFlashing == true) { screenDisplay.DrawCache(screenDisplay.hDC, cacheID, ref RECT, ref RECT); if (delay > 0) { System.Threading.Thread.Sleep(delay); screenDisplay.Invalidate(null, true, cacheID); screenDisplay.UpdateWindow(); System.Threading.Thread.Sleep(delay); } } } //--------------------------------------------------------------------- screenDisplay.RemoveCache(cacheID); cancelTracker.Reset(); } }