Beispiel #1
0
        /// <summary>
        /// Sets the image path.
        /// </summary>
        /// <param name="item">The item.</param>
        /// <param name="type">The type.</param>
        /// <param name="imageIndex">Index of the image.</param>
        /// <param name="path">The path.</param>
        /// <param name="sourceUrl">The source URL.</param>
        /// <exception cref="System.ArgumentNullException">imageIndex
        /// or
        /// imageIndex</exception>
        private void SetImagePath(BaseItem item, ImageType type, int?imageIndex, string path, string sourceUrl)
        {
            switch (type)
            {
            case ImageType.Screenshot:

                if (!imageIndex.HasValue)
                {
                    throw new ArgumentNullException("imageIndex");
                }

                if (item.ScreenshotImagePaths.Count > imageIndex.Value)
                {
                    item.ScreenshotImagePaths[imageIndex.Value] = path;
                }
                else if (!item.ScreenshotImagePaths.Contains(path, StringComparer.OrdinalIgnoreCase))
                {
                    item.ScreenshotImagePaths.Add(path);
                }
                break;

            case ImageType.Backdrop:
                if (!imageIndex.HasValue)
                {
                    throw new ArgumentNullException("imageIndex");
                }
                if (item.BackdropImagePaths.Count > imageIndex.Value)
                {
                    item.BackdropImagePaths[imageIndex.Value] = path;
                }
                else if (!item.BackdropImagePaths.Contains(path, StringComparer.OrdinalIgnoreCase))
                {
                    item.BackdropImagePaths.Add(path);
                }

                if (string.IsNullOrEmpty(sourceUrl))
                {
                    item.RemoveImageSourceForPath(path);
                }
                else
                {
                    item.AddImageSource(path, sourceUrl);
                }
                break;

            default:
                item.SetImage(type, path);
                break;
            }
        }
Beispiel #2
0
        /// <summary>
        /// Sets the image path.
        /// </summary>
        /// <param name="item">The item.</param>
        /// <param name="type">The type.</param>
        /// <param name="imageIndex">Index of the image.</param>
        /// <param name="path">The path.</param>
        /// <param name="sourceUrl">The source URL.</param>
        /// <exception cref="System.ArgumentNullException">imageIndex
        /// or
        /// imageIndex</exception>
        private void SetImagePath(BaseItem item, ImageType type, int? imageIndex, string path, string sourceUrl)
        {
            switch (type)
            {
                case ImageType.Screenshot:

                    if (!imageIndex.HasValue)
                    {
                        throw new ArgumentNullException("imageIndex");
                    }

                    if (item.ScreenshotImagePaths.Count > imageIndex.Value)
                    {
                        item.ScreenshotImagePaths[imageIndex.Value] = path;
                    }
                    else if (!item.ScreenshotImagePaths.Contains(path, StringComparer.OrdinalIgnoreCase))
                    {
                        item.ScreenshotImagePaths.Add(path);
                    }
                    break;
                case ImageType.Backdrop:
                    if (!imageIndex.HasValue)
                    {
                        throw new ArgumentNullException("imageIndex");
                    }
                    if (item.BackdropImagePaths.Count > imageIndex.Value)
                    {
                        item.BackdropImagePaths[imageIndex.Value] = path;
                    }
                    else if (!item.BackdropImagePaths.Contains(path, StringComparer.OrdinalIgnoreCase))
                    {
                        item.BackdropImagePaths.Add(path);
                    }

                    if (string.IsNullOrEmpty(sourceUrl))
                    {
                        item.RemoveImageSourceForPath(path);
                    }
                    else
                    {
                        item.AddImageSource(path, sourceUrl);
                    }
                    break;
                default:
                    item.SetImage(type, path);
                    break;
            }
        }