public Puzzle(Graphics dc, string imgFile, int columns, int rows, Size size) { tilesheet = new Tilesheet("picture", imgFile); int tileWidth = (int)((float)tilesheet.Bmp.Width / (float)columns); int tileHeight = (int)((float)tilesheet.Bmp.Height / (float)rows); int adjWidth = tileWidth * columns; int adjHeight = tileHeight * rows; tilesheet.TileSize = new Size(tileWidth, tileHeight); originalSize = tilesheet.Bmp.Size; numColumns = columns; numRows = rows; adjustedSize = new Size(adjWidth, adjHeight); GridPointMatrix matrix = new GridPointMatrix(numColumns, numRows, tileWidth, tileHeight); matrix.CoordinateSystem = new SquareIsoCoordinates(); matrixes = new GridPointMatrixes(matrix); surface = new VisibleSurface(dc, size.Width, size.Height, matrixes); surface.Erase(); InitializeSprites(tileWidth, tileHeight); //Gondwana.Scripting.Parser.WriteToFile("bmpProp_file.gond", System.IO.FileMode.Create, tilesheet); //Engine.ScriptEngineState("file.gond", true); delMoveStart = new SpriteMovementEventHandler(Sprites_SpriteMovementStarted); delMoveStop = new SpriteMovementEventHandler(Sprites_SpriteMovementStopped); Sprites.SpriteMovementStarted += delMoveStart; Sprites.SpriteMovementStopped += delMoveStop; }
protected internal Backbuffer(VisibleSurface visSurface) { // make the dimensions equal to the VisibleSurface dimensions range = new Rectangle(0, 0, visSurface.Width, visSurface.Height); // create a new temp GDI+ Bitmap to get old GDI32 bitmap handle Bitmap memBmp = new Bitmap(range.Width, range.Height, visSurface.DC); // obtain handle to VisibleSurface Graphics object for Backbuffer instantiation IntPtr visDC = visSurface.DC.GetHdc(); // create a DC compatible with the visible surface DC IntPtr compatDC = pInvoke.CreateCompatibleDC(visDC); // associate the new bitmap handle with the Backbuffer DC pInvoke.SelectObject(compatDC, memBmp.GetHbitmap()); //create a GDI+ Graphics object for the Backbuffer dc = Graphics.FromHdc(compatDC); // release handle to VisibleSurface Graphics object visSurface.DC.ReleaseHdc(visDC); // Dispose of temp GDI+ Bitmap memBmp.Dispose(); // set default FogPen value to black with 128 alpha blending fogBrush = new SolidBrush(Color.FromArgb(128, Color.Black)); // set default GridPen value to white gridPen = new Pen(Color.White); //showGrid = false; matrixDisposeDel = new GridPointMatrixesDisposingEventHandler(source_Disposing); }
protected internal Backbuffer(VisibleSurface visSurface) { // make the dimensions equal to the VisibleSurface dimensions range = new Rectangle(0, 0, visSurface.Width, visSurface.Height); // create a new temp GDI+ Bitmap to get old GDI32 bitmap handle Bitmap memBmp = new Bitmap(range.Width, range.Height, visSurface.DC); // obtain handle to VisibleSurface Graphics object for Backbuffer instantiation IntPtr visDC = visSurface.DC.GetHdc(); // create a DC compatible with the visible surface DC IntPtr compatDC = pInvoke.CreateCompatibleDC(visDC); // associate the new bitmap handle with the Backbuffer DC pInvoke.SelectObject(compatDC, memBmp.GetHbitmap()); //create a GDI+ Graphics object for the Backbuffer dc = Graphics.FromHdc(compatDC); // release handle to VisibleSurface Graphics object visSurface.DC.ReleaseHdc(visDC); // Dispose of temp GDI+ Bitmap memBmp.Dispose(); // set default FogPen value to black with 128 alpha blending fogBrush = new SolidBrush(Color.FromArgb(128, Color.Black)); // set default GridPen value to white gridPen = new Pen(Color.White); //showGrid = false; matrixDisposeDel = new GridPointMatrixesDisposingEventHandler(source_Disposing); }
public static void LoadVisibleSurfaces(Form1 frm) { Graphics g = frm.CreateGraphics(); visSurf = new VisibleSurface(g, frm.Width, frm.Height); visSurf.Bind(layers); layers[0].ShowGridLines = false; layers[1].ShowGridLines = false; visSurf.RedrawDirtyRectangleOnly = true; fpsCounter = new Text(visSurf, "fps:", new Font("Times New Roman", 8), new Rectangle(0, 0, 200, 300), Color.White, Color.Transparent); Engine.CPSCalculated += new Gondwana.Common.EventArgs.CyclesPerSecondCalculatedHandler(Engine_CPSCalculated); }