GDI: Dynamical Multiple Graphics in a page?
Posted
by SirLenz0rlot
on Stack Overflow
See other posts from Stack Overflow
or by SirLenz0rlot
Published on 2010-04-15T08:36:49Z
Indexed on
2010/04/15
8:43 UTC
Read the original article
Hit count: 227
Hi all, I'm quite new to drawing shapes, graphics, bitmaps etc. I googled for a few days,but still havent got a real clue what to do, so please help me:
I want to draw a floorplan with certain objects(represented as circles) moving on it. When I click on a object, it needs to show something.
So far, I ve been able to draw some circles on a graphic and been able to move the dots by clearing the graphic every time. Ofcourse, this isnt a real solution, since I cant keep track of the different objects on the floorplan (which i need for my clickevent and movings).
I hope I explained my problem ok here.
This is the (stripped version of the) sourcecode that gets called every second: (dev (of type Device) is the object i want to draw)
Graphics gfx = FloorplanTabPage.CreateGraphics();
gfx.Clear(Color.White);
foreach (Device dev in _deviceList)
{
Pen myPen = new Pen(Color.Black) { Width = 10 };
dev.InRoom != null)
{
myPen.Color = Color.DarkOrchid;
int x = dev.InRoom.XPos + (dev.InRoom.Width / 2) - 5;
int y = (dev.InRoom.YPos + (dev.InRoom.Height / 2) - 5;
if (dev.ToRoom != null)
{
x = (x + (dev.ToRoom.XPos + (dev.ToRoom.Width / 2)) / 2;
y = (y + (dev.ToRoom.YPos + (dev.ToRoom.Height / 2)) / 2;
}
gfx.DrawEllipse(myPen, x, y, 10, 10);
gfx.DrawString(dev.Name, new Font("Arial", 10), Brushes.Purple, x, y - 15);
}
}
© Stack Overflow or respective owner