diff options
| author | Roy Ben-Shabat <Roy@Twine-s.com> | 2018-05-27 19:33:15 +0300 |
|---|---|---|
| committer | Roy Ben-Shabat <Roy@Twine-s.com> | 2018-05-27 19:33:15 +0300 |
| commit | e571f20e27c4fca6bb6efe03d6427a1f332f9830 (patch) | |
| tree | b16041b76ea3b4e8368039c9396f9bbf9624dcc2 /Software/Visual_Studio/Tango.Touch/Controls/TouchToggleButton.cs | |
| parent | 157e0685abb2e7b22b6584cdc7d6f5838ed0a808 (diff) | |
| download | Tango-e571f20e27c4fca6bb6efe03d6427a1f332f9830.tar.gz Tango-e571f20e27c4fca6bb6efe03d6427a1f332f9830.zip | |
Working on panel pc.
Diffstat (limited to 'Software/Visual_Studio/Tango.Touch/Controls/TouchToggleButton.cs')
| -rw-r--r-- | Software/Visual_Studio/Tango.Touch/Controls/TouchToggleButton.cs | 87 |
1 files changed, 87 insertions, 0 deletions
diff --git a/Software/Visual_Studio/Tango.Touch/Controls/TouchToggleButton.cs b/Software/Visual_Studio/Tango.Touch/Controls/TouchToggleButton.cs new file mode 100644 index 000000000..bc4e6994f --- /dev/null +++ b/Software/Visual_Studio/Tango.Touch/Controls/TouchToggleButton.cs @@ -0,0 +1,87 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Controls.Primitives; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace Tango.Touch.Controls +{ + public class TouchToggleButton : ToggleButton, ITouchControl + { + private Object _uncheckedContent; + + #region ITouchControl + + public CornerRadius CornerRadius + { + get { return (CornerRadius)GetValue(CornerRadiusProperty); } + set { SetValue(CornerRadiusProperty, value); } + } + public static readonly DependencyProperty CornerRadiusProperty = + DependencyProperty.Register("CornerRadius", typeof(CornerRadius), typeof(TouchToggleButton), new PropertyMetadata(new CornerRadius())); + + public bool EnableDropShadow + { + get { return (bool)GetValue(EnableDropShadowProperty); } + set { SetValue(EnableDropShadowProperty, value); } + } + public static readonly DependencyProperty EnableDropShadowProperty = + DependencyProperty.Register("EnableDropShadow", typeof(bool), typeof(TouchToggleButton), new PropertyMetadata(true)); + + public double BlurRadius + { + get { return (double)GetValue(BlurRadiusProperty); } + set { SetValue(BlurRadiusProperty, value); } + } + public static readonly DependencyProperty BlurRadiusProperty = + DependencyProperty.Register("BlurRadius", typeof(double), typeof(TouchToggleButton), new PropertyMetadata(10.0)); + + public double ShadowDepth + { + get { return (double)GetValue(ShadowDepthProperty); } + set { SetValue(ShadowDepthProperty, value); } + } + public static readonly DependencyProperty ShadowDepthProperty = + DependencyProperty.Register("ShadowDepth", typeof(double), typeof(TouchToggleButton), new PropertyMetadata(1.0)); + + public Color ShadowColor + { + get { return (Color)GetValue(ShadowColorProperty); } + set { SetValue(ShadowColorProperty, value); } + } + public static readonly DependencyProperty ShadowColorProperty = + DependencyProperty.Register("ShadowColor", typeof(Color), typeof(TouchToggleButton), new PropertyMetadata(Colors.Gray)); + + #endregion + + public Object CheckedContent + { + get { return (Object)GetValue(CheckedContentProperty); } + set { SetValue(CheckedContentProperty, value); } + } + public static readonly DependencyProperty CheckedContentProperty = + DependencyProperty.Register("CheckedContent", typeof(Object), typeof(TouchToggleButton), new PropertyMetadata(null)); + + static TouchToggleButton() + { + DefaultStyleKeyProperty.OverrideMetadata(typeof(TouchToggleButton), new FrameworkPropertyMetadata(typeof(TouchToggleButton))); + } + + public TouchToggleButton() + { + Loaded += (_, __) => _uncheckedContent = Content; + Checked += (_, __) => Content = CheckedContent != null ? CheckedContent : Content; + Unchecked += (_, __) => Content = _uncheckedContent; + } + } +} |
