From 60a94bdb9e2dc1cb8678d0050559f88f3bcee492 Mon Sep 17 00:00:00 2001 From: sr55 Date: Thu, 23 Apr 2009 23:26:31 +0000 Subject: WinGui: - Moved the code which loads the preset panel into the PresetHandler class. - rewritten the preset panel loader so that it's easier to understand. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@2352 b64f7644-9d1e-0410-96f1-a4d463321fa5 --- win/C#/frmMain.cs | 111 ++++++------------------------------------------------ 1 file changed, 12 insertions(+), 99 deletions(-) (limited to 'win/C#/frmMain.cs') diff --git a/win/C#/frmMain.cs b/win/C#/frmMain.cs index 8c3725dae..c40651e12 100644 --- a/win/C#/frmMain.cs +++ b/win/C#/frmMain.cs @@ -31,7 +31,6 @@ namespace Handbrake private frmQueue queueWindow; private frmPreview qtpreview; private Form splash; - private string lastAction; public int maxWidth; public int maxHeight; @@ -42,10 +41,8 @@ namespace Handbrake // Applicaiton Startup ************************************************ #region Application Startup - public frmMain() { - // Load and setup the splash screen in this thread splash = new frmSplashScreen(); splash.Show(); @@ -124,13 +121,9 @@ namespace Handbrake splash.Dispose(); this.Enabled = true; - // Event Handlers + // Event Handlers and Queue Recovery events(); - - // Queue Recovery queueRecovery(); - - } // Startup Functions @@ -571,8 +564,6 @@ namespace Handbrake } private void loadNormalPreset() { - treeView_presets.Nodes.Find("Normal", true); - foreach (TreeNode treenode in treeView_presets.Nodes) { foreach (TreeNode node in treenode.Nodes) @@ -580,7 +571,7 @@ namespace Handbrake if (node.Text.Equals("Normal")) treeView_presets.SelectedNode = treeView_presets.Nodes[treenode.Index].Nodes[0]; } - } + } } #endregion @@ -1120,7 +1111,6 @@ namespace Handbrake break; } } - /// /// Set the container format options /// @@ -1696,7 +1686,6 @@ namespace Handbrake enableGUI(); } } - private void enableGUI() { try @@ -1808,7 +1797,6 @@ namespace Handbrake #endregion #region DVD Drive Detection - // Source Button Drive Detection private delegate void ProgressUpdateHandler(); private void getDriveInfoThread() { @@ -1975,93 +1963,18 @@ namespace Handbrake #region Public Methods /// - /// Reload the preset panel display + /// Access the preset Handler and setup the preset panel. /// public void loadPresetPanel() { - presetHandler.loadPresetData(); - treeView_presets.Nodes.Clear(); - - TreeNode preset_treeview; - TreeNode rootNode = new TreeNode(); - TreeNode rootNodeTwo = new TreeNode(); - TreeNode childNode; - int workingLevel = 0; - string previousCategory = String.Empty, currentCategory = String.Empty; - - List presetNameList = presetHandler.getBuildInPresets(); - if (presetNameList.Count != 0) - { - foreach (Preset preset in presetNameList) - { - // Handle Root Nodes - - // First Case - No presets have been read yet so setup the root category - if (preset.Level == 1 && currentCategory == String.Empty) - { - rootNode = new TreeNode(preset.Category); - workingLevel = preset.Level; - currentCategory = preset.Category; - previousCategory = preset.Category; - } - - // Second Case - This is the first sub child node. - if (preset.Level == 2 && workingLevel == 1 && currentCategory != preset.Category) - { - rootNodeTwo = new TreeNode(preset.Category); - workingLevel = preset.Level; - currentCategory = preset.Category; - rootNode.Nodes.Add(rootNodeTwo); - } - - // Third Case - Any presets the sub presets detected in the above if statment. - if (preset.Level == 1 && workingLevel == 2) - { - workingLevel = preset.Level; - currentCategory = preset.Category; - } - - // Fourth Case - We've finished this root node and are onto the next root node. - if (preset.Level == 1 && workingLevel == 1 && previousCategory != preset.Category) - { - treeView_presets.Nodes.Add(rootNode); // Add the finished node - - rootNode = new TreeNode(preset.Category); - workingLevel = preset.Level; - currentCategory = preset.Category; - previousCategory = preset.Category; - } - - // Handle Child Nodes - // Add First level child nodes to the current root node - if (preset.Level == 1 && workingLevel == 1 && currentCategory == preset.Category) - { - childNode = new TreeNode(preset.Name); - rootNode.Nodes.Add(childNode); - } - - // Add Second level child nodes to the current sub root node - if (preset.Level == 2 && workingLevel == 2 && currentCategory == preset.Category) - { - childNode = new TreeNode(preset.Name); - rootNodeTwo.Nodes.Add(childNode); - } - } - - // Add the final root node which does not get added above. - treeView_presets.Nodes.Add(rootNode); - } - - // User Presets - List presetNames = presetHandler.getUserPresetNames(); - foreach (string preset in presetNames) - { - preset_treeview = new TreeNode(preset) { ForeColor = Color.Black }; - - // Now Fill Out List View with Items - treeView_presets.Nodes.Add(preset_treeview); - } + presetHandler.getPresetPanel(ref treeView_presets); + treeView_presets.Update(); } + + /// + /// Either Encode or Scan was last performed. + /// + public string lastAction { get; set; } #endregion #region overrides @@ -2083,6 +1996,6 @@ namespace Handbrake } #endregion - // This is the END of the road ------------------------------------------------------------------------------ + // This is the END of the road **************************************** } -} +} \ No newline at end of file -- cgit v1.2.3