private void CreateNewControl()
{
int left, top, width, height;
GetSelectionRectangle(out left, out top, out width, out height);
ConvertCoordinatesToGameUnits(ref left, ref top, ref width, ref height);
if ((width < 2) || (height < 2))
{
return;
}
GUIControl newControl = null;
switch (_controlAddMode)
{
case GUIAddType.Button:
newControl = new GUIButton(left, top, width, height);
break;
case GUIAddType.Label:
newControl = new GUILabel(left, top, width, height);
break;
case GUIAddType.TextBox:
newControl = new GUITextBox(left, top, width, height);
break;
case GUIAddType.ListBox:
newControl = new GUIListBox(left, top, width, height);
break;
case GUIAddType.Slider:
newControl = new GUISlider(left, top, width, height);
break;
case GUIAddType.InvWindow:
newControl = new GUIInventory(left, top, width, height);
break;
default:
throw new AGSEditorException("Unknown control type added: " + _controlAddMode.ToString());
}
newControl.Name = Factory.AGSEditor.GetFirstAvailableScriptName(newControl.ControlType);
newControl.ZOrder = _gui.Controls.Count;
newControl.ID = _gui.Controls.Count;
_gui.Controls.Add(newControl);
_selectedControl = newControl;
_selected.Clear();
_selected.Add(newControl);
RaiseOnControlsChanged();
Factory.AGSEditor.CurrentGame.NotifyClientsGUIControlAddedOrRemoved(_gui, newControl);
Factory.GUIController.SetPropertyGridObject(newControl);
bgPanel.Invalidate();
UpdateCursorImage();
// Revert back to Select cursor
OnCommandClick(Components.GuiComponent.MODE_SELECT_CONTROLS);
}