Example #1
0
            public List <EffectVideo> GetEffects(SMS cSMS, ushort nMaxWidth)
            {
                _cSMS      = cSMS;
                _nMaxWidth = nMaxWidth;
                List <EffectVideo> aRetVal = new List <EffectVideo>();
                Text cText;

                switch (eType)
                {
                case Type.smile:
                    Animation cAnim = stSmile.cAnimation;
                    if (null != cAnim)
                    {
                        aRetVal.Add(stSmile.cAnimation);
                    }
                    else
                    {
                        (new Logger()).WriteNotice("-------SMILE------ попытка создать Animation из смайла [" + stSmile.sText + "] не удалась. Смс вышла c текстовым смайлом.");
                        cText = new BTL.Play.Text(stSmile.sText, cSMS.cPreferences.cFont, cSMS.cPreferences.nBorderWidth, SMILE.stTextSmileColor, cSMS.cPreferences.stBorderColor);
                        //cText.bCUDA = false;
                        aRetVal.Add(cText);
                    }
                    return(aRetVal);

                case Type.flag:
                    if (null != cSMS._cFlagAnim)
                    {
                        aRetVal.Add(cSMS._cFlagAnim);
                    }
                    else
                    {
                        (new Logger()).WriteError(new Exception("-------FLAG------ попытка получить Animation флага из SMS с телефоном [" + cSMS._sPhone + "] не удалась. Смс вышла без флага."));
                    }
                    return(aRetVal);

                case Type.text:
                    cText = new BTL.Play.Text(sText, cSMS.cPreferences.cFont, cSMS.cPreferences.nBorderWidth, cSMS.cPreferences.stColor, cSMS.cPreferences.stBorderColor, ushort.MaxValue, cSMS.cPreferences.nShiftTop, cSMS.cPreferences.nPressBottom);
                    if (nMaxWidth < cText.stArea.nWidth)
                    {
                        aRetVal.AddRange(SplitLongWord(sText));
                    }
                    else
                    {
                        //cText.bCUDA = false;
                        aRetVal.Add(cText);
                    }
                    return(aRetVal);
                }
                return(null);
            }
Example #2
0
            private void MaxTextLengthSearch()
            {
                string sText;

                btl.Text cBTLText;
                nTextMaxFound = 0;
                foreach (XmlNode cNodeChild in cNodeRoll.SelectNodes("effects/text"))
                {
                    sText    = cNodeChild.NodeGet("value").FirstChild.Value;
                    cBTLText = new BTL.Play.Text(cNodeChild);
                    if (nTextMaxFound < cBTLText.stArea.nWidth)
                    {
                        nTextMaxFound = cBTLText.stArea.nWidth;
                    }
                }
            }
Example #3
0
            private List <EffectVideo> CutWord(string sText)
            {
                List <EffectVideo> aRetVal = new List <EffectVideo>();
                Text cText = new BTL.Play.Text(sText, _cSMS.cPreferences.cFont, _cSMS.cPreferences.nBorderWidth, _cSMS.cPreferences.stColor, _cSMS.cPreferences.stBorderColor);
                Text cTextPrev = null;;
                int  ni = 0, nk = 1;

                if (_nMaxWidth < cText.stArea.nWidth)
                {
                    while (ni + nk < sText.Length)
                    {
                        cText = new BTL.Play.Text(sText.Substring(ni, nk), _cSMS.cPreferences.cFont, _cSMS.cPreferences.nBorderWidth, _cSMS.cPreferences.stColor, _cSMS.cPreferences.stBorderColor);
                        while (_nMaxWidth > cText.stArea.nWidth && (ni + nk < sText.Length))
                        {
                            nk++;
                            cTextPrev = cText;
                            cText     = new BTL.Play.Text(sText.Substring(ni, nk), _cSMS.cPreferences.cFont, _cSMS.cPreferences.nBorderWidth, _cSMS.cPreferences.stColor, _cSMS.cPreferences.stBorderColor);
                        }
                        ni += nk - 1;
                        nk  = 1;
                        if (ni + nk == sText.Length)
                        {
                            cTextPrev = cText;
                        }
                        aRetVal.Add(cTextPrev);
                    }
                }
                else
                {
                    aRetVal.Add(cText);
                }
                //foreach (Text cEff in aRetVal)
                //{
                //    cEff.bCUDA = false;
                //}
                return(aRetVal);
            }
Example #4
0
        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;
			}
        }
Example #5
0
 public TextItem TextItemGet(btl.Text cText)
 {
     return(_aTextItems.FirstOrDefault(o => o.cBTLText == cText));
 }
