Exemplo n.º 1
0
    public void OnDrag(PointerEventData eventData)
    {
        if (!_onDrag)
        {
            return;
        }

        transform.position = new Vector2(transform.position.x + eventData.delta.x, transform.position.y + eventData.delta.y);
        if (eventData.pointerEnter && eventData.pointerEnter.name == "ScrollSlot")
        {
            ScrollSlot sSlot = eventData.pointerEnter.gameObject.GetComponent <ScrollSlot>();
            if (sSlot)
            {
                _newScrollSlot = sSlot;
            }
        }
        else if (eventData.pointerEnter && eventData.pointerEnter.name == "ScrollImage")
        {
            ScrollElement sRlement = eventData.pointerEnter.GetComponentInParent <ScrollElement>();
            ScrollSlot    sSlot    = null;
            if (sRlement)
            {
                sSlot = sRlement.GetScrollSlot();
            }

            if (sSlot)
            {
                _newScrollSlot = sSlot;
            }
        }
        else
        {
            _newScrollSlot = null;
        }
    }
Exemplo n.º 2
0
 public void RemoveFromSlot()
 {
     if (_scrollSlot)
     {
         _scrollSlot.RemoveFromSlot();
     }
     _scrollSlot = null;
     transform.SetParent(_startParent);
 }
Exemplo n.º 3
0
    public void OnEndDrag(PointerEventData eventData)
    {
        if (!_onDrag)
        {
            return;
        }

        if (_newScrollSlot && _newScrollSlot.ValidForChangeSlotSpell())
        {
            Image.raycastTarget = true;
            if (_newScrollSlot)
            {
                if (_scrollSlot)
                {
                    _scrollSlot.RemoveFromSlot();
                }
                transform.SetParent(_newScrollSlot.transform);
                transform.SetAsFirstSibling();
                _newScrollSlot.AddToSlot(this);
                _scrollSlot    = _newScrollSlot;
                _newScrollSlot = null;
            }
            else
            {
                if (_scrollSlot)
                {
                    _scrollSlot.RemoveFromSlot();
                }
                _scrollSlot = null;
                transform.SetParent(_startParent);
            }
        }
        else
        {
            if (_scrollSlot)
            {
                _scrollSlot.RemoveFromSlot();
            }
            Image.raycastTarget = true;
            _scrollSlot         = null;
            transform.SetParent(_startParent);
        }

        _onDrag = false;
    }
Exemplo n.º 4
0
        private async void ScrollThread()
        {
            int scrollPostion = 0;
            Queue <Headline> headlineQueue = new Queue <Headline>();

            scrollSlots = new List <ScrollSlot>();
            for (byte i = 0; i < maxScrollSlots; i++)
            {
                ScrollSlot scrollslot = new ScrollSlot(i * (fontsize + margin), new Headline(string.Empty, string.Empty, new DateTime()));
                scrollSlots.Add(scrollslot);
            }


            while (true)
            {
                headlineBox.Children.Clear();
                while (state)
                {
                    if (headlineQueue.Count == 0)
                    {
                        foreach (Headline hl in headlines)
                        {
                            headlineQueue.Enqueue(hl);
                        }
                    }
                    headlineBox.Children.Clear();

                    foreach (ScrollSlot sl in scrollSlots)
                    {
                        int currentPosition = sl.lastPosition;
                        int newPosition     = ((sl.position + scrollPostion) % ((int)widgetBox.Height + (fontsize))) - (fontsize + margin);

                        if (newPosition < currentPosition && headlineQueue.Count > 0) //slot is naar boven gesprongen
                        {
                            sl.headline = headlineQueue.Dequeue();
                        }

                        TextBlock tb = new TextBlock();
                        tb.FontSize      = fontsize;
                        tb.Foreground    = new SolidColorBrush(Colors.White);
                        tb.Padding       = new Thickness(0, 0, 70, 0);
                        tb.TextAlignment = TextAlignment.Right;
                        tb.Text          = sl.headline.ToString();
                        tb.Margin        = new Thickness(20, newPosition, 0, 0);
                        tb.TextWrapping  = TextWrapping.WrapWholeWords;

                        TextBlock date = new TextBlock();
                        date.FontSize      = fontsize;
                        date.FontWeight    = FontWeights.Bold;
                        date.Foreground    = new SolidColorBrush(Colors.White);
                        date.TextAlignment = TextAlignment.Right;
                        if (sl.headline.date.ToString("H:mm") != "0:00")
                        {
                            date.Text = sl.headline.date.ToString("H:mm");
                        }
                        date.Margin       = new Thickness(0, newPosition, 0, 0);
                        date.TextWrapping = TextWrapping.WrapWholeWords;
                        sl.lastPosition   = newPosition;

                        headlineBox.Children.Add(tb);
                        headlineBox.Children.Add(date);
                    }

                    scrollPostion += 1;

                    await Task.Delay(TimeSpan.FromMilliseconds(35));
                }
                await Task.Delay(TimeSpan.FromMilliseconds(35));
            }
        }