Exemplo n.º 1
0
        internal Dictionary <FlashParameters, Int32> ReadAllParameters()
        {
            Dictionary <FlashParameters, Int32> dic = new Dictionary <FlashParameters, int>();
            RovioResponse response = MovementControl(Commands.ReadParameter);

            foreach (RovioResponseItem item in response)
            {
                if (!item.Key.StartsWith("v"))
                {
                    continue;
                }
                FlashParameters paraId = (FlashParameters)int.Parse(item.Key.Substring(1));
                int             value  = -1;
                if (string.IsNullOrEmpty(item.Value))
                {
                    value = -1;
                }
                else
                {
                    value = Int32.Parse(item.Value);
                }
                if (dic.ContainsKey(paraId))
                {
                    dic[paraId] = value;
                }
                else
                {
                    dic.Add(paraId, value);
                }
            }

            return(dic);
        }
Exemplo n.º 2
0
    /// <summary>
    /// Creates the flash object
    /// </summary>
    private void CreateFlash()
    {
        FlashParameters flParams = new FlashParameters();

        flParams.Url       = URLHelper.GetAbsoluteUrl(Url);
        flParams.Extension = Type;
        flParams.Width     = Width;
        flParams.Height    = Height;
        flParams.Autoplay  = AutoPlay;
        flParams.Loop      = Loop;
        flParams.Menu      = Menu;
        flParams.Scale     = Scale;
        flParams.Id        = HttpUtility.UrlDecode(Id);
        flParams.Title     = HttpUtility.UrlDecode(Title);
        flParams.Class     = HttpUtility.UrlDecode(Class);
        flParams.Style     = HttpUtility.UrlDecode(Style);
        flParams.FlashVars = HttpUtility.UrlDecode(FlashVars);

        ltlMedia.Text = MediaHelper.GetFlash(flParams);
    }
    /// <summary>
    /// Initializes all the nested controls.
    /// </summary>
    private void SetupControls()
    {
        MediaFileInfo mFile = MediaFileInfoProvider.GetMediaFileInfo(FileGuid, SiteName);
        if (mFile != null)
        {
            SiteInfo si = SiteInfoProvider.GetSiteInfo(mFile.FileSiteID);
            if (si != null)
            {
                MediaLibraryInfo mLibrary = MediaLibraryInfoProvider.GetMediaLibraryInfo(mFile.FileLibraryID);

                string extension = mFile.FileExtension.ToLowerCSafe().TrimStart('.');

                string path = MediaFileInfoProvider.GetMediaFilePath(SiteName, mLibrary.LibraryFolder, mFile.FilePath);
                string url = MediaFileInfoProvider.GetMediaFileAbsoluteUrl(SiteName, mFile.FileGUID, mFile.FileName);

                if (ImageHelper.IsImage(extension) && File.Exists(path))
                {
                    // Get image dimension
                    // New dimensions
                    int[] newDims = ImageHelper.EnsureImageDimensions(Width, Height, MaxSideSize, mFile.FileImageWidth, mFile.FileImageHeight);

                    // If new dimensions are diferent use them
                    if (((newDims[0] != mFile.FileImageWidth) || (newDims[1] != mFile.FileImageHeight)) && (newDims[0] > 0) && (newDims[1] > 0))
                    {
                        string dimensions = "?width=" + newDims[0] + "&height=" + newDims[1];

                        ltlOutput.Text = "<img alt=\"" + mFile.FileName + "\" src=\"" + url + dimensions + "\" width=\"" + newDims[0] + "\" height=\"" + newDims[1] + "\" border=\"0\" />";
                    }
                    else
                    {
                        ltlOutput.Text = "<img alt=\"" + mFile.FileName + "\" src=\"" + url + "\" width=\"" + Width + "\" height=\"" + Height + "\" border=\"0\" />";
                    }
                }
                else
                {
                    // Set default dimensions of rendered object if required
                    int width = (Width > 0) ? Width : DEFAULT_WIDTH;
                    int height = (Height > 0) ? Height : DEFAULT_HEIGHT;

                    if (MediaHelper.IsFlash(extension))
                    {
                        // Initialize flash parameters
                        FlashParameters flashParams = new FlashParameters();
                        flashParams.Height = height;
                        flashParams.Width = width;
                        flashParams.Url = url;

                        ltlOutput.Text = MediaHelper.GetFlash(flashParams);
                    }
                    else
                    {
                        if (MediaHelper.IsAudio(extension))
                        {
                            // Initialize audio/video parameters
                            AudioVideoParameters audioParams = new AudioVideoParameters();

                            audioParams.SiteName = CMSContext.CurrentSiteName;
                            audioParams.Url = url;
                            audioParams.Width = width;
                            audioParams.Height = height;
                            audioParams.Extension = extension;

                            ltlOutput.Text = MediaHelper.GetAudioVideo(audioParams);
                        }
                        else if (MediaHelper.IsVideo(extension))
                        {
                            // Initialize audio/video parameters
                            AudioVideoParameters videoParams = new AudioVideoParameters();

                            videoParams.SiteName = CMSContext.CurrentSiteName;
                            videoParams.Url = url;
                            videoParams.Width = width;
                            videoParams.Height = height;
                            videoParams.Extension = extension;

                            ltlOutput.Text = MediaHelper.GetAudioVideo(videoParams);
                        }
                    }
                }
            }
        }
    }
