Ejemplo n.º 1
0
 public SlidingPosition(
     BadgeCaps device,
     MessageQueueItem item,
     SlidingDirection direction,
     Easing ease,
     float speed,
     float padding)
 {
     Item      = item;
     Direction = direction;
     Ease      = ease;
     Speed     = speed;
     Padding   = padding;
     if (IsVertical)
     {
         m_distance = Item.Element.ClipHeight - device.Height;
     }
     else
     {
         m_distance = Item.Element.ClipWidth - device.Width;
     }
     m_distance     += 2 * Padding;
     m_startOffset   = Padding;
     m_currOffset    = 0;
     m_totalDuration = m_distance / Speed;
 }
Ejemplo n.º 2
0
 public SlidingPosition2D(
     BadgeCaps device,
     MessageQueueItem item,
     float directionX,
     float directionY,
     Easing ease,
     float speed,
     float paddingX,
     float paddingY)
 {
     Item            = item;
     DirectionX      = directionX == 0.0f ? 0 : directionX > 0.0f ? 1.0f : -1.0f;
     DirectionY      = directionY == 0.0f ? 0 : directionY > 0.0f ? 1.0f : -1.0f;
     Ease            = ease;
     Speed           = speed;
     PaddingX        = paddingX;
     PaddingY        = paddingY;
     m_distanceX     = (Item.Element.ClipWidth - device.Width) + 2 * PaddingX;
     m_distanceY     = (Item.Element.ClipHeight - device.Height) + 2 * PaddingY;
     m_startOffsetX  = PaddingX;
     m_startOffsetY  = PaddingY;
     m_currOffsetX   = 0;
     m_currOffsetY   = 0;
     m_totalDuration = Math.Max(m_distanceX, m_distanceY) / Speed;
 }
Ejemplo n.º 3
0
 public SlidingTransition(
     BadgeCaps device,
     MessageQueueItem item1,
     MessageQueueItem item2,
     SlidingDirection direction,
     Easing ease,
     float speed,
     float?padding)
 {
     Item1     = item1;
     Item2     = item2;
     Direction = direction;
     Ease      = ease;
     Speed     = speed;
     if (IsVertical)
     {
         Padding       = padding.HasValue ? padding.Value : device.Height;
         m_startOffset = Item1.Element.RenderY;
         m_distance    = AnimHelper.Round(Item1.Element.ClipHeight + m_startOffset + Padding);
     }
     else
     {
         Padding       = padding.HasValue ? padding.Value : device.Width;
         m_startOffset = Item1.Element.RenderX;
         m_distance    = AnimHelper.Round(Item1.Element.ClipWidth + m_startOffset + Padding);
     }
     m_currOffset    = m_startOffset;
     m_totalDuration = m_distance / Speed;
 }
Ejemplo n.º 4
0
 public TimedDisplay(
     MessageQueueItem item,
     float duration)
 {
     Item     = item;
     Duration = duration;
 }
Ejemplo n.º 5
0
        void BeginTransition(MessageQueueItem from, MessageQueueItem to, float initialStep)
        {
            m_currentTransition = GetTransitionController(from, to);
            m_currentItem       = null;

            UpdateTransition(initialStep);
        }
Ejemplo n.º 6
0
 public NullTransition(
     MessageQueueItem item1,
     MessageQueueItem item2)
 {
     Item1 = item1;
     Item2 = item2;
 }
Ejemplo n.º 7
0
 IDisplayController GetDisplayController(MessageQueueItem item)
 {
     if (GetDisplay != null)
     {
         return(GetDisplay(item));
     }
     else
     {
         return(new TimedDisplay(item, 1.0f));
     }
 }
Ejemplo n.º 8
0
 ITransitionController GetTransitionController(MessageQueueItem item1, MessageQueueItem item2)
 {
     if (GetTransition != null)
     {
         return(GetTransition(item1, item2));
     }
     else
     {
         return(new NullTransition(item1, item2));
     }
 }
