using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Drawing;
namespace VstupniTest
{
public class Control
{
private Window window;
private Point position;
private int drawCount;
private int moveCount;
public int DrawCount
{
get
{
return this.drawCount;
}
}
public int MoveCount
{
get
{
return this.moveCount;
}
}
private Control() { }
///
/// Objekt pro ovladani.
///
/// Startovni pozice na ose X.
/// Startovni pozice na ose Y.
public Control(int x, int y)
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
this.window = new Window(this);
this.position = new Point(x, y);
this.drawCount = 0;
this.moveCount = 0;
}
///
/// Posune se do zadane pozice.
///
/// Souradnice X.
/// Souradnice Y.
/// Pocet presunu.
public int Move(int x, int y)
{
this.position = new Point(x, -y);
this.window.SetMoveCount(++this.moveCount);
return this.moveCount;
}
///
/// Vykresli usecku z aktualni pozice do nove pozice.
///
/// Souradnice X.
/// Souradnice Y.
/// Tloustka usecky.
/// Barva usecky.
/// Pocet vykreslenych usecek.
public int Draw(int x, int y, int width = 1, Color? color = null)
{
this.window.AddLine(new Line(this.position, new Point(x, -y), width, color));
this.position = new Point(x, -y);
this.window.SetDrawCount(++this.drawCount);
return this.drawCount;
}
///
/// Dalsi hodnota N.
///
public void Next()
{
Program.Next();
}
///
/// Zobrazeni GUI.
///
public void Show()
{
Application.Run(this.window);
}
///
/// Prekresleni okna.
///
public void Refresh()
{
this.window.Refresh();
}
///
/// Vycisti okno pro nove malovani
///
/// Startovni pozice na ose X.
/// Startovni pozice na ose Y.
public void Reset(int x, int y)
{
this.position = new Point(x, y);
this.drawCount = 0;
this.moveCount = 0;
this.window.SetDrawCount(0);
this.window.SetMoveCount(0);
this.window.Reset();
}
}
}