void AddBT_Click(object sender, EventArgs e) { List <string> sel = editor.GetSelection(); List <Area> areas = new List <Area>(); float minX = float.MaxValue; float maxX = float.MinValue; float minY = float.MaxValue; float maxY = float.MinValue; foreach (string selItem in sel) { RigElement elem = editor.GenData.RealNamesControls[selItem]; Area oscarControlArea = AreaMapComponent.AddOscarControl(selItem, elem, editor.GenData.CtrlsInfos[elem.FullName], editor.Projection); Vector2 corner = oscarControlArea.Corner; Vector2 otherCorner = oscarControlArea.Shape.LowerRightCorner; if (maxX < otherCorner.X) { maxX = otherCorner.X; } if (minX > corner.X) { minX = corner.X; } if (maxY < otherCorner.Y) { maxY = otherCorner.Y; } if (minY > corner.Y) { minY = corner.Y; } areas.Add(oscarControlArea); } float Yextension = maxY - minY; float Xextension = maxX - minX; float scale = Math.Min(AreaMapComponent.Width / Xextension, AreaMapComponent.Height / Yextension); foreach (Area area in areas) { area.Center *= new Vector2(1.0f, -1.0f); area.Center += new Vector2(-minX, maxY); area.Scale(new Vector2(scale, scale), new Vector2(0f, 0f)); } AreaMapComponent.Invalidate(); RefreshListBox(); }