Пример #1
0
        static ResourceElement CreateSerializedImage(Stream stream, string filename)
        {
            object obj;
            string typeName;

            if (filename.EndsWith(".ico", StringComparison.OrdinalIgnoreCase))
            {
                obj      = new System.Drawing.Icon(stream);
                typeName = SerializedImageUtilities.SystemDrawingIcon.AssemblyQualifiedName;
            }
            else
            {
                obj      = new System.Drawing.Bitmap(stream);
                typeName = SerializedImageUtilities.SystemDrawingBitmap.AssemblyQualifiedName;
            }
            var serializedData = Serialize(obj);

            var userType = new UserResourceType(typeName, ResourceTypeCode.UserTypes);
            var rsrcElem = new ResourceElement {
                Name         = Path.GetFileName(filename),
                ResourceData = new BinaryResourceData(userType, serializedData),
            };

            return(rsrcElem);
        }
Пример #2
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="type">User resource type</param>
 /// <param name="data">Raw serialized data</param>
 public BinaryResourceData(UserResourceType type, byte[] data)
     : base(type) => this.data = data;
Пример #3
0
 public ImageResourceData(UserResourceType type, byte[] data) : base(type) => bitmap = new Bitmap(Image.FromStream(new MemoryStream(data)));
Пример #4
0
 public IconResourceData(UserResourceType type, byte[] data) : base(type) => icon = new Icon(new MemoryStream(data));
Пример #5
0
 public CharArrayResourceData(UserResourceType type, char[] data) : base(type) => this.data = data;