43 lines
1.2 KiB
C#
43 lines
1.2 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Drawing;
|
|
using System.Windows.Forms;
|
|
|
|
namespace NonoGramme
|
|
{
|
|
internal class Nonogramme : PictureBox
|
|
{
|
|
const int DEFAULT_GRID_SIZE = 5;
|
|
const int DEFAULT_UI_RATIO = 30;
|
|
private Size _gridSize;
|
|
private Grid _gameGrid;
|
|
public Size GridSize { get => _gridSize; set => _gridSize = value; }
|
|
internal Grid GameGrid { get => _gameGrid; set => _gameGrid = value; }
|
|
public Nonogramme()
|
|
{
|
|
GameGrid = new Grid(new Size(DEFAULT_GRID_SIZE,DEFAULT_GRID_SIZE));
|
|
}
|
|
public void NewRandomGame(Size gridSize)
|
|
{
|
|
GameGrid = new Grid(gridSize);
|
|
}
|
|
public void LoadNewGame(string filePath)
|
|
{
|
|
GameGrid.ImportFromFile(filePath);
|
|
}
|
|
public override void Refresh()
|
|
{
|
|
base.Refresh();
|
|
Bitmap bmp = new Bitmap(Width, Height);
|
|
this.Image = GameGrid.Draw(bmp, new Point((Width / 100) * DEFAULT_UI_RATIO, (Height / 100) * DEFAULT_UI_RATIO));
|
|
}
|
|
public void CursorClick(Point position)
|
|
{
|
|
GameGrid.Click(position);
|
|
}
|
|
}
|
|
}
|