public static BitmapImage LoadBitmapImageFromPackage(AdminShellPackageEnv package, string path)
        {
            if (package == null || path == null)
            {
                return(null);
            }

            // ReSharper disable EmptyGeneralCatchClause
            try
            {
                var thumbStream = package.GetLocalStreamFromPackage(path);
                if (thumbStream == null)
                {
                    return(null);
                }

                // load image
                var bi = new BitmapImage();
                bi.BeginInit();
                bi.CacheOption  = BitmapCacheOption.OnLoad;
                bi.StreamSource = thumbStream;
                bi.EndInit();

                // note: no closing required!
                // give this back
                return(bi);
            }
            catch { }
            // ReSharper enable EmptyGeneralCatchClause

            return(null);
        }
Exemple #2
0
        public static BitmapImage LoadBitmapImageFromPackage(AdminShellPackageEnv package, string path)
        {
            if (package == null || path == null)
            {
                return(null);
            }

            try
            {
                var thumbStream = package.GetLocalStreamFromPackage(path);
                if (thumbStream == null)
                {
                    return(null);
                }

                // load image
                var bi = new BitmapImage();
                bi.BeginInit();
                bi.CacheOption  = BitmapCacheOption.OnLoad;
                bi.StreamSource = thumbStream;
                bi.EndInit();

                // note: no closing required!
                // give this back
                return(bi);
            }
            catch (Exception ex)
            {
                AdminShellNS.LogInternally.That.SilentlyIgnoredError(ex);
            }

            return(null);
        }
Exemple #3
0
        public UInt32 Open(Byte mode)
        {
            // access file handle
            if (this.package == null || this.file == null)
            {
                throw new InvalidOperationException("no admin-shell package or file");
            }
            var nh = GetMaxHandle() + 1;
            var fh = new PackageFileHandle(nh);

            fh.packStream = package.GetLocalStreamFromPackage(file.value);
            if (fh.packStream == null)
            {
                throw new InvalidOperationException("no admin-shell package or file");
            }
            handles.Add(nh, fh);

            // care about the particularities of write
            fh.UaMode  = mode;
            fh.IsRead  = ((mode & 0x01) > 0);
            fh.IsWrite = ((mode & 0x02) > 0);
            if ((mode & 0x04) > 0)
            {
                // Erase existing
                fh.packStream.Seek(0, SeekOrigin.Begin);
                fh.packStream.SetLength(0);
                fh.packStream.Flush();
            }
            if ((mode & 0x08) > 0)
            {
                // Append
                fh.packStream.Seek(0, SeekOrigin.End);
                fh.packStream.Flush();
            }

            // done
            return(nh);
        }
Exemple #4
0
        /// <summary>
        /// Checks, if a FileType node is advisable for representing an AASX file ..
        /// Shall be TRUE for local, existing files ..
        /// </summary>
        /// <returns></returns>
        public bool CheckSuitablity(AdminShellPackageEnv package, AdminShell.File file)
        {
            // trivial
            if (package == null || file == null)
            {
                return(false);
            }

            // try get a stream ..
            Stream s = null;

            try
            {
                s = package.GetLocalStreamFromPackage(file.value);
            }
            catch
            {
                return(false);
            }

            // ok?
            return(s != null);
        }
Exemple #5
0
        /// <summary>
        /// Checks, if a FileType node is advisable for representing an AASX file ..
        /// Shall be TRUE for local, existing files ..
        /// </summary>
        /// <returns></returns>
        public bool CheckSuitablity(AdminShellPackageEnv package, AdminShell.File file)
        {
            // trivial
            if (package == null || file == null)
            {
                return(false);
            }

            // try get a stream ..
            Stream s = null;

            try
            {
                s = package.GetLocalStreamFromPackage(file.value);
            }
            catch (Exception ex)
            {
                AdminShellNS.LogInternally.That.SilentlyIgnoredError(ex);
                return(false);
            }

            // ok?
            return(s != null);
        }