aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Tango.Visuals/Themes/TreeViewItemExtensions.cs
blob: 736b84d477c42f73b0e4b038999b34adfc605d98 (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
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Media;

namespace DarkBlendTheme
{
    internal static class TreeViewItemExtensions
    {
        public static int GetDepth(this TreeViewItem item)
        {
            TreeViewItem parent;
            while ((parent = GetParent(item)) != null)
            {
                return GetDepth(parent) + 1;
            }
            return 0;
        }

        private static TreeViewItem GetParent(TreeViewItem item)
        {
            var parent = VisualTreeHelper.GetParent(item);
				
            while (!(parent is TreeViewItem || parent is TreeView))
            {
				if (parent == null) return null;
                parent = VisualTreeHelper.GetParent(parent);
            }
            return parent as TreeViewItem;
        }
    }
}
span>{ get { return _machineversionsconfigurations; } set { _machineversionsconfigurations = value; RaisePropertyChanged(nameof(MachineVersionsConfigurations)); } } private ObservableCollection<Machine> _machines; /// <summary> /// Gets or sets the machineversion machines. /// </summary> [EntityFieldName("MACHINES")] public ObservableCollection<Machine> Machines { get { return _machines; } set { _machines = value; RaisePropertyChanged(nameof(Machines)); } } /// <summary> /// Initializes a new instance of the <see cref="MachineVersion" /> class. /// </summary> public MachineVersion() : base() { Init(); } /// <summary> /// Initializes a new instance of the <see cref="MachineVersion" /> class. /// </summary> /// <param name="entity">The entity.</param> public MachineVersion(MACHINE_VERSIONS entity) : base(entity) { Init(); MapEntityToObservable(entity, this); } /// <summary> /// Initialize complex types. /// </summary> private void Init() { MachineVersionsConfigurations = new ObservableCollection<MachineVersionsConfiguration>(); Machines = new ObservableCollection<Machine>(); } } }