コード例 #1
0
        public static Bitmap getEmoji(string text)
        {
            string file;

            if (emoticons.TryGetValue(text, out file))
            {
                Bitmap emoji = null;
                if (!animations.TryGetValue(file, out emoji))
                {
                    try{
                        object res = getResosource(System.IO.Path.GetFileNameWithoutExtension(file.Replace(' ', '_')));
                        if (res is Bitmap)
                        {
                            emoji = (Bitmap)res;
                        }
                        if (emoji != null && ImageAnimator.CanAnimate(emoji))
                        {
                            ImageAnimator.Animate(emoji, new EventHandler(OnFrameChanged));
                        }
                        animations.Add(file, emoji);
                    }catch {
                    }
                }
                return(emoji);
            }
            return(null);
        }
コード例 #2
0
        private void DrawGameIcon(Graphics g, LiveSplitState state, float height)
        {
            var icon = state.Run.GameIcon;

            if (OldImage != icon)
            {
                ImageAnimator.Animate(icon, (s, o) => { });
                OldImage = icon;
            }

            var aspectRatio = (float)icon.Width / icon.Height;
            var drawWidth   = height - 4;
            var drawHeight  = height - 4;

            if (icon.Width > icon.Height)
            {
                var ratio = icon.Height / (float)icon.Width;
                drawHeight *= ratio;
            }
            else
            {
                var ratio = icon.Width / (float)icon.Height;
                drawWidth *= ratio;
            }

            ImageAnimator.UpdateFrames(icon);

            g.DrawImage(
                icon,
                7 + (height - 4 - drawWidth) / 2,
                2 + (height - 4 - drawHeight) / 2,
                drawWidth,
                drawHeight);
        }
コード例 #3
0
ファイル: AnimateImage.cs プロジェクト: githjub/Study
 public void changeImage(string path)
 {
     Stop();
     image = new Bitmap(path);
     ImageAnimator.Animate(image, new EventHandler(FrameChanged));
     Start();
 }
コード例 #4
0
        private bool _StartAnimate()
        {
            if (this.Image == null)
            {
                return(false);
            }
            if (this.FrameChangedHandlerCallbacks == null || this.FrameChangedHandlerCallbacks.Count == 0)
            {
                return(false);
            }

            this.IsAnimating = CanAnimate();
            if (this.IsAnimating)
            {
                foreach (EventHandler h in FrameChangedHandlerCallbacks)
                {
                    try
                    {
                        ImageAnimator.Animate(this.Image, h);
                    }
                    catch { }
                }
                return(true);
            }
            return(false);
        }
コード例 #5
0
ファイル: SplashScreen.cs プロジェクト: ODIN74/HW_Klyushin_1
        /// <summary>
        /// Метод анимации gif изображения
        /// </summary>
        private void AnimateImage()
        {
            // Предоставляет доступ к главному буферу графического контекста для текущего приложения
            g = this.CreateGraphics();

            // Создаем объект (поверхность рисования) и связываем его с формой
            // Запоминаем размеры формы
            Width  = this.ClientSize.Width;
            Height = this.ClientSize.Height;

            // Связываем буфер в памяти с графическим объектом, чтобы рисовать в буфере
            Buffer = context.Allocate(g, new Rectangle(0, 0, Width, Height));

            //Активация двойной буфризации
            this.DoubleBuffered = true;

            this.stretchImage = new PointF[] { new PointF(0.0f, 0.0f), new PointF(0.0f, Height), new PointF(Width, 0.0f) };

            this.showText = new PointF(Width - 100, Height - 30);

            if (!this.currentlyAnimating)
            {
                //Begin the animation only once.
                ImageAnimator.Animate(this.animatedImage, new EventHandler(this.OnFrameChanged));
                this.currentlyAnimating = true;
            }
        }
コード例 #6
0
ファイル: GameForm.cs プロジェクト: GSO-SW/2DRunner
 /// <summary>
 /// Animiert den Spieler
 /// </summary>
 public void AnimateImage()
 {
     if (player.AnimatedImage != null)
     {
         ImageAnimator.Animate(player.AnimatedImage, new EventHandler(this.OnFrameChanged));
     }
 }
コード例 #7
0
 public void BeginAnimation()
 {
     if (ImageAnimator.CanAnimate(Image))
     {
         ImageAnimator.Animate(Image, ImageAnimation);
     }
 }
