Esempio n. 1
0
        /// <summary>
        /// Constructor
        /// </summary>
        public GameLogControl()
        {
            GameTextRectangles = new List <Rectangle[]>();
            CellRectangles     = new Rectangle[Columns.Length];
            Rectangle[] titleTextRects = new Rectangle[Columns.Length];
            int         left           = CellMargin;

            for (int i = 0; i < Columns.Length; i++)
            {
                GameHistoryColumn col = Columns[i];
                int right             = left + col.Width;
                CellRectangles[i] = new Rectangle(left, CellMargin, right - left, CellHeight);
                left = right + CellMargin;

                titleTextRects[i] = new Rectangle(new Point(left, CellMargin), TextRenderer.MeasureText(col.Title, TitleFont, CellRectangles[i].Size));
                if (col.TextFormat.HasFlag(TextFormatFlags.VerticalCenter))
                {
                    titleTextRects[i].Offset(0, (CellHeight - titleTextRects[i].Height) / 2);
                }
                if (col.TextFormat.HasFlag(TextFormatFlags.HorizontalCenter))
                {
                    titleTextRects[i].Offset((CellRectangles[i].Width - titleTextRects[i].Width) / 2, 0);
                }
            }
            GameTextRectangles.Add(titleTextRects);
            Games = new List <GameRecord>();

            InitializeComponent();
        }
Esempio n. 2
0
        /// <summary>
        /// Adda game to history
        /// </summary>
        /// <param name="gr">Game record to add</param>
        /// <param name="shouldInvalidate">Should window be redrawn</param>
        public void AddGameRecord(GameRecord gr, bool shouldInvalidate = true)
        {
            GameTextRectangles.Insert(1, new Rectangle[Columns.Length]);
            // Move all existing rectangles down
            for (int i = 2; i < GameTextRectangles.Count; i++)
            {
                for (int j = 0; j < GameTextRectangles[i].Length; j++)
                {
                    GameTextRectangles[i][j].Offset(0, CellHeight + CellMargin);
                }
            }

            int left = CellMargin;

            for (int i = 0; i < Columns.Length; i++)
            {
                GameHistoryColumn col  = Columns[i];
                string            text = gr.ReadPropertyAsString(col.PropertyName);
                GameTextRectangles[1][i] = new Rectangle(new Point(left, CellMargin + CellHeight + CellMargin), TextRenderer.MeasureText(text, ListFont, CellRectangles[i].Size));
                left += col.Width + CellMargin;
                if (col.TextFormat.HasFlag(TextFormatFlags.VerticalCenter))
                {
                    GameTextRectangles[1][i].Offset(0, (CellHeight - GameTextRectangles[1][i].Height) / 2);
                }
                if (col.TextFormat.HasFlag(TextFormatFlags.HorizontalCenter))
                {
                    GameTextRectangles[1][i].Offset((CellRectangles[i].Width - GameTextRectangles[1][i].Width) / 2, 0);
                }
            }
            GameLogDisplay.Width  = BestWidth;
            GameLogDisplay.Height = BestHeight;

            if (shouldInvalidate)
            {
                Invalidate();
            }
        }