示例#1
0
        private void AddPalette_Click(object sender, RoutedEventArgs e)
        {
            string paletteName = InputWindow.GetInput("Enter palette name.");

            if (paletteName != null)
            {
                PaletteList.SelectedValue = _palettesService.NewPalette(paletteName, _editingPalette).Id;
            }
        }
示例#2
0
        private void Rename_Click(object sender, RoutedEventArgs e)
        {
            if (WorldTree.SelectedItem != null)
            {
                object dataContext = ((TreeViewItem)WorldTree.SelectedItem).DataContext;

                if (dataContext is LevelInfo)
                {
                    LevelInfo levelInfo    = dataContext as LevelInfo;
                    string    previousName = levelInfo.Name;

                    string newName = InputWindow.GetInput("Rename level", levelInfo.Name);
                    if (newName != null)
                    {
                        LevelInfo existingInfo = _levelService.AllLevels().Where(l => l.Name.Equals(newName, System.StringComparison.OrdinalIgnoreCase)).FirstOrDefault();
                        if (existingInfo == null)
                        {
                            _levelService.RenameLevel(levelInfo.Name, newName);
                            levelInfo.Name = newName;

                            _levelService.NotifyUpdate(levelInfo);
                            NameUpdated(new NameUpdate((IInfo)levelInfo, previousName, levelInfo.Name));
                            ((TreeViewItem)WorldTree.SelectedItem).Header = levelInfo.Name;
                        }
                        else
                        {
                            AlertWindow.Alert(newName + " already exists!");
                        }
                    }
                }
                else if (dataContext is WorldInfo)
                {
                    WorldInfo worldInfo    = dataContext as WorldInfo;
                    string    previousName = worldInfo.Name;

                    string newName = InputWindow.GetInput("Rename map", worldInfo.Name);
                    if (newName != null)
                    {
                        WorldInfo existingInfo = _worldService.AllWorlds().Where(w => w.Name.Equals(newName, System.StringComparison.OrdinalIgnoreCase)).FirstOrDefault();
                        if (existingInfo == null)
                        {
                            _worldService.RenameWorld(worldInfo.Name, newName);
                            worldInfo.Name = newName;

                            NameUpdated(new NameUpdate((IInfo)worldInfo, previousName, worldInfo.Name));
                            ((TreeViewItem)WorldTree.SelectedItem).Header = worldInfo.Name;
                        }
                        else
                        {
                            AlertWindow.Alert(newName + " already exists!");
                        }
                    }
                }
            }
        }
示例#3
0
        private void NewButton_Click(object sender, RoutedEventArgs e)
        {
            string inputText = InputWindow.GetInput("Text Table Name");

            if (!string.IsNullOrWhiteSpace(inputText))
            {
                _textService.AddTable(inputText);
                var newTables = _textService.TableNames();
                TextTables.ItemsSource  = newTables;
                TextTables.SelectedItem = newTables[newTables.Count - 1];
            }
        }