Example #1
0
        /// <summary>Creates an event relative to this slide.</summary>
        public SlideEvent createEvent(string type)
        {
            SlideEvent de = track.createRawEvent("slide" + type);

            de.slide = this;
            return(de);
        }
Example #2
0
        /// <summary>Cues this slide right now.</summary>
        public void cue()
        {
            // Create the cue event:
            SlideEvent cue = createEvent("cue");

            // Run it now:
            if (dispatchEvent(cue))
            {
                // Cue the text for each speaker.


                // Cue all actions (always after text):
                if (actions != null)
                {
                    // Param set:
                    object[] arr = new object[] { cue };

                    // Cue! Run each action now:
                    for (int i = 0; i < actions.Length; i++)
                    {
                        // Get it:
                        Action a = actions[i];

                        // Update event:
                        cue.action = a;

                        // Invoke it:
                        a.Method.Invoke(null, arr);
                    }
                }
            }
        }
        /// <summary>Dispatches an event of the given name.</summary>
        public void dispatch(string name)
        {
            SlideEvent se = new SlideEvent("timeline" + name, null);

            se.timeline = this;
            se.SetTrusted(true);
            dispatchEvent(se);
        }
Example #4
0
        /// <summary>Creates an event relative to this track. Type is 'as-is'.</summary>
        public SlideEvent createRawEvent(string type)
        {
            SlideEvent de = new SlideEvent(type, null);

            de.timeline = timeline;
            de.track    = this;
            de.SetTrusted();
            return(de);
        }
Example #5
0
        /// <summary>Loads a track from some JSON data with an optional header.</summary>
        public virtual void load(JSObject json, JSObject header)
        {
            // Got a header? Might contain an ID:
            if (header != null)
            {
                // ID:
                int.TryParse(json.String("id"), out id);
            }

            // Slides:
            JSArray slides = json as JSArray;

            if (slides == null)
            {
                // Never null:
                this.slides = new Slide[0];
                return;
            }

            if (!slides.IsIndexed)
            {
                throw new Exception("Incorrect PowerSlide track: 'slides' must be an indexed array.");
            }

            // Create array now:
            this.slides = new Slide[slides.length];

            // For each one..
            foreach (KeyValuePair <string, JSObject> kvp in slides.Values)
            {
                // index is..
                int index;
                int.TryParse(kvp.Key, out index);

                // Create and setup the slide now:
                Slide c = createSlide();
                c.track = this;
                c.index = index;

                // Load the info:
                c.load(kvp.Value);

                // Apply:
                this.slides[index] = c;
            }

            // Dispatch the load event which enables any custom info being added:
            rawJson = json;
            SlideEvent de = createEvent("trackload");

            timeline.dispatchEvent(de);
        }
Example #6
0
        /// <summary>This slide is now starting.</summary>
        internal virtual void start()
        {
            // Dispatch a "timelinestart" event.
            SlideEvent se = createEvent("start");

            // Dispatch here:
            dispatchEvent(se);

            // Dispatch to the element too:
            EventTarget et = eventTarget;

            if (et != null)
            {
                et.dispatchEvent(se);
            }
        }
Example #7
0
        /// <summary>This slide is now starting.</summary>
        internal override void start()
        {
            base.start();

            Timeline tl = track.timeline;

            // Display this dialogue slide now!

            // Any audio?
            if (!string.IsNullOrEmpty(audioFilePath))
            {
                // Play the audio now.
                // Note that PowerSlide will follow the lead of the audio engine.
                playAudio();
            }

            // Get the template to use:
            string templateToUse = (template == null)? tl.template:template;

            // Open the widget (which closes the prev one for us):
            Widgets.Widget widget = tl.openWidget(templateToUse);

            if (widget != null)
            {
                // Trigger a dialogue start event:
                SlideEvent s = new SlideEvent("dialoguestart", null);
                s.slide = this;
                tl.dispatchEvent(s);
            }

            if (waitForCue)
            {
                // Wait! Advance to the end of the slide now too
                // (because it has an auto duration which doesn't have any meaning).
                tl.setPause(true);

                if (tl.backwards)
                {
                    tl.currentTime = computedStart;
                }
                else
                {
                    tl.currentTime = computedEnd;
                }
            }
        }
Example #8
0
        /// <summary>This slide is now done.</summary>
        internal virtual void end()
        {
            // Dispatch a "slideend" event.
            SlideEvent se = createEvent("end");

            // Dispatch here:
            dispatchEvent(se);

            // Dispatch to the element too:
            EventTarget et = eventTarget;

            if (et != null)
            {
                et.dispatchEvent(se);
            }

            // Quit timing lead:
            endTimingLead();
        }
Example #9
0
        /// <summary>This dialogue is now offscreen.</summary>
        internal override void end()
        {
            base.end();

            // Trigger dialogue end event if we have a widget:
            Timeline tl = track.timeline;

            // Trigger a dialogue end event:
            SlideEvent s = new SlideEvent("dialogueend", null);

            s.slide = this;
            tl.dispatchEvent(s);

            if (tl.currentWidget == null)
            {
                return;
            }

            // Close the widget if this is the last slide non-ignored slide.
            bool last = true;

            for (int i = index + 1; i < track.slides.Length; i++)
            {
                if (!track.slides[i].ignore)
                {
                    last = false;
                    break;
                }
            }

            if (last)
            {
                // Close the widget now:
                tl.currentWidget.close();
                tl.currentWidget = null;
            }
        }
Example #10
0
        /// <summary>Loads a slide from the given JSON.</summary>
        public virtual void load(JSObject json)
        {
            // Start:
            string startText = json.String("start");

            if (startText != null)
            {
                // Load the start value:
                startValue = Css.Value.Load(startText);
            }

            // Duration:
            string durationText = json.String("duration");

            if (durationText != null)
            {
                // Load the duration value:
                durationValue = Css.Value.Load(durationText);
            }

            // Action:
            JSArray acts = json["actions"] as JSArray;

            if (acts != null)
            {
                if (acts.IsIndexed)
                {
                    // Multiple actions:

                    // For each one..
                    foreach (KeyValuePair <string, JSObject> kvp in acts.Values)
                    {
                        // index is..
                        int index;
                        int.TryParse(kvp.Key, out index);

                        // Set it up:
                        loadAction(index, kvp.Value);
                    }
                }
                else
                {
                    // Should be an array but we'll also accept just one.
                    loadAction(0, acts);
                }
            }
            else
            {
                // Check if they mis-named as just 'action':
                acts = json["action"] as JSArray;

                if (acts != null)
                {
                    loadAction(0, acts);
                }
            }

            rawJson = json;

            if (OnLoad != null)
            {
                // Dispatch the load event which enables any custom info being added:
                SlideEvent de = createEvent("load");
                OnLoad(de);
            }
        }