コード例 #8
0
ファイル: PozadinaForm.cs プロジェクト: momir64/Asocijacije
        protected override void WndProc(ref Message m)
        {
            const int WM_NCLBUTTONDOWN = 0x00A1;

            base.WndProc(ref m);
            if (m.Msg == WM_NCLBUTTONDOWN && egg && !playing)
            {
                long nowClick = DateTimeOffset.Now.ToUnixTimeMilliseconds();
                if (nowClick - lastClick > 400)
                {
                    clickCount = 0;
                }
                else
                {
                    clickCount++;
                }
                if (clickCount == 3)
                {
                    clickCount = 0;
                    ImageAnimator.Animate(eggImg, new EventHandler(OnFrameChanged));
                    FrameDimension dimension = new FrameDimension(eggImg.FrameDimensionsList[0]);
                    frameCount = eggImg.GetFrameCount(dimension);
                    playing    = true;
                }
                lastClick = nowClick;
            }
        }
コード例 #9
0
 protected override void OnPaint(PaintEventArgs e)
 {
     //e.Graphics.DrawRectangle(new Pen(Color.Blue, 1), new Rectangle(0, 0, Width - 1, Height - 1));
     if (GifImage != null)
     {
         if (ImageAnimator.CanAnimate(GifImage) == false)
         {
             //e.Graphics.Clear(Color.White);
             e.Graphics.DrawImage(GifImage, Location.X, Location.Y);
         }
         else
         {
             if (_FirstTime)
             {
                 //这个函数其实只调用一次,以后只调用updateframes函数。
                 ImageAnimator.Animate(GifImage, OnFramChanged);
                 _FirstTime = false;
             }
             e.Graphics.Clear(Color.Transparent);
             e.Graphics.DrawImage(GifImage, Location.X, Location.Y);
             ImageAnimator.UpdateFrames(GifImage);
         }
     }
     else
     {
         base.OnPaint(e);
     }
 }
コード例 #10
0
 private void Form2_Load(object sender, EventArgs e)
 {
     if (ImageAnimator.CanAnimate(fire))
     {
         ImageAnimator.Animate(fire, new EventHandler(this.OnFrameChanged));
     }
 }
コード例 #11
0
ファイル: ImageAnimatorTests.cs プロジェクト: z77ma/runtime
        public void UpdateFrames_Succeeds_ForAnimatedImages_WithCurrentAnimations()
        {
            var animatedImage = new Bitmap(Helpers.GetTestBitmapPath("animated-timer-100fps-repeat-2.gif"));

            ImageAnimator.Animate(animatedImage, (object o, EventArgs e) => { });
            ImageAnimator.UpdateFrames(animatedImage);
        }
コード例 #12
0
 public void Right(bool withBox)
 {
     this.withBox = withBox;
     dir          = Direction.Right;
     steps        = x;
     ImageAnimator.Animate(rightImage, new EventHandler(this.GoRight));
 }
コード例 #13
0
 public void Left(bool withBox)
 {
     this.withBox = withBox;
     dir          = Direction.Left;
     steps        = x;
     ImageAnimator.Animate(leftImage, new EventHandler(this.GoLeft));
 }
コード例 #14
0
 public void Down(bool withBox)
 {
     this.withBox = withBox;
     dir          = Direction.Down;
     steps        = y;
     ImageAnimator.Animate(downImage, new EventHandler(this.GoDown));
 }
コード例 #15
0
        private void button_GO_Click(object sender, EventArgs e)
        {
            game_sound.Open(new Uri(@"Objects\Music\HOME-DreamHead.mp3", UriKind.Relative));
            start_music.Stop();
            game_sound.Play();
            if (car_number == 1)
            {
                car_skin_ingame = new Bitmap(@"Objects\Images\delorean__kopia.png");
            }
            else
            {
                car_skin_ingame = new Bitmap(@"Objects\Images\delorean.png");
            }
            car_ingame.BackgroundImage = car_skin_ingame;
            Bitmap bg_fon1 = new Bitmap(@"Objects\Gif\lvl1.gif");

            this.BackgroundImage = bg_fon1;
            ImageAnimator.Animate(this.BackgroundImage, OnFrameChanged);
            start_button_menu.Enabled = false;
            start_button_menu.Visible = false;
            exit_button_menu.Enabled  = false;
            exit_button_menu.Visible  = false;
            logo_picture.Visible      = false;
            car_name.Visible          = false;
            car_left_change.Visible   = false;
            car_right_change.Visible  = false;
            car_settings.Visible      = false;
            button_GO.Visible         = false;
            car_ingame.Visible        = true;
            speedCar_text.Visible     = true;
        }
