RecurseWinFormsTest/RecurseWindowTest/Form1.cs

77 lines
2.1 KiB
C#
Raw Permalink Normal View History

2021-02-08 16:44:09 +03:00
using System;
using System.Drawing;
using System.Windows.Forms;
namespace RecurseWindowTest
{
public partial class Form1 : Form
{
private int iter_num;
private int mode;
public Form1(int iteration, int _mode = 0)
{
InitializeComponent();
iter_num = iteration;
mode = _mode;
Size = GetSizeByIterNum();
Text = $"{Size.Width}x{Size.Height}";
if (mode == 2)
new Form1(iter_num+1, mode).ShowDialog();
2021-02-08 16:53:12 +03:00
DateTime.Parse("17:30");
2021-02-08 16:44:09 +03:00
}
private void pictureBox1_Click(object sender, EventArgs e)
{
new Form1(iter_num+1, mode).ShowDialog();
}
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
switch (mode)
{
case 1:
case 2:
e.Cancel = true;
break;
default:
2021-02-08 16:53:12 +03:00
if (Size.Width < 250)
Environment.Exit(0);
else
e.Cancel = true;
2021-02-08 16:44:09 +03:00
/*else
new Form1(iter_num + 1, mode).ShowDialog();*/
break;
}
}
private Size GetSizeByIterNum()
{
int width = 800;
for (int i = 0; i < iter_num; ++i)
{
try
{
width -= (width / 100 * 20);
}
catch (Exception) {
MessageBox.Show("w!!!", "Отладка");
}
}
int height = 500;
for (int j = 0; j < iter_num; ++j)
{
try
{
height -= (height / 100 * 20);
}
catch (Exception) {
MessageBox.Show("h!!!", "Отладка");
}
}
return new Size(width, height);
}
}
}