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; }
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; }
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; }
public TimedDisplay( MessageQueueItem item, float duration) { Item = item; Duration = duration; }
void BeginTransition(MessageQueueItem from, MessageQueueItem to, float initialStep) { m_currentTransition = GetTransitionController(from, to); m_currentItem = null; UpdateTransition(initialStep); }
public NullTransition( MessageQueueItem item1, MessageQueueItem item2) { Item1 = item1; Item2 = item2; }
IDisplayController GetDisplayController(MessageQueueItem item) { if (GetDisplay != null) { return(GetDisplay(item)); } else { return(new TimedDisplay(item, 1.0f)); } }
ITransitionController GetTransitionController(MessageQueueItem item1, MessageQueueItem item2) { if (GetTransition != null) { return(GetTransition(item1, item2)); } else { return(new NullTransition(item1, item2)); } }
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); }
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; }
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); }
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); } } }
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; }
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; }
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; }
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); } }
ITransitionController GetTransitionController(MessageQueueItem item1, MessageQueueItem item2) { if(GetTransition != null) { return GetTransition(item1, item2); } else { return new NullTransition(item1, item2); } }
IDisplayController GetDisplayController(MessageQueueItem item) { if(GetDisplay != null) { return GetDisplay(item); } else { return new TimedDisplay(item, 1.0f); } }
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); } } }