Exemplo n.º 4
0
 /// <summary>
 /// Stores parameter in the robot’s Flash memory.
 /// </summary>
 /// <param name="index">0 – 19</param>
 /// <param name="value">32bit signed integer</param>
 /// <returns></returns>
 internal void SaveParameter(FlashParameters parameterId, Int32 value)
 {
     RovioResponse response = MovementControl(Commands.SaveParameter,
         new RequestItem("index", (int)parameterId),
         new RequestItem("value", value));
 }
Exemplo n.º 5
0
    /// <summary>
    /// Creates the flash object
    /// </summary>
    private void CreateFlash()
    {
        FlashParameters flParams = new FlashParameters();
        flParams.Url = URLHelper.GetAbsoluteUrl(this.Url);
        flParams.Extension = this.Type;
        flParams.Width = this.Width;
        flParams.Height = this.Height;
        flParams.Autoplay = this.AutoPlay;
        flParams.Loop = this.Loop;
        flParams.Menu = this.Menu;
        flParams.Scale = this.Scale;
        flParams.Id = HttpUtility.UrlDecode(this.Id);
        flParams.Title = HttpUtility.UrlDecode(this.Title);
        flParams.Class = HttpUtility.UrlDecode(this.Class);
        flParams.Style = HttpUtility.UrlDecode(this.Style);
        flParams.FlashVars = HttpUtility.UrlDecode(this.FlashVars);

        this.ltlMedia.Text = MediaHelper.GetFlash(flParams);
    }
