Пример #1
0
			public void AddAnimation(PlaylistItem cItem)
			{
				Animation cAnimation = new Animation();
				cAnimation.bKeepAlive = true;
				cAnimation.nLoopsQty = (ushort)cItem._nFramesQty;
				cAnimation.sFolder = cItem.sFilenameFull;
				cAnimation.stArea = new Area(0, 0, cPL_PrefTemplate.stScaleVideo.nWidth, cPL_PrefTemplate.stScaleVideo.nHeight);
				cAnimation.nPixelAspectRatio = cPL_PrefTemplate.nPixelAspectRatio;

				cItem.nAtomHashCode = cAnimation.GetHashCode();
				_cPlaylist.EffectAdd(cAnimation, cItem.nTransDuration);
				_cPlaylist.EndTransDurationSet(cItem.nEndTransDuration);
				lock (_aPlaylistItems)
					_aPlaylistItems.Add(cItem);
				cItem.nEffectID = cAnimation.GetHashCode();
				Player.dtPlaylistStopPlanned = dtPlaylistStopPlanned;
			}
Пример #2
0
		private void ParseXML()
		{
            if ("" == sFile) // т.е. файл не неправильный, а его просто нет
                return;
			_aAtoms.Clear();
			if (!System.IO.File.Exists(sFile))
				throw new Exception("отсутствует указанный файл шаблона [FL:" + sFile + "]"); //TODO LANG
			XmlDocument cXMLTemplate = new XmlDocument();
			string sXML = System.IO.File.ReadAllText(sFile);
			sXML = ProcessMacros(sXML);

			cXMLTemplate.Load(new System.IO.StringReader(sXML));
			XmlNode cXmlNode = cXMLTemplate.GetElementsByTagName("template")[0];

			if (0 < cXmlNode.Attributes.Count)
			{
				foreach (XmlAttribute cAttr in cXmlNode.Attributes)
					switch (cAttr.Name)
					{
						case "destroy":
							try
							{
								eDestroyType = (Template.DESTROY_TYPE)Enum.Parse(typeof(Template.DESTROY_TYPE), System.Text.RegularExpressions.Regex.Replace(cAttr.Value.Trim(), "\\W", "_"), true);
							}
							catch
							{
								throw new Exception("указан некорректный тип удаления [" + cAttr.Name + "=" + cAttr.Value + "][TPL:" + cXmlNode.BaseURI + "]"); //TODO LANG
							}
							break;
					}
			}
			XmlNodeList aChildNodes = cXmlNode.ChildNodes;
			Atom cAtom;
            this.aInclusions = null;
            List<Inclusion> aInclusions = new List<Inclusion>();
			for (int nIndx = 0; nIndx < aChildNodes.Count; nIndx++)
			{
				cAtom = null;
				switch (aChildNodes[nIndx].Name)
				{
					case "show":
                        #region show
						if (0 < aChildNodes[nIndx].Attributes.Count)
						{
                            foreach (XmlAttribute cAttr in aChildNodes[nIndx].Attributes)
                            {
                                switch (cAttr.Name)
                                {
                                    case "exists":
                                        try
                                        {
                                            eOnExists = (Template.EXISTS_BEHAVIOR)Enum.Parse(typeof(Template.EXISTS_BEHAVIOR), System.Text.RegularExpressions.Regex.Replace(cAttr.Value.Trim(), "\\W", "_"), true);
                                        }
                                        catch
                                        {
                                            throw new Exception("указан некорректный тип замещения [" + cAttr.Name + "=" + cAttr.Value + "][TPL:" + cXmlNode.BaseURI + "]"); //TODO LANG
                                        }
                                        break;
                                    case "lifetime":
                                        try
                                        {
                                            eLifeTime = (Template.LIFETIME)Enum.Parse(typeof(Template.LIFETIME), cAttr.Value.Trim(), true);
                                        }
                                        catch
                                        {
                                            try
                                            {
                                                nLifeTimeSeconds = cAttr.Value.Trim().ToInt32();
                                                eLifeTime = LIFETIME.Seconds;
                                            }
                                            catch
                                            {
                                                nLifeTimeSeconds = -1;
                                            }
                                            if (0 > nLifeTimeSeconds)
                                                throw new Exception("указана некорректная продолжительность существования [" + cAttr.Name + "=" + cAttr.Value + "][TPL:" + cXmlNode.BaseURI + "]"); //TODO LANG
                                        }
                                        break;
                                    case "misprepared":
                                        try
                                        {
                                            bMispreparedShow = cAttr.Value.Trim().ToBool();
                                        }
                                        catch
                                        {
                                            throw new Exception("указано некорректное значение поведения при нецелевой подготовке [" + cAttr.Name + "=" + cAttr.Value + "][TPL:" + cXmlNode.BaseURI + "]"); //TODO LANG
                                        }
                                        break;
                                }
                            }
						}
                        #endregion
						break;
                    case "include":
                    case "inclusion":
                    case "template":
                        Inclusion cInclusion = new Inclusion(this);
                        cInclusion.LoadXML(aChildNodes[nIndx]);
                        aInclusions.Add(cInclusion);
                        break;
					case "plugin":
						cAtom = new Plugin();
						break;
					case "video":
						cAtom = new Video();
						break;
					case "audio":
						cAtom = new Audio();
						break;
					case "animation":
						cAtom = new Animation();
						break;
					case "clock":
						cAtom = new Clock();
						break;
					case "text":
						cAtom = new Text();
						break;
					case "playlist":
						cAtom = new Playlist();
						break;
					case "roll":
						cAtom = new Roll();
						break;
				}
				if (null != cAtom)
				{
					cAtom.cTemplate = this;
                    cAtom.LoadXML(aChildNodes[nIndx]);
					if (!(cAtom is Effect) || ((Effect)cAtom).cShow.bShow)
						_aAtoms.Add(cAtom);
				}
                if(0 < aInclusions.Count)
                    this.aInclusions = aInclusions.ToArray();
			}
		}