Пример #1
0
        public Screen(
            Page page,
            drawing::RectangleF box,
            String text,
            Rendition rendition
            ) : base(page, PdfName.Screen, box, text)
        {
            Render render = new Render(this, Render.OperationEnum.PlayResume, rendition);

            {
                // Adding preview and play/pause control...

                /*
                 * NOTE: Mouse-related actions don't work when the player is active; therefore, in order to let
                 * the user control the rendering of the media clip (play/pause) just by mouse-clicking on the
                 * player, we can only rely on the player's focus event. Furthermore, as the player's focus can
                 * only be altered setting it on another widget, we have to define an ancillary field on the
                 * same page (so convoluted!).
                 */
                string playerReference = "__player" + ((PdfReference)render.BaseObject).ObjectNumber;
                Document.Form.Fields.Add(new TextField(playerReference, new Widget(page, new drawing::RectangleF(box.X, box.Y, 0, 0)), "")); // Ancillary field.
                render.Script = RenderScript.Replace(PlayerPlaceholder, playerReference);
            }
            Actions.OnPageOpen = render;

            if (rendition is MediaRendition)
            {
                PdfObjectWrapper data = ((MediaRendition)rendition).Clip.Data;
                if (data is FileSpecification)
                {
                    // Adding fallback annotation...

                    /*
                     * NOTE: In case of viewers which don't support video rendering, this annotation gently
                     * degrades to a file attachment that can be opened on the same location of the corresponding
                     * screen annotation.
                     */
                    FileAttachment attachment = new FileAttachment(page, box, text, (FileSpecification)data);
                    BaseDataObject[PdfName.T] = PdfString.Get(((FileSpecification)data).Path);
                    // Force empty appearance to ensure no default icon is drawn on the canvas!
                    attachment.BaseDataObject[PdfName.AP] = new PdfDictionary(new PdfName[] { PdfName.D, PdfName.R, PdfName.N }, new PdfDirectObject[] { new PdfDictionary(), new PdfDictionary(), new PdfDictionary() });
                }
            }
        }