OSDN Git Service

WinGui:
authorsr55 <sr55@b64f7644-9d1e-0410-96f1-a4d463321fa5>
Sun, 4 Jul 2010 17:50:37 +0000 (17:50 +0000)
committersr55 <sr55@b64f7644-9d1e-0410-96f1-a4d463321fa5>
Sun, 4 Jul 2010 17:50:37 +0000 (17:50 +0000)
- Next step in the new Add Presets Window.  Now added Picture Size modes "None" and "Source Maximum". Note cropping values are stored with "Source Maximum" if custom crop is selected. Also included option to include filter settings.

git-svn-id: svn://localhost/HandBrake/trunk@3425 b64f7644-9d1e-0410-96f1-a4d463321fa5

win/C#/Controls/PictureSettings.Designer.cs
win/C#/Controls/PictureSettings.cs
win/C#/Functions/PresetLoader.cs
win/C#/Functions/QueryGenerator.cs
win/C#/Presets/Preset.cs
win/C#/Presets/PresetsHandler.cs
win/C#/frmAddPreset.Designer.cs
win/C#/frmAddPreset.cs
win/C#/frmMain.Designer.cs
win/C#/frmMain.cs

index 83dfc9b..21c796d 100644 (file)
@@ -610,7 +610,7 @@ namespace Handbrake.Controls
             this.lbl_presetCropWarning.TabIndex = 118;\r
             this.lbl_presetCropWarning.Text = "( Preset values are in use! )";\r
             // \r
-            // PictureSettings\r
+            // CropSettings\r
             // \r
             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit;\r
             this.BackColor = System.Drawing.Color.Transparent;\r
index 1528d07..e0319a6 100644 (file)
@@ -81,11 +81,16 @@ namespace Handbrake.Controls
         /// </param>\r
         public void SetPresetCropWarningLabel(Preset selectedPreset)\r
         {\r
-            lbl_presetCropWarning.Visible = true;\r
-            if (selectedPreset != null && selectedPreset.PictureSettings == false)\r
-                lbl_presetCropWarning.Visible = false;\r
-            else if (selectedPreset == null)\r
+            if (this.check_customCrop.Checked)\r
+            {\r
+                lbl_presetCropWarning.Visible = true;\r
+                if (selectedPreset != null && selectedPreset.CropSettings == false) lbl_presetCropWarning.Visible = false;\r
+                else if (selectedPreset == null) lbl_presetCropWarning.Visible = false;\r
+            }\r
+            else\r
+            {\r
                 lbl_presetCropWarning.Visible = false;\r
+            }\r
         }\r
 \r
         /// <summary>\r
@@ -97,7 +102,7 @@ namespace Handbrake.Controls
             lbl_src_res.Text = sourceTitle.Resolution.Width + " x " + sourceTitle.Resolution.Height;\r
 \r
             // Set the Recommended Cropping values, but only if a preset doesn't have hard set picture settings.\r
