Example #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref='StringFormat'/> class from the specified
        /// existing <see cref='System.Drawing.StringFormat'/>.
        /// </summary>
        public StringFormat(StringFormat format)
        {
            ArgumentNullException.ThrowIfNull(format);

            int status = Gdip.GdipCloneStringFormat(new HandleRef(format, format.nativeFormat), out nativeFormat);

            if (status != Gdip.Ok)
            {
                throw Gdip.StatusException(status);
            }
        }
Example #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref='StringFormat'/> class from the specified
        /// existing <see cref='System.Drawing.StringFormat'/>.
        /// </summary>
        public StringFormat(StringFormat format)
        {
            if (format == null)
            {
                throw new ArgumentNullException(nameof(format));
            }

            int status = Gdip.GdipCloneStringFormat(new HandleRef(format, format.nativeFormat), out nativeFormat);

            if (status != Gdip.Ok)
            {
                throw Gdip.StatusException(status);
            }
        }
Example #3
0
        /// <summary>
        /// Creates an exact copy of this <see cref='StringFormat'/>.
        /// </summary>
        public object Clone()
        {
            IntPtr cloneFormat;

            int status = Gdip.GdipCloneStringFormat(new HandleRef(this, nativeFormat), out cloneFormat);

            if (status != Gdip.Ok)
            {
                throw Gdip.StatusException(status);
            }

            StringFormat newCloneStringFormat = new StringFormat(cloneFormat);

            return(newCloneStringFormat);
        }