public Icon(Icon original, int width, int height) : this()
 {
     if (original == null)
     {
         throw new ArgumentException(System.Drawing.SR.GetString("InvalidArgument", new object[] { "original", "null" }));
     }
     this.iconData = original.iconData;
     if (this.iconData == null)
     {
         this.iconSize = original.Size;
         this.handle   = SafeNativeMethods.CopyImage(new HandleRef(original, original.Handle), 1, this.iconSize.Width, this.iconSize.Height, 0);
     }
     else
     {
         this.Initialize(width, height);
     }
 }
Exemple #2
0
        public Icon(Icon original, int width, int height) : this()
        {
            if (original == null)
            {
                throw new ArgumentNullException(nameof(original));
            }

            _iconData = original._iconData;

            if (_iconData == null)
            {
                _iconSize = original.Size;
                _handle   = SafeNativeMethods.CopyImage(new HandleRef(original, original.Handle), SafeNativeMethods.IMAGE_ICON, _iconSize.Width, _iconSize.Height, 0);
            }
            else
            {
                Initialize(width, height);
            }
        }
Exemple #3
0
        /// <include file='doc\Icon.uex' path='docs/doc[@for="Icon.Icon2"]/*' />
        /// <devdoc>
        ///     Duplicates the given icon, attempting to find a version of the icon
        ///     that matches the requested size.  If a version cannot be found that
        ///     exactally matches the size, the closest match will be used.  Note
        ///     that if original is an icon with a single size, this will
        ///     merely create a dupicate icon.  You can use the stretching modes
        ///     of drawImage to force the icon to the size you want.
        /// </devdoc>
        public Icon(Icon original, int width, int height) : this()
        {
            if (original == null)
            {
                throw new ArgumentException(SR.GetString(SR.InvalidArgument, "original", "null"));
            }

            iconData = original.iconData;

            if (iconData == null)
            {
                iconSize = original.Size;
                handle   = SafeNativeMethods.CopyImage(new HandleRef(original, original.Handle), SafeNativeMethods.IMAGE_ICON, iconSize.Width, iconSize.Height, 0);
            }
            else
            {
                Initialize(width, height);
            }
        }