diff options
author | sr55 <[email protected]> | 2013-06-01 14:21:10 +0000 |
---|---|---|
committer | sr55 <[email protected]> | 2013-06-01 14:21:10 +0000 |
commit | ca5ac69f4f80e86e396f0c21aa5a16c364997b89 (patch) | |
tree | 5b962419fe18a97b64ad8646205dca0d354e6e22 /win/CS/HandBrakeWPF/Controls | |
parent | 665b3364b361897b572bfafb80e36a993668a943 (diff) |
WinGui: Change the Add button on the Audio/Subtitle tabs to DropButtons to better expose the add options.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@5538 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'win/CS/HandBrakeWPF/Controls')
-rw-r--r-- | win/CS/HandBrakeWPF/Controls/DropButton/DropButton.cs | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/win/CS/HandBrakeWPF/Controls/DropButton/DropButton.cs b/win/CS/HandBrakeWPF/Controls/DropButton/DropButton.cs new file mode 100644 index 000000000..22383b871 --- /dev/null +++ b/win/CS/HandBrakeWPF/Controls/DropButton/DropButton.cs @@ -0,0 +1,65 @@ +// --------------------------------------------------------------------------------------------------------------------
+// <copyright file="DropButton.cs" company="HandBrake Project (http://handbrake.fr)">
+// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.
+// </copyright>
+// <summary>
+// Defines the DropDownButton type.
+// </summary>
+// --------------------------------------------------------------------------------------------------------------------
+
+namespace HandBrakeWPF.Controls.DropButton
+{
+ using System.Windows;
+ using System.Windows.Controls;
+ using System.Windows.Controls.Primitives;
+ using System.Windows.Data;
+
+ /// <summary>
+ /// The drop down button.
+ /// </summary>
+ public class DropButton : ToggleButton
+ {
+ /// <summary>
+ /// The drop down property.
+ /// </summary>
+ public static readonly DependencyProperty DropDownProperty =
+ DependencyProperty.Register("DropDown",
+ typeof(ContextMenu),
+ typeof(DropButton),
+ new UIPropertyMetadata(null));
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="DropButton"/> class.
+ /// </summary>
+ public DropButton()
+ {
+ // Bind the ToogleButton.IsChecked property to the drop-down's IsOpen property
+ Binding binding = new Binding("DropDown.IsOpen") { Source = this };
+ this.SetBinding(IsCheckedProperty, binding);
+ }
+
+ /// <summary>
+ /// Gets or sets the drop down.
+ /// </summary>
+ public ContextMenu DropDown
+ {
+ get { return (ContextMenu)this.GetValue(DropDownProperty); }
+ set { this.SetValue(DropDownProperty, value); }
+ }
+
+ /// <summary>
+ /// Handle the users click on the button.
+ /// </summary>
+ protected override void OnClick()
+ {
+ if (this.DropDown != null)
+ {
+ // If there is a drop-down assigned to this button, then position and display it
+
+ this.DropDown.PlacementTarget = this;
+ this.DropDown.Placement = PlacementMode.Bottom;
+ this.DropDown.IsOpen = true;
+ }
+ }
+ }
+}
|