-            if ((CurrentlySelectedPreset != null && CurrentlySelectedPreset.PictureSettings == false) || CurrentlySelectedPreset == null)\r
+            if ((CurrentlySelectedPreset != null && CurrentlySelectedPreset.CropSettings == false) || CurrentlySelectedPreset == null)\r
             {\r
                 crop_top.Value = GetCropMod2Clean(sourceTitle.AutoCropDimensions.Top);\r
                 crop_bottom.Value = GetCropMod2Clean(sourceTitle.AutoCropDimensions.Bottom);\r
index 9b6d154..6498049 100644 (file)
@@ -29,7 +29,7 @@ namespace Handbrake.Functions
         /// <param name="pictureSettings">\r
         /// Save picture settings in the preset\r
         /// </param>\r
-        public static void LoadPreset(frmMain mainWindow, QueryParser presetQuery, string name, bool pictureSettings)\r
+        public static void LoadPreset(frmMain mainWindow, QueryParser presetQuery, string name)\r
         {\r
             #region Source\r
 \r
@@ -83,22 +83,19 @@ namespace Handbrake.Functions
             #region Picture\r
 \r
             mainWindow.PictureSettings.check_autoCrop.Checked = true;\r
-            if (pictureSettings) // only Load picture settings if the perset requires it\r
+            if (presetQuery.CropValues != null)\r
             {\r
-                if (presetQuery.CropValues != null)\r
-                {\r
-                    int top, bottom, left, right;\r
-                    int.TryParse(presetQuery.CropTop, out top);\r
-                    int.TryParse(presetQuery.CropBottom, out bottom);\r
-                    int.TryParse(presetQuery.CropLeft, out left);\r
-                    int.TryParse(presetQuery.CropRight, out right);\r
-\r
-                    mainWindow.PictureSettings.check_customCrop.Checked = true;\r
-                    mainWindow.PictureSettings.crop_top.Value = top;\r
-                    mainWindow.PictureSettings.crop_bottom.Value = bottom;\r
-                    mainWindow.PictureSettings.crop_left.Value = left;\r
-                    mainWindow.PictureSettings.crop_right.Value = right;\r
-                }\r
+                int top, bottom, left, right;\r
+                int.TryParse(presetQuery.CropTop, out top);\r
+                int.TryParse(presetQuery.CropBottom, out bottom);\r
+                int.TryParse(presetQuery.CropLeft, out left);\r
+                int.TryParse(presetQuery.CropRight, out right);\r
+\r
+                mainWindow.PictureSettings.check_customCrop.Checked = true;\r
+                mainWindow.PictureSettings.crop_top.Value = top;\r
+                mainWindow.PictureSettings.crop_bottom.Value = bottom;\r
+                mainWindow.PictureSettings.crop_left.Value = left;\r
+                mainWindow.PictureSettings.crop_right.Value = right;\r
             }\r
 \r
             // Set the anamorphic mode 0,1,2,3\r
index f29bdd4..2c4706f 100644 (file)
@@ -219,7 +219,7 @@ namespace Handbrake.Functions
             string cropLeft = mainWindow.PictureSettings.crop_left.Text;\r
             string cropRight = mainWindow.PictureSettings.crop_right.Text;\r
 \r
-            if (mainWindow.PictureSettings.check_customCrop.Checked)\r
+            if (mainWindow.PictureSettings.check_customCrop.Checked && mode != QueryPictureSettingsMode.None)\r
             {\r
                 if (mainWindow.PictureSettings.crop_top.Text == string.Empty)\r
                     cropTop = "0";\r
index bf41e47..024d316 100644 (file)
@@ -5,8 +5,6 @@
 \r
 namespace Handbrake.Presets\r
 {\r
-    using System.Windows.Controls;\r
-\r
     /// <summary>\r
     /// A Preset\r
     /// </summary>\r
@@ -30,7 +28,7 @@ namespace Handbrake.Presets
         /// <summary>\r
         /// Gets or sets a value indicating whether to use picture Settings in presets.\r
         /// </summary>\r
-        public bool PictureSettings { get; set; }\r
+        public bool CropSettings { get; set; }\r
 \r
         /// <summary>\r
         /// Gets or sets The version number which associates this preset with a HB build\r
index 1a47a4d..971a478 100644 (file)
@@ -46,6 +46,11 @@ namespace Handbrake.Presets
         private List<Preset> userPresets = new List<Preset>();\r
 \r
         /// <summary>\r
+        ///  Last preset added\r
+        /// </summary>\r
+        public Preset LastPresetAdded { get; set; }\r
+\r
+        /// <summary>\r
         /// Add a new preset to the system\r
         /// </summary>\r
         /// <param name="presetName">\r
@@ -68,11 +73,12 @@ namespace Handbrake.Presets
                                        {\r
                                            Name = presetName, \r
                                            Query = query, \r
-                                           PictureSettings = pictureSettings, \r
+                                           CropSettings = pictureSettings, \r
                                            Version = Properties.Settings.Default.hb_version\r
                                        };\r
                 this.userPresets.Add(newPreset);\r
                 this.UpdatePresetFiles();\r
+                this.LastPresetAdded = newPreset;\r
                 return true;\r
             }\r
             return false;\r
@@ -135,7 +141,7 @@ namespace Handbrake.Presets
                 if (item.Name == presetName)\r
                 {\r
                     item.Query = query;\r
-                    item.PictureSettings = pictureSettings;\r
+                    item.CropSettings = pictureSettings;\r
                     MessageBox.Show(\r
                         "Changes to \"" + presetName + "\" Saved",\r
                                     "Success",\r
@@ -216,7 +222,7 @@ namespace Handbrake.Presets
                                                    Name = presetName[0].Replace("+", string.Empty).Trim(), \r
                                                    Query = presetName[2], \r
                                                    Version = Properties.Settings.Default.hb_version, \r
-                                                   PictureSettings = pic\r
+                                                   CropSettings = pic\r
                                                };\r
                         this.presets.Add(newPreset);\r
                     }\r
index 348c430..5301221 100644 (file)
@@ -40,18 +40,17 @@ namespace Handbrake
             this.txt_preset_name = new System.Windows.Forms.TextBox();\r
             this.btn_add = new System.Windows.Forms.Button();\r
             this.btn_cancel = new System.Windows.Forms.Button();\r
-            this.check_pictureSettings = new System.Windows.Forms.CheckBox();\r
+            this.check_useFilters = new System.Windows.Forms.CheckBox();\r
             this.toolTip = new System.Windows.Forms.ToolTip(this.components);\r
-            this.label1 = new System.Windows.Forms.Label();\r
-            this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel();\r
-            this.tableLayoutPanel1.SuspendLayout();\r
+            this.cb_usePictureSettings = new System.Windows.Forms.ComboBox();\r
+            this.label2 = new System.Windows.Forms.Label();\r
+            this.label3 = new System.Windows.Forms.Label();\r
             this.SuspendLayout();\r
             // \r
             // lbl_name\r
             // \r
-            this.lbl_name.Anchor = System.Windows.Forms.AnchorStyles.Left;\r
             this.lbl_name.AutoSize = true;\r
-            this.lbl_name.Location = new System.Drawing.Point(3, 7);\r
+            this.lbl_name.Location = new System.Drawing.Point(12, 18);\r
             this.lbl_name.Name = "lbl_name";\r
             this.lbl_name.Size = new System.Drawing.Size(75, 13);\r
             this.lbl_name.TabIndex = 1;\r
@@ -59,21 +58,18 @@ namespace Handbrake
             // \r
             // txt_preset_name\r
             // \r
-            this.txt_preset_name.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right)));\r
-            this.tableLayoutPanel1.SetColumnSpan(this.txt_preset_name, 2);\r
-            this.txt_preset_name.Location = new System.Drawing.Point(84, 3);\r
+            this.txt_preset_name.Location = new System.Drawing.Point(130, 15);\r
             this.txt_preset_name.Name = "txt_preset_name";\r