Ejemplo n.º 9
0
        public MessageQueueItem Enqueue(MessageQueueItem message, QueuePriority priority = QueuePriority.Medium, QueueLocation location = QueueLocation.Back)
        {
            lock (SyncRoot)
            {
                if (location == QueueLocation.Back)
                {
                    m_queue[(int)priority].Add(message);
                }
                else
                {
                    m_queue[(int)priority].Insert(0, message);
                }
            }

            return(message);
        }
Ejemplo n.º 10
0
        public MessageQueueItem Enqueue(MessageQueueItem message, QueuePriority priority = QueuePriority.Medium, QueueLocation location = QueueLocation.Back)
        {
            lock(SyncRoot)
            {
                if(location == QueueLocation.Back)
                {
                    m_queue[(int)priority].Add(message);
                }
                else
                {
                    m_queue[(int)priority].Insert(0, message);
                }
            }

            return message;
        }
Ejemplo n.º 11
0
        public MessageQueueItem Dequeue()
        {
            MessageQueueItem message = null;

            lock (SyncRoot)
            {
                for (int i = m_queue.Length - 1; i >= 0; --i)
                {
                    if (m_queue[i].Count > 0)
                    {
                        message = m_queue[i][0];
                        m_queue[i].RemoveAt(0);
                    }
                }
            }

            return(message);
        }
Ejemplo n.º 12
0
        public void Update(float dt)
        {
            if (m_currentTransition != null)
            {
                // step the transition
                m_currentTransition.Item1.Element.Update(dt);
                m_currentTransition.Item2.Element.Update(dt);
                UpdateTransition(dt);
            }
            else if (m_currentItem != null)
            {
                // step the current item
                m_currentItem.Element.Update(dt);
                m_currentItem.DisplayController.Update(dt);
                if (m_currentItem.DisplayController.IsFinished)
                {
                    float remTime = m_currentItem.DisplayController.OverTime;

                    // transition to the next item, if there is one
                    var nextItem = GetNext();
                    if (nextItem != null)
                    {
                        nextItem.Element.Update(remTime);
                        BeginTransition(m_currentItem, nextItem, remTime);
                    }
                }
            }
            else
            {
                // no item of transition is active? better get one...
                var nextItem = GetNext();
                if (nextItem != null)
                {
                    nextItem.Element.Update(0.0f);
                    var empty = new MessageQueueItem(new EmptyVisual(ClipWidth, ClipHeight));
                    BeginTransition(empty, nextItem, 0);
                }
            }
        }
Ejemplo n.º 13
0
 public SlidingPosition(
     MessageQueueItem item,
     SlidingDirection direction,
     Easing ease,
     float speed,
     float padding)
 {
     Item = item;
     Direction = direction;
     Ease = ease;
     Speed = speed;
     Padding = padding;
     if(IsVertical)
     {
         m_distance = Item.Element.ClipHeight - BadgeCaps.Height;
     }
     else
     {
         m_distance = Item.Element.ClipWidth - BadgeCaps.Width;
     }
     m_distance += 2 * Padding;
     m_startOffset = Padding;
     m_currOffset = 0;
     m_totalDuration = m_distance / Speed;
 }
Ejemplo n.º 14
0
 public TimedDisplay(
     MessageQueueItem item,
     float duration)
 {
     Item = item;
     Duration = duration;
 }
Ejemplo n.º 15
0
 public SlidingTransition(
     MessageQueueItem item1,
     MessageQueueItem item2,
     SlidingDirection direction,
     Easing ease,
     float speed,
     float? padding)
 {
     Item1 = item1;
     Item2 = item2;
     Direction = direction;
     Ease = ease;
     Speed = speed;
     if(IsVertical)
     {
         Padding = padding.HasValue ? padding.Value : BadgeCaps.Height;
         m_startOffset = Item1.Element.RenderY;
         m_distance = AnimHelper.Round(Item1.Element.ClipHeight + m_startOffset + Padding);
     }
     else
     {
         Padding = padding.HasValue ? padding.Value : BadgeCaps.Width;
         m_startOffset = Item1.Element.RenderX;
         m_distance = AnimHelper.Round(Item1.Element.ClipWidth + m_startOffset + Padding);
     }
     m_currOffset = m_startOffset;
     m_totalDuration = m_distance / Speed;
 }
