Exemplo n.º 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="DisplayObject"/> class.
        /// </summary>
        /// <param name="parent">The parent.</param>
        /// <param name="displayType">The display type.</param>
        /// <param name="mimeType">Specifies the category to which this mime type belongs. This usually corresponds to the first portion of
        /// the full mime type description. (e.g. "image" if the full mime type is "image/jpeg").</param>
        private DisplayObject(IGalleryObject parent, DisplayObjectType displayType, MimeTypeCategory mimeType)
        {
            if (displayType != DisplayObjectType.External)
            {
                throw new BusinessException(String.Format(CultureInfo.CurrentCulture, "This overload of the DisplayObject constructor can only be called when the displayType parameter is DisplayObjectType.External. Instead, it was {0}.", displayType.ToString()));
            }

            this._width                = int.MinValue;
            this._height               = int.MinValue;
            this._filename             = String.Empty;
            this._mimeType             = GalleryServerPro.Business.MimeType.CreateInstance(mimeType);
            this._externalType         = this._mimeType.TypeCategory;
            this._parent               = parent;
            this._displayType          = displayType;
            this._displayObjectCreator = new NullObjects.NullDisplayObjectCreator();

            if (this._parent is IAlbum)
            {
                this._mediaObjectId = int.MinValue;
            }
            else
            {
                this._mediaObjectId = parent.Id;
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Create a new display object instance with the specified properties. No data is retrieved from the
        /// data store. A lazy load is used to inflate the object when necessary
        /// </summary>
        /// <param name="parent">The media object to which this display object applies.</param>
        /// <param name="displayType">The type of the display object.</param>
        /// <param name="mimeType">Specifies the category to which this mime type belongs. This usually corresponds to the first portion of
        /// the full mime type description. (e.g. "image" if the full mime type is "image/jpeg").</param>
        /// <returns>Create a new display object instance with the specified properties.</returns>
        public static IDisplayObject CreateInstance(IGalleryObject parent, DisplayObjectType displayType, MimeTypeCategory mimeType)
        {
            if (displayType != DisplayObjectType.External)
            {
                throw new BusinessException(String.Format(CultureInfo.CurrentCulture, "This overload of DisplayObject.CreateInstance can only be called when the displayType parameter is DisplayObjectType.External. Instead, it was {0}.", displayType.ToString()));
            }

            return(new DisplayObject(parent, displayType, mimeType));
        }
Exemplo n.º 3
0
		/// <summary>
		/// Initializes a new instance of the <see cref="DisplayObject"/> class.
		/// </summary>
		/// <param name="parent">The parent.</param>
		/// <param name="displayType">The display type.</param>
		/// <param name="mimeType">Specifies the category to which this mime type belongs. This usually corresponds to the first portion of 
		/// the full mime type description. (e.g. "image" if the full mime type is "image/jpeg").</param>
		private DisplayObject(IGalleryObject parent, DisplayObjectType displayType, MimeTypeCategory mimeType)
		{
#if DEBUG
			tt.Tools.StartingMethod(parent, displayType, mimeType);
#endif
			if (displayType != DisplayObjectType.External)
				throw new BusinessException(String.Format("This overload of the DisplayObject constructor can only be called when the displayType parameter is DisplayObjectType.External. Instead, it was {0}.", displayType.ToString()));

			this._width = int.MinValue;
			this._height = int.MinValue;
			this._filename = String.Empty;
			this._mimeType = GalleryServerPro.Business.MimeType.CreateInstance(mimeType);
			this._externalType = this._mimeType.TypeCategory;
			this._parent = parent;
			this._displayType = displayType;
			this._displayObjectCreator = new NullObjects.NullDisplayObjectCreator();

			if (this._parent is IAlbum)
			{
				this._mediaObjectId = int.MinValue;
			}
			else
			{
				this._mediaObjectId = parent.Id;
			}

		}
Exemplo n.º 4
0
		/// <summary>
		/// Get the URL to the thumbnail, optimized, or original media object. Example:
		/// /dev/gs/handler/getmediaobject.ashx?moid=34&amp;aid=8&amp;mo=C%3A%5Cgs%5Cmypics%5Cbirthday.jpeg&amp;mtc=1&amp;dt=1&amp;isp=false
		/// The URL can be used to assign to the src attribute of an image tag (&lt;img src='...' /&gt;).
		/// Not tested: It should be possible to pass an album and request the url to its thumbnail image.
		/// </summary>
		/// <param name="galleryObject">The gallery object for which an URL to the specified image is to be generated.</param>
		/// <param name="displayType">A DisplayObjectType enumeration value indicating the version of the
		/// object for which the URL should be generated. Possible values: Thumbnail, Optimized, Original.
		/// An exception is thrown if any other enumeration is passed.</param>
		/// <returns>Returns the URL to the thumbnail, optimized, or original version of the requested media object.</returns>
		public static string GetMediaObjectUrl(IGalleryObject galleryObject, DisplayObjectType displayType)
		{
			string filenamePhysicalPath = null;

			switch (displayType)
			{
				case DisplayObjectType.Thumbnail: filenamePhysicalPath = galleryObject.Thumbnail.FileNamePhysicalPath; break;
				case DisplayObjectType.Optimized: filenamePhysicalPath = galleryObject.Optimized.FileNamePhysicalPath; break;
				case DisplayObjectType.Original: filenamePhysicalPath = galleryObject.Original.FileNamePhysicalPath; break;
				default: throw new ArgumentOutOfRangeException(String.Format(CultureInfo.CurrentCulture, Resources.GalleryServerPro.Error_GetMediaObjectUrl_Ex_Msg1, displayType.ToString()));
			}
			
			return MediaObjectHtmlBuilder.GenerateUrl(galleryObject.Id, galleryObject.Parent.Id, galleryObject.MimeType, filenamePhysicalPath, displayType, galleryObject.IsPrivate);
		}
Exemplo n.º 5
0
		/// <summary>
		/// Create a new display object instance with the specified properties. No data is retrieved from the
		/// data store. A lazy load is used to inflate the object when necessary
		/// </summary>
		/// <param name="parent">The media object to which this display object applies.</param>
		/// <param name="displayType">The type of the display object.</param>
		/// <param name="mimeType">Specifies the category to which this mime type belongs. This usually corresponds to the first portion of 
		/// the full mime type description. (e.g. "image" if the full mime type is "image/jpeg").</param>
		/// <returns>Create a new display object instance with the specified properties.</returns>
		public static IDisplayObject CreateInstance(IGalleryObject parent, DisplayObjectType displayType, MimeTypeCategory mimeType)
		{
			if (displayType != DisplayObjectType.External)
				throw new BusinessException(String.Format("This overload of DisplayObject.CreateInstance can only be called when the displayType parameter is DisplayObjectType.External. Instead, it was {0}.", displayType.ToString()));

			return new DisplayObject(parent, displayType, mimeType);
		}