예제 #1
0
        public override void SetProperty(string name, object value)
        {
            switch (name.ToLower())
            {
            case "imagetype":
                this.ImageType = GetStringValue(value);
                break;

            case "imagefieldname":
                this.ImageFieldName = GetStringValue(value);
                break;

            case "width":
                try
                {
                    int w = Int32.Parse(GetStringValue(value));
                    if (w < 0)
                    {
                        throw new Exception();
                    }
                    this.Width = w;
                }
                catch (Exception)
                {
                    throw new Exception("Property 'Width' is not a valid number or less than zero.");
                }
                break;

            case "height":
                try
                {
                    int h = Int32.Parse(GetStringValue(value));
                    if (h < 0)
                    {
                        throw new Exception();
                    }
                    this.Height = h;
                }
                catch (Exception)
                {
                    throw new Exception("Property 'Height' is not a valid number or less than zero.");
                }
                break;

            case "stretch":
                try
                {
                    this.Stretch = Boolean.Parse(GetStringValue(value));
                }
                catch (Exception)
                {
                    throw new Exception("Property 'Stretch' is not a valid boolean value.");
                }
                break;

            case "outputformat": this.ResizeOutputFormat = GetImageFormat(GetStringValue(value)); break;

            case "smoothingmode": this.ResizeSmoothingMode = (SmoothingMode)Enum.Parse(ResizeSmoothingMode.GetType(), GetStringValue(value), true); break;

            case "interpolationmode": this.ResizeInterpolationMode = (InterpolationMode)Enum.Parse(ResizeInterpolationMode.GetType(), GetStringValue(value), true); break;

            case "pixeloffsetmode": this.ResizePixelOffsetMode = (PixelOffsetMode)Enum.Parse(ResizePixelOffsetMode.GetType(), GetStringValue(value), true); break;

            case "resizetypemode": this.ResizeType = (ResizeTypeList)Enum.Parse(ResizeType.GetType(), GetStringValue(value), true); break;

            case "cropvalign":
                this.CropVAlign = GetStringValue(value);
                break;

            case "crophalign":
                this.CropHAlign = GetStringValue(value);
                break;

            default:
                base.SetProperty(name, value);
                break;
            }
        }