Hey, i want to save the Positions of Points i draw on the Screen in an Array List, and then later when i press a button, draw that Points back on the screen.
When i type pos[i]. it does’t show me that i could use the properties x and y.
The commented line is not working like that, how could i make it work?
Thank you, and sry if this is a stupid beginners Question…
class Position
class Position
{
uint x;
public uint X
{
get { return x; }
set { x = value; }
}
uint y;
public uint Y
{
get { return y; }
set { y = value; }
}
public Position(uint _x, uint _y)
{
this.x = _x;
this.y = _y;
}
}
class Program
public partial class Program
{
static uint r = 1;
ArrayList pos = new ArrayList();
void ProgramStarted()
{
display.SimpleGraphics.AutoRedraw = true;
display.WPFWindow.TouchDown += new Microsoft.SPOT.Input.TouchEventHandler(WPFWindow_TouchDown);
display.WPFWindow.TouchUp += new Microsoft.SPOT.Input.TouchEventHandler(WPFWindow_TouchUp);
display.WPFWindow.TouchMove += new Microsoft.SPOT.Input.TouchEventHandler(WPFWindow_TouchMove);
button.ButtonPressed += new Button.ButtonEventHandler(button_ButtonPressed);
button1.ButtonPressed += new Button.ButtonEventHandler(button1_ButtonPressed);
display.SimpleGraphics.BackgroundColor = GT.Color.Black;
display.WPFWindow.Invalidate();
Debug.Print("Programm gestartet");
}
void WPFWindow_TouchMove(object sender, Microsoft.SPOT.Input.TouchEventArgs e)
{
display.SimpleGraphics.DisplayEllipse(GT.Color.Blue, (uint)e.Touches[0].X, (uint)e.Touches[0].Y, r, r);
Position p = new Position((uint)e.Touches[0].X, (uint)e.Touches[0].Y);
pos.Add(p);
}
void WPFWindow_TouchDown(object sender, Microsoft.SPOT.Input.TouchEventArgs e)
{
multicolorLed.TurnGreen();
}
void WPFWindow_TouchUp(object sender, Microsoft.SPOT.Input.TouchEventArgs e)
{
multicolorLed.TurnOff();
}
void button_ButtonPressed(Button sender, Button.ButtonState state)
{
display.SimpleGraphics.Clear();
pos.Clear();
}
void button1_ButtonPressed(Button sender, Button.ButtonState state)
{
display.SimpleGraphics.Clear();
for (int i = 0; i < pos.Count; i++)
{
display.SimpleGraphics.DisplayEllipse(GT.Color.Blue, pos[i].x, pos[i].y, r, r); // This line is wat doesnt work like that, can anyone tell me how i could do that?
}
}
}