aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Resources/SharedResourceDictionary.cs
blob: d422df26c38d1a592ad6bd3724f30ef67ac023c8 (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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using Tango.Settings;

namespace Tango.MachineStudio.Common.Resources
{
/// <summary>
/// The shared resource dictionary is a specialized resource dictionary
/// that loads it content only once. If a second instance with the same source
/// is created, it only merges the resources from the cache.
/// </summary>
    public class SharedResourceDictionary : ResourceDictionary
    {
        /// <summary>
        /// Internal cache of loaded dictionaries 
        /// </summary>
        public static Dictionary<Uri, ResourceDictionary> _sharedDictionaries =
            new Dictionary<Uri, ResourceDictionary>();

        /// <summary>
        /// Local member of the source uri
        /// </summary>
        private Uri _sourceUri;

        /// <summary>
        /// Gets or sets the uniform resource identifier (URI) to load resources from.
        /// </summary>
        public new Uri Source
        {
            get { return _sourceUri; }
            set
            {
                _sourceUri = value;
                var settings = SettingsManager.Default.GetOrCreate<MachineStudioSettings>();
                //add current theme
                MachineStudioTheme wTheme = settings.Theme;
                if ((wTheme == MachineStudioTheme.Dark && value.LocalPath.Contains("Light")) || (wTheme == MachineStudioTheme.Light && value.LocalPath.Contains("Dark")))
                    return;

                if (!_sharedDictionaries.ContainsKey(value))
                {
                    // If the dictionary is not yet loaded, load it by setting
                    // the source of the base class
                    base.Source = value;

                    // add it to the cache
                    _sharedDictionaries.Add(value, this);
                }
                else
                {
                    // If the dictionary is already loaded, get it from the cache
                    MergedDictionaries.Add(_sharedDictionaries[value]);
                }
            }
        }
    }
}
text-align: left; overflow: hidden; width: 80%; margin: 0 auto; display: table; margin-top: 50px; padding: 0 0 8em 0; border-spacing: 0px; } .container td, .container th { padding-bottom: 2%; padding-top: 2%; padding-left: 2%; } /* Background-color of the odd rows */ .container tr:nth-child(odd) { background-color: #1b1b1b; } /* Background-color of the even rows */ .container tr:nth-child(even) { background-color: #2B2B2B; } .container th { border-bottom: 1px solid #00ceff; } .container td:first-child a { color: #A7A1AE; /*cursor: pointer;*/ } .container td:first-child a:hover { color:white; } .container tbody tr { /*cursor:pointer;*/ } .container tr:hover { /*background-color: #A0A0A0; -webkit-box-shadow: 0 6px 6px -6px #0E1119; -moz-box-shadow: 0 6px 6px -6px #0E1119; box-shadow: 0 6px 6px -6px #0E1119; color: Black;*/ } .container tbody tr:hover { /*background-color: #00ceff; color: Black; font-weight: bold; box-shadow: #008CAE -1px 1px, #008CAE -2px 2px, #008CAE -3px 3px, #008CAE -4px 4px, #008CAE -5px 5px, #008CAE -6px 6px; transform: translate3d(6px, -6px, 0); transition-delay: 0s; transition-duration: 0.4s; transition-property: all; transition-timing-function: line;*/ } @media (max-width: 800px) { .container td:nth-child(4), .container th:nth-child(4) { display: none; } }