aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Scripting/Tango.Scripting.IDE/Controls/SharedResourceDictionary.cs
diff options
context:
space:
mode:
authorShlomo Hecht <shlomo@twine-s.com>2019-04-08 15:09:50 +0300
committerShlomo Hecht <shlomo@twine-s.com>2019-04-08 15:09:50 +0300
commit46cdc21087d55e3bc5ca1d04b183f47bcfb3924f (patch)
tree175525aa0fe7e5831775fd9bb9f404d4dcf78b35 /Software/Visual_Studio/Scripting/Tango.Scripting.IDE/Controls/SharedResourceDictionary.cs
parentc36ea9eb28cd27cbf68187a0ce77536ca3442129 (diff)
parent33de6bbb3668c5d1edf9c28ee337058a29331443 (diff)
downloadTango-46cdc21087d55e3bc5ca1d04b183f47bcfb3924f.tar.gz
Tango-46cdc21087d55e3bc5ca1d04b183f47bcfb3924f.zip
Merge branch 'master' of https://twinetfs.visualstudio.com/Tango/_git/Tango
Diffstat (limited to 'Software/Visual_Studio/Scripting/Tango.Scripting.IDE/Controls/SharedResourceDictionary.cs')
-rw-r--r--Software/Visual_Studio/Scripting/Tango.Scripting.IDE/Controls/SharedResourceDictionary.cs55
1 files changed, 55 insertions, 0 deletions
diff --git a/Software/Visual_Studio/Scripting/Tango.Scripting.IDE/Controls/SharedResourceDictionary.cs b/Software/Visual_Studio/Scripting/Tango.Scripting.IDE/Controls/SharedResourceDictionary.cs
new file mode 100644
index 000000000..a163355c4
--- /dev/null
+++ b/Software/Visual_Studio/Scripting/Tango.Scripting.IDE/Controls/SharedResourceDictionary.cs
@@ -0,0 +1,55 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Windows;
+
+namespace Tango.Scripting.IDE.Controls
+{
+
+ /// <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;
+
+ 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]);
+ }
+ }
+ }
+ }
+} \ No newline at end of file