Exemplo n.º 1
0
        public static RectCard CreateSelector(Vector2f pos)
        {
            var selector = new RectCard();

            selector.PositionBehavior.Position = pos;
            selector.SizeBehavior.Size         = Vector2f.Zero;
            selector.SizeBehavior.HookNegativeSize(selector.PositionBehavior);
            selector.Classes.Add("card-selector");

            return(selector);
        }
Exemplo n.º 2
0
        //public static RectCard CreateHighlighter(Card card)
        //{
        //    //Console.WriteLine($"Creatin highlighter!! {card.GetType()} {card.Highlightable}");
        //    if (!card.Highlightable) return null;

        //    var highlighter = new RectCard();
        //    highlighter.PositionBehavior.Position = card.GetGlobalPosition();
        //    highlighter.SizeBehavior.Size = card.GetSize();
        //    highlighter.Clickable = false;
        //    highlighter.Classes.Add("card-highlighter");
        //    //highlighter.PositionBehavior.Update();

        //    //Console.WriteLine($"Created highlighter with size: {highlighter.SizeBehavior.Width} {highlighter.SizeBehavior.Height}, position {highlighter.PositionBehavior.Position.X}, {highlighter.PositionBehavior.Position.Y}");
        //    return highlighter;
        //}

        public static RectCard CreateHighlighter(IList <Card> cards)
        {
            if (cards.Count == 1 && !cards[0].Highlightable)
            {
                return(null);
            }
            if (cards.Count <= 0)
            {
                return(null);
            }

            var pos  = cards[0].GetGlobalPosition();
            var size = cards[0].GetSize() + pos;

            //Console.WriteLine($"Creating highlighter with BASE size x:{cards[0].GetSize().X} y:{cards[0].GetSize().Y}");

            var notedPos = cards[0].GetGlobalPosition();

            foreach (var card in cards)
            {
                var cardPos         = card.GetGlobalPosition();
                var cardRightBottom = card.GetSize() + cardPos;
                if (cardPos.X < pos.X)
                {
                    pos.X = cardPos.X;
                }
                if (cardPos.Y < pos.Y)
                {
                    pos.Y = cardPos.Y;
                }

                if (cardRightBottom.X > size.X)
                {
                    size.X = cardRightBottom.X;
                }

                if (cardRightBottom.Y > size.Y)
                {
                    size.Y = cardRightBottom.Y;
                }
            }

            size -= pos;


            var highlighter = new RectCard();

            highlighter.PositionBehavior.Position = pos;
            highlighter.SizeBehavior.Size         = size;
            highlighter.Clickable = false;
            highlighter.Classes.Add("card-highlighter");

            return(highlighter);
        }
Exemplo n.º 3
0
        private void Init()
        {
            this.Selected     = new List <Card>();
            this.Mouse        = new MouseState(this);
            this.Touch        = new TouchState(this);
            this.Keyboard     = new KeyboardState(this);
            this.InteropQueue = new InteropQueueState(this);
            this.Storage      = new StorageState(this);

            this.Selector         = RectFactory.CreateSelector(Vector2f.Zero);
            this.Selector.Visible = false;
        }
Exemplo n.º 4
0
        public void Init()
        {
            for (int i = 0; i < 20; i++)
            {
                var card = new RectCard();
                card.PositionBehavior.Position = new Vector2f(i * 30 + 300, i % 10 * 30 + 300);
                this.Cards.Add(card);

                if (i <= 10)
                {
                    var textCard = new TextCard();
                    textCard.PositionBehavior.Position = new Vector2f(i * 30 + 340, i % 10 * 30 + 300);
                    this.Cards.Add(textCard);
                }
                else
                {
                    var textBlockCard = new TextBlockCard();
                    textBlockCard.PositionBehavior.Position = new Vector2f(i * 30 + 340, i % 10 * 30 + 300);
                    textBlockCard.TextBehavior.Value        = "SHIFT & DRAG to multi-select";
                    this.Cards.Add(textBlockCard);
                }
            }


            var list = new VerticalListCard(false);

            list.AddChild(new RectCard());
            list.AddChild(new TextCard());

            var drop = new DropAreaCard();

            drop.OnDrop += (o, e) =>
            {
                foreach (var card in e.Cards) // add on drop
                {
                    if (this.Cards.Contains(card))
                    {
                        this.Cards.Remove(card);
                    }

                    list.AddChild(card);
                }
            };

            list.AddChild(drop);

            list.AddChild(new ButtonCard("Button1", (s, e) =>
            {
                var card = new TextCard();
                card.TextBehavior.Value = $"Added via button";
                //card.PositionBehavior.Position = new Vector2f(0, 10000); // order FIX NEEDED!
                list.AddChild(card);
            }));

            list.PositionBehavior.Position = new Vector2f(300, 740);

            var innerList = new HorizontalListCard(false, 10);

            innerList.AddChild(new RectCard());
            innerList.AddChild(new TextCard());
            innerList.AddChild(new RectCard());

            list.AddChild(innerList);

            this.Cards.Add(list);
        }