protected override void OnPropertyChanged(string propertyName, object oldValue)
{
if (propertyName == "Name")
{
object objectBeingChanged = _gui;
string newName = _gui.Name;
if (_selectedControl != null)
{
objectBeingChanged = _selectedControl;
newName = _selectedControl.Name;
}
Game game = Factory.AGSEditor.CurrentGame;
bool nameInUse = game.IsScriptNameAlreadyUsed(newName, objectBeingChanged);
if (newName.StartsWith("g") && newName.Length > 1)
{
nameInUse |= game.IsScriptNameAlreadyUsed(newName.Substring(1).ToUpper(), objectBeingChanged);
}
if (nameInUse)
{
Factory.GUIController.ShowMessage("This script name is already used by another item.", MessageBoxIcon.Warning);
if (_selectedControl != null)
{
_selectedControl.Name = (string)oldValue;
}
else
{
_gui.Name = (string)oldValue;
}
}
else if (_selectedControl == null)
{
RaiseOnGuiNameChanged();
}
}
else if (propertyName == "Image")
{
if ((_selectedControl != null) && (_selectedControl is GUIButton))
{
GUIButton selectedButton = (GUIButton)_selectedControl;
if (selectedButton.Image > 0)
{
int newWidth, newHeight;
Utilities.GetSizeSpriteWillBeRenderedInGame(selectedButton.Image, out newWidth, out newHeight);
selectedButton.Width = newWidth;
selectedButton.Height = newHeight;
}
}
}
}