aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Tango.Touch/Components
diff options
context:
space:
mode:
authorRoy Ben Shabat <Roy.mail.net@gmail.com>2019-04-22 09:33:28 +0300
committerRoy Ben Shabat <Roy.mail.net@gmail.com>2019-04-22 09:33:28 +0300
commit13887d7b53fec7e2d357fd377a6a1fbd0e875e65 (patch)
treef400c960cc086a6615de95d155b5da19044e37b6 /Software/Visual_Studio/Tango.Touch/Components
parent26ede873b194b0df70979b6f1b62e0c91ca19341 (diff)
downloadTango-13887d7b53fec7e2d357fd377a6a1fbd0e875e65.tar.gz
Tango-13887d7b53fec7e2d357fd377a6a1fbd0e875e65.zip
Working on PPC optimizations...
Diffstat (limited to 'Software/Visual_Studio/Tango.Touch/Components')
-rw-r--r--Software/Visual_Studio/Tango.Touch/Components/SharedResourceDictionary.cs55
1 files changed, 55 insertions, 0 deletions
diff --git a/Software/Visual_Studio/Tango.Touch/Components/SharedResourceDictionary.cs b/Software/Visual_Studio/Tango.Touch/Components/SharedResourceDictionary.cs
new file mode 100644
index 000000000..efa1e77e4
--- /dev/null
+++ b/Software/Visual_Studio/Tango.Touch/Components/SharedResourceDictionary.cs
@@ -0,0 +1,55 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+
+namespace Tango.Touch.Components
+{
+ /// <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]);
+ }
+ }
+ }
+ }
+}