Beispiel #1
0
		private void RollFeed(object cState)
		{
			try
			{
				while (true)
				{
					if (_cPreferences.nQueueLength > _cRoll.nEffectsQty)
					{
						Item[] aItems;
						lock (_aItems)
							aItems = _aItems.ToArray();
						DateTime dtNow = DateTime.Now;
						Composite cComposite;
						ushort nHeight, nTargetHeight, nLineHeight, nPauseDuration = 0, nPreviousPauseDuration = 0;
						float nSpeed = _cPreferences.nSpeed / 25;
						uint nFramesIn = 0;
						int nDelay;
						float nMiddleRounded;
						int nCorrectionPosition = 1;     //UNDONE   Через параметры!!
						btl.Roll.Keyframe[] aKeyframes = null;

						foreach (Item cItem in aItems.OrderBy(o => o.dt).Take(_cPreferences.nQueueLength - _cRoll.nEffectsQty).ToArray())
						{
							cItem.dt = dtNow.AddSeconds(1);
							cComposite = ItemParse(cItem);
							aKeyframes = null;
							if (0 < _cPreferences.nPause)
							{

								nPreviousPauseDuration = nPauseDuration;
								nDelay = _cRoll.nEffectsQty == 0 ? 0 : 1;
								nTargetHeight = _cRoll.stArea.nHeight;

								nHeight = nLineHeight = cComposite.stArea.nHeight;
								nPauseDuration = (ushort)(_cPreferences.nPause / 40);

								nMiddleRounded = (float)Math.Round((nTargetHeight + nHeight) / 2F);
								nFramesIn = (uint)Math.Round(nMiddleRounded / nSpeed);
								aKeyframes = new btl.Roll.Keyframe[] {
									new btl.Roll.Keyframe()
									{
										eType = btl.Roll.Keyframe.Type.linear,
										nFrame = 0,
										nPosition = nTargetHeight
									},
									new btl.Roll.Keyframe()
									{
										eType = btl.Roll.Keyframe.Type.linear,
										nFrame = nFramesIn,
										nPosition = nTargetHeight - nMiddleRounded + nCorrectionPosition
									},
									new btl.Roll.Keyframe()
									{
										eType = btl.Roll.Keyframe.Type.linear,
										nFrame = nFramesIn + nPauseDuration,
										nPosition = nTargetHeight - nMiddleRounded + nCorrectionPosition
									},
									new btl.Roll.Keyframe()
									{
										eType = btl.Roll.Keyframe.Type.linear,
										nFrame = 2 * nFramesIn + nPauseDuration,
										nPosition = nTargetHeight - 2 * nMiddleRounded - 1
									}
								};
							}
							_cRoll.EffectAdd(cComposite, aKeyframes, nPauseDuration + nFramesIn / 2);
						}
					}
					Thread.Sleep(1000);
				}
			}
			catch (ThreadAbortException)
			{ }
			catch (Exception ex)
			{
				(new Logger()).WriteError(ex);
			}
		}
