コード例 #1
0
    protected void DisplayCode()
    {
        System.Text.StringBuilder sbCode = new System.Text.StringBuilder();
        string crlf = "\r\n";

        sbCode.Append("InlinePictureTrimmer1.ShowZoomPanel = false;" + crlf);

        GfxUnit unit = (GfxUnit)Enum.Parse(typeof(GfxUnit), this.ddlUnit.SelectedValue);

        if (unit != GfxUnit.Pixel)
        {
            // Default value: Pixel
            sbCode.Append("InlinePictureTrimmer1.UIUnit = GfxUnit." + unit.ToString() + ";" + crlf);
        }

        if (this.cbEnableResize.Checked)
        {
            // Default = AutoZoomMode.Standard
            sbCode.Append("InlinePictureTrimmer1.AutoZoomMode = PictureTrimmerAutoZoomMode.Disabled;" + crlf);
        }
        else
        {
            // Default = true
            sbCode.Append("InlinePictureTrimmer1.ShowResizePanel = false;" + crlf);
            sbCode.Append("InlinePictureTrimmer1.ShowDetailsPanel = false;" + crlf);

            sbCode.Append("InlinePictureTrimmer1.AutoZoomMode = PictureTrimmerAutoZoomMode.EnabledOnlyForLargeImages;" + crlf);
        }

        sbCode.Append("InlinePictureTrimmer1.LoadImageFromFileSystem(Server.MapPath(\"~/repository/source/flowers1.jpg\"));" + crlf);

        this.phCodeContainer.Visible = true;
        this.litCode.Text            = sbCode.ToString();
    }
コード例 #2
0
    protected void DisplayCode()
    {
        System.Text.StringBuilder sbCode = new System.Text.StringBuilder();
        string crlf = "\r\n";

        GfxUnit unit = (GfxUnit)Enum.Parse(typeof(GfxUnit), this.ddlUnit.SelectedValue);

        if (unit != GfxUnit.Pixel)
        {
            // Default value: Pixel
            sbCode.Append("InlinePictureTrimmer1.UIUnit = GfxUnit." + unit.ToString() + ";" + crlf);
        }

        switch (this.ddlCropMode.SelectedValue)
        {
        case "Fixed":
            if (unit == GfxUnit.Pixel)
            {
                sbCode.Append("FixedCropConstraint cropConstrant = new FixedCropConstraint(" + this.ddlConstraint_Fixed_Width.SelectedValue + ", " + this.ddlConstraint_Fixed_Height.SelectedValue + ");" + crlf);
            }
            else
            {
                sbCode.Append("FixedCropConstraint cropConstrant = new FixedCropConstraint(GfxUnit." + unit.ToString() + ", " + this.ddlConstraint_Fixed_Width.SelectedValue + "F, " + this.ddlConstraint_Fixed_Height.SelectedValue + "F);" + crlf);
            }
            break;

        case "FixedAspectRatio":
            sbCode.Append("FixedAspectRatioCropConstraint cropConstrant = new FixedAspectRatioCropConstraint(" + this.ddlConstraint_FixedAspectRatio_X.SelectedValue + "F/" + this.ddlConstraint_FixedAspectRatio_Y.SelectedValue + "F);" + crlf);
            if ((this.cb_FixedAspectRatio_Min.Checked) || (this.cb_FixedAspectRatio_Max.Checked))
            {
                if (unit != GfxUnit.Pixel)
                {
                    sbCode.Append("cropConstrant.Unit = GfxUnit." + unit.ToString() + ";" + crlf);
                }

                SizeDimension limitedDimension = (SizeDimension)Enum.Parse(typeof(SizeDimension), this.ddlConstraint_FixedAspectRatio_LimitedDimension.SelectedValue);
                if (limitedDimension != SizeDimension.Width)
                {
                    // Default value = Width
                    sbCode.Append("cropConstrant.LimitedDimension = SizeDimension." + limitedDimension.ToString() + ";" + crlf);
                }

                if (this.cb_FixedAspectRatio_Min.Checked)
                {
                    sbCode.Append("cropConstrant.Min = " + this.ddlConstraint_FixedAspectRatio_Min.SelectedValue + "F;" + crlf);
                }
                if (this.cb_FixedAspectRatio_Max.Checked)
                {
                    sbCode.Append("cropConstrant.Max = " + this.ddlConstraint_FixedAspectRatio_Max.SelectedValue + "F;" + crlf);
                }
            }

            break;

        case "Free":
            sbCode.Append("FreeCropConstraint cropConstrant = new FreeCropConstraint();" + crlf);

            if ((this.cb_Free_Width_Min.Checked) || (this.cb_Free_Width_Max.Checked) || (this.cb_Free_Height_Min.Checked) || (this.cb_Free_Height_Max.Checked))
            {
                if (unit != GfxUnit.Pixel)
                {
                    sbCode.Append("cropConstrant.Unit = GfxUnit." + unit.ToString() + ";" + crlf);
                }

                if (this.cb_Free_Width_Min.Checked)
                {
                    sbCode.Append("cropConstrant.MinWidth = " + this.ddlConstraint_Free_Width_Min.SelectedValue + "F;" + crlf);
                }
                if (this.cb_Free_Width_Max.Checked)
                {
                    sbCode.Append("cropConstrant.MaxWidth = " + this.ddlConstraint_Free_Width_Max.SelectedValue + "F;" + crlf);
                }
                if (this.cb_Free_Height_Min.Checked)
                {
                    sbCode.Append("cropConstrant.MinHeight = " + this.ddlConstraint_Free_Height_Min.SelectedValue + "F;" + crlf);
                }
                if (this.cb_Free_Height_Max.Checked)
                {
                    sbCode.Append("cropConstrant.MaxHeight = " + this.ddlConstraint_Free_Height_Max.SelectedValue + "F;" + crlf);
                }
            }
            break;
        }

        if (this.ddlMarginsH.SelectedValue != "")
        {
            // Default value = Auto
            sbCode.Append("cropConstrant.Margins.Horizontal = " + this.ddlMarginsH.SelectedValue + "F;" + crlf);
        }
        if (this.ddlMarginsV.SelectedValue != "")
        {
            // Default value = Auto
            sbCode.Append("cropConstrant.Margins.Vertical = " + this.ddlMarginsV.SelectedValue + "F;" + crlf);
        }

        CropConstraintImageSelectionStrategy defaultImageSelectionStrategy = (CropConstraintImageSelectionStrategy)Enum.Parse(typeof(CropConstraintImageSelectionStrategy), this.ddlImageSelectionStrategy.SelectedValue);

        if (defaultImageSelectionStrategy != CropConstraintImageSelectionStrategy.Slice)
        {
            // Default value: Slice
            sbCode.Append("cropConstrant.DefaultImageSelectionStrategy = CropConstraintImageSelectionStrategy." + defaultImageSelectionStrategy.ToString() + ";" + crlf);
        }

        if (this.ddlDPI.SelectedValue == "96")
        {
            // Default value = 96
            sbCode.Append("InlinePictureTrimmer1.LoadImageFromFileSystem(\"~/repository/source/donkey1.jpg\", cropConstrant);" + crlf);
        }
        else
        {
            sbCode.Append("InlinePictureTrimmer1.LoadImageFromFileSystem(\"~/repository/source/donkey1.jpg\", " + this.ddlDPI.SelectedValue + "F, cropConstrant);" + crlf);
        }

        this.phCodeContainer.Visible = true;
        this.litCode.Text            = sbCode.ToString();
    }