Exemplo n.º 6
0
    /// <summary>
    /// Initializes the control properties.
    /// </summary>
    public void ReloadData(bool forceReload)
    {
        if (!binded || forceReload)
        {
            if (this.mData != null)
            {
                MediaFileInfo mfi = new MediaFileInfo(this.mData);
                if (mfi != null)
                {
                    bool completeUrl = false;

                    // Get the site
                    SiteInfo si = null;
                    SiteInfo currentSite = CMSContext.CurrentSite;
                    if (mfi.FileSiteID == currentSite.SiteID)
                    {
                        si = currentSite;
                    }
                    else
                    {
                        si = SiteInfoProvider.GetSiteInfo(mfi.FileSiteID);
                    }

                    if (si != null)
                    {
                        // Complete URL only for other site than current
                        if (si.SiteID != currentSite.SiteID)
                        {
                            completeUrl = true;
                        }

                        string url = "";

                        if (this.UseSecureLinks)
                        {
                            if (completeUrl)
                            {
                                url = MediaFileInfoProvider.GetMediaFileAbsoluteUrl(si.SiteName, mfi.FileGUID, mfi.FileName);
                            }
                            else
                            {
                                url = MediaFileInfoProvider.GetMediaFileUrl(mfi.FileGUID, mfi.FileName);
                            }
                        }
                        else
                        {
                            MediaLibraryInfo li = MediaLibraryInfoProvider.GetMediaLibraryInfo(mfi.FileLibraryID);
                            if (li != null)
                            {
                                if (completeUrl)
                                {
                                    url = MediaFileInfoProvider.GetMediaFileAbsoluteUrl(si.SiteName, li.LibraryFolder, mfi.FilePath);
                                }
                                else
                                {
                                    url = MediaFileInfoProvider.GetMediaFileUrl(si.SiteName, li.LibraryFolder, mfi.FilePath);
                                }
                            }
                        }

                        if (this.DisplayActiveContent)
                        {
                            if (ImageHelper.IsImage(mfi.FileExtension) && File.Exists(MediaFileInfoProvider.GetMediaFilePath(mfi.FileLibraryID, mfi.FilePath)))
                            {
                                // Get new dimensions
                                int[] newDims = ImageHelper.EnsureImageDimensions(Width, Height, MaxSideSize, mfi.FileImageWidth, mfi.FileImageHeight);

                                // If dimensions changed use secure link
                                if ((newDims[0] != mfi.FileImageWidth) || (newDims[1] != mfi.FileImageHeight))
                                {
                                    if (completeUrl)
                                    {
                                        url = MediaFileInfoProvider.GetMediaFileAbsoluteUrl(si.SiteName, mfi.FileGUID, mfi.FileName);
                                    }
                                    else
                                    {
                                        url = MediaFileInfoProvider.GetMediaFileUrl(mfi.FileGUID, mfi.FileName);
                                    }
                                }
                                else
                                {
                                    // Use width and height from properties in case dimensions are bigger than original
                                    newDims[0] = Width;
                                    newDims[1] = Height;
                                }

                                // Initialize image parameters
                                ImageParameters imgParams = new ImageParameters();
                                imgParams.Alt = mfi.FileDescription;
                                imgParams.Width = newDims[0];
                                imgParams.Height = newDims[1];
                                imgParams.Url = url;

                                this.ltlOutput.Text = CMS.GlobalHelper.MediaHelper.GetImage(imgParams);
                            }
                            else if (CMS.GlobalHelper.MediaHelper.IsFlash(mfi.FileExtension))
                            {
                                // Initialize flash parameters
                                FlashParameters flashParams = new FlashParameters();
                                flashParams.Url = url;
                                flashParams.Width = this.Width;
                                flashParams.Height = this.Height;

                                this.ltlOutput.Text = CMS.GlobalHelper.MediaHelper.GetFlash(flashParams);
                            }
                            else if (CMS.GlobalHelper.MediaHelper.IsAudio(mfi.FileExtension))
                            {
                                // Initialize audio/video parameters
                                AudioVideoParameters audioParams = new AudioVideoParameters();

                                audioParams.SiteName = CMSContext.CurrentSiteName;
                                audioParams.Url = url;
                                audioParams.Width = this.Width;
                                audioParams.Height = this.Height;
                                audioParams.Extension = mfi.FileExtension;

                                this.ltlOutput.Text = CMS.GlobalHelper.MediaHelper.GetAudioVideo(audioParams);
                            }
                            else if (CMS.GlobalHelper.MediaHelper.IsVideo(mfi.FileExtension))
                            {
                                // Initialize audio/video parameters
                                AudioVideoParameters videoParams = new AudioVideoParameters();

                                videoParams.SiteName = CMSContext.CurrentSiteName;
                                videoParams.Url = url;
                                videoParams.Width = this.Width;
                                videoParams.Height = this.Height;
                                videoParams.Extension = mfi.FileExtension;

                                this.ltlOutput.Text = CMS.GlobalHelper.MediaHelper.GetAudioVideo(videoParams);
                            }
                            else
                            {
                                this.ltlOutput.Text = MediaLibraryHelper.ShowPreviewOrIcon(mfi, this.Width, this.Height, this.MaxSideSize, this.PreviewSuffix, this.IconSet, this.Page, this.DefaultImageUrl);
                            }
                        }
                        else
                        {
                            this.ltlOutput.Text = MediaLibraryHelper.ShowPreviewOrIcon(mfi, this.Width, this.Height, this.MaxSideSize, this.PreviewSuffix, this.IconSet, this.Page, this.DefaultImageUrl);
                        }
                    }
                }
            }
            binded = true;
        }
    }
