Exemplo n.º 1
0
        /// <summary>
        /// Checks for the user pressing the backspace key when a node is selected.
        /// If PromptOnDelete is enabled will prompt user with DeleteConfirmation otherwise
        /// will just delete the video when backspace is pressed and BackspaceDelete is
        /// enabled.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void nodeListView_KeyPress(object sender,
                                           KeyPressEventArgs e)
        {
            if (Properties.Settings.Default.BackspaceDelete)
            {
                if ((e.KeyChar == '\b') && (nodeListView.SelectedItems.Count > 0))
                {
                    bool delete = false; // this is set to true if delete should take place

                    // If PromptOnDelete then run the confirmation dialog
                    if (Properties.Settings.Default.PromptOnDelete)
                    {
                        DeleteConfirmation prompt = new DeleteConfirmation();
                        prompt.ShowDialog();
                        delete = prompt.Delete;
                    }
                    // else just set to delete
                    else
                    {
                        delete = true;
                    }

                    if (delete)
                    {
                        ListView.SelectedIndexCollection indexes = nodeListView.SelectedIndices;
                        foreach (int index in indexes)
                        {
                            db.removeNode(nodes[index]);
                        }
                        db.refreshNodes(ref nodes);
                        loadNodes();
                    }
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Deletes currently selected group. If PromptOnDelete is true
        /// it will prompt the users using DeleteConfirmation.
        /// Refreshes groups.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void deleteGroupMenuItem_Click(object sender, EventArgs e)
        {
            if (groupListBox.SelectedIndex >= 0)
            {
                bool delete = false; // This decides if the group should actually be deleted.

                if (Properties.Settings.Default.PromptOnDelete)
                {
                    DeleteConfirmation prompt = new DeleteConfirmation();
                    prompt.ShowDialog();
                    delete = prompt.Delete;
                }
                else
                {
                    delete = true; // If not prompted just delete it.
                }
                if (delete)
                {
                    db.removeGroup((AVM.Types.Group)groupListBox.SelectedItem);
                    refreshGroups();
                    db.CurrentGroup = db.ParentGroup;
                    if (groupListBox.Items.Count == 0)
                    {
                        forwardButton.Enabled = false;
                    }
                    db.refreshNodes(ref nodes);
                    loadNodes();
                    // See if a group is selected
                    if (db.CurrentGroup != 0)
                    {
                        groupTitleLabel.Text = db.findBreadcrumbs(db.CurrentGroup); //((AVM.Types.Group)groupListBox.SelectedItem).Name;
                    }
                    else
                    {
                        groupTitleLabel.Text = "";
                    }
                }
            }
        }