コード例 #16
0
        private void Animate(bool animate)
        {
            bool currentlyAnimating = labelState[StateAnimating] != 0;

            if (animate != currentlyAnimating)
            {
                Image image = (Image)Properties.GetObject(PropImage);
                if (animate)
                {
                    if (image != null)
                    {
                        ImageAnimator.Animate(image, new EventHandler(this.OnFrameChanged));
                        labelState[StateAnimating] = animate ? 1 : 0;
                    }
                }
                else
                {
                    if (image != null)
                    {
                        ImageAnimator.StopAnimate(image, new EventHandler(this.OnFrameChanged));
                        labelState[StateAnimating] = animate ? 1 : 0;
                    }
                }
            }
        }
コード例 #17
0
        private void go_menu_Click(object sender, EventArgs e)
        {
            game_sound.Stop();
            start_music.Play();
            Bitmap bg_fon1 = new Bitmap(@"Objects\Gif\bg.gif");

            this.BackgroundImage = bg_fon1;
            ImageAnimator.Animate(this.BackgroundImage, OnFrameChanged);
            start_button_menu.Enabled    = true;
            start_button_menu.Visible    = true;
            exit_button_menu.Enabled     = true;
            exit_button_menu.Visible     = true;
            logo_picture.Visible         = true;
            car_name.Visible             = false;
            car_left_change.Visible      = false;
            car_right_change.Visible     = false;
            car_settings.Visible         = false;
            button_GO.Visible            = false;
            car_ingame.Visible           = false;
            speedCar_text.Visible        = false;
            resume_button.Visible        = false;
            settings_button_game.Visible = false;
            go_menu.Visible = false;
            settings_button_menu.Visible = true;
        }
コード例 #18
0
ファイル: level1.cs プロジェクト: Mrhealman/Swell-Game
        public level1()
        {
            InitializeComponent();
            this.Text           = "Swell Game - Level 1";
            this.Width          = xWindowSize;
            this.Height         = yWindowSize;
            this.KeyDown       += level1_KeyDown;
            pictureBox2.Visible = false;
            pictureBox3.Visible = false;
            pictureBox4.Visible = false;
            Image car = new Bitmap(Properties.Resources.Delorean);

            pictureBox1.BackgroundImage = car;
            ImageAnimator.Animate(BackgroundImage, OnFrameChanged);
            pictureBox1.BackColor = Color.Transparent;
            Image menu_button_leave = new Bitmap(Properties.Resources.button_menu);

            pictureBox4.BackgroundImage = menu_button_leave;
            pictureBox4.BackColor       = Color.Transparent;
            pictureBox2.BackColor       = Color.Transparent;
            Image resume_button_leave = new Bitmap(Properties.Resources.button_resume);

            pictureBox2.BackgroundImage = resume_button_leave;
            pictureBox3.BackColor       = Color.Transparent;
            Image settings_button = new Bitmap(Properties.Resources.button_settings);

            pictureBox3.BackgroundImage = settings_button;
            label1.BackColor            = Color.Transparent;
            label1.Text          = (speedCar + " km/h");
            pictureBox1.Width    = 200;
            pictureBox1.Height   = 200;
            pictureBox1.Location = new Point(300, 350);
            music.Play();
        }
コード例 #19
0
        private void DrawGif(string targetFile)
        {
            // ねずみ返し_ファイルが存在しない場合
            if (!File.Exists(targetFile))
            {
                return;
            }
            // ねずみ返し_ファイル拡張子がGifでない場合
            if (Path.GetExtension(targetFile).ToLower() == "gif")
            {
                return;
            }

            // ピクチャボックス初期化
            pbGifPlayer.Image = null;

            // 画像読み込み
            animatedImage = new Bitmap(targetFile);

            // デフォサイズチェックボックス
            if (cbDefSize.Checked)
            {
                // 画像比率算出(縦のサイズに対する横の比率)
                double targetRatio = (double)animatedImage.Width / (double)animatedImage.Height;
                // デフォルト縦サイズに合わせる
                heightZoom = defHightSize / animatedImage.Height;
                widthZoom  = heightZoom * targetRatio;
            }

            // アニメ開始
            ImageAnimator.Animate(animatedImage, new EventHandler(Image_FrameChanged));
        }