Exemplo n.º 7
0
    /// <summary>
    /// Initializes all the nested controls.
    /// </summary>
    private void SetupControls()
    {
        MediaFileInfo mFile = MediaFileInfoProvider.GetMediaFileInfo(this.FileGuid, this.SiteName);

        if (mFile != null)
        {
            SiteInfo si = SiteInfoProvider.GetSiteInfo(mFile.FileSiteID);
            if (si != null)
            {
                MediaLibraryInfo mLibrary = MediaLibraryInfoProvider.GetMediaLibraryInfo(mFile.FileLibraryID);

                string extension = mFile.FileExtension.ToLower().TrimStart('.');

                string path = MediaFileInfoProvider.GetMediaFilePath(this.SiteName, mLibrary.LibraryFolder, mFile.FilePath);
                string url  = MediaFileInfoProvider.GetMediaFileAbsoluteUrl(this.SiteName, mFile.FileGUID, mFile.FileName);

                if (ImageHelper.IsImage(extension) && File.Exists(path))
                {
                    // Get image dimension
                    // New dimensions
                    int[] newDims = ImageHelper.EnsureImageDimensions(Width, Height, MaxSideSize, mFile.FileImageWidth, mFile.FileImageHeight);

                    // If new dimensions are diferent use them
                    if (((newDims[0] != mFile.FileImageWidth) || (newDims[1] != mFile.FileImageHeight)) && (newDims[0] > 0) && (newDims[1] > 0))
                    {
                        string dimensions = "?width=" + newDims[0] + "&height=" + newDims[1];

                        this.ltlOutput.Text = "<img alt=\"" + mFile.FileName + "\" src=\"" + url + dimensions + "\" width=\"" + newDims[0] + "\" height=\"" + newDims[1] + "\" border=\"0\" />";
                    }
                    else
                    {
                        this.ltlOutput.Text = "<img alt=\"" + mFile.FileName + "\" src=\"" + url + "\" width=\"" + Width + "\" height=\"" + Height + "\" border=\"0\" />";
                    }
                }
                else
                {
                    // Set default dimensions of rendered object if required
                    int width  = (this.Width > 0) ? this.Width : DEFAULT_WIDTH;
                    int height = (this.Height > 0) ? this.Height : DEFAULT_HEIGHT;

                    if (CMS.GlobalHelper.MediaHelper.IsFlash(extension))
                    {
                        // Initialize flash parameters
                        FlashParameters flashParams = new FlashParameters();
                        flashParams.Height = height;
                        flashParams.Width  = width;
                        flashParams.Url    = url;

                        this.ltlOutput.Text = CMS.GlobalHelper.MediaHelper.GetFlash(flashParams);
                    }
                    else
                    {
                        if (CMS.GlobalHelper.MediaHelper.IsAudio(extension))
                        {
                            // Initialize audio/video parameters
                            AudioVideoParameters audioParams = new AudioVideoParameters();

                            audioParams.SiteName  = CMSContext.CurrentSiteName;
                            audioParams.Url       = url;
                            audioParams.Width     = width;
                            audioParams.Height    = height;
                            audioParams.Extension = extension;

                            this.ltlOutput.Text = CMS.GlobalHelper.MediaHelper.GetAudioVideo(audioParams);
                        }
                        else if (CMS.GlobalHelper.MediaHelper.IsVideo(extension))
                        {
                            // Initialize audio/video parameters
                            AudioVideoParameters videoParams = new AudioVideoParameters();

                            videoParams.SiteName  = CMSContext.CurrentSiteName;
                            videoParams.Url       = url;
                            videoParams.Width     = width;
                            videoParams.Height    = height;
                            videoParams.Extension = extension;

                            this.ltlOutput.Text = CMS.GlobalHelper.MediaHelper.GetAudioVideo(videoParams);
                        }
                    }
                }
            }
        }
    }
