示例#1
0
		public void PrompterRestartFrom(int nLine)
		{
			Roll cOldRoll = (Roll)_aAtoms.FirstOrDefault(o => o is Roll);
			Roll cNewRoll = new Roll();
			cNewRoll.EffectOnScreen += new Container.EventDelegate(cRoll_EffectOnScreen);
			cNewRoll.EffectOffScreen += new Container.EventDelegate(cRoll_EffectOffScreen);
			if (null != cOldRoll)
			{
				cOldRoll.Stop();
				_aAtoms.Remove(cOldRoll);
				_aAtoms.Add(cNewRoll);
				cNewRoll.nLayer = cOldRoll.nLayer;
				cNewRoll.nSpeed = cOldRoll.nSpeed;
				cNewRoll.nLayer = cOldRoll.nLayer;
				cNewRoll.stArea = cOldRoll.stArea;
				cNewRoll.cHide = cOldRoll.cHide;
				cNewRoll.cShow = cOldRoll.cShow;
				cNewRoll.bOpacity = cOldRoll.bOpacity;
				cNewRoll.cDock = cOldRoll.cDock;
				cNewRoll.eDirection = cOldRoll.eDirection;
				List<Effect> aEffectsInRoll = cNewRoll.EffectsGet();
				for (int nI = nLine - 1; aSplittedEffects.Count > nI; nI++)
				{
					if (aSplittedEffects[nI].eStatus == Atom.Status.Idle || aSplittedEffects[nI].eStatus == Atom.Status.Prepared)
						cNewRoll.EffectAdd(aSplittedEffects[nI]);  //aEffectsInRoll.Add(aSplittedEffects[nI]);
					else
					{
						Text cT = new Text();
						cT.sText = aSplittedText[nI];
						cT.nLayer = cSourceText.nLayer;
						//cT.bOpacity = cT.bOpacity;
						cT.cDock = cSourceText.cDock;
						cT.cFont = cSourceText.cFont;
						aSplittedEffects[nI] = cT;
						cNewRoll.EffectAdd(cT);
						//aEffectsInRoll.Add(cT);
					}
				}
				nOnScreen = nOffScreen = nLine - 1;
				cNewRoll.Prepare();
				cNewRoll.Start();
			}
		}
示例#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();
			}
		}