Takto to mam napsané nevím ani kam tu podmínku mam napsat
namespace Hra
{
public partial class Hra : Form
{
public Hra()
{
InitializeComponent();
}
private void pnlUp_MouseClick(object sender, MouseEventArgs e)
{
pnlLod.Location = new Point(pnlLod.Location.X, pnlLod.Location.Y - (int)numKrok.Value);
if (pnlLod.Location.Y - numKrok.Value > 0)
pnlLod.Location = new Point(pnlLod.Location.X, pnlLod.Location.Y - (int)numKrok.Value);
else
pnlLod.Top = 0;
}
private void pnlDown_MouseClick(object sender, MouseEventArgs e)
{
if (pnlLod.Location.Y + pnlLod.Size.Height + numKrok.Value < ClientSize.Height)
pnlLod.Location = new Point(pnlLod.Location.X, pnlLod.Location.Y + (int)numKrok.Value);
else
pnlLod.Top = ClientSize.Height - pnlLod.Height;
}
private void pnlRight_MouseClick(object sender, MouseEventArgs e)
{
if (pnlLod.Location.X + pnlLod.Size.Width + numKrok.Value < ClientSize.Width)
pnlLod.Location = new Point(pnlLod.Location.X + (int)numKrok.Value, pnlLod.Location.Y);
else
pnlLod.Left = ClientSize.Width - pnlLod.Width;
}
private void pnlLeft_MouseClick(object sender, MouseEventArgs e)
{
if (pnlLod.Location.X - numKrok.Value > 0)
pnlLod.Location = new Point(pnlLod.Location.X - (int)numKrok.Value, pnlLod.Location.Y);
else
pnlLod.Left = 0;
}
private void Hra_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Up)
if (pnlLod.Location.Y - numKrok.Value > 0)
pnlLod.Location = new Point(pnlLod.Location.X, pnlLod.Location.Y - (int)numKrok.Value);
else
pnlLod.Top = 0;
if (pnlLod.Location.Y + pnlLod.Size.Height < ClientSize.Height)
if (e.KeyCode == Keys.Down)
if (pnlLod.Location.Y + pnlLod.Size.Height + numKrok.Value < ClientSize.Height)
pnlLod.Location = new Point(pnlLod.Location.X, pnlLod.Location.Y + (int)numKrok.Value);
else
pnlLod.Top = ClientSize.Height - pnlLod.Height;
if (e.KeyCode == Keys.Left)
if (pnlLod.Location.X - numKrok.Value > 0)
pnlLod.Location = new Point(pnlLod.Location.X - (int)numKrok.Value, pnlLod.Location.Y);
else
pnlLod.Left = 0;
if (e.KeyCode == Keys.Right)
if (pnlLod.Location.X + pnlLod.Size.Width + numKrok.Value < ClientSize.Width)
pnlLod.Location = new Point(pnlLod.Location.X + (int)numKrok.Value, pnlLod.Location.Y);
else
pnlLod.Left = ClientSize.Width - pnlLod.Width;
if (e.KeyCode == Keys.Escape)
Close();
}
private void Hra_MouseDown(object sender, MouseEventArgs e)
{
pnlLod.Location = new Point(e.X, e.Y);
if (pnlLod.Location.X + pnlLod.Size.Width > ClientSize.Width)
pnlLod.Left = ClientSize.Width - pnlLod.Width;
if (pnlLod.Location.Y + pnlLod.Size.Height > ClientSize.Height)
pnlLod.Top = ClientSize.Height - pnlLod.Height;
}
}
}