X-Git-Url: http://git.osdn.jp/view?a=blobdiff_plain;f=win%2FC%23%2FfrmMain.cs;h=93c889937fbd73cf451e18d264d3313b85b22b8d;hb=cfa1fb7010dc9324e15d257bad7a73af66e9eb10;hp=53b1541d7d962b120d1ec173237230f5c7e76205;hpb=f38b5e6c4125a13bbe1c2c7d497359cf31f77e78;p=handbrake-jp%2Fhandbrake-jp-git.git diff --git a/win/C#/frmMain.cs b/win/C#/frmMain.cs index 53b1541d..93c88993 100644 --- a/win/C#/frmMain.cs +++ b/win/C#/frmMain.cs @@ -35,6 +35,9 @@ namespace Handbrake private Form splash; public string sourcePath; private string lastAction; + private SourceType selectedSourceType; + private string dvdDrivePath; + private string dvdDriveLabel; // Delegates ********************************************************** private delegate void UpdateWindowHandler(); @@ -90,10 +93,10 @@ namespace Handbrake // Load the user's default settings or Normal Preset if (Properties.Settings.Default.defaultPreset != "") { - if (presetHandler.getPreset(Properties.Settings.Default.defaultPreset) != null) + if (presetHandler.GetPreset(Properties.Settings.Default.defaultPreset) != null) { - string query = presetHandler.getPreset(Properties.Settings.Default.defaultPreset).Query; - Boolean loadPictureSettings = presetHandler.getPreset(Properties.Settings.Default.defaultPreset).PictureSettings; + string query = presetHandler.GetPreset(Properties.Settings.Default.defaultPreset).Query; + Boolean loadPictureSettings = presetHandler.GetPreset(Properties.Settings.Default.defaultPreset).PictureSettings; if (query != null) { @@ -181,6 +184,21 @@ namespace Handbrake } #endregion + #region Properties + public string SourceName + { + get + { + if (this.selectedSourceType == SourceType.DvdDrive) + { + return this.dvdDriveLabel; + } + + return Path.GetFileNameWithoutExtension(this.sourcePath); + } + } + #endregion + #region Events // Encoding Events for setting up the GUI private void events() @@ -351,7 +369,7 @@ namespace Handbrake #region Presets Menu private void mnu_presetReset_Click(object sender, EventArgs e) { - presetHandler.updateBuiltInPresets(); + presetHandler.UpdateBuiltInPresets(); loadPresetPanel(); if (treeView_presets.Nodes.Count == 0) MessageBox.Show("Unable to load the presets.xml file. Please select \"Update Built-in Presets\" from the Presets Menu. \nMake sure you are running the program in Admin mode if running on Vista. See Windows FAQ for details!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); @@ -362,7 +380,7 @@ namespace Handbrake } private void mnu_delete_preset_Click(object sender, EventArgs e) { - presetHandler.removeBuiltInPresets(); + presetHandler.RemoveBuiltInPresets(); loadPresetPanel(); // Reload the preset panel } private void mnu_SelectDefault_Click(object sender, EventArgs e) @@ -455,15 +473,15 @@ namespace Handbrake { DialogResult result = MessageBox.Show("Do you wish to include picture settings when updating the preset: " + treeView_presets.SelectedNode.Text, "Update Preset", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question); if (result == DialogResult.Yes) - presetHandler.updatePreset(treeView_presets.SelectedNode.Text, QueryGenerator.GenerateTabbedComponentsQuery(this), true); + presetHandler.Update(treeView_presets.SelectedNode.Text, QueryGenerator.GenerateTabbedComponentsQuery(this), true); else if (result == DialogResult.No) - presetHandler.updatePreset(treeView_presets.SelectedNode.Text, QueryGenerator.GenerateTabbedComponentsQuery(this), false); + presetHandler.Update(treeView_presets.SelectedNode.Text, QueryGenerator.GenerateTabbedComponentsQuery(this), false); } private void pmnu_delete_click(object sender, EventArgs e) { if (treeView_presets.SelectedNode != null) { - presetHandler.remove(treeView_presets.SelectedNode.Text); + presetHandler.Remove(treeView_presets.SelectedNode.Text); treeView_presets.Nodes.Remove(treeView_presets.SelectedNode); } treeView_presets.Select(); @@ -475,7 +493,7 @@ namespace Handbrake // Now enable the save menu if the selected preset is a user preset if (treeView_presets.SelectedNode != null) - if (presetHandler.checkIfUserPresetExists(treeView_presets.SelectedNode.Text)) + if (presetHandler.CheckIfUserPresetExists(treeView_presets.SelectedNode.Text)) pmnu_saveChanges.Enabled = true; treeView_presets.Select(); @@ -494,7 +512,7 @@ namespace Handbrake { if (treeView_presets.SelectedNode != null) { - presetHandler.remove(treeView_presets.SelectedNode.Text); + presetHandler.Remove(treeView_presets.SelectedNode.Text); treeView_presets.Nodes.Remove(treeView_presets.SelectedNode); } } @@ -542,7 +560,7 @@ namespace Handbrake if (result == DialogResult.Yes) { if (treeView_presets.SelectedNode != null) - presetHandler.remove(treeView_presets.SelectedNode.Text); + presetHandler.Remove(treeView_presets.SelectedNode.Text); // Remember each nodes expanded status so we can reload it List nodeStatus = new List(); @@ -570,10 +588,10 @@ namespace Handbrake { // Ok, so, we've selected a preset. Now we want to load it. string presetName = treeView_presets.SelectedNode.Text; - if (presetHandler.getPreset(presetName) != null) + if (presetHandler.GetPreset(presetName) != null) { - string query = presetHandler.getPreset(presetName).Query; - Boolean loadPictureSettings = presetHandler.getPreset(presetName).PictureSettings; + string query = presetHandler.GetPreset(presetName).Query; + Boolean loadPictureSettings = presetHandler.GetPreset(presetName).PictureSettings; if (query != null) { @@ -610,23 +628,23 @@ namespace Handbrake if (openPreset.ShowDialog() == DialogResult.OK) { QueryParser parsed = imp.importMacPreset(openPreset.FileName); - if (presetHandler.checkIfUserPresetExists(parsed.PresetName + " (Imported)")) + if (presetHandler.CheckIfUserPresetExists(parsed.PresetName + " (Imported)")) { DialogResult result = MessageBox.Show("This preset appears to already exist. Would you like to overwrite it?", "Overwrite preset?", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (result == DialogResult.Yes) { PresetLoader.presetLoader(this, parsed, parsed.PresetName, parsed.UsesPictureSettings); - presetHandler.updatePreset(parsed.PresetName + " (Imported)", queryGen.GenerateCLIQuery(this, 0, null), + presetHandler.Update(parsed.PresetName + " (Imported)", queryGen.GenerateCLIQuery(this, 0, null), parsed.UsesPictureSettings); } } else { PresetLoader.presetLoader(this, parsed, parsed.PresetName, parsed.UsesPictureSettings); - presetHandler.addPreset(parsed.PresetName, queryGen.GenerateCLIQuery(this, 0, null), parsed.UsesPictureSettings); + presetHandler.Add(parsed.PresetName, queryGen.GenerateCLIQuery(this, 0, null), parsed.UsesPictureSettings); - if (presetHandler.addPreset(parsed.PresetName + " (Imported)", queryGen.GenerateCLIQuery(this, 0, null), parsed.UsesPictureSettings)) + if (presetHandler.Add(parsed.PresetName + " (Imported)", queryGen.GenerateCLIQuery(this, 0, null), parsed.UsesPictureSettings)) { TreeNode preset_treeview = new TreeNode(parsed.PresetName + " (Imported)") { ForeColor = Color.Black }; treeView_presets.Nodes.Add(preset_treeview); @@ -674,10 +692,10 @@ namespace Handbrake if (Properties.Settings.Default.PromptOnUnmatchingQueries && !string.IsNullOrEmpty(specifiedQuery) && generatedQuery != specifiedQuery) { DialogResult result = MessageBox.Show("The query under the \"Query Editor\" tab " + - "does not match the current GUI settings. Because the manual query takes " + + "does not match the current GUI settings.\n\nBecause the manual query takes " + "priority over the GUI, your recently updated settings will not be taken " + "into account when encoding this job." + Environment.NewLine + Environment.NewLine + - "Do you want to replace the manual query with the GUI-generated query?", + "Do you want to replace the manual query with the updated GUI-generated query?", "Manual Query does not Match GUI", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Asterisk, MessageBoxDefaultButton.Button3); @@ -700,7 +718,7 @@ namespace Handbrake } else { - query = generatedQuery; + query = specifiedQuery; } DialogResult overwrite = DialogResult.Yes; @@ -711,17 +729,19 @@ namespace Handbrake if (overwrite == DialogResult.Yes) { if (encodeQueue.Count == 0) - encodeQueue.AddJob(query, sourcePath, text_destination.Text); + encodeQueue.AddJob(query, sourcePath, text_destination.Text, (rtf_query.Text != "")); queueWindow.setQueue(); if (encodeQueue.Count > 1) queueWindow.Show(false); setEncodeStarted(); // Encode is running, so setup the GUI appropriately - if (ActivityWindow != null) - ActivityWindow.setLogView(false); encodeQueue.StartEncodeQueue(); // Start The Queue Encoding Process lastAction = "encode"; // Set the last action to encode - Used for activity window. + + if (ActivityWindow != null) + ActivityWindow.SetLogView(false); + } this.Focus(); } @@ -744,11 +764,13 @@ namespace Handbrake DialogResult result = MessageBox.Show("There is already a queue item for this destination path. \n\n If you continue, the encode will be overwritten. Do you wish to continue?", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (result == DialogResult.Yes) - encodeQueue.AddJob(query, sourcePath, text_destination.Text); + encodeQueue.AddJob(query, sourcePath, text_destination.Text, (rtf_query.Text != "")); } else - encodeQueue.AddJob(query, sourcePath, text_destination.Text); + encodeQueue.AddJob(query, sourcePath, text_destination.Text, (rtf_query.Text != "")); + + lbl_encode.Text = encodeQueue.Count + " encode(s) pending in the queue"; queueWindow.Show(); } @@ -756,6 +778,7 @@ namespace Handbrake private void btn_showQueue_Click(object sender, EventArgs e) { queueWindow.Show(); + queueWindow.Activate(); } private void tb_preview_Click(object sender, EventArgs e) { @@ -783,6 +806,8 @@ namespace Handbrake if (ActivityWindow == null) ActivityWindow = new frmActivityWindow(file, encodeQueue, this); + ActivityWindow.SetLogView(!encodeQueue.isEncoding); + ActivityWindow.Show(); } #endregion @@ -820,24 +845,30 @@ namespace Handbrake private void btn_dvd_source_Click(object sender, EventArgs e) { if (DVD_Open.ShowDialog() == DialogResult.OK) - selectSource(DVD_Open.SelectedPath, 1); + { + this.selectedSourceType = SourceType.Folder; + selectSource(DVD_Open.SelectedPath); + } else UpdateSourceLabel(); } private void btn_file_source_Click(object sender, EventArgs e) { if (ISO_Open.ShowDialog() == DialogResult.OK) - selectSource(ISO_Open.FileName, 2); + { + this.selectedSourceType = SourceType.VideoFile; + selectSource(ISO_Open.FileName); + } else UpdateSourceLabel(); } private void mnu_dvd_drive_Click(object sender, EventArgs e) { - if (!mnu_dvd_drive.Text.Contains("VIDEO_TS")) return; - string[] path = mnu_dvd_drive.Text.Split(' '); - selectSource(path[0], 3); + if (this.dvdDrivePath == null) return; + this.selectedSourceType = SourceType.DvdDrive; + selectSource(this.dvdDrivePath); } - private void selectSource(string file, int type) + private void selectSource(string file) { Check_ChapterMarkers.Enabled = true; lastAction = "scan"; @@ -858,18 +889,8 @@ namespace Handbrake return; } - switch (type) // Start the scan - { - case 1: // btn_dvd_source_Click() - case 3: // mnu_dvd_drive_Click() - sourcePath = Path.GetFullPath(file); - startScan(file); - break; - case 2: // btn_file_source_Click() - sourcePath = Path.GetFileName(file); - startScan(file); - break; - } + sourcePath = Path.GetFileName(file); + startScan(file); } private void drp_dvdtitle_Click(object sender, EventArgs e) { @@ -894,7 +915,7 @@ namespace Handbrake // Populate the Angles dropdown drop_angle.Items.Clear(); - if (Properties.Settings.Default.dvdnav) + if (!Properties.Settings.Default.noDvdNav) { drop_angle.Visible = true; lbl_angle.Visible = true; @@ -928,7 +949,8 @@ namespace Handbrake Subtitles.drp_subtitleTracks.Items.Add("Foreign Audio Search (Bitmap)"); Subtitles.drp_subtitleTracks.Items.AddRange(selectedTitle.Subtitles.ToArray()); Subtitles.drp_subtitleTracks.SelectedIndex = 0; - Subtitles.setSubtitleTrackAuto(); + Subtitles.Clear(); + Subtitles.SetSubtitleTrackAuto(); } // Run the autoName & chapterNaming functions @@ -938,7 +960,7 @@ namespace Handbrake if (autoPath != null) text_destination.Text = autoPath; else - MessageBox.Show("You currently have \"Automatically name output files\" enabled for the destination file box, but you do not have a default direcotry set.\n\nYou should set a \"Default Path\" in HandBrakes preferences. (See 'Tools' menu -> 'Options' -> 'General' Tab -> 'Default Path')", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); + MessageBox.Show("You currently have \"Automatically name output files\" enabled for the destination file box, but you do not have a default directory set.\n\nYou should set a \"Default Path\" in HandBrakes preferences. (See 'Tools' menu -> 'Options' -> 'General' Tab -> 'Default Path')", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); } data_chpt.Rows.Clear(); @@ -1103,7 +1125,7 @@ namespace Handbrake } AudioSettings.SetContainer(drop_format.Text); - Subtitles.setContainer(drop_format.SelectedIndex); + Subtitles.SetContainer(drop_format.SelectedIndex); if (drop_format.Text.Contains("MP4")) { @@ -1124,9 +1146,8 @@ namespace Handbrake else newExtension = ".mp4"; - text_destination.Text = text_destination.Text.Replace(".mp4", newExtension); - text_destination.Text = text_destination.Text.Replace(".m4v", newExtension); - text_destination.Text = text_destination.Text.Replace(".mkv", newExtension); + if (Path.HasExtension(newExtension)) + text_destination.Text = Path.ChangeExtension(text_destination.Text, newExtension); } //Video Tab @@ -1411,7 +1432,7 @@ namespace Handbrake try { if (ActivityWindow != null) - ActivityWindow.setLogView(true); + ActivityWindow.SetLogView(true); isScanning = true; ThreadPool.QueueUserWorkItem(scanProcess); } @@ -1433,8 +1454,8 @@ namespace Handbrake File.Delete(dvdInfoPath); String dvdnav = string.Empty; - if (Properties.Settings.Default.dvdnav) - dvdnav = " --dvdnav"; + if (Properties.Settings.Default.noDvdNav) + dvdnav = " --no-dvdnav"; string strCmdLine = String.Format(@"cmd /c """"{0}"" -i ""{1}"" -t0 {2} -v >""{3}"" 2>&1""", handbrakeCLIPath, sourcePath, dvdnav, dvdInfoPath); ProcessStartInfo hbParseDvd = new ProcessStartInfo("CMD.exe", strCmdLine) { WindowStyle = ProcessWindowStyle.Hidden }; @@ -1579,7 +1600,7 @@ namespace Handbrake } private void UpdateSourceLabel() { - labelSource.Text = string.IsNullOrEmpty(sourcePath) ? "Select \"Source\" to continue." : Path.GetFileName(sourcePath); + labelSource.Text = string.IsNullOrEmpty(sourcePath) ? "Select \"Source\" to continue." : this.SourceName; } #endregion @@ -1630,7 +1651,7 @@ namespace Handbrake } lbl_encode.Visible = true; - lbl_encode.Text = "Encoding in Progress"; + lbl_encode.Text = "Encoding with " + encodeQueue.Count + " encode(s) pending"; btn_start.Text = "Stop"; btn_start.ToolTipText = "Stop the encoding process."; btn_start.Image = Properties.Resources.stop; @@ -1661,7 +1682,9 @@ namespace Handbrake { if (File.Exists(curDrive.RootDirectory + "VIDEO_TS\\VIDEO_TS.IFO")) { - mnu_dvd_drive.Text = curDrive.RootDirectory + "VIDEO_TS (" + curDrive.VolumeLabel + ")"; + this.dvdDrivePath = curDrive.RootDirectory + "VIDEO_TS"; + this.dvdDriveLabel = curDrive.VolumeLabel; + mnu_dvd_drive.Text = this.dvdDrivePath + " (" + this.dvdDriveLabel + ")"; foundDrive = true; break; } @@ -1684,13 +1707,13 @@ namespace Handbrake /// public void loadPresetPanel() { - if (presetHandler.checkIfPresetsAreOutOfDate()) + if (presetHandler.CheckIfPresetsAreOutOfDate()) if (!Properties.Settings.Default.presetNotification) MessageBox.Show(splash, "HandBrake has determined your built-in presets are out of date... These presets will now be updated.", "Preset Update", MessageBoxButtons.OK, MessageBoxIcon.Information); - presetHandler.getPresetPanel(ref treeView_presets); + presetHandler.GetPresetPanel(ref treeView_presets); treeView_presets.Update(); } #endregion @@ -1741,6 +1764,16 @@ namespace Handbrake } #endregion + #region enum + private enum SourceType + { + None = 0, + Folder, + DvdDrive, + VideoFile + } + #endregion + // This is the END of the road **************************************** } } \ No newline at end of file