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); }
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); }
public void changeImage(string path) { Stop(); image = new Bitmap(path); ImageAnimator.Animate(image, new EventHandler(FrameChanged)); Start(); }
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); }
/// <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; } }
/// <summary> /// Animiert den Spieler /// </summary> public void AnimateImage() { if (player.AnimatedImage != null) { ImageAnimator.Animate(player.AnimatedImage, new EventHandler(this.OnFrameChanged)); } }
public void BeginAnimation() { if (ImageAnimator.CanAnimate(Image)) { ImageAnimator.Animate(Image, ImageAnimation); } }
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; } }
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); } }
private void Form2_Load(object sender, EventArgs e) { if (ImageAnimator.CanAnimate(fire)) { ImageAnimator.Animate(fire, new EventHandler(this.OnFrameChanged)); } }
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); }
public void Right(bool withBox) { this.withBox = withBox; dir = Direction.Right; steps = x; ImageAnimator.Animate(rightImage, new EventHandler(this.GoRight)); }
public void Left(bool withBox) { this.withBox = withBox; dir = Direction.Left; steps = x; ImageAnimator.Animate(leftImage, new EventHandler(this.GoLeft)); }
public void Down(bool withBox) { this.withBox = withBox; dir = Direction.Down; steps = y; ImageAnimator.Animate(downImage, new EventHandler(this.GoDown)); }
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; }
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; } } } }
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; }
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(); }
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)); }
private void Form1_Load(object sender, EventArgs e) { if (ImageAnimator.CanAnimate(RotatingBlocks)) { ImageAnimator.Animate(RotatingBlocks, new EventHandler(this.OnFrameChanged)); } }
public void PlayAnimate() { if (ImageAnimator.CanAnimate(imagegif)) { ImageAnimator.Animate(imagegif, new EventHandler(this.OnFrameChanged)); } }
public void AnimateImage() { if (!isActive) { ImageAnimator.Animate(animatedImage, new EventHandler(OnFramesChanged)); } }
private void WaitWindow_Load(object sender, EventArgs e) { waitAnimation = Resources.ResourceManager.GetObject("waitAni") as Image; ImageAnimator.Animate(waitAnimation, onAnimate); picWaitAni.Image = waitAnimation; timer1.Start(); }
private void StartAnimate() { if (CanAnimate) { ImageAnimator.Animate(_image, EventAnimator); } }
public void Up(bool withBox) { this.withBox = withBox; dir = Direction.Up; steps = y; ImageAnimator.Animate(upImage, new EventHandler(this.GoUp)); }
/// <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)); } }
private void StartAnimate() { if (this.CanAnimate) { ImageAnimator.Animate(this._image, this.EventAnimator); } }
public void AnimateImage() { if (!currentlyAnimating) { ImageAnimator.Animate(image_player, new EventHandler(OnFrameChanged)); currentlyAnimating = true; } }
//开始动画方法 private void BeginAnimate() { if (m_Image != null) { //当gif动画每隔一定时间后,都会变换一帧,那么就会触发一事件,该方法就是将当前image每变换一帧时,都会调用当前这个委托所关联的方法。 ImageAnimator.Animate(m_Image, evtHandler); } }
private void AnimateImage() { if (!_currentlyAnimating) { ImageAnimator.Animate(_animatedImage, new EventHandler(this.OnFrameChanged)); _currentlyAnimating = true; } }