コード例 #1
0
 public static void AddTheme(this ThemeResourceDictionary resource, Application application)
 {
     if (resource != null)
     {
         application.Resources.MergedDictionaries.Add(resource);
     }
 }
コード例 #2
0
ファイル: ThemeManager.cs プロジェクト: mike-koch/Statman
        private static void ApplyTheme(FrameworkElement p_TargetElement, Uri p_DictionaryUri)
        {
            if (p_TargetElement == null)
            {
                return;
            }

            ThemeResourceDictionary s_ThemeDictionary = null;

            if (p_DictionaryUri != null)
            {
                s_ThemeDictionary = new ThemeResourceDictionary {
                    Source = p_DictionaryUri
                };
                p_TargetElement.Resources.MergedDictionaries.Insert(0, s_ThemeDictionary);
            }

            var s_ExistingDictionaries =
                (from s_Dictionary in p_TargetElement.Resources.MergedDictionaries.OfType <ThemeResourceDictionary>()
                 select s_Dictionary).ToList();

            foreach (var s_Dictionary in s_ExistingDictionaries.Where(p_Dictionary => s_ThemeDictionary != p_Dictionary))
            {
                p_TargetElement.Resources.MergedDictionaries.Remove(s_Dictionary);
            }
        }
コード例 #3
0
        public static void ApplyTheme(FrameworkElement targetElement, Uri dictionaryUri)
        {
            var resources = targetElement != null ? targetElement.Resources :  Application.Current.Resources;

            try {
                // find if already has a theme applied
                var existingDictionaries = resources.MergedDictionaries.OfType <ThemeResourceDictionary>().ToList();
                var index = existingDictionaries.Count > 0 ? resources.MergedDictionaries.IndexOf(existingDictionaries[0]) : -1;

                // remove the existing dictionaries
                foreach (ThemeResourceDictionary thDictionary in existingDictionaries)
                {
                    resources.MergedDictionaries.Remove(thDictionary);
                }

                if (dictionaryUri != null)
                {
                    var themeDictionary = new ThemeResourceDictionary {
                        Source = dictionaryUri
                    };
                    // add the new dictionary to the collection of merged dictionaries of the target object
                    resources.MergedDictionaries.Insert(index >= 0 ? index : 0, themeDictionary);
                }
            }
            catch (Exception ex) {
                Debug.WriteLine("ThemeSelector caught an " + ex.GetType().Name + "\r\n" + ex.ToString());
            }
            finally { }
        }
コード例 #4
0
        private static void ApplyTheme(FrameworkElement targetElement, Uri dictionaryUri)
        {
            if (targetElement == null) return;

            try
            {
                ThemeResourceDictionary themeDictionary = null;
                if (dictionaryUri != null)
                {
                    themeDictionary = new ThemeResourceDictionary();
                    themeDictionary.Source = dictionaryUri;

                    // add the new dictionary to the collection of merged dictionaries of the target object
                    targetElement.Resources.MergedDictionaries.Insert(0, themeDictionary);
                }

                // find if the target element already has a theme applied
                List<ThemeResourceDictionary> existingDictionaries =
                    (from dictionary in targetElement.Resources.MergedDictionaries.OfType<ThemeResourceDictionary>()
                     select dictionary).ToList();

                // remove the existing dictionaries 
                foreach (ThemeResourceDictionary thDictionary in existingDictionaries)
                {
                    if (themeDictionary == thDictionary) continue;  // don't remove the newly added dictionary
                    targetElement.Resources.MergedDictionaries.Remove(thDictionary);
                }
            }
            finally { }
        }
コード例 #5
0
        private static void ApplyTheme(FrameworkElement targetElement, Uri dictionaryUri)
        {
            if (targetElement == null)
            {
                return;
            }

            try {
                ThemeResourceDictionary themeDictionary = null;
                if (dictionaryUri != null)
                {
                    themeDictionary        = new ThemeResourceDictionary();
                    themeDictionary.Source = dictionaryUri;

                    // add the new dictionary to the collection of merged dictionaries of the target object
                    targetElement.Resources.MergedDictionaries.Insert(0, themeDictionary);
                }

                // find if the target element already has a theme applied
                List <ThemeResourceDictionary> existingDictionaries =
                    (from dictionary in targetElement.Resources.MergedDictionaries.OfType <ThemeResourceDictionary>()
                     select dictionary).ToList();

                // remove the existing dictionaries
                foreach (ThemeResourceDictionary thDictionary in existingDictionaries)
                {
                    if (themeDictionary == thDictionary)
                    {
                        continue;                                   // don't remove the newly added dictionary
                    }
                    targetElement.Resources.MergedDictionaries.Remove(thDictionary);
                }
            }
            finally { }
        }
