示例#1
0
        private void LayoutControls()
        {
            AutoScrollMargin = new Size(0, VerticalScroll.Visible ? SystemInformation.HorizontalScrollBarHeight : 0);

            DeckBuilderLayout layout = new DeckBuilderLayout(this);

            for (int column = 0; column < columns.Count; column++)
            {
                for (int row = 0; row < 2; row++)
                {
                    for (int cardNum = 0; cardNum < columns[column][row].Count; cardNum++)
                    {
                        // Set location and size.
                        DeckBuilderCard card = columns[column][row][cardNum];
                        layout.GetCardLeftAndTop(new CardPosition(column, row, cardNum), out var left, out var top);
                        card.Left   = (int)Math.Round(left);
                        card.Top    = (int)Math.Round(top);
                        card.Width  = (int)Math.Round(layout.cardWidth);
                        card.Height = (int)Math.Round(layout.cardHeight);

                        // Set child index.
                        Controls.SetChildIndex(card, columns[column][row].Count - cardNum);
                    }
                }
            }

            indicator.BringToFront();
            SetCardCounts();
        }
示例#2
0
        protected override void OnMouseMove(MouseEventArgs e)
        {
            base.OnMouseMove(e);
            if (dragged == CardPosition.None)
            {
                return;
            }
            var columnRowNum = GetPosFromClickCoor(e.X, e.Y, true);

            // Check if the hovered area has changed.
            if (columnRowNum == hovered)
            {
                return;
            }
            // Toggle visibility of indicator or change position.
            hovered = columnRowNum;
            if (hovered == CardPosition.None)
            {
                indicator.Hide();
            }
            else
            {
                // If the hovered position is immediately before or after the dragged card, don't draw the indicator.
                if (hovered.Col == dragged.Col && hovered.Row == dragged.Row && (hovered.Num == dragged.Num || hovered.Num == dragged.Num + 1))
                {
                    indicator.Hide();
                }
                // Otherwise, draw the indicator.
                else
                {
                    DeckBuilderLayout layout = new DeckBuilderLayout(this);
                    layout.GetCardLeftAndTop(hovered, out var left, out var top);
                    if (hovered.Num != 0 && hovered.Num == columns[hovered.Col][hovered.Row].Count)
                    {
                        // draw at bottom of last card
                        top += layout.cardHeight - layout.headerSize;
                    }
                    indicator.Left   = (int)Math.Round(left - 2);
                    indicator.Top    = (int)Math.Round(top - 1);
                    indicator.Width  = (int)Math.Round(layout.cardWidth + 4);
                    indicator.Height = 2;
                    indicator.Show();
                }
            }
            Invalidate();
        }