Example #6
0
        private List <Composite> MakeComposites(string sText, ushort nMaxWidth)
        {
            sText = sText.RemoveNewLines();
            if (0 == _nWidthOfSpace)
            {
                _nWidthOfSpace = (ushort)(BTL.Play.Text.Measure("SSS SSS", _cPreferences.cFont, 0).nWidth - BTL.Play.Text.Measure("SSSSSS", _cPreferences.cFont, 0).nWidth);
            }
            List <Composite>   aRetVal  = new List <Composite>();
            List <EffectVideo> aEffects = new List <EffectVideo>();
            ushort             nIdent   = 0;
            int nIndx = 0;

            Text cText = new BTL.Play.Text(sText, _cPreferences.cFont, _cPreferences.nBorderWidth)
            {
                bCUDA = false, stColor = _cPreferences.stColor, stColorBorder = _cPreferences.stColorBorder
            };

            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, _cPreferences.cFont, _cPreferences.nBorderWidth)
                    {
                        bCUDA = false, stColor = _cPreferences.stColor, stColorBorder = _cPreferences.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), _cPreferences.cFont, _cPreferences.nBorderWidth)
                            {
                                bCUDA = false, stColor = _cPreferences.stColor, stColorBorder = _cPreferences.stColorBorder
                            };
                            while (nMaxWidth > cText.stArea.nWidth && (ni + nk < sStr.Length))
                            {
                                nk++;
                                cTextPrev = cText;
                                cText     = new BTL.Play.Text(sStr.Substring(ni, nk), _cPreferences.cFont, _cPreferences.nBorderWidth)
                                {
                                    bCUDA = false, stColor = _cPreferences.stColor, stColorBorder = _cPreferences.stColorBorder
                                };
                            }
                            ni += nk - 1;
                            nk  = 1;
                            if (ni + nk == sStr.Length)
                            {
                                cTextPrev = cText;
                            }
                            aEffects.Add(cTextPrev);
                        }
                    }
                    else
                    {
                        aEffects.Add(cText);
                    }
                }
            }
            else
            {
                aEffects.Add(cText);
            }
            Composite cTemp;

            while (nIndx < aEffects.Count)
            {
                cTemp  = new Composite(nMaxWidth, Composite.Type.Vertical);
                nIdent = 0;
                while (true)
                {
                    if (cTemp.stArea.nWidth + aEffects[nIndx].stArea.nWidth + nIdent > nMaxWidth)
                    {
                        break;
                    }
                    cTemp.EffectAdd(aEffects[nIndx], nIdent);
                    nIdent = _nWidthOfSpace;
                    nIndx++;
                    if (nIndx >= aEffects.Count)
                    {
                        break;
                    }
                }
                cTemp.bCUDA = false;
                aRetVal.Add(cTemp);
            }
            return(aRetVal);
        }
Example #7
0
 public List<EffectVideo> GetEffect(SMS cSMS, ushort nMaxWidth)
 {
     _cSMS = cSMS;
     _nMaxWidth = nMaxWidth;
     List<EffectVideo> aRetVal = new List<EffectVideo>();
     Text cText;
     switch (eType)
     {
         case Type.smile:
             Animation cAnim = stSmile.cAnimation;
             if (null != cAnim)
                 aRetVal.Add(stSmile.cAnimation);
             else
             {
                 (new Logger()).WriteNotice("-------SMILE------ попытка создать Animation из смайла [" + stSmile.sText + "] не удалась. Смс вышла c текстовым смайлом.");
                 cText = new BTL.Play.Text(stSmile.sText, cSMS.cPreferences.cFont, cSMS.cPreferences.nBorderWidth);
                 cText.bCUDA = false;
                 cText.stColor = SMILE.stTextSmileColor;
                 cText.stColorBorder = cSMS.cPreferences.stBorderColor;
                 aRetVal.Add(cText);
             }
             return aRetVal;
         case Type.flag:
             if (null != cSMS._cFlagAnim)
                 aRetVal.Add(cSMS._cFlagAnim);
             else
                 (new Logger()).WriteError(new Exception("-------FLAG------ попытка получить Animation флага из SMS с телефоном [" + cSMS._sPhone + "] не удалась. Смс вышла без флага."));
             return aRetVal;
         case Type.text:
             cText = new BTL.Play.Text(sText, cSMS.cPreferences.cFont, cSMS.cPreferences.nBorderWidth);
             if (nMaxWidth < cText.stArea.nWidth)
             {
                 aRetVal.AddRange(SplitLongWord(sText));
             }
             else
             {
                 cText.bCUDA = false;
                 cText.stColor = cSMS.cPreferences.stColor;
                 cText.stColorBorder = cSMS.cPreferences.stBorderColor;
                 aRetVal.Add(cText);
             }
             return aRetVal;
     }
     return null;
 }