コード例 #6
0
ファイル: AppThemeSelector.cs プロジェクト: zyhong/LediReader
        public static void ApplyTheme(ResourceDictionary targetResourceDictionary, Uri[] dictionaryUris)
        {
            try
            {
                var newThemeDictionaries = new HashSet <ThemeResourceDictionary>();
                if (dictionaryUris != null)
                {
                    int index = 0;
                    foreach (var uri in dictionaryUris)
                    {
                        var themeDictionary = new ThemeResourceDictionary();
                        newThemeDictionaries.Add(themeDictionary);
                        themeDictionary.Source = uri;
                        // add the new dictionary to the collection of merged dictionaries of the target object
                        targetResourceDictionary.MergedDictionaries.Insert(index, themeDictionary);
                        ++index;
                    }
                }

                // find if the target element already has a theme applied
                var existingDictionaries = targetResourceDictionary.MergedDictionaries.OfType <ThemeResourceDictionary>().ToList();

                // remove the existing dictionaries
                foreach (ThemeResourceDictionary themeDictionary in existingDictionaries)
                {
                    if (!newThemeDictionaries.Contains(themeDictionary))
                    {
                        targetResourceDictionary.MergedDictionaries.Remove(themeDictionary);
                    }
                }
            }
            finally { }
        }
コード例 #7
0
 public MainWindow()
 {
     settings = new UserPreferenceSettings();
     ThemeResourceDictionary.SetTheme(settings.CurrentTheme);
     InitializeComponent();
     FindAndDisplayStep();
 }
コード例 #8
0
        public App()
        {
            //Setup unhandled exception handling and NBug
            AttachUnhandledExceptionHandlers();

            //Log startup diagnostic info
            Log.Info("STARTING UP.");
            LogDiagnosticInfo();

            //Attach shutdown handler
            var originalCulture   = Thread.CurrentThread.CurrentCulture;
            var originalUiCulture = Thread.CurrentThread.CurrentUICulture;

            Current.Exit += (o, args) =>
            {
                Log.Info("PERSISTING USER SETTINGS AND SHUTTING DOWN.");
                Settings.Default.Save();

                //Restoration of current culture is an attempt to prevent the OS language from being altered
                Log.InfoFormat("Restoring original CurrentCulture ({0}) and CurrentUICulture ({1})", originalCulture, originalUiCulture);
                Thread.CurrentThread.CurrentCulture   = originalCulture;
                Thread.CurrentThread.CurrentUICulture = originalUiCulture;
            };

            HandleCorruptSettings();

            //Upgrade settings (if required) - this ensures that user settings migrate between version changes
            if (Settings.Default.SettingsUpgradeRequired)
            {
                Settings.Default.Upgrade();
                Settings.Default.SettingsUpgradeRequired = false;
                Settings.Default.Save();
                Settings.Default.Reload();
            }

            //Adjust log4net logging level if in debug mode
            ((Hierarchy)LogManager.GetRepository()).Root.Level = Settings.Default.Debug ? Level.Debug : Level.Info;
            ((Hierarchy)LogManager.GetRepository()).RaiseConfigurationChanged(EventArgs.Empty);

            //Logic to initially apply the theme and change the theme on setting changes
            applyTheme = () =>
            {
                var themeDictionary = new ThemeResourceDictionary
                {
                    Source = new Uri(Settings.Default.Theme, UriKind.Relative)
                };

                var previousThemes = Resources.MergedDictionaries
                                     .OfType <ThemeResourceDictionary>()
                                     .ToList();

                //N.B. Add replacement before removing the previous as having no applicable resource
                //dictionary can result in the first element not being rendered (usually the first key).
                Resources.MergedDictionaries.Add(themeDictionary);
                previousThemes.ForEach(rd => Resources.MergedDictionaries.Remove(rd));
            };

            Settings.Default.OnPropertyChanges(settings => settings.Theme).Subscribe(_ => applyTheme());
        }