-            this.txt_preset_name.Size = new System.Drawing.Size(208, 21);\r
+            this.txt_preset_name.Size = new System.Drawing.Size(172, 21);\r
             this.txt_preset_name.TabIndex = 0;\r
             // \r
             // btn_add\r
             // \r
-            this.btn_add.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));\r
             this.btn_add.BackColor = System.Drawing.Color.Transparent;\r
             this.btn_add.FlatAppearance.BorderColor = System.Drawing.Color.Black;\r
             this.btn_add.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
             this.btn_add.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(128)))), ((int)(((byte)(0)))));\r
-            this.btn_add.Location = new System.Drawing.Point(172, 72);\r
+            this.btn_add.Location = new System.Drawing.Point(185, 133);\r
             this.btn_add.Name = "btn_add";\r
             this.btn_add.Size = new System.Drawing.Size(57, 22);\r
             this.btn_add.TabIndex = 2;\r
@@ -87,7 +83,7 @@ namespace Handbrake
             this.btn_cancel.FlatAppearance.BorderColor = System.Drawing.Color.Black;\r
             this.btn_cancel.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
             this.btn_cancel.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(128)))), ((int)(((byte)(0)))));\r
-            this.btn_cancel.Location = new System.Drawing.Point(235, 72);\r
+            this.btn_cancel.Location = new System.Drawing.Point(248, 133);\r
             this.btn_cancel.Name = "btn_cancel";\r
             this.btn_cancel.Size = new System.Drawing.Size(57, 22);\r
             this.btn_cancel.TabIndex = 3;\r
@@ -95,55 +91,48 @@ namespace Handbrake
             this.btn_cancel.UseVisualStyleBackColor = false;\r
             this.btn_cancel.Click += new System.EventHandler(this.BtnCancelClick);\r
             // \r
