2024-02-08 08:44:33 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.ComponentModel;
|
|
|
|
|
using System.Data;
|
|
|
|
|
using System.Drawing;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
|
|
|
|
|
namespace Hanoitornyai
|
|
|
|
|
{
|
|
|
|
|
public partial class Form1 : Form
|
|
|
|
|
{
|
|
|
|
|
public Rud[] rudak;
|
|
|
|
|
private Color[] kszinek = {Color.Red, Color.Orange, Color.Yellow, Color.Aqua, Color.Blue};
|
|
|
|
|
public Form1()
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
rudak = new Rud[3];
|
|
|
|
|
for (int i = 0; i < rudak.Length; i++)
|
|
|
|
|
{
|
|
|
|
|
rudak[i] = new Rud(Color.Black);
|
|
|
|
|
}
|
|
|
|
|
for (int i = 0;i < kszinek.Length;i++)
|
|
|
|
|
{
|
2024-02-08 09:41:20 +00:00
|
|
|
|
rudak[0].korongok.Add(new Korong(kszinek[i], 5-i));
|
2024-02-08 08:44:33 +00:00
|
|
|
|
}
|
2024-02-08 09:04:50 +00:00
|
|
|
|
rudakPozicioSzamitas();
|
2024-02-08 08:44:33 +00:00
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void Form1_ResizeEnd(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
//Initialize();
|
|
|
|
|
}
|
|
|
|
|
|
2024-02-08 09:04:50 +00:00
|
|
|
|
private void rudakPozicioSzamitas()
|
2024-02-08 08:44:33 +00:00
|
|
|
|
{
|
|
|
|
|
float psz = JatekPanel.Width;
|
|
|
|
|
float pm = JatekPanel.Height;
|
|
|
|
|
float rm = pm * 0.75f;
|
|
|
|
|
float rsz = rm / 12;
|
|
|
|
|
float rkoz = (psz - (3 * rsz)) / 4;
|
|
|
|
|
for (int i = 0; i < rudak.Length; i++)
|
|
|
|
|
{
|
|
|
|
|
rudak[i].magassag = rm;
|
|
|
|
|
rudak[i].szelesseg = rsz;
|
|
|
|
|
rudak[i].y = pm / 4;
|
|
|
|
|
rudak[i].x = (rkoz*(i+1))+(i*rsz);
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-02-08 09:04:50 +00:00
|
|
|
|
|
|
|
|
|
private void KorongSzamitas()
|
|
|
|
|
{
|
|
|
|
|
float km = rudak[0].szelesseg*1.5f;
|
2024-02-08 09:41:20 +00:00
|
|
|
|
float rsz = rudak[0].szelesseg;
|
|
|
|
|
for (int i = 0; i < 3; i++)
|
|
|
|
|
{
|
|
|
|
|
for (int j = 0; j < rudak[i].korongok.Count; j++)
|
|
|
|
|
{
|
|
|
|
|
rudak[i].korongok[j].magassag = km;
|
|
|
|
|
int meret = rudak[i].korongok[j].meretjelzo;
|
|
|
|
|
rudak[i].korongok[j].szelesseg = rsz + (rsz*meret);
|
|
|
|
|
float rx = rudak[i].x;
|
|
|
|
|
rudak[i].korongok[j].x = rx - ((rudak[i].korongok[j].szelesseg - rsz) / 2);
|
|
|
|
|
rudak[i].korongok[j].y = JatekPanel.Height - ((j + 1) * km);
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-02-08 09:04:50 +00:00
|
|
|
|
}
|
2024-02-08 08:44:33 +00:00
|
|
|
|
/*
|
|
|
|
|
public void Initialize()
|
|
|
|
|
{
|
|
|
|
|
Graphics g = JatekPanel.CreateGraphics();
|
|
|
|
|
g.Clear(Color.White);
|
|
|
|
|
Pen toll = new Pen(Color.Black);
|
|
|
|
|
Brush brush = new SolidBrush(Color.Black);
|
|
|
|
|
int egynegyed = JatekPanel.Width / 4;
|
|
|
|
|
int ketharmad = (JatekPanel.Height / 3) * 2;
|
|
|
|
|
g.FillRectangle(brush, new Rectangle(egynegyed - 10, JatekPanel.Height - ketharmad, 20, ketharmad));
|
|
|
|
|
g.FillRectangle(brush, new Rectangle(egynegyed * 2 - 10, JatekPanel.Height - ketharmad, 20, ketharmad));
|
|
|
|
|
g.FillRectangle(brush, new Rectangle(egynegyed * 3 - 10, JatekPanel.Height - ketharmad, 20, ketharmad));
|
|
|
|
|
g.FillRectangle(brush, new Rectangle(0, JatekPanel.Height - 20, JatekPanel.Width, 20));
|
|
|
|
|
|
|
|
|
|
}*/
|
|
|
|
|
private void Paint(object sender, PaintEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
Graphics g = JatekPanel.CreateGraphics();
|
2024-02-08 09:04:50 +00:00
|
|
|
|
g.Clear(JatekPanel.BackColor);
|
2024-02-08 08:44:33 +00:00
|
|
|
|
Brush brush = new SolidBrush(rudak[0].szin);
|
2024-02-08 09:04:50 +00:00
|
|
|
|
rudakPozicioSzamitas();
|
2024-02-08 09:41:20 +00:00
|
|
|
|
KorongSzamitas();
|
2024-02-08 08:44:33 +00:00
|
|
|
|
for (int i = 0; i < rudak.Length; i++)
|
|
|
|
|
{
|
|
|
|
|
g.FillRectangle(brush, rudak[i].x, rudak[i].y, rudak[i].szelesseg, rudak[i].magassag);
|
2024-02-08 09:41:20 +00:00
|
|
|
|
foreach(Korong k in rudak[i].korongok)
|
|
|
|
|
{
|
|
|
|
|
Brush korongecset = new SolidBrush(k.szin);
|
|
|
|
|
g.FillRectangle(korongecset, k.x, k.y, k.szelesseg, k.magassag);
|
|
|
|
|
}
|
2024-02-08 08:44:33 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|