コード例 #1
0
    /// <summary>
    /// Shows correct properties according to the settings.
    /// </summary>
    private void ShowProperties()
    {
        ItemProperties.Config = Config;

        // Save session data before shoving properties
        Hashtable dialogParameters = SessionHelper.GetValue("DialogSelectedParameters") as Hashtable;

        if (dialogParameters != null)
        {
            dialogParameters = (Hashtable)dialogParameters.Clone();
        }

        DisplayProperties();

        MediaItem mi = new MediaItem();

        mi.Url = txtUrl.Text;
        if (mWidth > 0)
        {
            mi.Width = mWidth;
        }
        if (mHeight > 0)
        {
            mi.Height = mHeight;
        }

        // Try get source type from URL extension
        string ext   = null;
        int    index = txtUrl.Text.LastIndexOfCSafe('.');

        if (index > 0)
        {
            ext = txtUrl.Text.Substring(index);
        }

        if (Config.OutputFormat == OutputFormatEnum.HTMLMedia)
        {
            switch (drpMediaType.SelectedValue)
            {
            case "image":
                propMedia.ViewMode = MediaTypeEnum.Image;
                mi.Extension       = String.IsNullOrEmpty(ext) ? "jpg" : ext;
                break;

            case "av":
                propMedia.ViewMode = MediaTypeEnum.AudioVideo;
                mi.Extension       = String.IsNullOrEmpty(ext) ? "avi" : ext;
                break;

            case "flash":
                propMedia.ViewMode = MediaTypeEnum.Flash;
                mi.Extension       = String.IsNullOrEmpty(ext) ? "swf" : ext;
                break;

            default:
                plcHTMLMediaProp.Visible = false;
                break;
            }
            if (URLHelper.IsPostback())
            {
                ItemProperties.LoadSelectedItems(mi, dialogParameters);
            }
        }
        else if ((Config.OutputFormat == OutputFormatEnum.BBMedia) && (URLHelper.IsPostback()))
        {
            mi.Extension = String.IsNullOrEmpty(ext) ? "jpg" : ext;
            ItemProperties.LoadSelectedItems(mi, dialogParameters);
        }
        else if ((Config.OutputFormat == OutputFormatEnum.URL) && (URLHelper.IsPostback()))
        {
            ItemProperties.LoadSelectedItems(mi, dialogParameters);
        }
        // Set saved session data back into session
        if (dialogParameters != null)
        {
            SessionHelper.SetValue("DialogSelectedParameters", dialogParameters);
        }
    }