コード例 #9
0
        private void Application_Startup(object sender, StartupEventArgs e)
        {
            if (!Directory.Exists(vtubeCommon))
            {
                Directory.CreateDirectory(vtubeCommon);
            }

            logFile = Path.Combine(vtubeCommon, "Log.txt");

            LogThread = new Thread(new ThreadStart(LogLoop))
            {
                IsBackground = true
            };
            LogThread.Start();

            var themeResourceDictionary = new ThemeResourceDictionary();

            this.Resources.MergedDictionaries.Add(themeResourceDictionary);

            var stringsResourceDictionary = new StringsResourceDictionary();

            this.Resources.MergedDictionaries.Add(stringsResourceDictionary);

            ContainerBuilder cb = new ContainerBuilder();

            var logger = new EventLogger();

            logger.OnLog += Logger_OnLog;
            cb.RegisterInstance(themeResourceDictionary);
            cb.RegisterInstance(stringsResourceDictionary);
            cb.RegisterInstance(logger).As <ILogger>();

            cb.RegisterModule <IOModule>();
            cb.RegisterModule <DatabaseModule>();
            cb.RegisterModule <DiscordModule>();
            cb.RegisterModule <ViewModelModule>();
            cb.RegisterModule <CoreModule>();
            cb.RegisterModule <SettingsModule>();

            Container = cb.Build();

            try
            {
                logger.Log("------ New Startup ------");
                Container.Resolve <IIOService>().SetPath(vtubeCommon);
                mainWindow = new MainWindow();
                mainWindow.ShowDialog();
            }
            catch (Exception ex)
            {
                logger.Log(ex);
                MessageBox.Show(ex.ToString(), "Fatal Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }

            logger.Log("------ Session End ------");
        }
コード例 #10
0
 /// <summary>
 /// 应用主题
 /// </summary>
 /// <param name="resource">主题资源字典</param>
 /// <param name="element">控件级别的对象</param>
 public static void ApplyTheme(this ThemeResourceDictionary resource, FrameworkElement element)
 {
     if (resource != null)
     {
         element.Resources.MergedDictionaries.Clear();
         if (resource != null)
         {
             element.Resources.MergedDictionaries.Add(resource);
         }
     }
 }
コード例 #11
0
        internal ThemeResourceDictionary Clone()
        {
            var themeResourceDictionary = new ThemeResourceDictionary();

            foreach (var key in Keys)
            {
                themeResourceDictionary.Add(key, this[key]);
            }

            return(themeResourceDictionary);
        }
コード例 #12
0
ファイル: App.xaml.cs プロジェクト: ninibnu/OptiKey
        public App()
        {
            //Setup unhandled exception handling and NBug
            AttachUnhandledExceptionHandlers();

            //Log startup diagnostic info
            Log.Info("STARTING UP.");
            LogDiagnosticInfo();

            //Attach shutdown handler
            Application.Current.Exit += (o, args) =>
            {
                Log.Info("PERSISTING USER SETTINGS AND SHUTTING DOWN.");
                Settings.Default.Save();
            };

            HandleCorruptSettings();

            //Upgrade settings (if required) - this ensures that user settings migrate between version changes
            if (Settings.Default.SettingsUpgradeRequired)
            {
                Settings.Default.Upgrade();
                Settings.Default.SettingsUpgradeRequired = false;
                Settings.Default.Save();
                Settings.Default.Reload();
            }

            //Adjust log4net logging level if in debug mode
            ((log4net.Repository.Hierarchy.Hierarchy)LogManager.GetRepository()).Root.Level = Settings.Default.Debug ? Level.Debug : Level.Info;
            ((log4net.Repository.Hierarchy.Hierarchy)LogManager.GetRepository()).RaiseConfigurationChanged(EventArgs.Empty);

            //Logic to initially apply the theme and change the theme on setting changes
            applyTheme = () =>
            {
                var themeDictionary = new ThemeResourceDictionary
                {
                    Source = new Uri(Settings.Default.Theme, UriKind.Relative)
                };
                
                var previousThemes = Resources.MergedDictionaries
                    .OfType<ThemeResourceDictionary>()
                    .ToList();
                    
                //N.B. Add replacement before removing the previous as having no applicable resource
                //dictionary can result in the first element not being rendered (usually the first key).
                Resources.MergedDictionaries.Add(themeDictionary);
                previousThemes.ForEach(rd => Resources.MergedDictionaries.Remove(rd));
            };
            
            Settings.Default.OnPropertyChanges(settings => settings.Theme).Subscribe(_ => applyTheme());
        }
コード例 #13
0
ファイル: ThemeInfo.cs プロジェクト: xuehng/TccDispatcher
        static public ResourceDictionary GetResourceDictionary(string themename, ref Brush appBackgroudBrush)
        {
            ThemeResourceDictionary resource = null;

            if (themename == Officesilver)
            {
                resource          = new Office2007SilverResourceDictionary();
                appBackgroudBrush = Office2007SilverResources.ApplicationBackgroundBrush;
            }
            else if (themename == Officeblack)
            {
                resource          = new Office2007BlackResourceDictionary();
                appBackgroudBrush = Office2007BlackResources.ApplicationBackgroundBrush;
            }
            else if (themename == Officeblue)
            {
                resource          = new Office2007BlueResourceDictionary();
                appBackgroudBrush = Office2007BlueResources.ApplicationBackgroundBrush;
            }
            else if (themename == Media)
            {
                resource          = new MediaResourceDictionary();
                appBackgroudBrush = MediaResources.ApplicationBackgroundBrush;
            }
            else if (themename == Glass)
            {
                resource          = new GlassResourceDictionary();
                appBackgroudBrush = GlassResources.ApplicationBackgroundBrush;
            }
            else if (themename == Liveexplorer)
            {
                resource          = new LiveExplorerResourceDictionary();
                appBackgroudBrush = LiveExplorerResources.ApplicationBackgroundBrush;
            }
            else if (themename == Window7)
            {
                resource          = new Windows7ResourceDictionary();
                appBackgroudBrush = Windows7Resources.ApplicationBackgroundBrush;
            }

            if (resource != null)
            {
                resource.LicenseKey = Key;
            }

            return(resource);
        }
コード例 #14
0
ファイル: ThemeManager.cs プロジェクト: GVNCoder/34HLauncher
        public static void ApplyTheme(ThemeEnum theme)
        {
            if (_currentTheme == theme)
            {
                return;
            }

            var newThemeDictionary = new ThemeResourceDictionary
            {
                Source = new Uri($"/Launcher.Theme;component/Themes/Theme.{theme}.xaml", UriKind.Relative)
            };

            _entryPoint.MergedDictionaries.Insert(1, newThemeDictionary);
            _entryPoint.MergedDictionaries.Remove(_currentThemeDictionary);

            _currentThemeDictionary = newThemeDictionary;
            _currentTheme           = theme;
        }
コード例 #15
0
ファイル: ThemeManager.cs プロジェクト: OrfeasZ/Statman
        private static void ApplyTheme(FrameworkElement p_TargetElement, Uri p_DictionaryUri)
        {
            if (p_TargetElement == null)
                return;

            ThemeResourceDictionary s_ThemeDictionary = null;

            if (p_DictionaryUri != null)
            {
                s_ThemeDictionary = new ThemeResourceDictionary {Source = p_DictionaryUri};
                p_TargetElement.Resources.MergedDictionaries.Insert(0, s_ThemeDictionary);
            }

            var s_ExistingDictionaries =
                (from s_Dictionary in p_TargetElement.Resources.MergedDictionaries.OfType<ThemeResourceDictionary>()
                    select s_Dictionary).ToList();

            foreach (var s_Dictionary in s_ExistingDictionaries.Where(p_Dictionary => s_ThemeDictionary != p_Dictionary))
                p_TargetElement.Resources.MergedDictionaries.Remove(s_Dictionary);
        }
コード例 #16
0
        /// <summary>
        /// Removes any existing ThemeResourceDictionary in the specified element's Merged Dictionaries and
        /// prepends a ThemeResourceDictionary based on the specified color theme to the Merged Dictionaries
        /// </summary>
        /// <param name="element">The element whose Merged Dictionaries will be updated</param>
        /// <param name="colorTheme">The current ColorTheme of the Application</param>
        public static void UpdateThemeResourceDictionary(this FrameworkElement element, ColorTheme colorTheme)
        {
            var mergedDictionaries = element.Resources.MergedDictionaries;

            foreach (var resourceDictionary in mergedDictionaries)
            {
                if (!(resourceDictionary is ThemeResourceDictionary))
                {
                    continue;
                }

                element.Dispatcher.Invoke(new Action(() => mergedDictionaries.Remove(resourceDictionary)));
                break;
            }

            // We are inserting this Theme at the front of the MergedDictionaries because default styles are applied in
            // the order in which the Resource Dictionaries appear in the MergedDictionaries. If this were appended to
            // the back of a Window or Pane which uses the MahApps styles, for example, the styles in this theme will
            // be applied instead of the MahApps' styles, which is (usually) undesirable.
            var newThemeDictionary = ThemeResourceDictionary.FromColorTheme(colorTheme);

            element.Dispatcher.Invoke(new Action(() => mergedDictionaries.Insert(0, newThemeDictionary)));
        }
コード例 #17
0
        public MainWindow CreateKeyboard()
        {
            ////Apply resource language (and listen for changes)
            Action <OptiKey.Enums.Languages> applyResourceLanguage = language => OptiKey.Properties.Resources.Culture = language.ToCultureInfo();

            Settings.Default.OnPropertyChanges(s => s.UiLanguage).Subscribe(applyResourceLanguage);
            applyResourceLanguage(Settings.Default.UiLanguage);

            MainWindow mainWindow;

            //Define MainViewModel before services so I can setup a delegate to call into the MainViewModel
            //This is to work around the fact that the MainViewModel is created after the services.
            OptiKey.UI.ViewModels.MainViewModel mainViewModel = null;
            Action <KeyValue> fireKeySelectionEvent           = kv =>
            {
                if (mainViewModel != null) //Access to modified closure is a good thing here, for once!
                {
                    mainViewModel.FireKeySelectionEvent(kv);
                }
            };

            //Create services
            var                          errorNotifyingServices      = new List <INotifyErrors>();
            IAudioService                audioService                = new AudioService();
            IDictionaryService           dictionaryService           = new DictionaryService(OptiKey.Enums.AutoCompleteMethods.NGram);
            IPublishService              publishService              = new PublishService();
            ISuggestionStateService      suggestionService           = new SuggestionStateService();
            ICalibrationService          calibrationService          = OptiKey.App.CreateCalibrationService();
            ICapturingStateManager       capturingStateManager       = new CapturingStateManager(audioService);
            ILastMouseActionStateManager lastMouseActionStateManager = new LastMouseActionStateManager();
            IKeyStateService             keyStateService             = new KeyStateService(suggestionService, capturingStateManager, lastMouseActionStateManager, calibrationService, fireKeySelectionEvent);
            IInputService                inputService                = CreateInputService(keyStateService, dictionaryService, audioService, calibrationService, capturingStateManager, errorNotifyingServices);
            IKeyboardOutputService       keyboardOutputService       = new KeyboardOutputService(keyStateService, suggestionService, publishService, dictionaryService, fireKeySelectionEvent);
            IMouseOutputService          mouseOutputService          = new MouseOutputService(publishService);

            errorNotifyingServices.Add(audioService);
            errorNotifyingServices.Add(dictionaryService);
            errorNotifyingServices.Add(publishService);
            errorNotifyingServices.Add(inputService);

            //Release keys on application exit
            //ReleaseKeysOnApplicationExit(keyStateService, publishService);

            //Compose UI
            mainWindow = new MainWindow(audioService, dictionaryService, inputService, keyStateService);

            //for testing just hard code the size and position of the mainWindow

            ////get the size of the screen
            Rectangle screenSize   = Screen.PrimaryScreen.Bounds;
            double    windowWidth  = screenSize.Width - toolBarOffset;
            double    windowHeight = screenSize.Height * 0.40;

            Rect windowDimensions = new Rect(0, (screenSize.Height - windowHeight) - taskBarOffset, windowWidth, windowHeight);

            //Settings.Default.MainWindowFloatingSizeAndPosition = windowDimensions;

            IWindowManipulationService mainWindowManipulationService = new WindowManipulationService(
                mainWindow,
                () => Settings.Default.MainWindowOpacity,
                () => Settings.Default.MainWindowState,
                () => Settings.Default.MainWindowPreviousState,
                //() => Settings.Default.MainWindowFloatingSizeAndPosition,
                () => windowDimensions,
                () => Settings.Default.MainWindowDockPosition,
                () => Settings.Default.MainWindowDockSize,
                () => Settings.Default.MainWindowFullDockThicknessAsPercentageOfScreen,
                () => Settings.Default.MainWindowCollapsedDockThicknessAsPercentageOfFullDockThickness,
                () => Settings.Default.MainWindowMinimisedPosition,
                o => Settings.Default.MainWindowOpacity                               = o,
                state => Settings.Default.MainWindowState                             = state,
                state => Settings.Default.MainWindowPreviousState                     = state,
                rect => Settings.Default.MainWindowFloatingSizeAndPosition            = rect,
                pos => Settings.Default.MainWindowDockPosition                        = pos,
                size => Settings.Default.MainWindowDockSize                           = size,
                t => Settings.Default.MainWindowFullDockThicknessAsPercentageOfScreen = t,
                t => Settings.Default.MainWindowCollapsedDockThicknessAsPercentageOfFullDockThickness = t);

            errorNotifyingServices.Add(mainWindowManipulationService);
            mainWindow.WindowManipulationService = mainWindowManipulationService;

            mainViewModel = new MainViewModel(
                audioService, calibrationService, dictionaryService, keyStateService,
                suggestionService, capturingStateManager, lastMouseActionStateManager,
                inputService, keyboardOutputService, mouseOutputService, mainWindowManipulationService, errorNotifyingServices);

            mainWindow.MainView.DataContext = mainViewModel;

            //Setup actions to take once main view is loaded (i.e. the view is ready, so hook up the services which kicks everything off)
            Action postMainViewLoaded = mainViewModel.AttachServiceEventHandlers;

            if (mainWindow.MainView.IsLoaded)
            {
                postMainViewLoaded();
            }
            else
            {
                RoutedEventHandler loadedHandler = null;
                loadedHandler = (s, a) =>
                {
                    postMainViewLoaded();
                    mainWindow.MainView.Loaded -= loadedHandler; //Ensure this handler only triggers once
                };
                mainWindow.MainView.Loaded += loadedHandler;
            }

            //Show the main window
            ResourceDictionary resourses = new ResourceDictionary();

            mainWindow.Resources = resourses;
            ThemeResourceDictionary themeDictionary = new ThemeResourceDictionary();

            resourses.MergedDictionaries.Add(themeDictionary);

            //setSize

            //Display splash screen and check for updates (and display message) after the window has been sized and positioned for the 1st time
            EventHandler sizeAndPositionInitialised = null;

            sizeAndPositionInitialised = async(_, __) =>
            {
                mainWindowManipulationService.SizeAndPositionInitialised -= sizeAndPositionInitialised; //Ensure this handler only triggers once
                inputService.RequestResume();                                                           //Start the input service
            };
            if (mainWindowManipulationService.SizeAndPositionIsInitialised)
            {
                sizeAndPositionInitialised(null, null);
            }
            else
            {
                mainWindowManipulationService.SizeAndPositionInitialised += sizeAndPositionInitialised;
            }


            mainWindow.Closed           += (_, __) => ReleaseKeysOnApplicationExit(keyStateService, publishService);
            mainWindow.IsVisibleChanged += (_, __) => ReleaseKeysOnApplicationExit(keyStateService, publishService);

            return(mainWindow);
        }
コード例 #18
0
        private static void ApplyTheme(Collection<ResourceDictionary> mergedDictionaries, Uri dictionaryUri)
        {
            if (mergedDictionaries == null) return;

            using (var d = Application.Current.Dispatcher.DisableProcessing())
            {
                try
                {
                    ThemeResourceDictionary themeDictionary = null;
                    if (dictionaryUri != null)
                    {
                        themeDictionary = new ThemeResourceDictionary();
                        themeDictionary.Source = dictionaryUri;

                    }

                    // Find if the target element already has a theme applied
                    // we always want to remove them in case 'None' was selected.
                    var existingDictionaries = mergedDictionaries
                        .OfType<ThemeResourceDictionary>()
                        .ToList();

                    // Remove the existing dictionaries
                    foreach (ThemeResourceDictionary thDictionary in existingDictionaries)
                    {
                        mergedDictionaries.Remove(thDictionary);
                    }

                    if (themeDictionary != null)
                    {
                        // Add the new dictionary to the collection of merged dictionaries of the target object
                        mergedDictionaries.Insert(0, themeDictionary);
                    }
                }
                finally { }
            }
        }