aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/FSE/Tango.FSE.Common/Controls/FSETabControl.cs
blob: 44cfd48722512af1aef0ea5a921b5b5aaf8130f5 (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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
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.Markup;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Tango.SharedUI;
using Tango.SharedUI.Controls;
using static Tango.SharedUI.Controls.NavigationControl;

namespace Tango.FSE.Common.Controls
{
    [ContentProperty(nameof(Elements))]
    public class FSETabControl : Control
    {
        private NavigationControl _navigationControl;

        public ObservableCollection<FrameworkElement> Elements
        {
            get { return (ObservableCollection<FrameworkElement>)GetValue(ElementsProperty); }
            set { SetValue(ElementsProperty, value); }
        }
        public static readonly DependencyProperty ElementsProperty =
            DependencyProperty.Register("Elements", typeof(ObservableCollection<FrameworkElement>), typeof(FSETabControl), new PropertyMetadata(null));

        public FrameworkElement SelectedElement
        {
            get { return (FrameworkElement)GetValue(SelectedElementProperty); }
            set { SetValue(SelectedElementProperty, value); }
        }
        public static readonly DependencyProperty SelectedElementProperty =
            DependencyProperty.Register("SelectedElement", typeof(FrameworkElement), typeof(FSETabControl), new PropertyMetadata(null));

        public TransitionTypes TransitionType
        {
            get { return (TransitionTypes)GetValue(TransitionTypeProperty); }
            set { SetValue(TransitionTypeProperty, value); }
        }
        public static readonly DependencyProperty TransitionTypeProperty =
            DependencyProperty.Register("TransitionType", typeof(TransitionTypes), typeof(FSETabControl), new PropertyMetadata(TransitionTypes.Slide));

        public bool TransitionAlwaysFades
        {
            get { return (bool)GetValue(TransitionAlwaysFadesProperty); }
            set { SetValue(TransitionAlwaysFadesProperty, value); }
        }
        public static readonly DependencyProperty TransitionAlwaysFadesProperty =
            DependencyProperty.Register("TransitionAlwaysFades", typeof(bool), typeof(FSETabControl), new PropertyMetadata(false));

        public Duration TransitionDuration
        {
            get { return (Duration)GetValue(TransitionDurationProperty); }
            set { SetValue(TransitionDurationProperty, value); }
        }
        public static readonly DependencyProperty TransitionDurationProperty =
            DependencyProperty.Register("TransitionDuration", typeof(Duration), typeof(FSETabControl), new PropertyMetadata(new Duration(TimeSpan.FromSeconds(0.2))));

        public object SelectedObject
        {
            get { return (object)GetValue(SelectedObjectProperty); }
            set { SetValue(SelectedObjectProperty, value); }
        }
        public static readonly DependencyProperty SelectedObjectProperty =
            DependencyProperty.Register("SelectedObject", typeof(object), typeof(FSETabControl), new PropertyMetadata(null));

        public double TabsWidth
        {
            get { return (double)GetValue(TabsWidthProperty); }
            set { SetValue(TabsWidthProperty, value); }
        }
        public static readonly DependencyProperty TabsWidthProperty =
            DependencyProperty.Register("TabsWidth", typeof(double), typeof(FSETabControl), new PropertyMetadata(double.NaN));

        public FSETabControl()
        {
            Elements = new ObservableCollection<FrameworkElement>();
        }

        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();
            _navigationControl = GetTemplateChild("navigation") as NavigationControl;
            _navigationControl.SelectedElementChanged += (x, e) => 
            {
                SelectedElement = e;
            };

            _navigationControl.Elements = Elements;
        }

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