zoukankan      html  css  js  c++  java
  • GMap.NET 显示GIF图标的定制

    利用System.Drawing.ImageAnimator类实现GIF图标显示

    public class GMapMarkerImage : GMapMarker
    {
        private Image image;
        private bool currentlyAnimating;
    
        public GMapMarkerImage(PointLatLng pos, Image image) : base(pos)
        {
            Size = new Size(image.Width, image.Height);
            Offset = new Point(-Size.Width / 2, -Size.Height / 2);
            this.image = image;
        }
    
        protected GMapMarkerImage(SerializationInfo info, StreamingContext context) : base(info, context)
        {
        }
        private bool isAnimateImage()
        {
            if (image == null)
                return false;
            return ImageAnimator.CanAnimate(image);
        }
        public void AnimateImage()
        {
            if (!currentlyAnimating)
            {
                ImageAnimator.Animate(image, new EventHandler(this.OnFrameChanged));
                currentlyAnimating = true;
            }
        }
    
        private void OnFrameChanged(object sender, EventArgs e)
        {
            
        }
    
        public override void OnRender(Graphics g)
        {
            if (image == null)
            {
                return;
            }
            if (isAnimateImage())
            {
                AnimateImage();
                //更新到下一帧
                ImageAnimator.UpdateFrames();
            }
             rect = new Rectangle(LocalPosition.X, LocalPosition.Y, Size.Width, Size.Height);
            g.DrawImage(image, rect);
        }
    }

    定时器设置为300毫秒

    private void timer1_Tick(object sender, EventArgs e)
    {
        _mmapControl.Refresh();
    }
  • 相关阅读:
    函数length属性
    vue面试题
    ES6引进新的原始数据类型symbol使用及特性
    jq动画
    防抖和节流
    this指向
    前端:性能优化之回流和重绘
    react生命周期
    vue生命周期
    react-redux的实现原理
  • 原文地址:https://www.cnblogs.com/joe62/p/6882229.html
Copyright © 2011-2022 走看看