コード例 #20
0
ファイル: Form1.cs プロジェクト: MaxymGorn/WinForms-project
 private void Form1_Load(object sender, EventArgs e)
 {
     if (ImageAnimator.CanAnimate(RotatingBlocks))
     {
         ImageAnimator.Animate(RotatingBlocks, new EventHandler(this.OnFrameChanged));
     }
 }
コード例 #21
0
ファイル: Form1.cs プロジェクト: andylaufzf/Reimu
 public void PlayAnimate()
 {
     if (ImageAnimator.CanAnimate(imagegif))
     {
         ImageAnimator.Animate(imagegif, new EventHandler(this.OnFrameChanged));
     }
 }
コード例 #22
0
ファイル: Visual.cs プロジェクト: OlegCiofu/Agroparser
 public void AnimateImage()
 {
     if (!isActive)
     {
         ImageAnimator.Animate(animatedImage, new EventHandler(OnFramesChanged));
     }
 }
コード例 #23
0
 private void WaitWindow_Load(object sender, EventArgs e)
 {
     waitAnimation = Resources.ResourceManager.GetObject("waitAni") as Image;
     ImageAnimator.Animate(waitAnimation, onAnimate);
     picWaitAni.Image = waitAnimation;
     timer1.Start();
 }
コード例 #24
0
 private void StartAnimate()
 {
     if (CanAnimate)
     {
         ImageAnimator.Animate(_image, EventAnimator);
     }
 }
コード例 #25
0
 public void Up(bool withBox)
 {
     this.withBox = withBox;
     dir          = Direction.Up;
     steps        = y;
     ImageAnimator.Animate(upImage, new EventHandler(this.GoUp));
 }
コード例 #26
0
ファイル: LuckForm.cs プロジェクト: unix8net/CSharpProjAtYC
        /// <summary>
        /// 画恭喜
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void gongxiPicBox_Paint(object sender, PaintEventArgs e)
        {
            //如果函数首次调用,将执行IF语句中的内容,再次调用时,将不再执行IF中的语句,防止第二次调用Animate()方法。
            if (!current)
            {
                ImageAnimator.Animate(gongxi, new EventHandler(this.GXOnFrameChanged));
                ImageAnimator.Animate(gongxix, new EventHandler(this.GXOnFrameChanged));
                current = true;
            }
            if (!isStart)
            {
                return;
            }

            //ImageAnimator.StopAnimate(gongxi, new EventHandler(this.OnFrameChanged));//停止
            //ImageAnimator.Animate(gongxi, new EventHandler(this.OnFrameChanged));//播放

            ImageAnimator.UpdateFrames();
            if (e.ClipRectangle.Width == 200)
            {
                e.Graphics.DrawImage(gongxix, new Point(10, 10));
            }
            else
            {
                e.Graphics.DrawImage(gongxi, new Point(10, 10));
            }
        }
コード例 #27
0
ファイル: GifBox.cs プロジェクト: jollitycn/JGNet
 private void StartAnimate()
 {
     if (this.CanAnimate)
     {
         ImageAnimator.Animate(this._image, this.EventAnimator);
     }
 }
コード例 #28
0
ファイル: Player.cs プロジェクト: IDAlreaning/rhythm_runner
 public void AnimateImage()
 {
     if (!currentlyAnimating)
     {
         ImageAnimator.Animate(image_player, new EventHandler(OnFrameChanged));
         currentlyAnimating = true;
     }
 }
コード例 #29
0
        //开始动画方法

        private void BeginAnimate()
        {
            if (m_Image != null)
            {
                //当gif动画每隔一定时间后,都会变换一帧,那么就会触发一事件,该方法就是将当前image每变换一帧时,都会调用当前这个委托所关联的方法。
                ImageAnimator.Animate(m_Image, evtHandler);
            }
        }
コード例 #30
0
 private void AnimateImage()
 {
     if (!_currentlyAnimating)
     {
         ImageAnimator.Animate(_animatedImage, new EventHandler(this.OnFrameChanged));
         _currentlyAnimating = true;
     }
 }