Ejemplo n.º 1
0
        /// <summary>
        /// Saves an <see cref="Identicon"/> as an Enhanced Metafile (EMF).
        /// </summary>
        /// <param name="icon">The identicon to save.</param>
        /// <param name="stream">The stream to which the EMF data will be written.</param>
        /// <exception cref="ArgumentNullException"><paramref name="stream"/> was <c>null</c>.</exception>
        public static void SaveAsEmf(this Identicon icon, Stream stream)
        {
            if (stream == null)
            {
                throw new ArgumentNullException(nameof(stream));
            }

            var emf = icon.ToMetafile();

            stream.Write(emf, 0, emf.Length);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Saves an <see cref="Identicon"/> as an Enhanced Metafile (EMF) asynchronously.
        /// </summary>
        /// <param name="icon">The identicon to save.</param>
        /// <param name="stream">The stream to which the EMF data will be written.</param>
        /// <exception cref="ArgumentNullException"><paramref name="stream"/> was <c>null</c>.</exception>
        public static Task SaveAsEmfAsync(this Identicon icon, Stream stream)
        {
            if (stream == null)
            {
                throw new ArgumentNullException(nameof(stream));
            }

            var emf = icon.ToMetafile();

            return(stream.WriteAsync(emf, 0, emf.Length));
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Saves an <see cref="Identicon"/> as an Enhanced Metafile (EMF) asynchronously.
        /// </summary>
        /// <param name="icon">The identicon to save.</param>
        /// <param name="path">The path to the EMF file to create. If the file already exists it will be overwritten.</param>
        /// <exception cref="ArgumentNullException"><paramref name="path"/> was <c>null</c>.</exception>
        public static async Task SaveAsEmfAsync(this Identicon icon, string path)
        {
            if (path == null)
            {
                throw new ArgumentNullException(nameof(path));
            }

            using (var stream = new FileStream(path, FileMode.Create, FileAccess.Write))
            {
                var emf = icon.ToMetafile();
                await stream.WriteAsync(emf, 0, emf.Length);
            }
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Saves an <see cref="Identicon"/> as an Enhanced Metafile (EMF).
 /// </summary>
 /// <param name="icon">The identicon to save.</param>
 public static Stream SaveAsEmf(this Identicon icon)
 {
     return(new MemoryStream(icon.ToMetafile(), false));
 }