-            // check_pictureSettings\r
-            // \r
-            this.check_pictureSettings.Anchor = System.Windows.Forms.AnchorStyles.Left;\r
-            this.check_pictureSettings.AutoSize = true;\r
-            this.tableLayoutPanel1.SetColumnSpan(this.check_pictureSettings, 2);\r
-            this.check_pictureSettings.Location = new System.Drawing.Point(84, 30);\r
-            this.check_pictureSettings.Name = "check_pictureSettings";\r
-            this.check_pictureSettings.Size = new System.Drawing.Size(132, 17);\r
-            this.check_pictureSettings.TabIndex = 1;\r
-            this.check_pictureSettings.Text = "Store Cropping Values";\r
-            this.toolTip.SetToolTip(this.check_pictureSettings, "Save Picture Width/Height and Crop Values");\r
-            this.check_pictureSettings.UseVisualStyleBackColor = true;\r
-            // \r
-            // label1\r
-            // \r
-            this.label1.Anchor = System.Windows.Forms.AnchorStyles.Left;\r
-            this.label1.AutoSize = true;\r
-            this.tableLayoutPanel1.SetColumnSpan(this.label1, 2);\r
-            this.label1.Location = new System.Drawing.Point(84, 53);\r
-            this.label1.Margin = new System.Windows.Forms.Padding(3);\r
-            this.label1.Name = "label1";\r
-            this.label1.Size = new System.Drawing.Size(200, 13);\r
-            this.label1.TabIndex = 4;\r
-            this.label1.Text = "Note: Subtitles are not stored in presets";\r
-            // \r
-            // tableLayoutPanel1\r
-            // \r
-            this.tableLayoutPanel1.AutoSize = true;\r
-            this.tableLayoutPanel1.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;\r
-            this.tableLayoutPanel1.ColumnCount = 3;\r
-            this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());\r
-            this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F));\r
-            this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());\r
-            this.tableLayoutPanel1.Controls.Add(this.lbl_name, 0, 0);\r
-            this.tableLayoutPanel1.Controls.Add(this.btn_cancel, 2, 3);\r
-            this.tableLayoutPanel1.Controls.Add(this.label1, 1, 2);\r
-            this.tableLayoutPanel1.Controls.Add(this.btn_add, 1, 3);\r
-            this.tableLayoutPanel1.Controls.Add(this.txt_preset_name, 1, 0);\r
-            this.tableLayoutPanel1.Controls.Add(this.check_pictureSettings, 1, 1);\r
-            this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill;\r
-            this.tableLayoutPanel1.Location = new System.Drawing.Point(9, 9);\r
-            this.tableLayoutPanel1.Name = "tableLayoutPanel1";\r
-            this.tableLayoutPanel1.RowCount = 4;\r
-            this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle());\r
-            this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle());\r
-            this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle());\r
-            this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle());\r
-            this.tableLayoutPanel1.Size = new System.Drawing.Size(295, 125);\r
-            this.tableLayoutPanel1.TabIndex = 5;\r
+            // check_useFilters\r
+            // \r
+            this.check_useFilters.AutoSize = true;\r
+            this.check_useFilters.Location = new System.Drawing.Point(130, 106);\r
+            this.check_useFilters.Name = "check_useFilters";\r
+            this.check_useFilters.Size = new System.Drawing.Size(112, 17);\r
+            this.check_useFilters.TabIndex = 1;\r
+            this.check_useFilters.Text = "Use Picture Filters";\r
+            this.toolTip.SetToolTip(this.check_useFilters, "Save Picture Width/Height and Crop Values");\r
+            this.check_useFilters.UseVisualStyleBackColor = true;\r
+            // \r
+            // cb_usePictureSettings\r
+            // \r
+            this.cb_usePictureSettings.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;\r
+            this.cb_usePictureSettings.FormattingEnabled = true;\r
+            this.cb_usePictureSettings.Items.AddRange(new object[] {\r
+            "None",\r
+            "Source Maximum"});\r
+            this.cb_usePictureSettings.Location = new System.Drawing.Point(130, 79);\r
+            this.cb_usePictureSettings.Name = "cb_usePictureSettings";\r
+            this.cb_usePictureSettings.Size = new System.Drawing.Size(172, 21);\r
+            this.cb_usePictureSettings.TabIndex = 6;\r
+            // \r
+            // label2\r
+            // \r
+            this.label2.AutoSize = true;\r
+            this.label2.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
+            this.label2.Location = new System.Drawing.Point(12, 57);\r
+            this.label2.Name = "label2";\r
+            this.label2.Size = new System.Drawing.Size(100, 13);\r
+            this.label2.TabIndex = 7;\r
+            this.label2.Text = "Picture Settings:";\r
+            // \r
+            // label3\r
+            // \r
+            this.label3.AutoSize = true;\r
+            this.label3.Location = new System.Drawing.Point(12, 82);\r
+            this.label3.Margin = new System.Windows.Forms.Padding(3);\r
+            this.label3.Name = "label3";\r
+            this.label3.Size = new System.Drawing.Size(87, 13);\r
+            this.label3.TabIndex = 8;\r
+            this.label3.Text = "Use Picture Size:";\r
             // \r
             // frmAddPreset\r
             // \r
