/// <summary>
        /// Creates a minimal number of <see cref="DicomSoftcopyPresentationState"/>s for the given images.
        /// </summary>
        /// <remarks>
        /// <para>
        /// Presentation state instances can contain information for multiple images, but the images must all be of the same type,
        /// and contain non-conflicting presentation state information. This method creates a minimal number of presentation
        /// state objects for the collection of given images.
        /// </para>
        /// </remarks>
        /// <param name="images">The images for which presentation states are to be created.</param>
        /// <param name="callback">A callback method that initializes the instance properties of the created <see cref="DicomSoftcopyPresentationState"/>s.</param>
        /// <returns>A dictionary mapping of presentation images to its associated presentation state instance.</returns>
        /// <exception cref="ArgumentException">Thrown if softcopy presentation states are not supported for the type of any one of the given <paramref name="images"/>.</exception>
        /// <seealso cref="DicomSoftcopyPresentationState"/>
        public static IDictionary <IPresentationImage, DicomSoftcopyPresentationState> Create(IEnumerable <IPresentationImage> images, InitializeDicomSoftcopyPresentationStateCallback callback)
        {
            callback = callback ?? DefaultInitializeDicomSoftcopyPresentationStateCallback;

            List <IPresentationImage> grayscaleImages = new List <IPresentationImage>();
            List <IPresentationImage> colorImages     = new List <IPresentationImage>();

            foreach (IPresentationImage image in images)
            {
                if (image is DicomGrayscalePresentationImage)
                {
                    grayscaleImages.Add(image);
                }
                else if (image is DicomColorPresentationImage)
                {
                    colorImages.Add(image);
                }
                else
                {
                    throw new ArgumentException("DICOM presentation state serialization is not supported for that type of image.");
                }
            }

            Dictionary <IPresentationImage, DicomSoftcopyPresentationState> presentationStates = new Dictionary <IPresentationImage, DicomSoftcopyPresentationState>();

            if (grayscaleImages.Count > 0)
            {
                DicomGrayscaleSoftcopyPresentationState grayscaleSoftcopyPresentationState = new DicomGrayscaleSoftcopyPresentationState();
                callback.Invoke(grayscaleSoftcopyPresentationState);
                grayscaleSoftcopyPresentationState.Serialize(grayscaleImages);
                foreach (IPresentationImage image in grayscaleImages)
                {
                    presentationStates.Add(image, grayscaleSoftcopyPresentationState);
                }
            }
            if (colorImages.Count > 0)
            {
                DicomColorSoftcopyPresentationState colorSoftcopyPresentationState = new DicomColorSoftcopyPresentationState();
                callback.Invoke(colorSoftcopyPresentationState);
                colorSoftcopyPresentationState.Serialize(colorImages);
                foreach (IPresentationImage image in colorImages)
                {
                    presentationStates.Add(image, colorSoftcopyPresentationState);
                }
            }
            return(presentationStates);
        }
        /// <summary>
        /// Creates a <see cref="DicomSoftcopyPresentationState"/> for a given image.
        /// </summary>
        /// <param name="image">The image for which the presentation state should be created.</param>
        /// <param name="callback">A callback method that initializes the instance properties of the created <see cref="DicomSoftcopyPresentationState"/>.</param>
        /// <returns>One of the derived <see cref="DicomSoftcopyPresentationState"/> classes, depending on the type of the <paramref name="image"/>.</returns>
        /// <exception cref="ArgumentException">Thrown if softcopy presentation states for the type of the given <paramref name="image"/> are not supported.</exception>
        /// <seealso cref="DicomSoftcopyPresentationState"/>
        public static DicomSoftcopyPresentationState Create(IPresentationImage image, InitializeDicomSoftcopyPresentationStateCallback callback)
        {
            callback = callback ?? DefaultInitializeDicomSoftcopyPresentationStateCallback;

            if (image is DicomGrayscalePresentationImage)
            {
                DicomGrayscaleSoftcopyPresentationState grayscaleSoftcopyPresentationState = new DicomGrayscaleSoftcopyPresentationState();
                callback.Invoke(grayscaleSoftcopyPresentationState);
                grayscaleSoftcopyPresentationState.Serialize(image);
                return(grayscaleSoftcopyPresentationState);
            }
            else if (image is DicomColorPresentationImage)
            {
                DicomColorSoftcopyPresentationState colorSoftcopyPresentationState = new DicomColorSoftcopyPresentationState();
                callback.Invoke(colorSoftcopyPresentationState);
                colorSoftcopyPresentationState.Serialize(image);
                return(colorSoftcopyPresentationState);
            }
            else
            {
                throw new ArgumentException("DICOM presentation state serialization is not supported for that type of image.");
            }
        }
 private DicomColorSoftcopyPresentationState(DicomColorSoftcopyPresentationState source, ICloningContext context)
     : base(source, context)
 {
     context.CloneFields(source, this);
 }