Beispiel #1
0
        private static void SetImageSource(ImageBrush brush, PackageFileInfo path)
        {
            ImageSource ddsSource;

            if (!_materialImages.TryGetValue(path.ToString(), out ddsSource))
            {
                string packagePath;
                if (!PackageStream.IsFileExisted(path.PackagePath, path.FileInPackagePath))
                {
                    packagePath = Path.Combine(Path.GetFullPath(Path.GetDirectoryName(path.PackagePath)), "shared_content.pkg");
                }
                else
                {
                    packagePath = path.PackagePath;
                }

                using (var Stream = new PackageStream(packagePath, path.FileInPackagePath))
                {
                    var dds = new DDSImage(Stream);
                    ddsSource = dds.BitmapSource(0);
                }
            }

            brush.ImageSource = ddsSource;
        }