private void btnRemove_Click(object sender, EventArgs e) { int index = lboxFiles.SelectedIndex; if (index != -1) { lboxFiles.Items.RemoveAt(lboxFiles.SelectedIndex); } else { return; } if (lboxFiles.Items.Count > 0) { lboxFiles.SelectedIndex = index - 1; } if (lboxFiles.Items.Count == 0) { UIStatus = UIStatuses.Input; } }
private void DragDropHandler(object sender, DragEventArgs e) { WriteLog("User dropped mkv(s) on the UI"); //temp: Clear the lboxFiles if no queue if (UIMode == UIModes.Simple) { lboxFiles.Items.Clear(); } string[] s = (string[]) e.Data.GetData(DataFormats.FileDrop); bool exist = false; foreach (string str in s) { foreach (string itm in lboxFiles.Items) { if (itm == str) { exist = true; } } if (exist) { continue; } lboxFiles.Items.Add(str); if (UIMode == UIModes.Advanced) { tabControl.SelectedIndex = 1; } } FileInfo fi = new FileInfo(s[0]); //Get runtime of movie with MediaInfo WriteLog("Retrieving movie runtime"); try { duration = thechapterizer.GetMovieRuntime(fi.FullName); } catch (Exception) { //The value fetched from MediaInfo is invalid, the mkv is probably corrupt or invalid MessageBox.Show("The mkv file you dropped is either corrupt or invalid, please choose another!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (UIMode == UIModes.Simple) { if (ChaptersExist(fi.FullName)) { ChaptersExist f = new ChaptersExist(this); f.ShowDialog(this); switch (f.Result) { case 0: //Cancel WriteLog("User chose to cancel mkv drop"); return; case 1: //Remove WriteLog("User chose to de-chapterize the mkv"); btnMerge.Text = "De-Chapterize"; UIStatus = UIStatuses.RemoveChapters; break; case 2: //Remove and Insert New WriteLog("User chose to re-chapterize the mkv"); UIStatus = UIStatuses.Input; btnMerge.Text = "Re-Chapterize"; //Calculate the number of chapters with default chapter interval ChapterCount = CalcChapterCount(duration, ConvertToSeconds(tbarInterval.Value, cboxUnit.Text)); break; } } else { UIStatus = UIStatuses.Input; //Calculate the number of chapters with default chapter interval ChapterCount = CalcChapterCount(duration, ConvertToSeconds(tbarInterval.Value, cboxUnit.Text)); } } else { UIStatus = UIStatuses.Input; } }
private void btnMerge_Click(object sender, EventArgs e) { //Check if any file is selected if (lboxFiles.Items.Count < 1) { MessageBox.Show("Your queue is empty, please add at least one mkv to it!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } if (UIMode == UIModes.Simple && ModifierKeys == Keys.Shift) { if (Mode == ChapterMode.ChapterFile) { MessageBox.Show("Why would you want to create a chapter file out of a chapter file? duh!"); return; } if (CreateChapterFile(lboxFiles.Items[0].ToString())) { UIStatus = UIStatuses.AwaitFileDrop; } } else { UseChapterizer(); } }
private void UseChapterizer() { if (Properties.Settings.Default.customMKVMerge) { WriteLog(string.Format("Setting mkvmerge path: {0}", Properties.Settings.Default.customMKVMergePath)); thechapterizer.MKVMergePath = Properties.Settings.Default.customMKVMergePath; } else { WriteLog(@"Setting mkvmerge path: mkvmerge\mkvmerge.exe"); thechapterizer.MKVMergePath = "mkvmerge\\mkvmerge.exe"; } thechapterizer.ChapterCreationPattern = Properties.Settings.Default.chapterPattern; thechapterizer.MKVExtractPath = "mkvmerge\\mkvextract.exe"; thechapterizer.CustomChapterName = Properties.Settings.Default.customChapterName; thechapterizer.ShowConsole = Properties.Settings.Default.showConsole; thechapterizer.CustomOutputName = Properties.Settings.Default.customOutputName; thechapterizer.ExtraChapterEnd = Properties.Settings.Default.extraChapEnd; thechapterizer.ExtraChapterStart = Properties.Settings.Default.extraChapStart; if (btnMerge.Text == "Chapterize") { UIStatus = UIStatuses.Working; List<string> mkvList = lboxFiles.Items.Cast<string>().ToList(); thechapterizer.Files = mkvList; thechapterizer.ChaptersExistAction = queueAction; if (Mode == ChapterMode.ChapterDB && chapterSet != null) { thechapterizer.CustomChapterSet = chapterSet; thechapterizer.ChapterMode = Chapterizer.ChapterModes.ChapterSet; } else if (Mode == ChapterMode.ChapterFile && !string.IsNullOrWhiteSpace(txtChapterFileLocation.Text)) { thechapterizer.CustomChapterFile = txtChapterFileLocation.Text; thechapterizer.ChapterMode = Chapterizer.ChapterModes.File; } else { thechapterizer.ChapterInterval = ConvertToSeconds(tbarInterval.Value, cboxUnit.Text); thechapterizer.ChapterMode = Chapterizer.ChapterModes.Interval; } thechapterizer.OverwriteOutput = chkboxOverwrite.Checked; } else if (btnMerge.Text == "Re-Chapterize") { UIStatus = UIStatuses.Working; List<string> mkvList = lboxFiles.Items.Cast<string>().ToList(); thechapterizer.Files = mkvList; thechapterizer.ChaptersExistAction = 1; if (pnlChapterDB.Visible && chapterSet != null) { thechapterizer.CustomChapterSet = chapterSet; } else { thechapterizer.ChapterInterval = ConvertToSeconds(tbarInterval.Value, cboxUnit.Text); } thechapterizer.OverwriteOutput = chkboxOverwrite.Checked; } else if (btnMerge.Text == "De-Chapterize") { UIStatus = UIStatuses.Working; List<string> mkvList = lboxFiles.Items.Cast<string>().ToList(); thechapterizer.Files = mkvList; thechapterizer.ChaptersExistAction = 2; thechapterizer.ChapterInterval = ConvertToSeconds(tbarInterval.Value, cboxUnit.Text); thechapterizer.OverwriteOutput = chkboxOverwrite.Checked; } else if (btnMerge.Text == "Cancel") { //Cancel the ongoing merge WriteLog("User chose to cancel current operation"); btnMerge.Text = "Cancelling..."; thechapterizer.Cancel(); return; } WriteLog("Starting chapterizer"); if (UIMode == UIModes.Advanced) { if (!chkboxOutputChapterfile.Checked) { thechapterizer.Start(Chapterizer.Operations.Chapterize); } else { thechapterizer.Start(rbtnExtractChapters.Checked ? Chapterizer.Operations.ExtractChapter : Chapterizer.Operations.Chapterfile); } } else { //Chapterize is the only mode availbe in single mode thechapterizer.Start(Chapterizer.Operations.Chapterize); } }
private void thechapterizer_Finished(object sender, RunWorkerCompletedEventArgs e) { if (UIMode == UIModes.Simple) { UIStatus = UIStatuses.AwaitFileDrop; } else { lboxFiles.Items.Clear(); UIStatus = UIStatuses.Input; } if (e.Cancelled == false && e.Error == null) { MessageBox.Show("Finished without errors", "Finished", MessageBoxButtons.OK, MessageBoxIcon.Information); } else if (e.Cancelled == false && e.Error != null) { MessageBox.Show("Finished with this error:" + e.Error.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } thechapterizer.Clean(); }
private void MKVC_Load(object sender, EventArgs e) { WriteLog(string.Format("Starting MKV Chapterizer {0}", Application.ProductVersion)); if (Properties.Settings.Default.autoUpdate) { CheckUpdates(); } WriteLog("Getting screen scale multiplier"); screenMultiplier = GetScreenScaleMulitplier(); WriteLog(string.Format("Screen scale multiplier = {0}", screenMultiplier)); //Set to default mode switch (Properties.Settings.Default.defaultMode) { case "Simple": UIMode = UIModes.Simple; UIStatus = UIStatuses.AwaitFileDrop; break; case "Advanced": UIMode = UIModes.Advanced; UIStatus = UIStatuses.Input; break; } tbarInterval.Value = Properties.Settings.Default.defChapInterval; lblTrackbarValue.Text = tbarInterval.Value.ToString(); lblVersion.Text = "v" + Convert.ToString(GetVersion(Version.Parse(Application.ProductVersion))); //Check if any format is set if (String.IsNullOrWhiteSpace(Properties.Settings.Default.chapterPattern)) { Properties.Settings.Default.chapterPattern = string.Join(((char)0).ToString(), "CHAPTER%I=%T" + Environment.NewLine + "CHAPTER%INAME=%N", "%L"); } if (Properties.Settings.Default.rememberOverwrite) { chkboxOverwrite.Checked = Properties.Settings.Default.overwrite; } }
private void lblUIMode_Click(object sender, EventArgs e) { if (UIMode == UIModes.Simple) { //Change to advanced mode UIMode = UIModes.Advanced; UIStatus = UIStatuses.Input; } else { UIMode = UIModes.Simple; UIStatus = UIStatuses.AwaitFileDrop; } }