コード例 #1
0
ファイル: ImageHelper.cs プロジェクト: seniorOtaka/ndoctor
 /// <summary>
 /// Creates a thumbnail from the specified <see cref="Picture"/>.
 /// If a thumbnail already exist, it doesn't change it and returns <c>False</c>; otherwise
 /// it creates the thumbnail and returns <c>True</c>
 /// </summary>
 /// <returns><c>True</c> if the thumbnail is created; otherwise <c>False</c></returns>
 public bool TryCreateThumbnail(Picture picture)
 {
     if (!this.HasThumbnail(picture)) { return false; }
     else
     {
         this.UpdateThumbnail(picture);
         return true;
     }
 }
コード例 #2
0
ファイル: ImageHelper.cs プロジェクト: seniorOtaka/ndoctor
        /// <summary>
        /// If the specified picture doesn't have a thumbnail, it creates it. Otherwise, throws an exception
        /// </summary>
        /// <param name="picture">The picture.</param>
        /// <exception cref="BusinessLogicException">If the picture already has an exception</exception>
        public void CreateThumbnail(Picture picture)
        {
            if (!this.HasThumbnail(picture)) { throw new ThumbnailSetException(); }

            this.UpdateThumbnail(picture);
        }
コード例 #3
0
ファイル: ImageHelper.cs プロジェクト: seniorOtaka/ndoctor
 /// <summary>
 /// Determines whether the specified picture has thumbnail.
 /// </summary>
 /// <param name="picture">The picture.</param>
 /// <returns>
 ///   <c>true</c> if the specified picture has thumbnail; otherwise, <c>false</c>.
 /// </returns>
 public bool HasThumbnail(Picture picture)
 {
     return (picture.ThumbnailBitmap == null || picture.ThumbnailBitmap.Length == 0);
 }
コード例 #4
0
ファイル: ImageHelper.cs プロジェクト: seniorOtaka/ndoctor
 /// <summary>
 /// Updates the thumbnail even if a thumbnail already exist.
 /// </summary>
 /// <param name="picture">The picture.</param>
 public void UpdateThumbnail(Picture picture)
 {
     var img = Converter.ByteArrayToImage(picture.Bitmap);
     var thumb = img.GetThumbnail();
     picture.ThumbnailBitmap = thumb;
 }