Example #8
0
 private List<EffectVideo> CutWord(string sText)
 {
     List<EffectVideo> aRetVal = new List<EffectVideo>();
     Text cText = new BTL.Play.Text(sText, _cSMS.cPreferences.cFont, _cSMS.cPreferences.nBorderWidth);
     Text cTextPrev = null; ;
     int ni = 0, nk = 1;
     if (_nMaxWidth < cText.stArea.nWidth)
     {
         while (ni + nk < sText.Length)
         {
             cText = new BTL.Play.Text(sText.Substring(ni, nk), _cSMS.cPreferences.cFont, _cSMS.cPreferences.nBorderWidth);
             while (_nMaxWidth > cText.stArea.nWidth && (ni + nk < sText.Length))
             {
                 nk++;
                 cTextPrev = cText;
                 cText = new BTL.Play.Text(sText.Substring(ni, nk), _cSMS.cPreferences.cFont, _cSMS.cPreferences.nBorderWidth);
             }
             ni += nk - 1;
             nk = 1;
             if (ni + nk == sText.Length)
                 cTextPrev = cText;
             aRetVal.Add(cTextPrev);
         }
     }
     else
         aRetVal.Add(cText);
     foreach (Text cEff in aRetVal)
     {
         cEff.bCUDA = false;
         cEff.stColor = _cSMS.cPreferences.stColor;
         cEff.stColorBorder = _cSMS.cPreferences.stBorderColor;
     }
     return aRetVal;
 }
Example #9
0
        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 = BTL.Play.Text.SizeOfSpaceGet(cPreferencesItem.cFont, 0).nWidth;
            }
            List <EffectVideo> aEffects = new List <EffectVideo>();
            ushort             nIdent   = 0;

            Text cText;
            Text cTextSource = new BTL.Play.Text(sText, cPreferencesItem.cFont, cPreferencesItem.nBorderWidth, cPreferencesItem.stColor, cPreferencesItem.stColorBorder, cPreferencesItem.nWidthMax)
            {
                stMergingMethod = new MergingMethod()
            };
            ushort nTextWidth = cTextSource.stArea.nWidth;
            ushort nMaxWidth  = _cPreferences.stArea.nWidth;

            if (nMaxWidth < nTextWidth)
            {
                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, cPreferencesItem.stColor, cPreferencesItem.stColorBorder, cPreferencesItem.nWidthMax)
                    {
                        stMergingMethod = new MergingMethod()
                    };
                    Text cTextPrev = null;;
                    int  ni        = 0;
                    nk = 1;
                    if (nMaxWidth < nTextWidth)
                    {
                        while (ni + nk < sStr.Length)
                        {
                            cText = new BTL.Play.Text(sStr.Substring(ni, nk), cPreferencesItem.cFont, cPreferencesItem.nBorderWidth, cPreferencesItem.stColor, cPreferencesItem.stColorBorder, cPreferencesItem.nWidthMax)
                            {
                                stMergingMethod = new MergingMethod()
                            };
                            while (nMaxWidth > nTextWidth && (ni + nk < sStr.Length))
                            {
                                nk++;
                                cText = new BTL.Play.Text(sStr.Substring(ni, nk), cPreferencesItem.cFont, cPreferencesItem.nBorderWidth, cPreferencesItem.stColor, cPreferencesItem.stColorBorder, cPreferencesItem.nWidthMax)
                                {
                                    stMergingMethod = new MergingMethod()
                                };
                            }
                            if (nk == 1)                             // т.е. оочень слишком длинное слово - циклом не исправить уже. можно ужать пытаться в будущем, если проблема будет.
                            {
                                (new Logger()).WriteWarning("попалось слишком длинное слово: " + sText);
                                break;
                            }
                            ni += nk - 1;
                            nk  = 1;
                            if (ni + nk == sStr.Length)
                            {
                                cTextPrev = cTextSource;
                            }
                            aEffects.Add(cTextPrev);
                        }
                    }
                    else
                    {
                        aEffects.Add(cTextSource);
                    }
                }
            }
            else
            {
                aEffects.Add(cTextSource);
            }

            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;
            }
        }