Exemplo n.º 8
0
 /// <summary>
 /// Stores parameter in the robot’s Flash memory.
 /// </summary>
 /// <param name="index">0 – 19</param>
 /// <param name="value">32bit signed integer</param>
 /// <returns></returns>
 internal void SaveParameter(FlashParameters parameterId, Int32 value)
 {
     RovioResponse response = MovementControl(Commands.SaveParameter,
                                              new RequestItem("index", (int)parameterId),
                                              new RequestItem("value", value));
 }
    /// <summary>
    /// Initializes the control properties.
    /// </summary>
    public void ReloadData(bool forceReload)
    {
        if (!binded || forceReload)
        {
            if (mData != null)
            {
                MediaFileInfo mfi = new MediaFileInfo(mData);
                if (mfi != null)
                {
                    bool completeUrl = false;

                    // Get the site
                    SiteInfo si          = null;
                    SiteInfo currentSite = CMSContext.CurrentSite;
                    if (mfi.FileSiteID == currentSite.SiteID)
                    {
                        si = currentSite;
                    }
                    else
                    {
                        si = SiteInfoProvider.GetSiteInfo(mfi.FileSiteID);
                    }

                    if (si != null)
                    {
                        // Complete URL only for other site than current
                        if (si.SiteID != currentSite.SiteID)
                        {
                            completeUrl = true;
                        }

                        string url = "";

                        if (UseSecureLinks)
                        {
                            if (completeUrl)
                            {
                                url = MediaFileInfoProvider.GetMediaFileAbsoluteUrl(si.SiteName, mfi.FileGUID, mfi.FileName);
                            }
                            else
                            {
                                url = MediaFileInfoProvider.GetMediaFileUrl(mfi.FileGUID, mfi.FileName);
                            }
                        }
                        else
                        {
                            MediaLibraryInfo li = MediaLibraryInfoProvider.GetMediaLibraryInfo(mfi.FileLibraryID);
                            if (li != null)
                            {
                                if (completeUrl)
                                {
                                    url = MediaFileInfoProvider.GetMediaFileAbsoluteUrl(si.SiteName, li.LibraryFolder, mfi.FilePath);
                                }
                                else
                                {
                                    url = MediaFileInfoProvider.GetMediaFileUrl(si.SiteName, li.LibraryFolder, mfi.FilePath);
                                }
                            }
                        }

                        if (DisplayActiveContent)
                        {
                            if (ImageHelper.IsImage(mfi.FileExtension) && File.Exists(MediaFileInfoProvider.GetMediaFilePath(mfi.FileLibraryID, mfi.FilePath)))
                            {
                                // Get new dimensions
                                int[] newDims = ImageHelper.EnsureImageDimensions(Width, Height, MaxSideSize, mfi.FileImageWidth, mfi.FileImageHeight);

                                // If dimensions changed use secure link
                                if ((newDims[0] != mfi.FileImageWidth) || (newDims[1] != mfi.FileImageHeight))
                                {
                                    if (completeUrl)
                                    {
                                        url = MediaFileInfoProvider.GetMediaFileAbsoluteUrl(si.SiteName, mfi.FileGUID, mfi.FileName);
                                    }
                                    else
                                    {
                                        url = MediaFileInfoProvider.GetMediaFileUrl(mfi.FileGUID, mfi.FileName);
                                    }
                                }
                                else
                                {
                                    // Use width and height from properties in case dimensions are bigger than original
                                    newDims[0] = Width;
                                    newDims[1] = Height;
                                }

                                // Initialize image parameters
                                ImageParameters imgParams = new ImageParameters();
                                imgParams.Alt    = mfi.FileDescription;
                                imgParams.Width  = newDims[0];
                                imgParams.Height = newDims[1];
                                imgParams.Url    = url;

                                ltlOutput.Text = MediaHelper.GetImage(imgParams);
                            }
                            else if (MediaHelper.IsFlash(mfi.FileExtension))
                            {
                                // Initialize flash parameters
                                FlashParameters flashParams = new FlashParameters();
                                flashParams.Url    = url;
                                flashParams.Width  = Width;
                                flashParams.Height = Height;

                                ltlOutput.Text = MediaHelper.GetFlash(flashParams);
                            }
                            else if (MediaHelper.IsAudio(mfi.FileExtension))
                            {
                                // Initialize audio/video parameters
                                AudioVideoParameters audioParams = new AudioVideoParameters();

                                audioParams.SiteName  = CMSContext.CurrentSiteName;
                                audioParams.Url       = url;
                                audioParams.Width     = Width;
                                audioParams.Height    = Height;
                                audioParams.Extension = mfi.FileExtension;

                                ltlOutput.Text = MediaHelper.GetAudioVideo(audioParams);
                            }
                            else if (MediaHelper.IsVideo(mfi.FileExtension))
                            {
                                // Initialize audio/video parameters
                                AudioVideoParameters videoParams = new AudioVideoParameters();

                                videoParams.SiteName  = CMSContext.CurrentSiteName;
                                videoParams.Url       = url;
                                videoParams.Width     = Width;
                                videoParams.Height    = Height;
                                videoParams.Extension = mfi.FileExtension;

                                ltlOutput.Text = MediaHelper.GetAudioVideo(videoParams);
                            }
                            else
                            {
                                ltlOutput.Text = MediaLibraryHelper.ShowPreviewOrIcon(mfi, Width, Height, MaxSideSize, PreviewSuffix, IconSet, Page, DefaultImageUrl);
                            }
                        }
                        else
                        {
                            ltlOutput.Text = MediaLibraryHelper.ShowPreviewOrIcon(mfi, Width, Height, MaxSideSize, PreviewSuffix, IconSet, Page, DefaultImageUrl);
                        }
                    }
                }
            }
            binded = true;
        }
    }
Exemplo n.º 10
0
 public void AddFlashParams(FlashParameters varName, string varValue)
 {
     FlashParams.Add(varName.ToString(), varValue);
 }
Exemplo n.º 11
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="index">0 – 19</param>
 /// <param name="value">32bit signed integer</param>
 public FlashParameterItem(FlashParameters key, Int32 value)
 {
     this.Key = key;
     this.Value = value;
 }
Exemplo n.º 12
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="index">0 – 19</param>
 /// <param name="value">32bit signed integer</param>
 public FlashParameterItem(FlashParameters key, Int32 value)
 {
     this.Key   = key;
     this.Value = value;
 }