private void MakeComposites(XmlNode cXmlNode, string sDefaultID, Composite cRetVal) { XmlNode[] aNodes = cXmlNode.NodesGet("item", false); string sID = cXmlNode.AttributeValueGet("id", false); if (null == sID) sID = sDefaultID; if (!aNodes.IsNullOrEmpty()) { foreach (XmlNode cXN in aNodes) MakeComposites(cXN, sID, cRetVal); return; } Preferences.Item.Text cPreferencesItem = (Preferences.Item.Text)_cPreferences[sID]; string sText = cXmlNode.InnerText; sText = sText.RemoveNewLines(); if (0 == _nWidthOfSpace) _nWidthOfSpace = (ushort)(BTL.Play.Text.Measure("SSS SSS", cPreferencesItem.cFont, 0).nWidth - BTL.Play.Text.Measure("SSSSSS", cPreferencesItem.cFont, 0).nWidth); List<EffectVideo> aEffects = new List<EffectVideo>(); ushort nIdent = 0; Text cText = new BTL.Play.Text(sText, cPreferencesItem.cFont, cPreferencesItem.nBorderWidth) { bCUDA = false, stColor = cPreferencesItem.stColor, stColorBorder = cPreferencesItem.stColorBorder }; ushort nMaxWidth = _cPreferences.stArea.nWidth; if (nMaxWidth < cText.stArea.nWidth) { List<string> aSplited = new List<string>(); int nk = 0; bool bLastLetter = false, bLastDigit = false; //, bLastLetter = false; for (int ni = 0; sText.Length > ni; ni++) { if (0 != ni && ((!bLastDigit && !bLastLetter && Char.IsLetterOrDigit(sText[ni])) || (bLastLetter && !(Char.IsLetter(sText[ni]))) || (bLastDigit && !(Char.IsDigit(sText[ni]))))) { aSplited.Add(sText.Substring(nk, ni - nk)); nk = ni; } bLastLetter = Char.IsLetter(sText[ni]); bLastDigit = Char.IsDigit(sText[ni]); } foreach (string sStr in aSplited) { cText = new BTL.Play.Text(sStr, cPreferencesItem.cFont, cPreferencesItem.nBorderWidth) { bCUDA = false, stColor = cPreferencesItem.stColor, stColorBorder = cPreferencesItem.stColorBorder }; Text cTextPrev = null; ; int ni = 0; nk = 1; if (nMaxWidth < cText.stArea.nWidth) { while (ni + nk < sStr.Length) { cText = new BTL.Play.Text(sStr.Substring(ni, nk), cPreferencesItem.cFont, cPreferencesItem.nBorderWidth) { bCUDA = false, stColor = cPreferencesItem.stColor, stColorBorder = cPreferencesItem.stColorBorder }; while (nMaxWidth > cText.stArea.nWidth && (ni + nk < sStr.Length)) { nk++; cTextPrev = cText; cText = new BTL.Play.Text(sStr.Substring(ni, nk), cPreferencesItem.cFont, cPreferencesItem.nBorderWidth) { bCUDA = false, stColor = cPreferencesItem.stColor, stColorBorder = cPreferencesItem.stColorBorder }; } ni += nk - 1; nk = 1; if (ni + nk == sStr.Length) cTextPrev = cText; aEffects.Add(cTextPrev); } } else aEffects.Add(cText); } } else aEffects.Add(cText); nIdent = 0; for(int nIndx = 0; aEffects.Count > nIndx; nIndx++) { if (cRetVal.stArea.nWidth + aEffects[nIndx].stArea.nWidth + nIdent > nMaxWidth) break; aEffects[nIndx].stArea = new Area(aEffects[nIndx].stArea.nLeft, (short)(aEffects[nIndx].stArea.nTop + cPreferencesItem.nTopOffset), aEffects[nIndx].stArea.nWidth, aEffects[nIndx].stArea.nHeight); cRetVal.EffectAdd(aEffects[nIndx], nIdent); nIdent = _nWidthOfSpace; } }
private List<Composite> MakeComposites(List<Item> aItems, ushort nMaxWidth) { List<Composite> aRetVal = new List<Composite>(); ushort nIdent = 0; List<EffectVideo> aEffectsInSMS = new List<EffectVideo>(); List<EffectVideo> aEff; int nIndx = 0; foreach (Item cItem in aItems) if (null != (aEff = cItem.GetEffect(this, nMaxWidth))) aEffectsInSMS.AddRange(aEff); Composite cTemp; while (nIndx < aEffectsInSMS.Count) { cTemp = new Composite(nMaxWidth, Composite.Type.Vertical); nIdent = 0; while (true) { if (cTemp.stArea.nWidth + aEffectsInSMS[nIndx].stArea.nWidth + nIdent > nMaxWidth) break; cTemp.EffectAdd(aEffectsInSMS[nIndx], nIdent); nIdent = _nWidthOfSpace; nIndx++; if (nIndx >= aEffectsInSMS.Count) break; } cTemp.bCUDA = false; aRetVal.Add(cTemp); } return aRetVal; }