コード例 #1
0
        // Add audio to list
        private void btnAppend_Click(object sender, EventArgs e)
        {
            var opfDialog = new OpenFileDialog {
                Title            = "選取音訊檔案",
                Filter           = "音訊檔案|*.m4a;*.mp3;*.wav;*.wma;*.aac",
                RestoreDirectory = true
            };

            if (opfDialog.ShowDialog() != DialogResult.OK)
            {
                return;
            }
            var newAudio = new frmNewAudio(_audioList, opfDialog.FileName);

            if (newAudio.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            // Update controls
            _audioList.ToListViewItemCollection(listPending);
            lblTotalTime.Text = $"總時長:{MsToTime(_audioList.totalDuration)}";
            btnExport.Enabled = listPending.Items.Count != 0;

            // Scroll to bottom
            if (listPending.Items.Count != 0)
            {
                listPending.Items[listPending.Items.Count - 1].EnsureVisible();
            }
        }
コード例 #2
0
        // Load list from a project file (.lmtproj)
        private void tsmOpenProject_Click(object sender, EventArgs e)
        {
            // Check if current project saved
            if (!_audioList.IsSaved)
            {
                Alert();
                var dr = MessageBox.Show(
                    "現有的專案尚未儲存,你是否要儲存變更?",
                    "儲存變更",
                    MessageBoxButtons.YesNoCancel);
                if (dr == DialogResult.Yes)
                {
                    tsmSave_Click(sender, e);
                }
                if (dr == DialogResult.Cancel)
                {
                    return;
                }
            }

            // Chooses file
            var openDialog = new OpenFileDialog {
                Filter           = "LMTool專案|*.lmtproj",
                Title            = "開啟舊檔",
                RestoreDirectory = true
            };

            if (openDialog.ShowDialog() != DialogResult.OK)
            {
                return;
            }
            _projectPath = openDialog.FileName;

            // Creates new temp dir
            _tempPath = $@"{Path.GetTempPath()}LMTool\{DateTime.Now.ToString()
                .Replace("/", "").Replace(":", "").Replace(" ", "")}";
            Directory.CreateDirectory(_tempPath);

            // Re-create AudioTaskItemsCollection object
            _audioList = new AudioTaskItemsCollection(openDialog.FileName, _tempPath);

            // Clean up UI
            _audioList.ToListViewItemCollection(listPending);
            btnExport.Enabled = false;
            btnDown.Enabled   = false;
            btnUp.Enabled     = false;
            lblTotalTime.Text = $"總時間:{MsToTime(_audioList.totalDuration)}";
        }
コード例 #3
0
        private void tsmNewProject_Click(object sender, EventArgs e)
        {
            // Check if current project saved
            if (!_audioList.IsSaved)
            {
                Alert();
                var dr = MessageBox.Show(
                    "現有的專案尚未儲存,你是否要儲存變更?",
                    "儲存變更",
                    MessageBoxButtons.YesNoCancel);
                if (dr == DialogResult.Yes)
                {
                    tsmSave_Click(sender, e);
                }
                if (dr == DialogResult.Cancel)
                {
                    return;
                }
            }

            // Creates new temp dir
            _tempPath = $@"{Path.GetTempPath()}LMTool\{DateTime.Now.ToString()
                .Replace("/", "").Replace(":", "").Replace(" ", "")}";
            Directory.CreateDirectory(_tempPath);

            // Re-create AudioTaskItemsCollection object
            _audioList = new AudioTaskItemsCollection(_tempPath);

            // Create a new file
            var i = 0;

            while (File.Exists($"./ProjectFiles/NewProject({i}).lmtproj"))
            {
                i++;
            }
            _projectPath = Path.GetFullPath($"./ProjectFiles/NewProject({i}).lmtproj");
            Text         = $"{_formTitle} - {Path.GetFileNameWithoutExtension(_projectPath)}";
            _audioList.SaveFile(_projectPath);
            _firstSaved = false;

            // Clean up UI
            _audioList.ToListViewItemCollection(listPending);
            btnExport.Enabled = false;
            btnDown.Enabled   = false;
            btnUp.Enabled     = false;
            lblTotalTime.Text = $"總時間:{MsToTime(_audioList.totalDuration)}";
        }