AtlasPlugin.ViewModels.AtlasListViewModel.HandleListBoxKeyDown C# (CSharp) Method

HandleListBoxKeyDown() private method

private HandleListBoxKeyDown ( System e ) : void
e System
return void
        internal void HandleListBoxKeyDown(System.Windows.Input.KeyEventArgs e)
        {
            if(e.Key == Key.Delete)
            {
                bool canRemove = SelectedAtlas != null && 
                    // If "" is selected, then that means that the "entire content folder"
                    // atlas is selected, so don't remove
                    SelectedAtlas.Folder != "";

                if (canRemove)
                {

                    Atlases.Remove(SelectedAtlas);

                    if (Atlases.Count == 0)
                    {
                        // need to add the empty atlas:
                        var emptyFolderViewModel = new AtlasViewModel();
                        emptyFolderViewModel.Folder = "";
                        Atlases.Add(emptyFolderViewModel);
                    }
                }
            }
        }