public TMXGlueLib.property AddProperty(mapTilesetTile tile, string name, string type,
            bool raiseChangedEvent = true)
        {
            var newProperty = new TMXGlueLib.property();
            LayersController.SetPropertyNameFromNameAndType(name, type, newProperty);

            tile.properties.Add(newProperty);

            bool newTileAdded = false;
            if (AppState.Self.CurrentTileset.Tiles.Contains(tile) == false)
            {
                AppState.Self.CurrentTileset.Tiles.Add(tile);
                newTileAdded = true;
            }
            UpdateXnaDisplayToTileset();

            UpdatePropertiesUI();

            if (raiseChangedEvent && AnyTileMapChange != null)
            {
                TileMapChangeEventArgs args = new TileMapChangeEventArgs();
                args.ChangeType = ChangeType.Tileset;
                AnyTileMapChange(this, args);
            }
            return newProperty;
        }
        private static TypeConverter GetTypeConverterForProperty(property property)
        {
            int lastOpen = property.name.LastIndexOf('(');
            int lastClosed = property.name.LastIndexOf(')');
            string type = null;
            if (lastOpen != -1 && lastClosed != -1 && lastClosed > lastOpen)
            {
                type = property.name.Substring(lastOpen + 1, lastClosed - (lastOpen + 1));
            }

            switch (type)
            {
                case "float":
                case "Single":
                case "System.Single":
                    return new System.ComponentModel.SingleConverter();
                //break;
                case "int":
                case "System.Int32":
                    return new System.ComponentModel.Int32Converter();
                //break;
                case "bool":
                case "Boolean":
                case "System.Boolean":
                    return new System.ComponentModel.BooleanConverter();
                //break;
                case "long":
                case "System.Int64":
                    return new System.ComponentModel.Int64Converter();
                //break;
                case "double":
                case "Double":
                case "System.Double":
                    return new System.ComponentModel.DoubleConverter();
                // break;
                default:
                    return null;
            }
        }
        private void HandlePasteTilesetTileProperties(KeyPressEventArgs e)
        {
            e.Handled = true;
            // Paste CTRL+V stuff

            if (CurrentTilesetTile != null)
            {
                if (CopyPasteManager.Self.CopiedTilesetTile != null)
                {
                    bool wasAnythingChanged = false;

                    foreach (var propertyToCopy in CopyPasteManager.Self.CopiedTilesetTile.properties)
                    {
                        if (propertyToCopy.StrippedNameLower != "name")
                        {
                            // Is there already a property with this name?
                            property toPasteOn = CurrentTilesetTile.properties.FirstOrDefault(item => item.StrippedNameLower == propertyToCopy.StrippedNameLower);

                            if (toPasteOn == null)
                            {
                                toPasteOn = new property();
                                CurrentTilesetTile.properties.Add(toPasteOn);
                            }

                            toPasteOn.name = propertyToCopy.name;
                            toPasteOn.value = propertyToCopy.value;

                            CurrentTilesetTile.ForceRebuildPropertyDictionary();

                            wasAnythingChanged = true;

                        }
                    }

                    if (wasAnythingChanged)
                    {
                        if (GetExistingProperty("Name", CurrentTilesetTile) == null)
                        {
                            AddRandomNameTo(CurrentTilesetTile);
                        }

                    }

                    if (wasAnythingChanged)
                    {
                        UpdateXnaDisplayToTileset();

                        RefreshUiToSelectedTile();

                        if (AnyTileMapChange != null)
                        {
                            AnyTileMapChange(this, null);
                        }

                    }
                }
            }
        }