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]);
                }
            }
        }
    }
}
"w"> static const ::google::protobuf::internal::ParseTableField entries[]; static const ::google::protobuf::internal::AuxillaryParseTableField aux[]; static const ::google::protobuf::internal::ParseTable schema[]; static const ::google::protobuf::uint32 offsets[]; static const ::google::protobuf::internal::FieldMetadata field_metadata[]; static const ::google::protobuf::internal::SerializationTable serialization_table[]; static void InitDefaultsImpl(); }; void AddDescriptors(); void InitDefaults(); } // namespace protobuf_StubCartridgeReadRequest_2eproto // =================================================================== class StubCartridgeReadRequest : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:Tango.PMR.Stubs.StubCartridgeReadRequest) */ { public: StubCartridgeReadRequest(); virtual ~StubCartridgeReadRequest(); StubCartridgeReadRequest(const StubCartridgeReadRequest& from); inline StubCartridgeReadRequest& operator=(const StubCartridgeReadRequest& from) { CopyFrom(from); return *this; } #if LANG_CXX11 StubCartridgeReadRequest(StubCartridgeReadRequest&& from) noexcept : StubCartridgeReadRequest() { *this = ::std::move(from); } inline StubCartridgeReadRequest& operator=(StubCartridgeReadRequest&& from) noexcept { if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) { if (this != &from) InternalSwap(&from); } else { CopyFrom(from); } return *this; } #endif static const ::google::protobuf::Descriptor* descriptor(); static const StubCartridgeReadRequest& default_instance(); static inline const StubCartridgeReadRequest* internal_default_instance() { return reinterpret_cast<const StubCartridgeReadRequest*>( &_StubCartridgeReadRequest_default_instance_); } static PROTOBUF_CONSTEXPR int const kIndexInFileMessages = 0; void Swap(StubCartridgeReadRequest* other); friend void swap(StubCartridgeReadRequest& a, StubCartridgeReadRequest& b) { a.Swap(&b); } // implements Message ---------------------------------------------- inline StubCartridgeReadRequest* New() const PROTOBUF_FINAL { return New(NULL); } StubCartridgeReadRequest* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL; void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void CopyFrom(const StubCartridgeReadRequest& from); void MergeFrom(const StubCartridgeReadRequest& from); void Clear() PROTOBUF_FINAL; bool IsInitialized() const PROTOBUF_FINAL; size_t ByteSizeLong() const PROTOBUF_FINAL; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL; void SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL; ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); void SetCachedSize(int size) const PROTOBUF_FINAL; void InternalSwap(StubCartridgeReadRequest* other); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { return NULL; } inline void* MaybeArenaPtr() const { return NULL; } public: ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL; // nested types ---------------------------------------------------- // accessors ------------------------------------------------------- // uint32 CartridgeId = 1; void clear_cartridgeid(); static const int kCartridgeIdFieldNumber = 1; ::google::protobuf::uint32 cartridgeid() const; void set_cartridgeid(::google::protobuf::uint32 value); // @@protoc_insertion_point(class_scope:Tango.PMR.Stubs.StubCartridgeReadRequest) private: ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; ::google::protobuf::uint32 cartridgeid_; mutable int _cached_size_; friend struct protobuf_StubCartridgeReadRequest_2eproto::TableStruct; }; // =================================================================== // =================================================================== #if !PROTOBUF_INLINE_NOT_IN_HEADERS #ifdef __GNUC__ #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wstrict-aliasing" #endif // __GNUC__ // StubCartridgeReadRequest // uint32 CartridgeId = 1; inline void StubCartridgeReadRequest::clear_cartridgeid() { cartridgeid_ = 0u; } inline ::google::protobuf::uint32 StubCartridgeReadRequest::cartridgeid() const { // @@protoc_insertion_point(field_get:Tango.PMR.Stubs.StubCartridgeReadRequest.CartridgeId) return cartridgeid_; } inline void StubCartridgeReadRequest::set_cartridgeid(::google::protobuf::uint32 value) { cartridgeid_ = value; // @@protoc_insertion_point(field_set:Tango.PMR.Stubs.StubCartridgeReadRequest.CartridgeId) } #ifdef __GNUC__ #pragma GCC diagnostic pop #endif // __GNUC__ #endif // !PROTOBUF_INLINE_NOT_IN_HEADERS // @@protoc_insertion_point(namespace_scope) } // namespace Stubs } // namespace PMR } // namespace Tango // @@protoc_insertion_point(global_scope) #endif // PROTOBUF_StubCartridgeReadRequest_2eproto__INCLUDED