From fc8a05358a92cc3c77c5f1e30d536807ef0614fd Mon Sep 17 00:00:00 2001 From: Victoria Plitt Date: Mon, 8 Apr 2019 13:49:55 +0300 Subject: were added scripting projects --- .../Search/DropDownButton.cs | 60 ++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 Software/Visual_Studio/Scripting/Tango.Scripting.Editors/Search/DropDownButton.cs (limited to 'Software/Visual_Studio/Scripting/Tango.Scripting.Editors/Search/DropDownButton.cs') diff --git a/Software/Visual_Studio/Scripting/Tango.Scripting.Editors/Search/DropDownButton.cs b/Software/Visual_Studio/Scripting/Tango.Scripting.Editors/Search/DropDownButton.cs new file mode 100644 index 000000000..dca5bea30 --- /dev/null +++ b/Software/Visual_Studio/Scripting/Tango.Scripting.Editors/Search/DropDownButton.cs @@ -0,0 +1,60 @@ +// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) +// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) + +using System; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Controls.Primitives; +using System.Windows.Input; + +namespace Tango.Scripting.Editors.Search +{ + /// + /// A button that opens a drop-down menu when clicked. + /// + class DropDownButton : ButtonBase + { + public static readonly DependencyProperty DropDownContentProperty + = DependencyProperty.Register("DropDownContent", typeof(Popup), + typeof(DropDownButton), new FrameworkPropertyMetadata(null)); + + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes")] + protected static readonly DependencyPropertyKey IsDropDownContentOpenPropertyKey + = DependencyProperty.RegisterReadOnly("IsDropDownContentOpen", typeof(bool), + typeof(DropDownButton), new FrameworkPropertyMetadata(false)); + + public static readonly DependencyProperty IsDropDownContentOpenProperty = IsDropDownContentOpenPropertyKey.DependencyProperty; + + static DropDownButton() + { + DefaultStyleKeyProperty.OverrideMetadata(typeof(DropDownButton), new FrameworkPropertyMetadata(typeof(DropDownButton))); + } + + public Popup DropDownContent { + get { return (Popup)GetValue(DropDownContentProperty); } + set { SetValue(DropDownContentProperty, value); } + } + + public bool IsDropDownContentOpen { + get { return (bool)GetValue(IsDropDownContentOpenProperty); } + protected set { SetValue(IsDropDownContentOpenPropertyKey, value); } + } + + protected override void OnClick() + { + if (DropDownContent != null && !IsDropDownContentOpen) { + DropDownContent.Placement = PlacementMode.Bottom; + DropDownContent.PlacementTarget = this; + DropDownContent.IsOpen = true; + DropDownContent.Closed += DropDownContent_Closed; + this.IsDropDownContentOpen = true; + } + } + + void DropDownContent_Closed(object sender, EventArgs e) + { + ((Popup)sender).Closed -= DropDownContent_Closed; + this.IsDropDownContentOpen = false; + } + } +} -- cgit v1.3.1