Example #1
0
        // Save list
        private void tsmSave_Click(object sender, EventArgs e)
        {
            if (!_firstSaved)
            {
                tsmSaveAs_Click(sender, e);
                return;
            }

            _audioList.SaveFile(_projectPath);
        }
Example #2
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)}";
        }