void AddElement(EditElement e) { lock (Elements) { Elements.Add(e); panel1.Controls.Add(e.ImageTile); } }
internal void RemoveElement(EditElement e) { lock (Elements) { Elements.Remove(e); panel1.Controls.Remove(e.ImageTile); } }
void AddNewElement(int width, int height) { SignComponent c = new SignComponent() { Width = width, Height = height }; EditElement e = new EditElement(this, c); // Find a new grid-aligned location that doesn't overlap with any other element for (int y = 0; y < MaxY; y += height) { for (int x = 0; x < MaxX; x += width) { e.Location.X = x; e.Location.Y = y; if (!e.Collides()) break; } if (!e.Collides()) break; } if(e.Collides()) { // Silently fail. return; } e.SyncLocation(); AddElement(e); ConfigurationChange(); }