Example #1
0
        private void mainListView_DragDrop(object sender, DragEventArgs e)
        {
            String[] fileNames = e.Data.GetData(DataFormats.FileDrop) as String[];

            if (fileNames != null && fileNames.Length > 0)
            {
                foreach (String name in fileNames)
                {
                    if ((File.GetAttributes(name) & FileAttributes.Directory) == FileAttributes.Directory)
                    {
                        FormHelper.AddAudioFilesToListView(mainListView, FileHelper.GetAudioFilesFromFolder(name));
                    }
                }

                FormHelper.AddAudioFilesToListView(mainListView, fileNames);

                runToolStripButton.Enabled = (mainListView.Items.Count > 0);
            }
        }
Example #2
0
        private void mainToolStrip_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
        {
            if (e.ClickedItem == addFileToolStripButton)
            {
                using (OpenFileDialog dlg = new OpenFileDialog())
                {
                    dlg.Title       = "Select audio files";
                    dlg.Filter      = FormHelper.BuildFilterString();
                    dlg.Multiselect = true;

                    if (dlg.ShowDialog(this) == DialogResult.OK)
                    {
                        FormHelper.AddAudioFilesToListView(mainListView, dlg.FileNames);

                        runToolStripButton.Enabled = (mainListView.Items.Count > 0);
                    }
                }
            }
            else if (e.ClickedItem == addFolderToolStripButton)
            {
                using (FolderBrowserDialog dlg = new FolderBrowserDialog())
                {
                    dlg.Description         = "Select a folder contains audio files";
                    dlg.ShowNewFolderButton = false;

                    if (dlg.ShowDialog(this) == DialogResult.OK)
                    {
                        FormHelper.AddAudioFilesToListView(mainListView, FileHelper.GetAudioFilesFromFolder(dlg.SelectedPath));

                        runToolStripButton.Enabled = (mainListView.Items.Count > 0);
                    }
                }
            }
            else if (e.ClickedItem == removeToolStripButton)
            {
                while (mainListView.SelectedItems.Count > 0)
                {
                    mainListView.Items.Remove(mainListView.SelectedItems[mainListView.SelectedItems.Count - 1]);
                }

                runToolStripButton.Enabled = (mainListView.Items.Count > 0);
            }
            else if (e.ClickedItem == runToolStripButton)
            {
                if (VariableHelper.DeleteSourceFiles)
                {
                    DialogResult promptResult = MessageBox.Show(
                        String.Format("The source files will be deleted from disk after decoding.{0}{0}Are you sure you want to proceed?", Environment.NewLine),
                        Application.ProductName,
                        MessageBoxButtons.YesNo,
                        MessageBoxIcon.Warning,
                        MessageBoxDefaultButton.Button2);

                    if (promptResult == DialogResult.No)
                    {
                        return;
                    }
                }

                List <ListViewItem> deletedFileItems = new List <ListViewItem>();

                foreach (ListViewItem item in mainListView.Items)
                {
                    if (!File.Exists(FormHelper.GetAudioFileNameFromListViewItem(item)))
                    {
                        deletedFileItems.Add(item);
                    }
                }

                if (deletedFileItems.Count > 0)
                {
                    DialogResult promptResult = MessageBox.Show(
                        String.Format("One or more files may not exist anymore since they have been added.{0}They will be removed from the list if proceed.{0}{0}Are you sure you want to proceed?", Environment.NewLine),
                        Application.ProductName,
                        MessageBoxButtons.YesNo,
                        MessageBoxIcon.Warning);

                    if (promptResult == DialogResult.No)
                    {
                        return;
                    }
                }

                foreach (ListViewItem item in deletedFileItems)
                {
                    mainListView.Items.Remove(item);
                }

                deletedFileItems.Clear();

                using (ProgressForm progressForm = new ProgressForm(mainListView))
                {
                    progressForm.ShowDialog(this);
                }
            }
            else if (e.ClickedItem == configToolStripButton)
            {
                using (ConfigForm configForm = new ConfigForm())
                {
                    configForm.ShowDialog(this);
                }

                addFileToolStripButton.Enabled   = (VariableHelper.AudioDecoders.Count > 0);
                addFolderToolStripButton.Enabled = (VariableHelper.AudioDecoders.Count > 0);
            }
            else if (e.ClickedItem == aboutToolStripButton)
            {
                using (AboutBox aboutBox = new AboutBox())
                {
                    aboutBox.ShowDialog(this);
                }
            }
        }