Esempio n. 1
0
        public Step(FlythroughState state, XmlNode node, Text subtitlesText, int subtitleTimeoutS, IMediaPlayer player)
        {
            if (node.Attributes["St››ep"] == null && !int.TryParse(node.Attributes["Step"].Value, out mStep))
                throw new ArgumentException("Unable to load slideshow step. A valid 'Step' attribute must be supplied.");

            #if DEBUG
            if (sStatistics == null) {
                sStatistics = new TickStatistics();
                StatisticsCollection.AddStatistics(sStatistics, "Flythrough Steps");
            }
            #endif

            mPlayer = player;
            mManager = state.Manager;
            mStep = GetInt(node, -1, "Step");
            if (mStep == -1)
                throw new ArgumentException("Unable to load step ID. A valid Step attribute is expected.");

            XmlAttribute voiceoverAttribute = node.Attributes["Voiceover"];
            if (voiceoverAttribute != null && File.Exists(Path.GetFullPath(voiceoverAttribute.Value))) {
                if (mPlayer != null)
                    mVoiceoverFile = Path.GetFullPath(voiceoverAttribute.Value);
                else
                    Logger.Warn("Unable to load voiceover for flythrough step. No MediaPlayer supplied.");
            }

            mSubtitlesText = subtitlesText;

            XmlNode newFontNode = node.SelectSingleNode("child::SubtitlesFont");
            if (newFontNode != null)
                mNewSubtitlesFont = state.Manager.MakeText(newFontNode);

            if (mSubtitlesText != null) {
                mTickListener = new Action(mCoordinator_Tick);
                mSubtitleTimeoutS = subtitleTimeoutS;
                XmlNode subtitlesNode = node.SelectSingleNode("child::Subtitles");
                if (subtitlesNode != null) {
                    foreach (XmlNode child in subtitlesNode.ChildNodes) {
                        if (child is XmlElement) {
                            double time = child.Attributes["Time"] != null ? double.Parse(child.Attributes["Time"].Value) : 0;
                            mSubtitles.Add(time, child.InnerText.Trim('\n', ' ', Environment.NewLine[0]).Replace("  ", ""));
                        }
                    }
                }
            }

            foreach (var featureNode in GetChildrenOfChild(node, "Features")) {
                IFeature feature = mManager.GetFeature(featureNode, "flythrough step " + (mStep + 1), null);
                if (feature != null) {
                    mFeatures.Add(feature);
                    state.AddFeature(feature);
                    feature.Active = false;
                }
            }
        }
Esempio n. 2
0
        public Step(FlythroughState state, XmlNode node, Text subtitlesText, int subtitleTimeoutS, IMediaPlayer player)
        {
            if (node.Attributes["St››ep"] == null && !int.TryParse(node.Attributes["Step"].Value, out mStep))
            {
                throw new ArgumentException("Unable to load slideshow step. A valid 'Step' attribute must be supplied.");
            }

#if DEBUG
            if (sStatistics == null)
            {
                sStatistics = new TickStatistics();
                StatisticsCollection.AddStatistics(sStatistics, "Flythrough Steps");
            }
#endif

            mPlayer  = player;
            mManager = state.Manager;
            mStep    = GetInt(node, -1, "Step");
            if (mStep == -1)
            {
                throw new ArgumentException("Unable to load step ID. A valid Step attribute is expected.");
            }

            XmlAttribute voiceoverAttribute = node.Attributes["Voiceover"];
            if (voiceoverAttribute != null && File.Exists(Path.GetFullPath(voiceoverAttribute.Value)))
            {
                if (mPlayer != null)
                {
                    mVoiceoverFile = Path.GetFullPath(voiceoverAttribute.Value);
                }
                else
                {
                    Logger.Warn("Unable to load voiceover for flythrough step. No MediaPlayer supplied.");
                }
            }

            mSubtitlesText = subtitlesText;

            XmlNode newFontNode = node.SelectSingleNode("child::SubtitlesFont");
            if (newFontNode != null)
            {
                mNewSubtitlesFont = state.Manager.MakeText(newFontNode);
            }

            if (mSubtitlesText != null)
            {
                mTickListener     = new Action(mCoordinator_Tick);
                mSubtitleTimeoutS = subtitleTimeoutS;
                XmlNode subtitlesNode = node.SelectSingleNode("child::Subtitles");
                if (subtitlesNode != null)
                {
                    foreach (XmlNode child in subtitlesNode.ChildNodes)
                    {
                        if (child is XmlElement)
                        {
                            double time = child.Attributes["Time"] != null?double.Parse(child.Attributes["Time"].Value) : 0;

                            mSubtitles.Add(time, child.InnerText.Trim('\n', ' ', Environment.NewLine[0]).Replace("  ", ""));
                        }
                    }
                }
            }

            foreach (var featureNode in GetChildrenOfChild(node, "Features"))
            {
                IFeature feature = mManager.GetFeature(featureNode, "flythrough step " + (mStep + 1), null);
                if (feature != null)
                {
                    mFeatures.Add(feature);
                    state.AddFeature(feature);
                    feature.Active = false;
                }
            }
        }