public void Draw_Navi() { if (GLOn == false) { if (!(Host_Navi.Sprite == Host_Navi.OldSprite) || !(Host_Navi.FaceLeft == Host_Navi.OldFaceLeft)) { NaviForm.Invalidate(); Host_Navi.OldSprite = Host_Navi.Sprite; Host_Navi.OldFaceLeft = Host_Navi.FaceLeft; } } if (GLOn == true) { if (Init_GL == false) { Start_GL(); } ScreenScroll.X = Host_Navi.Location.X + Host_Navi.GetSize().X / 2 - ScreenSize.Width / 2; ScreenScroll.Y = Host_Navi.Location.Y + Host_Navi.GetSize().Y / 2 - ScreenSize.Height / 2; SizeF screenBounds = new SizeF(0 - (ScreenSize.Width - (ScreenSize.Width / ScreenZoom)) / 2, 0 - (ScreenSize.Height - (ScreenSize.Height / ScreenZoom)) / 2); SizeF stageBounds = new SizeF(0 - (stage.Bounds.Width - (stage.Bounds.Width / ScreenZoom)) / 2, 0 - (stage.Bounds.Height - (stage.Bounds.Height / ScreenZoom)) / 2); if (ScreenScroll.X + ScreenSize.Width > stage.Bounds.Width - screenBounds.Width) { ScreenScroll.X = stage.Bounds.Width - (ScreenSize.Width + screenBounds.Width); } if (ScreenScroll.X < screenBounds.Width) { ScreenScroll.X = screenBounds.Width; } if (ScreenScroll.Y < screenBounds.Height) { ScreenScroll.Y = screenBounds.Height; } if (ScreenScroll.Y + ScreenSize.Height > stage.Bounds.Height - screenBounds.Height) { ScreenScroll.Y = stage.Bounds.Height - (ScreenSize.Height + screenBounds.Height); } Draw_GL(); } }
public void Draw_Navi_GDI(object sender, System.Windows.Forms.PaintEventArgs e) { NaviForm.Width = Convert.ToInt32(Host_Navi.GetSize().X); NaviForm.Height = Convert.ToInt32(Host_Navi.GetSize().Y); e.Graphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.NearestNeighbor; float xoff = 0; float yoff = 0; xoff = Convert.ToSingle(-0.5 + 0.5 * Host_Navi.SpriteSize.X / Host_Navi.GetSize().X) + Host_Navi.SpriteSize.X * Host_Navi.Sprite.X; yoff = Convert.ToSingle(-0.5 + 0.5 * Host_Navi.SpriteSize.Y / Host_Navi.GetSize().Y) + Host_Navi.SpriteSize.Y * Host_Navi.Sprite.Y; if (Host_Navi.FaceLeft == true) { e.Graphics.DrawImage(Host_Navi.SpriteSheet, new Rectangle(Convert.ToInt32(Host_Navi.GetSize().X), 0, Convert.ToInt32(-Host_Navi.GetSize().X - 1), Convert.ToInt32(Host_Navi.GetSize().Y)), xoff, yoff, Host_Navi.SpriteSize.X, Host_Navi.SpriteSize.Y, GraphicsUnit.Pixel, NormalImage); } else { e.Graphics.DrawImage(Host_Navi.SpriteSheet, new Rectangle(0, 0, Convert.ToInt32(Host_Navi.GetSize().X), Convert.ToInt32(Host_Navi.GetSize().Y)), xoff, yoff, Host_Navi.SpriteSize.X, Host_Navi.SpriteSize.Y, GraphicsUnit.Pixel, NormalImage); } }