Ejemplo n.º 16
0
 public SlidingPosition2D(
     MessageQueueItem item,
     float directionX,
     float directionY,
     Easing ease,
     float speed,
     float paddingX,
     float paddingY)
 {
     Item = item;
     DirectionX = directionX == 0.0f ? 0 : directionX > 0.0f ? 1.0f : -1.0f;
     DirectionY = directionY == 0.0f ? 0 : directionY > 0.0f ? 1.0f : -1.0f;
     Ease = ease;
     Speed = speed;
     PaddingX = paddingX;
     PaddingY = paddingY;
     m_distanceX = (Item.Element.ClipWidth - BadgeCaps.Width) + 2 * PaddingX;
     m_distanceY = (Item.Element.ClipHeight - BadgeCaps.Height) + 2 * PaddingY;
     m_startOffsetX = PaddingX;
     m_startOffsetY = PaddingY;
     m_currOffsetX = 0;
     m_currOffsetY = 0;
     m_totalDuration = Math.Max(m_distanceX, m_distanceY) / Speed;
 }
Ejemplo n.º 17
0
 public NullTransition(
     MessageQueueItem item1,
     MessageQueueItem item2)
 {
     Item1 = item1;
     Item2 = item2;
 }
Ejemplo n.º 18
0
        void UpdateTransition(float dt)
        {
            m_currentTransition.Update(dt);
            if(m_currentTransition.IsFinished)
            {
                float remTime = m_currentTransition.OverTime;

                // end the transition
                m_currentItem = m_currentTransition.Item2;
                m_currentTransition = null;

                m_currentItem.DisplayController.Update(remTime);
            }
        }
Ejemplo n.º 19
0
 ITransitionController GetTransitionController(MessageQueueItem item1, MessageQueueItem item2)
 {
     if(GetTransition != null)
     {
         return GetTransition(item1, item2);
     }
     else
     {
         return new NullTransition(item1, item2);
     }
 }
Ejemplo n.º 20
0
 IDisplayController GetDisplayController(MessageQueueItem item)
 {
     if(GetDisplay != null)
     {
         return GetDisplay(item);
     }
     else
     {
         return new TimedDisplay(item, 1.0f);
     }
 }
Ejemplo n.º 21
0
        void BeginTransition(MessageQueueItem from, MessageQueueItem to, float initialStep)
        {
            m_currentTransition = GetTransitionController(from, to);
            m_currentItem = null;

            UpdateTransition(initialStep);
        }
Ejemplo n.º 22
0
        public void Update(float dt)
        {
            if(m_currentTransition != null)
            {
                // step the transition
                m_currentTransition.Item1.Element.Update(dt);
                m_currentTransition.Item2.Element.Update(dt);
                UpdateTransition(dt);
            }
            else if(m_currentItem != null)
            {
                // step the current item
                m_currentItem.Element.Update(dt);
                m_currentItem.DisplayController.Update(dt);
                if(m_currentItem.DisplayController.IsFinished)
                {
                    float remTime = m_currentItem.DisplayController.OverTime;

                    // transition to the next item, if there is one
                    var nextItem = GetNext();
                    if(nextItem != null)
                    {
                        nextItem.Element.Update(remTime);
                        BeginTransition(m_currentItem, nextItem, remTime);
                    }
                }
            }
            else
            {
                // no item of transition is active? better get one...
                var nextItem = GetNext();
                if(nextItem != null)
                {
                    nextItem.Element.Update(0.0f);
                    var empty = new MessageQueueItem(new EmptyVisual(ClipWidth, ClipHeight));
                    BeginTransition(empty, nextItem, 0);
                }
            }
        }