@@ -151,8 +140,15 @@ namespace Handbrake
             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;\r
             this.AutoSize = true;\r
             this.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;\r
-            this.ClientSize = new System.Drawing.Size(313, 143);\r
-            this.Controls.Add(this.tableLayoutPanel1);\r
+            this.ClientSize = new System.Drawing.Size(319, 166);\r
+            this.Controls.Add(this.label3);\r
+            this.Controls.Add(this.label2);\r
+            this.Controls.Add(this.cb_usePictureSettings);\r
+            this.Controls.Add(this.lbl_name);\r
+            this.Controls.Add(this.txt_preset_name);\r
+            this.Controls.Add(this.check_useFilters);\r
+            this.Controls.Add(this.btn_cancel);\r
+            this.Controls.Add(this.btn_add);\r
             this.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
             this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;\r
             this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));\r
@@ -164,10 +160,8 @@ namespace Handbrake
             this.ShowInTaskbar = false;\r
             this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide;\r
             this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;\r
-            this.Text = "Add Preset";\r
+            this.Text = "Add New Preset";\r
             this.TopMost = true;\r
-            this.tableLayoutPanel1.ResumeLayout(false);\r
-            this.tableLayoutPanel1.PerformLayout();\r
             this.ResumeLayout(false);\r
             this.PerformLayout();\r
 \r
@@ -179,9 +173,10 @@ namespace Handbrake
         private System.Windows.Forms.TextBox txt_preset_name;\r
         internal System.Windows.Forms.Button btn_add;\r
         internal System.Windows.Forms.Button btn_cancel;\r
-        private System.Windows.Forms.CheckBox check_pictureSettings;\r
+        private System.Windows.Forms.CheckBox check_useFilters;\r
         private System.Windows.Forms.ToolTip toolTip;\r
-        private System.Windows.Forms.Label label1;\r
-        private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1;\r
+        private System.Windows.Forms.ComboBox cb_usePictureSettings;\r
+        private System.Windows.Forms.Label label2;\r
+        private System.Windows.Forms.Label label3;\r
     }\r
 }
