Exemple #1
0
        public DispatcherHelper(DependencyObject dependencyObject = null)
        {
            if (SharedHelpers.IsDispatcherQueueAvailable())
            {
                dispatcherQueue = Windows.System.DispatcherQueue.GetForCurrentThread();
            }

            if (dispatcherQueue == null)
            {
                try
                {
                    if (dependencyObject != null)
                    {
                        coreDispatcher = dependencyObject.Dispatcher;
                    }
                    else if (CoreApplication.GetCurrentView() is CoreApplicationView currentView)
                    {
                        coreDispatcher = currentView.Dispatcher;
                    }
                }
                catch (Exception)
                {
                    // CoreApplicationView might throw in XamlPresenter scenarios or in LogonUI.exe.
                }
            }
        }
Exemple #2
0
        public static LoadedImageSurface GetImageSurface(string assetName, Size imageSize)
        {
            Uri getImageUri()
            {
                if (SharedHelpers.IsInFrameworkPackage())
                {
                    return(new Uri("ms-resource://" + MUXCONTROLS_PACKAGE_NAME + "/Files/Microsoft.UI.Xaml/Assets/" + assetName + ".png"));
                }
                else
                {
                    return(new Uri("ms-resource:///Files/Microsoft.UI.Xaml/Assets/" + assetName + ".png"));
                }
            }

            return(LoadedImageSurface.StartLoadFromUri(getImageUri(), imageSize));
        }
Exemple #3
0
        private static ResourceMap GetPackageResourceMap()
        {
            if (SharedHelpers.IsInFrameworkPackage())
            {
                string packageName = MUXCONTROLS_PACKAGE_NAME;
                if (ResourceManager.Current.AllResourceMaps.TryGetValue(packageName, out var value))
                {
                    return(value);
                }

                return(null);
            }
            else
            {
                return(ResourceManager.Current.MainResourceMap);
            }
        }