Files
Sharpy_Picross/NonoGramme/Form1.cs
T
2022-10-13 07:39:44 +02:00

87 lines
2.4 KiB
C#

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));
nonogramme1.Refresh();
}
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);
}
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);
}
}
}
}