using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace NonoGramme { public partial class Form1 : Form { const int UI_BORDER = 30; string selectedFolder; string selectedNonoGram; public Form1() { InitializeComponent(); NewGame(); } private void NewGame() { nonogramme1.NewRandomGame(new Size(5, 5)); RefreshUi(); } private void Form1_Load(object sender, EventArgs e) { //ScaleUi(); } private void Form1_Resize(object sender, EventArgs e) { //ScaleUi(); } private void ScaleUi() { if (ClientSize.Width > ClientSize.Height) { nonogramme1.Size = new Size(ClientSize.Height, ClientSize.Height - UI_BORDER); } else { nonogramme1.Size = new Size(ClientSize.Width - UI_BORDER, ClientSize.Width); } RefreshUi(); } private void RefreshUi() { nonogramme1.Refresh(); } private void button1_Click(object sender, EventArgs e) { FolderBrowserDialog dialog = new FolderBrowserDialog(); if (dialog.ShowDialog() == DialogResult.OK) { selectedFolder = dialog.SelectedPath; } else { MessageBox.Show("Ooops... Could not retrieve folder informations :("); } if (Directory.Exists(selectedFolder)) { string[] nonFiles = Directory.GetFiles(selectedFolder, "*.non"); foreach (string file in nonFiles) { lsbFiles.Items.Add(Path.GetFileName(file)); } } } private void lsbFiles_SelectedIndexChanged(object sender, EventArgs e) { string selectedFile = selectedFolder + "\\" + lsbFiles.Items[lsbFiles.SelectedIndex]; if (Directory.Exists(selectedFolder) && File.Exists(selectedFile)) { selectedNonoGram = selectedFile; nonogramme1.LoadNewGame(selectedNonoGram); RefreshUi(); } } } }