diff options
author | sr55 <[email protected]> | 2009-01-08 19:51:08 +0000 |
---|---|---|
committer | sr55 <[email protected]> | 2009-01-08 19:51:08 +0000 |
commit | a385d189c2830994e460b8739546825d7f4418d2 (patch) | |
tree | 3659a2f82578a3c894974c355532a6a6e8f744d2 | |
parent | 603a154a73ced4dbdfa187ee88eda66833952d87 (diff) |
WinGui:
- Patch (slightly modified) by ween to allow users to update their own presets via a "save changes" option in the presets right click menu.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@2068 b64f7644-9d1e-0410-96f1-a4d463321fa5
-rw-r--r-- | win/C#/Presets/PresetsHandler.cs | 45 | ||||
-rw-r--r-- | win/C#/frmMain.Designer.cs | 22 | ||||
-rw-r--r-- | win/C#/frmMain.cs | 36 |
3 files changed, 87 insertions, 16 deletions
diff --git a/win/C#/Presets/PresetsHandler.cs b/win/C#/Presets/PresetsHandler.cs index fbd36fbdb..171b313c1 100644 --- a/win/C#/Presets/PresetsHandler.cs +++ b/win/C#/Presets/PresetsHandler.cs @@ -20,6 +20,7 @@ namespace Handbrake.Presets /// </summary>
/// <param name="presetName">String, The name of the new preset</param>
/// <param name="query">String, the CLI query for the new preset</param>
+ /// <param name="pictureSettings"> Bool, store crop/picture sizes in the presets</param>
public Boolean addPreset(string presetName, string query, Boolean pictureSettings)
{
if (checkIfPresetExists(presetName) == false)
@@ -68,16 +69,32 @@ namespace Handbrake.Presets }
user_presets = newUserPresets;
- // Now, Update the presets.xml and user_presets.xml file with the new items.
- string userPresets = Application.StartupPath.ToString() + "\\user_presets.xml";
- string presetsFile = Application.StartupPath.ToString() + "\\presets.xml";
-
// Rebuild the user_presets.xml file
updateUserPresetsFile();
updatePresetsFile();
}
/// <summary>
+ /// Save changes to a given preset in the user preset list.
+ /// </summary>
+ /// <param name="presetName">String, The name of the new preset</param>
+ /// <param name="query">String, the CLI query for the new preset</param>
+ /// <param name="pictureSettings"> Bool, store crop/picture sizes in the preset</param>
+ public void updatePreset(string presetName, string query, Boolean pictureSettings)
+ {
+ // User Presets
+ foreach (Preset item in user_presets)
+ {
+ if (item.Name == presetName)
+ {
+ item.Query = query;
+ item.PictureSettings = pictureSettings;
+ MessageBox.Show("Changes to \"" + presetName + "\" Saved", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
+ }
+ }
+ }
+
+ /// <summary>
/// Get a List of all the built in preset names.
/// </summary>
/// <returns>List<String> of preset names</returns>
@@ -314,5 +331,25 @@ namespace Handbrake.Presets return false;
}
+
+ /// <summary>
+ /// Check if the user preset "name" exists in user_presets list.
+ /// </summary>
+ /// <param name="name"></param>
+ /// <returns></returns>
+ public Boolean checkIfUserPresetExists(string name)
+ {
+ if (name == string.Empty)
+ return false;
+
+ // User Presets
+ foreach (Preset item in user_presets)
+ {
+ if (item.Name == name)
+ return true;
+ }
+
+ return false;
+ }
}
}
\ No newline at end of file diff --git a/win/C#/frmMain.Designer.cs b/win/C#/frmMain.Designer.cs index b656adbd7..c52b60a07 100644 --- a/win/C#/frmMain.Designer.cs +++ b/win/C#/frmMain.Designer.cs @@ -232,6 +232,7 @@ namespace Handbrake this.pmnu_expandAll = new System.Windows.Forms.ToolStripMenuItem();
this.pmnu_collapse = new System.Windows.Forms.ToolStripMenuItem();
this.sep1 = new System.Windows.Forms.ToolStripSeparator();
+ this.pmnu_saveChanges = new System.Windows.Forms.ToolStripMenuItem();
this.pmnu_delete = new System.Windows.Forms.ToolStripMenuItem();
this.toolStrip1 = new System.Windows.Forms.ToolStrip();
this.btn_source = new System.Windows.Forms.ToolStripDropDownButton();
@@ -2705,33 +2706,43 @@ namespace Handbrake this.pmnu_expandAll,
this.pmnu_collapse,
this.sep1,
+ this.pmnu_saveChanges,
this.pmnu_delete});
this.presets_menu.Name = "presets_menu";
- this.presets_menu.Size = new System.Drawing.Size(140, 76);
+ this.presets_menu.Size = new System.Drawing.Size(155, 120);
+ this.presets_menu.Text = ";";
+ this.presets_menu.Opening += new System.ComponentModel.CancelEventHandler(this.presets_menu_Opening);
//
// pmnu_expandAll
//
this.pmnu_expandAll.Name = "pmnu_expandAll";
- this.pmnu_expandAll.Size = new System.Drawing.Size(139, 22);
+ this.pmnu_expandAll.Size = new System.Drawing.Size(154, 22);
this.pmnu_expandAll.Text = "Expand All";
this.pmnu_expandAll.Click += new System.EventHandler(this.pmnu_expandAll_Click);
//
// pmnu_collapse
//
this.pmnu_collapse.Name = "pmnu_collapse";
- this.pmnu_collapse.Size = new System.Drawing.Size(139, 22);
+ this.pmnu_collapse.Size = new System.Drawing.Size(154, 22);
this.pmnu_collapse.Text = "Collapse All";
this.pmnu_collapse.Click += new System.EventHandler(this.pmnu_collapse_Click);
//
// sep1
//
this.sep1.Name = "sep1";
- this.sep1.Size = new System.Drawing.Size(136, 6);
+ this.sep1.Size = new System.Drawing.Size(151, 6);
+ //
+ // pmnu_saveChanges
+ //
+ this.pmnu_saveChanges.Name = "pmnu_saveChanges";
+ this.pmnu_saveChanges.Size = new System.Drawing.Size(154, 22);
+ this.pmnu_saveChanges.Text = "Save Changes";
+ this.pmnu_saveChanges.Click += new System.EventHandler(this.pmnu_saveChanges_Click);
//
// pmnu_delete
//
this.pmnu_delete.Name = "pmnu_delete";
- this.pmnu_delete.Size = new System.Drawing.Size(139, 22);
+ this.pmnu_delete.Size = new System.Drawing.Size(154, 22);
this.pmnu_delete.Text = "Delete";
this.pmnu_delete.Click += new System.EventHandler(this.pmnu_delete_click);
//
@@ -3187,6 +3198,7 @@ namespace Handbrake private System.Windows.Forms.ToolStripDropDownButton tb_preview;
private System.Windows.Forms.ToolStripMenuItem mnu_qtpreview;
private System.Windows.Forms.ToolStripMenuItem mnu_vlcpreview;
+ private System.Windows.Forms.ToolStripMenuItem pmnu_saveChanges;
}
}
\ No newline at end of file diff --git a/win/C#/frmMain.cs b/win/C#/frmMain.cs index 828ff1ef0..83ea0de12 100644 --- a/win/C#/frmMain.cs +++ b/win/C#/frmMain.cs @@ -8,14 +8,10 @@ using System; using System.Collections;
using System.Collections.Generic;
using System.Drawing;
-using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Diagnostics;
using System.Threading;
-using System.Runtime.InteropServices;
-using System.Globalization;
-using System.Text.RegularExpressions;
namespace Handbrake
{
@@ -136,7 +132,7 @@ namespace Handbrake events();
// Queue Recovery
- queueRecovery();
+ queueRecovery();
}
// Startup Functions
@@ -332,6 +328,14 @@ namespace Handbrake {
treeView_presets.CollapseAll();
}
+ private void pmnu_saveChanges_Click(object sender, EventArgs e)
+ {
+ 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, queryGen.generateTabbedComponentsQuery(this), true);
+ else if (result == DialogResult.No)
+ presetHandler.updatePreset(treeView_presets.SelectedNode.Text, queryGen.generateTabbedComponentsQuery(this), false);
+ }
private void pmnu_delete_click(object sender, EventArgs e)
{
if (treeView_presets.SelectedNode != null)
@@ -349,6 +353,21 @@ namespace Handbrake }
treeView_presets.Select();
}
+ private void presets_menu_Opening(object sender, System.ComponentModel.CancelEventArgs e)
+ {
+ // Make sure that the save menu is always disabled by default
+ pmnu_saveChanges.Enabled = false;
+
+ // 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))
+ {
+ pmnu_saveChanges.Enabled = true;
+ }
+ }
+ treeView_presets.Select();
+ }
// Presets Management
private void btn_addPreset_Click(object sender, EventArgs e)
@@ -542,7 +561,7 @@ namespace Handbrake HandBrakeCLI = aProc[0];
HandBrakeCLI.Kill();
}
-
+
// Update the GUI
setEncodeFinished();
}
@@ -572,7 +591,7 @@ namespace Handbrake setEncodeStarted(); // Encode is running, so setup the GUI appropriately
encodeQueue.startEncode(); // Start The Queue Encoding Process
-
+
}
else if (text_source.Text == string.Empty || text_source.Text == "Click 'Source' to continue" || text_destination.Text == string.Empty)
MessageBox.Show("No source OR destination selected.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
@@ -1928,6 +1947,9 @@ namespace Handbrake #endregion
+
+
+
// This is the END of the road ------------------------------------------------------------------------------
}
}
\ No newline at end of file |