Inheritance: IconContainer
Exemplo n.º 1
0
        public PeContainer(IcoContainer container)
            : base(container)
        {
            if (container.Directory == null)
                throw new InvalidOperationException("Container Directory is null");

            Directory = new PeDirectory(container.Directory);
        }
Exemplo n.º 2
0
        public PeContainer(IcoContainer container) :
            base(container)
        {
            if (container.Directory == null)
            {
                throw new InvalidOperationException("Container Directory is null");
            }

            Directory = new PeDirectory(container.Directory);
        }
Exemplo n.º 3
0
        public static PeContainer ToPe(this IcoContainer container)
        {
            if (container == null)
            {
                throw new ArgumentNullException("container");
            }

            if (container.Directory == null)
            {
                throw new InvalidOperationException("Container Directory is null");
            }

            if (container.Images == null)
            {
                throw new InvalidOperationException("Container Images are null");
            }

            return(new PeContainer
            {
                Directory = container.Directory.ToPe(),
                Images = container.Images.Select(i => new IconImage(i)).ToArray()
            });
        }
Exemplo n.º 4
0
        // adds main icon to screensaver
        private static void InjectIcon(IUpdateIconArgs args)
        {
            byte[] icon;
            try
            {
                // read icon data
                icon = File.ReadAllBytes(args.IconPath);
            }
            catch (Exception ex)
            {
                var message = string.Format(Localization.InjectIconFileRead,
                    args.IconPath, ex.Message);
                throw new IOException(message, ex);
            }

            IcoContainer ico;
            try
            {
                // parse ico from data
                ico = new IcoContainer(icon);
            }
            catch (Exception ex)
            {
                var message = string.Format(Localization.InjectIconParseICO,
                    args.IconPath, ex.Message);
                throw new IOException(message, ex);
            }

            try
            {
                // convert ico representation to pe
                var pe = ico.ToPe();

                // update pe icon
                pe.ToFile(args.OutputPath, Constants.MainGroupIconName);
            }
            catch (Exception ex)
            {
                var message = string.Format(Localization.InjectIconPEToFile,
                    args.OutputPath, ex.Message);
                throw new IOException(message, ex);
            }
        }