Exemple #1
0
        public AudioOverlay parseAudioOverlay(XmlReader reader)
        {
            AudioOverlay ao = new AudioOverlay();

            do
            {
                if (reader.Name == "data" && reader.NodeType == XmlNodeType.EndElement)
                {
                    break;
                }
                else if (reader.NodeType != XmlNodeType.EndElement)
                {
                    switch (reader.Name)
                    {
                    case "audioUrl":
                        reader.Read();
                        ao.AudioUrl = reader.Value;
                        break;

                    case "autoStart":
                        reader.Read();
                        ao.AutoStart = Convert.ToBoolean(reader.Value);
                        break;

                    case "autoStartDelay":
                        reader.Read();
                        ao.AutoStartDelay = Convert.ToDouble(reader.Value);
                        break;

                    default:
                        break;
                    }
                }
            } while (reader.Read());
            return(ao);
        }
Exemple #2
0
        // searches the pages list for the proper page to add overlay to
        // creates an overlay for each orientation if there are more than one
        public Article parseOverlays(XmlReader reader, Article article)
        {
            while (reader.ReadToFollowing("overlay"))
            {
                double portraitX       = -1;
                double portraitY       = -1;
                double landscapeX      = -1;
                double landscapeY      = -1;
                double portraitWidth   = -1;
                double portraitHeight  = -1;
                double landscapeWidth  = -1;
                double landscapeHeight = -1;

                Tuple <int, double> portraitTuple  = new Tuple <int, double>(-1, -1);
                Tuple <int, double> landscapeTuple = new Tuple <int, double>(-1, -1);

                string type = reader.GetAttribute("type");
                string id   = reader.GetAttribute("id");

                while (reader.Read())
                {
                    // indicates the end of the overlay
                    if (reader.Name == "data")
                    {
                        break;
                    }
                    else if (reader.NodeType != XmlNodeType.EndElement)
                    {
                        //assigns the attributes for portrait orientation if it exists
                        if (reader.Name == "portraitBounds")
                        {
                            if (reader.ReadToFollowing("rectangle"))
                            {
                                portraitX      = Convert.ToDouble(reader.GetAttribute("x"));
                                portraitY      = Convert.ToDouble(reader.GetAttribute("y"));
                                portraitWidth  = Convert.ToDouble(reader.GetAttribute("width"));
                                portraitHeight = Convert.ToDouble(reader.GetAttribute("height"));
                                portraitTuple  = calculatePortraitPage(portraitY, article.Pages);
                            }
                        }
                        //assigns the attributes for landscape orientation if it exists
                        else if (reader.Name == "landscapeBounds")
                        {
                            if (reader.ReadToFollowing("rectangle"))
                            {
                                landscapeX      = Convert.ToDouble(reader.GetAttribute("x"));
                                landscapeY      = Convert.ToDouble(reader.GetAttribute("y"));
                                landscapeWidth  = Convert.ToDouble(reader.GetAttribute("width"));
                                landscapeHeight = Convert.ToDouble(reader.GetAttribute("height"));
                                landscapeTuple  = calculateLandscapePage(landscapeY, article.Pages);
                            }
                        }
                    }
                }

                switch (type)
                {
                case "audio":
                    AudioOverlay portraitAO  = new AudioOverlay();
                    AudioOverlay landscapeAO = new AudioOverlay();

                    // getting the overlay assets for each oreintation if there are any
                    do
                    {
                        if (reader.Name == "audioUrl")
                        {
                            break;
                        }
                        else if (reader.Name == "overlayAsset")
                        {
                            if (reader.GetAttribute("landscape") == "false")
                            {
                                portraitAO.OverlayAssets.Add(parseOverlayAsset(reader));
                            }
                            else if (reader.GetAttribute("landscape") == "true")
                            {
                                landscapeAO.OverlayAssets.Add(parseOverlayAsset(reader));
                            }
                        }
                    } while (reader.Read());

                    AudioOverlay ao = parseAudioOverlay(reader);

                    if (portraitTuple.Item1 != -1)      // there exists a portrait orientation for this overlay
                    {
                        portraitAO.Id             = id + "_P";
                        portraitAO.Orientation    = "portrait";
                        portraitAO.X              = portraitX;
                        portraitAO.Y              = portraitTuple.Item2;
                        portraitAO.Width          = portraitWidth;
                        portraitAO.Height         = portraitHeight;
                        portraitAO.AudioUrl       = ao.AudioUrl;
                        portraitAO.AutoStart      = ao.AutoStart;
                        portraitAO.AutoStartDelay = ao.AutoStartDelay;
                        article.Pages[portraitTuple.Item1].AudioOverlays.Add(portraitAO);
                    }
                    if (landscapeTuple.Item1 != -1)     // there exists a landscape orientation for this overlay
                    {
                        landscapeAO.Id             = id + "_L";
                        landscapeAO.Orientation    = "landscape";
                        landscapeAO.X              = landscapeX;
                        landscapeAO.Y              = landscapeTuple.Item2;
                        landscapeAO.Width          = landscapeWidth;
                        landscapeAO.Height         = landscapeHeight;
                        landscapeAO.AudioUrl       = ao.AudioUrl;
                        landscapeAO.AutoStart      = ao.AutoStart;
                        landscapeAO.AutoStartDelay = ao.AutoStartDelay;
                        article.Pages[landscapeTuple.Item1].AudioOverlays.Add(landscapeAO);
                    }
                    break;

                case "hyperlink":
                    HyperlinkOverlay ho          = parseHyperlinkOverlay(reader);
                    HyperlinkOverlay portraitHO  = new HyperlinkOverlay(ho);
                    HyperlinkOverlay landscapeHO = new HyperlinkOverlay(ho);

                    if (portraitTuple.Item1 != -1)     // there exists a portrait orientation for this overlay
                    {
                        portraitHO.Id          = id + "_P";
                        portraitHO.Orientation = "portrait";
                        portraitHO.X           = portraitX;
                        portraitHO.Y           = portraitTuple.Item2;
                        portraitHO.Width       = portraitWidth;
                        portraitHO.Height      = portraitHeight;
                        article.Pages[portraitTuple.Item1].HyperlinkOverlays.Add(portraitHO);
                    }
                    if (landscapeTuple.Item1 != -1)     // there exists a landscape orientation for this overlay
                    {
                        landscapeHO.Id          = id + "_L";
                        landscapeHO.Orientation = "landscape";
                        landscapeHO.X           = landscapeX;
                        landscapeHO.Y           = landscapeTuple.Item2;
                        landscapeHO.Width       = landscapeWidth;
                        landscapeHO.Height      = landscapeHeight;
                        article.Pages[landscapeTuple.Item1].HyperlinkOverlays.Add(landscapeHO);
                    }
                    break;

                case "imagepan":
                    ImagepanOverlay portraitIO  = new ImagepanOverlay();
                    ImagepanOverlay landscapeIO = new ImagepanOverlay();

                    // get overlay assets before we get the overlays attributes
                    while (reader.Read())
                    {
                        // indicates the end of the asstes
                        if (reader.Name == "anchorPoint")
                        {
                            break;
                        }
                        else if (reader.Name == "overlayAsset")
                        {
                            if (reader.GetAttribute("landscape") == "false")
                            {
                                portraitIO.OverlayAssets.Add(parseOverlayAsset(reader));
                            }
                            else if (reader.GetAttribute("landscape") == "true")
                            {
                                landscapeIO.OverlayAssets.Add(parseOverlayAsset(reader));
                            }
                        }
                    }

                    ImagepanOverlay io = parseImagepanOverlay(reader);

                    if (portraitTuple.Item1 != -1)      // there exists a portrait orientation for this overlay
                    {
                        portraitIO.Id          = id + "_P";
                        portraitIO.Orientation = "portrait";
                        portraitIO.X           = portraitX;
                        portraitIO.Y           = portraitTuple.Item2;
                        portraitIO.Width       = portraitWidth;
                        portraitIO.Height      = portraitHeight;
                        portraitIO.AnchorX     = io.AnchorX;
                        portraitIO.AnchorY     = io.AnchorY;
                        // getting the viewport bounds if they exist
                        while (reader.Read())
                        {
                            if ((reader.Name == "portraitBounds" && reader.NodeType == XmlNodeType.EndElement) || reader.Name == "landscapeBounds")
                            {
                                break;
                            }
                            else if (reader.Name == "portraitBounds")
                            {
                                portraitIO = parseImagepanOverlayViewportbounds(reader, portraitIO);
                            }
                        }

                        article.Pages[portraitTuple.Item1].ImagepanOverlays.Add(portraitIO);
                    }
                    if (landscapeTuple.Item1 != -1)      // there exists a landscape orientation for this overlay
                    {
                        landscapeIO.Id          = id + "_L";
                        landscapeIO.Orientation = "landscape";
                        landscapeIO.X           = landscapeX;
                        landscapeIO.Y           = landscapeTuple.Item2;
                        landscapeIO.Width       = landscapeWidth;
                        landscapeIO.Height      = landscapeHeight;
                        landscapeIO.AnchorX     = io.AnchorX;
                        landscapeIO.AnchorY     = io.AnchorY;
                        // getting the viewport bounds if they exist
                        do
                        {
                            if (reader.Name == "initialViewport" && reader.NodeType == XmlNodeType.EndElement)
                            {
                                break;
                            }
                            else if (reader.Name == "landscapeBounds")
                            {
                                landscapeIO = parseImagepanOverlayViewportbounds(reader, landscapeIO);
                            }
                        }while (reader.Read());

                        article.Pages[landscapeTuple.Item1].ImagepanOverlays.Add(landscapeIO);
                    }
                    break;

                case "slideshow":
                    // shared slideshow overlay attributes
                    SlideshowOverlay so = parseSlideShowOverlay(reader);

                    SlideshowOverlay portraitSO  = new SlideshowOverlay(so);
                    SlideshowOverlay landscapeSO = new SlideshowOverlay(so);

                    // getting the overlay assets for each oreintation if there are any
                    do
                    {
                        if (reader.Name == "portraitLayout" || reader.Name == "landscapeLayout")
                        {
                            break;
                        }
                        else if (reader.Name == "overlayAsset")
                        {
                            if (reader.GetAttribute("landscape") == "false")
                            {
                                portraitSO.OverlayAssets.Add(parseOverlayAsset(reader));
                            }
                            else if (reader.GetAttribute("landscape") == "true")
                            {
                                landscapeSO.OverlayAssets.Add(parseOverlayAsset(reader));
                            }
                        }
                    }while (reader.Read());

                    if (portraitTuple.Item1 != -1)      // there is a portrait layout for this overlay
                    {
                        portraitSO.Id          = id + "_P";
                        portraitSO.X           = portraitX;
                        portraitSO.Y           = portraitTuple.Item2;
                        portraitSO.Width       = portraitWidth;
                        portraitSO.Height      = portraitHeight;
                        portraitSO.Orientation = "portrait";

                        if (reader.Name == "portraitLayout")
                        {
                            portraitSO = parseSlideshowOverlayDisplaybounds(reader, portraitSO);
                            while (reader.Read())
                            {
                                if (reader.Name == "landscapeLayout" || (reader.Name == "data" && reader.NodeType == XmlNodeType.EndElement))
                                {
                                    break;
                                }
                                else if (reader.Name == "button")
                                {
                                    portraitSO.OverlayButtons.Add(parseOverlayButton(reader));
                                }
                            }
                        }
                        article.Pages[portraitTuple.Item1].SlideshowOverlays.Add(portraitSO);
                    }
                    if (landscapeTuple.Item1 != -1)      // there is a landscape layout for this overlay
                    {
                        landscapeSO.Id          = id + "_L";
                        landscapeSO.X           = landscapeX;
                        landscapeSO.Y           = landscapeTuple.Item2;
                        landscapeSO.Width       = landscapeWidth;
                        landscapeSO.Height      = landscapeHeight;
                        landscapeSO.Orientation = "landscape";

                        if (reader.Name == "landscapeLayout")
                        {
                            landscapeSO = parseSlideshowOverlayDisplaybounds(reader, landscapeSO);
                            while (reader.Read())
                            {
                                if (reader.Name == "data" && reader.NodeType == XmlNodeType.EndElement)
                                {
                                    break;
                                }
                                else if (reader.Name == "button")
                                {
                                    landscapeSO.OverlayButtons.Add(parseOverlayButton(reader));
                                }
                            }
                        }

                        article.Pages[landscapeTuple.Item1].SlideshowOverlays.Add(landscapeSO);
                    }
                    break;

                case "webview":
                    WebviewOverlay wo          = parseWebViewOverlay(reader);
                    WebviewOverlay portraitWO  = new WebviewOverlay(wo);
                    WebviewOverlay landscapeWO = new WebviewOverlay(wo);

                    if (portraitTuple.Item1 != -1)     // there is a portrait layout for this overlay
                    {
                        portraitWO.Id          = id + "_P";
                        portraitWO.Orientation = "portrait";
                        portraitWO.X           = portraitX;
                        portraitWO.Y           = portraitTuple.Item2;
                        portraitWO.Width       = portraitWidth;
                        portraitWO.Height      = portraitHeight;
                        article.Pages[portraitTuple.Item1].WebviewOverlay.Add(portraitWO);
                    }
                    if (landscapeTuple.Item1 != -1)     // there is a landscape layout for this overlay
                    {
                        landscapeWO.Id          = id + "_L";
                        landscapeWO.Orientation = "landscape";
                        landscapeWO.X           = landscapeX;
                        landscapeWO.Y           = landscapeTuple.Item2;
                        landscapeWO.Width       = landscapeWidth;
                        landscapeWO.Height      = landscapeHeight;
                        article.Pages[landscapeTuple.Item1].WebviewOverlay.Add(landscapeWO);
                    }
                    break;

                case "video":
                    VideoOverlay vo          = parseVideoOverlay(reader);
                    VideoOverlay portraitVO  = new VideoOverlay(vo);
                    VideoOverlay landscapeVO = new VideoOverlay(vo);

                    if (portraitTuple.Item1 != -1)      // there is a portrait layout for this overlay
                    {
                        portraitVO.Id          = id + "_P";
                        portraitVO.Orientation = "portrait";
                        portraitVO.X           = portraitX;
                        portraitVO.Y           = portraitTuple.Item2;
                        portraitVO.Width       = portraitWidth;
                        portraitVO.Height      = portraitHeight;
                        article.Pages[portraitTuple.Item1].VideoOverlays.Add(portraitVO);
                    }
                    if (landscapeTuple.Item1 != -1)      // there is a landscape layout for this overlay
                    {
                        landscapeVO.Id          = id + "_L";
                        landscapeVO.Orientation = "landscape";
                        landscapeVO.X           = landscapeX;
                        landscapeVO.Y           = landscapeTuple.Item2;
                        landscapeVO.Width       = landscapeWidth;
                        landscapeVO.Height      = landscapeHeight;
                        article.Pages[landscapeTuple.Item1].VideoOverlays.Add(landscapeVO);
                    }

                    break;

                default:
                    break;
                }
            }
            return(article);
        }