diff options
author | sr55 <[email protected]> | 2009-06-11 20:01:57 +0000 |
---|---|---|
committer | sr55 <[email protected]> | 2009-06-11 20:01:57 +0000 |
commit | 929760aca797da1c3388e769ce3381bf4935af72 (patch) | |
tree | 29730ba7f60516bc16b5c9139649228562187e6e /win/C# | |
parent | 025ec4178852643d51df2003d23a21bd74206a26 (diff) |
WinGui:
- Remove some code which isn't required to handle preset adding/removal/expand/collapse
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@2521 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'win/C#')
-rw-r--r-- | win/C#/Controls/PictureSettings.cs | 1 | ||||
-rw-r--r-- | win/C#/Presets/PresetsHandler.cs | 1 | ||||
-rw-r--r-- | win/C#/frmAddPreset.cs | 6 | ||||
-rw-r--r-- | win/C#/frmMain.cs | 104 |
4 files changed, 34 insertions, 78 deletions
diff --git a/win/C#/Controls/PictureSettings.cs b/win/C#/Controls/PictureSettings.cs index e7d5b7fa2..b7d08b809 100644 --- a/win/C#/Controls/PictureSettings.cs +++ b/win/C#/Controls/PictureSettings.cs @@ -8,6 +8,7 @@ namespace Handbrake.Controls {
// TODO
// - Tie in the cropping controls.
+ // - Cleanup this code. It's a bit messy.
public partial class PictureSettings : UserControl
{
diff --git a/win/C#/Presets/PresetsHandler.cs b/win/C#/Presets/PresetsHandler.cs index 6a8599a24..59c14dc7e 100644 --- a/win/C#/Presets/PresetsHandler.cs +++ b/win/C#/Presets/PresetsHandler.cs @@ -11,7 +11,6 @@ using System.IO; using System.Text.RegularExpressions;
using System.Diagnostics;
using System.Xml.Serialization;
-using System.Collections;
namespace Handbrake.Presets
{
diff --git a/win/C#/frmAddPreset.cs b/win/C#/frmAddPreset.cs index 56bc5f5c1..ca726c09b 100644 --- a/win/C#/frmAddPreset.cs +++ b/win/C#/frmAddPreset.cs @@ -5,6 +5,7 @@ It may be used under the terms of the GNU General Public License. */
using System;
+using System.Drawing;
using System.Windows.Forms;
namespace Handbrake
@@ -31,7 +32,10 @@ namespace Handbrake if (presetCode.addPreset(txt_preset_name.Text.Trim(), query, pictureSettings))
{
- frmMainWindow.loadPresetPanel();
+ TreeNode preset_treeview = new TreeNode(txt_preset_name.Text.Trim()) { ForeColor = Color.Black };
+ frmMainWindow.treeView_presets.Nodes.Add(preset_treeview);
+
+ //frmMainWindow.loadPresetPanel();
this.Close();
}
}
diff --git a/win/C#/frmMain.cs b/win/C#/frmMain.cs index f62519d04..3f67f3bc9 100644 --- a/win/C#/frmMain.cs +++ b/win/C#/frmMain.cs @@ -301,15 +301,8 @@ namespace Handbrake }
private void btn_new_preset_Click(object sender, EventArgs e)
{
- // Remember each nodes expanded status so we can reload it
- List<Boolean> nodeStatus = saveTreeViewState();
- nodeStatus.Add(true);
-
Form preset = new frmAddPreset(this, queryGen.GenerateTheQuery(this), presetHandler);
preset.ShowDialog();
-
- // Now reload the TreeView states
- loadTreeViewStates(nodeStatus);
}
#endregion
@@ -375,9 +368,7 @@ namespace Handbrake if (treeView_presets.SelectedNode != null)
{
presetHandler.remove(treeView_presets.SelectedNode.Text);
- List<Boolean> nodeStatus = saveTreeViewState(); // Remember each nodes expanded status so we can reload it
- loadPresetPanel();
- loadTreeViewStates(nodeStatus); // Now reload the TreeView states
+ treeView_presets.Nodes.Remove(treeView_presets.SelectedNode);
}
treeView_presets.Select();
}
@@ -397,16 +388,8 @@ namespace Handbrake // Presets Management
private void btn_addPreset_Click(object sender, EventArgs e)
{
- // Remember each nodes expanded status so we can reload it
- List<Boolean> nodeStatus = saveTreeViewState();
- nodeStatus.Add(true);
-
- // Now add the new preset
Form preset = new frmAddPreset(this, QueryGenerator.generateTabbedComponentsQuery(this), presetHandler);
preset.ShowDialog();
-
- // Now reload the TreeView states
- loadTreeViewStates(nodeStatus);
}
private void btn_removePreset_Click(object sender, EventArgs e)
{
@@ -414,11 +397,10 @@ namespace Handbrake if (result == DialogResult.Yes)
{
if (treeView_presets.SelectedNode != null)
+ {
presetHandler.remove(treeView_presets.SelectedNode.Text);
-
- List<Boolean> nodeStatus = saveTreeViewState(); // Remember each nodes expanded status so we can reload it
- loadPresetPanel();
- loadTreeViewStates(nodeStatus); // Now reload the TreeView states
+ treeView_presets.Nodes.Remove(treeView_presets.SelectedNode);
+ }
}
treeView_presets.Select();
}
@@ -456,35 +438,6 @@ namespace Handbrake {
selectPreset();
}
- private void selectPreset()
- {
- if (treeView_presets.SelectedNode != null)
- {
- // Ok, so, we've selected a preset. Now we want to load it.
- string presetName = treeView_presets.SelectedNode.Text;
- if (presetHandler.getPreset(presetName) != null)
- {
- string query = presetHandler.getPreset(presetName).Query;
- Boolean loadPictureSettings = presetHandler.getPreset(presetName).PictureSettings;
-
- if (query != null)
- {
- //Ok, Reset all the H264 widgets before changing the preset
- x264Panel.reset2Defaults();
-
- // Send the query from the file to the Query Parser class
- QueryParser presetQuery = QueryParser.Parse(query);
-
- // Now load the preset
- PresetLoader.presetLoader(this, presetQuery, presetName, loadPictureSettings);
-
- // The x264 widgets will need updated, so do this now:
- x264Panel.X264_StandardizeOptString();
- x264Panel.X264_SetCurrentSettingsInPanel();
- }
- }
- }
- }
private void treeView_presets_deleteKey(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Delete)
@@ -515,36 +468,35 @@ namespace Handbrake }
}
}
- private List<Boolean> saveTreeViewState()
- {
- // Remember each nodes expanded status so we can reload it
- List<Boolean> nodeStatus = new List<Boolean>();
- foreach (TreeNode node in treeView_presets.Nodes)
- {
- nodeStatus.Add(node.IsExpanded);
- foreach (TreeNode subNode in node.Nodes)
- nodeStatus.Add(node.IsExpanded);
- }
- return nodeStatus;
- }
- private void loadTreeViewStates(List<Boolean> nodeStatus)
+ private void selectPreset()
{
- // And finally, re-expand any of the nodes if required
- int i = 0;
- foreach (TreeNode node in treeView_presets.Nodes)
+ if (treeView_presets.SelectedNode != null)
{
- if (nodeStatus[i])
- node.Expand();
-
- foreach (TreeNode subNode in node.Nodes)
+ // 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 (nodeStatus[i])
- subNode.Expand();
- }
+ string query = presetHandler.getPreset(presetName).Query;
+ Boolean loadPictureSettings = presetHandler.getPreset(presetName).PictureSettings;
- i++;
+ if (query != null)
+ {
+ //Ok, Reset all the H264 widgets before changing the preset
+ x264Panel.reset2Defaults();
+
+ // Send the query from the file to the Query Parser class
+ QueryParser presetQuery = QueryParser.Parse(query);
+
+ // Now load the preset
+ PresetLoader.presetLoader(this, presetQuery, presetName, loadPictureSettings);
+
+ // The x264 widgets will need updated, so do this now:
+ x264Panel.X264_StandardizeOptString();
+ x264Panel.X264_SetCurrentSettingsInPanel();
+ }
+ }
}
- }
+ }
private void loadNormalPreset()
{
foreach (TreeNode treenode in treeView_presets.Nodes)
|