Example #1
0
 private static void ValidateUpdateIconArgs(IUpdateIconArgs args)
 {
     // icon file should exist
     if (!File.Exists(args.IconPath))
     {
         var message = string.Format(Localization.ValidateArgsIconFile, args.IconPath);
         throw new IOException(message);
     }
 }
Example #2
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);
            }
        }
Example #3
0
 private static void ValidateUpdateIconArgs(IUpdateIconArgs args)
 {
     // icon file should exist
     if (!File.Exists(args.IconPath))
     {
         var message = string.Format(Localization.ValidateArgsIconFile, args.IconPath);
         throw new IOException(message);
     }
 }
Example #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);
            }
        }