Beispiel #2
0
        private void RollFeed(object cState)
        {
            try
            {
                DateTime dtFirsItem = DateTime.MinValue;
                int      nLoop      = 0;
                bool     bFirsTime  = true;
                while (true)
                {
                    if (_cPreferences.nQueueLength > _cRoll.nEffectsQty)
                    {
                        Item[] aItems;
                        lock (_aItems)
                            aItems = _aItems.ToArray();
                        DateTime            dtNow = DateTime.Now;
                        Composite           cComposite;
                        ushort              nHeight, nTargetHeight, nLineHeight, nPauseDuration = 0, nPreviousPauseDuration = 0;
                        float               nSpeed = _cPreferences.nSpeed / 25;
                        uint                nFramesIn = 0;
                        int                 nDelay, nTransDelay = 0;
                        float               nMiddleRounded;
                        int                 nCorrectionPosition = 1;             //UNDONE   Через параметры!!
                        btl.Roll.Keyframe[] aKeyframes          = null;
                        nTransDelay = _cPreferences.nDelay / 40;

                        foreach (Item cItem in aItems.OrderBy(o => o.dt).Take(_cPreferences.nQueueLength - _cRoll.nEffectsQty).ToArray())
                        {
                            dtNow = DateTime.Now;

                            if (_cPreferences.nLoops > 0)                                                          // т.е. тормозимся сами по окончании проигрывания набора элементов столько-то раз
                            {
                                if (dtFirsItem == DateTime.MinValue && aItems.Count(o => o.dt == dtFirsItem) == 1) // 1-й луп был - это последний элемент лупа
                                {
                                    dtFirsItem = dtNow;
                                    nLoop      = 1;
                                }
                                else if (dtFirsItem > DateTime.MinValue && dtFirsItem == cItem.dt)                                    // очередной луп был  - это последний элемент лупа
                                {
                                    dtFirsItem = dtNow;
                                    nLoop++;
                                }
                                if (nLoop == _cPreferences.nLoops)
                                {
                                    _RollFeedStop = true;
                                }
                            }

                            cItem.dt          = dtNow.AddSeconds(1);
                            cComposite        = ItemParse(cItem);
                            cComposite.stArea = new Area(_stAreaComposite.nLeft, _stAreaComposite.nTop, cComposite.stArea.nWidth, cComposite.stArea.nHeight);
                            aKeyframes        = null;
                            if (0 < _cPreferences.nPause)
                            {
                                nPreviousPauseDuration = nPauseDuration;
                                nDelay        = _cRoll.nEffectsQty == 0 ? 0 : 1;
                                nTargetHeight = _cRoll.stArea.nHeight;

                                nHeight        = nLineHeight = cComposite.stArea.nHeight;
                                nPauseDuration = (ushort)(_cPreferences.nPause / 40);

                                nMiddleRounded = (float)Math.Round((nTargetHeight + nHeight) / 2F);
                                nFramesIn      = (uint)Math.Round(nMiddleRounded / nSpeed);
                                aKeyframes     = new btl.Roll.Keyframe[] {
                                    new btl.Roll.Keyframe()
                                    {
                                        eType     = btl.Roll.Keyframe.Type.linear,
                                        nFrame    = 0,
                                        nPosition = nTargetHeight
                                    },
                                    new btl.Roll.Keyframe()
                                    {
                                        eType     = btl.Roll.Keyframe.Type.linear,
                                        nFrame    = nFramesIn,
                                        nPosition = nTargetHeight - nMiddleRounded + nCorrectionPosition
                                    },
                                    new btl.Roll.Keyframe()
                                    {
                                        eType     = btl.Roll.Keyframe.Type.linear,
                                        nFrame    = nFramesIn + nPauseDuration,
                                        nPosition = nTargetHeight - nMiddleRounded + nCorrectionPosition
                                    },
                                    new btl.Roll.Keyframe()
                                    {
                                        eType     = btl.Roll.Keyframe.Type.linear,
                                        nFrame    = 2 * nFramesIn + nPauseDuration,
                                        nPosition = nTargetHeight - 2 * nMiddleRounded - 1
                                    }
                                };
                            }
                            if (bFirsTime)
                            {
                                bFirsTime = false;
                                if (_cPLBackground != null)
                                {
                                    btl.Roll.Keyframe[] aBackKeyframes = new BTL.Play.Roll.Keyframe[1] {
                                        new btl.Roll.Keyframe()
                                        {
                                            eType = btl.Roll.Keyframe.Type.hold, nFrame = 0, nPosition = 0
                                        }
                                    };
                                    _cRoll.EffectAdd(_cPLBackground, aBackKeyframes, 0, false);
                                }
                                if (_cPLMask != null)
                                {
                                    btl.Roll.Keyframe[] aMaskKeyframes = new BTL.Play.Roll.Keyframe[1] {
                                        new btl.Roll.Keyframe()
                                        {
                                            eType = btl.Roll.Keyframe.Type.hold, nFrame = 0, nPosition = 0
                                        }
                                    };
                                    _cPLMask.cMask = new Mask()
                                    {
                                        eMaskType = DisCom.Alpha.mask_all_upper
                                    };
                                    _cRoll.EffectAdd(_cPLMask, aMaskKeyframes, 0, false);
                                }
                            }
                            if (_cPreferences.nLoops > 0)
                            {
                                _cLastAddedEffect = cComposite;
                            }
                            _cRoll.EffectAdd(cComposite, aKeyframes, (ushort)((nTransDelay + nFramesIn / 2) > 0 ? (nTransDelay + nFramesIn / 2) : 0));
                            if (_RollFeedStop)
                            {
                                return;
                            }
                        }
                    }
                    Thread.Sleep(1000);
                }
            }
            catch (ThreadAbortException)
            { }
            catch (Exception ex)
            {
                (new Logger()).WriteError(ex);
            }
        }