\ No newline at end of file
index a04b074..22ba835 100644 (file)
@@ -6,8 +6,11 @@
 namespace Handbrake\r
 {\r
     using System;\r
-    using System.Drawing;\r
     using System.Windows.Forms;\r
+\r
+    using Handbrake.Functions;\r
+    using Handbrake.Model;\r
+\r
     using Presets;\r
 \r
     /// <summary>\r
@@ -15,9 +18,6 @@ namespace Handbrake
     /// </summary>\r
     public partial class frmAddPreset : Form\r
     {\r
-        /// <summary>\r
-        /// The Main  Window\r
-        /// </summary>\r
         private readonly frmMain mainWindow;\r
 \r
         /// <summary>\r
@@ -26,28 +26,19 @@ namespace Handbrake
         private readonly PresetsHandler presetCode;\r
 \r
         /// <summary>\r
-        /// The CLI Query\r
-        /// </summary>\r
-        private readonly string query = string.Empty;\r
-\r
-        /// <summary>\r
         /// Initializes a new instance of the <see cref="frmAddPreset"/> class.\r
         /// </summary>\r
-        /// <param name="fmw">\r
-        /// The fmw.\r
-        /// </param>\r
-        /// <param name="queryString">\r
-        /// The query string.\r
-        /// </param>\r
+        /// <param name="mainWindow"></param>\r
         /// <param name="presetHandler">\r
         /// The preset handler.\r
         /// </param>\r
-        public frmAddPreset(frmMain fmw, string queryString, PresetsHandler presetHandler)\r
+        public frmAddPreset(frmMain mainWindow, PresetsHandler presetHandler)\r
         {\r
             InitializeComponent();\r
-            mainWindow = fmw;\r
+            this.mainWindow = mainWindow;\r
             presetCode = presetHandler;\r
-            this.query = queryString;\r
+\r
+            cb_usePictureSettings.SelectedIndex = 0;\r
         }\r
 \r
         /// <summary>\r
@@ -61,11 +52,34 @@ namespace Handbrake
         /// </param>\r
         private void BtnAddClick(object sender, EventArgs e)\r
         {\r
-            if (presetCode.Add(txt_preset_name.Text.Trim(), query, check_pictureSettings.Checked))\r
+            if (string.IsNullOrEmpty(txt_preset_name.Text.Trim()))\r
+            {\r
+                MessageBox.Show("You must enter a preset name!", "Warning",\r
+                                MessageBoxButtons.OK, MessageBoxIcon.Warning);                \r
+                return;\r
+            }\r
+\r
+            QueryPictureSettingsMode pictureSettingsMode;\r
+\r
+            switch (cb_usePictureSettings.SelectedIndex)\r
+            {\r
+                case 0:\r
+                    pictureSettingsMode = QueryPictureSettingsMode.None;\r
+                    break;\r
+                case 1:\r
+                    pictureSettingsMode = QueryPictureSettingsMode.SourceMaximum;\r
+                    break;\r
+                default:\r
+                    pictureSettingsMode = QueryPictureSettingsMode.None;\r
+                    break;\r
+            }\r
+\r
+            string query = QueryGenerator.GenerateQueryForPreset(mainWindow, pictureSettingsMode, check_useFilters.Checked, 0, 0);\r
+\r
+            if (presetCode.Add(txt_preset_name.Text.Trim(), query, pictureSettingsMode != QueryPictureSettingsMode.None))\r
             {\r
-                TreeNode presetTreeview = new TreeNode(txt_preset_name.Text.Trim()) {ForeColor = Color.Black};\r
-                mainWindow.treeView_presets.Nodes.Add(presetTreeview);\r
-                this.Close();\r
+                this.DialogResult = DialogResult.OK;\r
+                this.Close();           \r
             }\r
             else\r
                 MessageBox.Show("Sorry, that preset name already exists. Please choose another!", "Warning", \r
@@ -83,6 +97,7 @@ namespace Handbrake
         /// </param>\r
         private void BtnCancelClick(object sender, EventArgs e)\r
         {\r
+            this.DialogResult = DialogResult.Cancel;\r
             this.Close();\r
         }\r
     }\r
index 589d674..4f6839e 100644 (file)
@@ -983,7 +983,7 @@ namespace Handbrake
             this.tab_picture.Text = "Picture";\r
             this.tab_picture.UseVisualStyleBackColor = true;\r
             // \r
-            // PictureSettings\r
+            // CropSettings\r
             // \r
             this.PictureSettings.BackColor = System.Drawing.Color.Transparent;\r
             this.PictureSettings.CurrentlySelectedPreset = null;\r
index b0fb65c..6937c59 100644 (file)
@@ -152,8 +152,7 @@ namespace Handbrake
                     x264Panel.Reset2Defaults();\r
 \r
                     QueryParser presetQuery = QueryParser.Parse(query);\r
-                    PresetLoader.LoadPreset(this, presetQuery, Properties.Settings.Default.defaultPreset,\r
-                                            presetHandler.GetPreset(Properties.Settings.Default.defaultPreset).PictureSettings);\r
+                    PresetLoader.LoadPreset(this, presetQuery, Properties.Settings.Default.defaultPreset);\r
 \r
                     x264Panel.StandardizeOptString();\r
                     x264Panel.SetCurrentSettingsInPanel();\r
@@ -538,9 +537,13 @@ namespace Handbrake
         /// </param>\r
         private void btn_new_preset_Click(object sender, EventArgs e)\r
         {\r
-            Form preset = new frmAddPreset(this, QueryGenerator.GenerateQueryForPreset(this, QueryPictureSettingsMode.SourceMaximum, true, 0, 0),\r
-                                           presetHandler);\r
-            preset.ShowDialog();\r
+            Form preset = new frmAddPreset(this, presetHandler);\r
+            if (preset.ShowDialog() == DialogResult.OK)\r
+            {\r
+                TreeNode presetTreeview = new TreeNode(presetHandler.LastPresetAdded.Name) { ForeColor = Color.Black };\r
+                treeView_presets.Nodes.Add(presetTreeview);\r
+                presetHandler.LastPresetAdded = null;\r
+            }\r
         }\r
 \r
         #endregion\r
@@ -718,9 +721,13 @@ namespace Handbrake
         /// </param>\r
         private void btn_addPreset_Click(object sender, EventArgs e)\r
         {\r
-            // TODO this requires a re-think due to the Query Editor Changing.\r
-            Form preset = new frmAddPreset(this, QueryGenerator.GenerateQueryForPreset(this, QueryPictureSettingsMode.SourceMaximum, true, 0, 0), presetHandler);\r
-            preset.ShowDialog();\r
+            Form preset = new frmAddPreset(this, presetHandler);\r
+            if (preset.ShowDialog() == DialogResult.OK)\r
+            {\r
+                TreeNode presetTreeview = new TreeNode(presetHandler.LastPresetAdded.Name) { ForeColor = Color.Black };\r
+                treeView_presets.Nodes.Add(presetTreeview);\r
+                presetHandler.LastPresetAdded = null;\r
+            }\r
         }\r
 \r
         /// <summary>\r
@@ -866,7 +873,6 @@ namespace Handbrake
                 if (preset != null)\r
                 {\r
                     string query = presetHandler.GetPreset(presetName).Query;\r
-                    bool loadPictureSettings = presetHandler.GetPreset(presetName).PictureSettings;\r
 \r
                     if (query != null)\r
                     {\r
@@ -877,7 +883,7 @@ namespace Handbrake
                         QueryParser presetQuery = QueryParser.Parse(query);\r
 \r
                         // Now load the preset\r
-                        PresetLoader.LoadPreset(this, presetQuery, presetName, loadPictureSettings);\r
+                        PresetLoader.LoadPreset(this, presetQuery, presetName);\r
 \r
                         // The x264 widgets will need updated, so do this now:\r
                         x264Panel.StandardizeOptString();\r
@@ -922,7 +928,7 @@ namespace Handbrake
                                         MessageBoxButtons.YesNo, MessageBoxIcon.Warning);\r
                     if (result == DialogResult.Yes)\r
                     {\r
-                        PresetLoader.LoadPreset(this, parsed, parsed.PresetName, parsed.UsesPictureSettings);\r
+                        PresetLoader.LoadPreset(this, parsed, parsed.PresetName);\r
                         presetHandler.Update(parsed.PresetName + " (Imported)",\r
                                              QueryGenerator.GenerateFullQuery(this),\r
                                              parsed.UsesPictureSettings);\r
@@ -930,7 +936,7 @@ namespace Handbrake
                 }\r
                 else\r
                 {\r
-                    PresetLoader.LoadPreset(this, parsed, parsed.PresetName, parsed.UsesPictureSettings);\r
+                    PresetLoader.LoadPreset(this, parsed, parsed.PresetName);\r
                     if (presetHandler.Add(parsed.PresetName + " (Imported)",\r
                                           QueryGenerator.GenerateFullQuery(this),\r
                                           parsed.UsesPictureSettings))\r
@@ -2216,7 +2222,7 @@ namespace Handbrake
                 QueryParser presetQuery = QueryParser.Parse(query);\r
 \r
                 // Now load the preset\r
-                PresetLoader.LoadPreset(this, presetQuery, "Load Back From Queue", true);\r
+                PresetLoader.LoadPreset(this, presetQuery, "Load Back From Queue");\r
 \r
                 // The x264 widgets will need updated, so do this now:\r
                 x264Panel.StandardizeOptString();\r