aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Tango.Touch/Controls/TouchPanelEureka.cs
blob: a1c07f306a1cf8ae7a5f4bf3413934eff9d7a4f9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
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.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 TouchPanelEureka : TouchPanel
    {
        #region Prevent Focus Steal

        /// <summary>
        /// The prevent scroll property
        /// </summary>
        public static readonly DependencyProperty MakeEurekaFullScreenProperty =
            DependencyProperty.RegisterAttached("MakeEurekaFullScreen",
            typeof(bool), typeof(TouchPanelEureka),
            new FrameworkPropertyMetadata(false));

        /// <summary>
        /// Sets the MakeEurekaFullScreen attached property.
        /// </summary>
        /// <param name="element">The element.</param>
        /// <param name="value">if set to <c>true</c> [value].</param>
        public static void SetMakeEurekaFullScreen(FrameworkElement element, bool value)
        {
            element.SetValue(MakeEurekaFullScreenProperty, value);
        }

        /// <summary>
        /// Gets the MakeEurekaFullScreen attached property.
        /// </summary>
        /// <param name="element">The element.</param>
        /// <returns></returns>
        public static bool GetMakeEurekaFullScreen(FrameworkElement element)
        {
            if (element != null)
            {
                return (bool)element.GetValue(MakeEurekaFullScreenProperty);
            }
            else
            {
                return false;
            }
        }

        #endregion

        static TouchPanelEureka()
        {
            DefaultStyleKeyProperty.OverrideMetadata(typeof(TouchPanelEureka), new FrameworkPropertyMetadata(typeof(TouchPanelEureka)));
        }

        protected override void OnCurrentDialogChanged(FrameworkElement dialog)
        {
            base.OnCurrentDialogChanged(dialog);

            if (dialog != null)
            {
                if (GetMakeEurekaFullScreen(dialog))
                {
                    _dialogBorder.CornerRadius = new CornerRadius(0);
                    _dialogBorder.Padding = new Thickness(0);
                    _dialogBorder.Margin = new Thickness(0, 125, 0, 0);
                    dialog.Width = this.ActualWidth;
                    dialog.Height = this.ActualHeight - 125;
                }
                else
                {
                    _dialogBorder.CornerRadius = new CornerRadius(5);
                    _dialogBorder.Padding = new Thickness(10);
                    _dialogBorder.Margin = new Thickness(0);
                }
            }
        }
    }
}