コード例 #1
0
        private void DrawList(Graphics g)
        {
            // подготовить массив строк displayedValuesAndButtons
            displayedValuesAndButtons = new List <ChartIconDropDownRowCells>();
            var linesCount = Height / cellHeight;
            var linesSpare = linesCount;

            if (btnUpShown)
            {
                linesSpare--;
            }
            if (btnDownShown)
            {
                linesSpare--;
            }
            rowsDisplayed = Math.Min(linesSpare, formattedValues.Count - startItemIndex);

            if (btnUpShown)
            {
                displayedValuesAndButtons.Add(new ChartIconDropDownRowCells(ChartIconDropDownRowCells.RowType.ArrowUp));
            }
            for (var i = 0; i < rowsDisplayed; i++)
            {
                displayedValuesAndButtons.Add(formattedValues[i + startItemIndex]);
            }
            if (btnDownShown)
            {
                displayedValuesAndButtons.Add(new ChartIconDropDownRowCells(ChartIconDropDownRowCells.RowType.ArrowDown));
            }

            // подготовить словарь шрифтов
            var fonts =
                displayedValuesAndButtons.Where(c => c.cells != null).SelectMany(c => c.cells.Select(cell => cell.FontStyle ?? default(FontStyle)))
                .Distinct()
                .ToDictionary(
                    s => s, s => s == default(FontStyle) ? CellFont : new Font(CellFont, s));

            // нарисовать обычные ячейки с текстом
            using (var brushes = new BrushesStorage())
            {
                // фон
                var brush = brushes.GetBrush(clCellBack);
                g.FillRectangle(brush, 0, 0, Width - 1, Height - 1);

                // ячейки
                for (var i = 0; i < displayedValuesAndButtons.Count; i++)
                {
                    DrawCell(g, fonts, i == selectedCellIndex, brushes, i, displayedValuesAndButtons[i], rowsDisplayed);
                }

                // скроллинг
                scrollPadRect = null;
                if (btnDownShown || btnUpShown)
                {
                    DrawScrollBar(g, brushes);
                }
            }
        }
コード例 #2
0
        private void DrawText(Graphics g, Dictionary <FontStyle, Font> fonts,
                              bool highlighted, BrushesStorage brushes, int y,
                              ChartIconDropDownCell cell, int left)
        {
            var top = y * cellHeight;
            var cy  = top + cellHeight / 2;

            // вывести текст
            var fontBrush = brushes.GetBrush(!highlighted
                ? cell.ColorFont ?? ClCellFont
                : ClCellFontHl);

            g.DrawString(cell.CellString, fonts[cell.FontStyle ?? default(FontStyle)], fontBrush, left, cy,
                         new StringFormat {
                LineAlignment = StringAlignment.Center
            });
        }
コード例 #3
0
        private void DrawScrollBar(Graphics g, BrushesStorage brushes)
        {
            // нарисовать фон
            var brushBack = brushes.GetBrush(clCellBack);

            using (var pen = new Pen(ClCellFont))
            {
                var rect = new Rectangle(Width - ScrollBarWidth - 1, 0, ScrollBarWidth, Height - 1);
                g.FillRectangle(brushBack, rect);
                g.DrawRectangle(pen, rect);

                // нарисовать пипочку для перетягивания
                CalcScrollPadRect();
                g.FillRectangle(brushBack, scrollPadRect.Value);
                g.DrawRectangle(pen, scrollPadRect.Value);
            }
        }
コード例 #4
0
        private void DrawArrowUpDown(Graphics g, bool highlighted, BrushesStorage brushes, bool up, int cy,
                                     int itemsLeft)
        {
            var       cx = Width / 2;
            const int aSzM = 3, sSzL = 3;
            var       points = up
                             ? new[] { new Point(cx, cy - aSzM), new Point(cx + aSzM, cy + sSzL), new Point(cx - aSzM, cy + sSzL) }
                             : new[] { new Point(cx, cy + aSzM), new Point(cx + aSzM, cy - sSzL), new Point(cx - aSzM, cy - sSzL) };
            var brush = brushes.GetBrush(!highlighted ? ClCellFont : ClCellFontHl);

            g.FillPolygon(brush, points);

            // справа подписать - сколько осталось
            g.DrawString(itemsLeft.ToString(), CellFont, brush, cx + aSzM + 3, cy, new StringFormat
            {
                LineAlignment = StringAlignment.Center
            });
        }
コード例 #5
0
        private void DrawBack(Graphics g, bool highlighted, BrushesStorage brushes, int y)
        {
            if (!highlighted)
            {
                return;
            }

            // подсветить ячейку
            var top   = y * cellHeight;
            var brush = brushes.GetBrush(clCellBackHl);
            var area  = new Rectangle(0, top, Width - 1, cellHeight - 1);

            g.FillRectangle(brush, area);

            // обвести
            using (var pen = new Pen(ClCellFontHl))
            {
                g.DrawRectangle(pen, area);
            }
        }
コード例 #6
0
ファイル: DropDownList.cs プロジェクト: johnmensen/TradeSharp
        private void DrawText(Graphics g, Dictionary<FontStyle, Font> fonts,
            bool highlighted, BrushesStorage brushes, int y,
            ChartIconDropDownCell cell, int left)
        {
            var top = y * cellHeight;
            var cy = top + cellHeight / 2;

            // вывести текст
            var fontBrush = brushes.GetBrush(!highlighted
                ? cell.ColorFont ?? ClCellFont
                : ClCellFontHl);
            g.DrawString(cell.CellString, fonts[cell.FontStyle ?? default(FontStyle)], fontBrush, left, cy,
                new StringFormat { LineAlignment = StringAlignment.Center });
        }
コード例 #7
0
ファイル: DropDownList.cs プロジェクト: johnmensen/TradeSharp
        private void DrawScrollBar(Graphics g, BrushesStorage brushes)
        {
            // нарисовать фон
            var brushBack = brushes.GetBrush(clCellBack);
            using (var pen = new Pen(ClCellFont))
            {
                var rect = new Rectangle(Width - ScrollBarWidth - 1, 0, ScrollBarWidth, Height - 1);
                g.FillRectangle(brushBack, rect);
                g.DrawRectangle(pen, rect);

                // нарисовать пипочку для перетягивания
                CalcScrollPadRect();
                g.FillRectangle(brushBack, scrollPadRect.Value);
                g.DrawRectangle(pen, scrollPadRect.Value);
            }
        }
コード例 #8
0
ファイル: DropDownList.cs プロジェクト: johnmensen/TradeSharp
        private void DrawList(Graphics g)
        {
            // подготовить массив строк displayedValuesAndButtons
            displayedValuesAndButtons = new List<ChartIconDropDownRowCells>();
            var linesCount = Height / cellHeight;
            var linesSpare = linesCount;
            if (btnUpShown) linesSpare--;
            if (btnDownShown) linesSpare--;
            rowsDisplayed = Math.Min(linesSpare, formattedValues.Count - startItemIndex);

            if (btnUpShown)
                displayedValuesAndButtons.Add(new ChartIconDropDownRowCells(ChartIconDropDownRowCells.RowType.ArrowUp));
            for (var i = 0; i < rowsDisplayed; i++)
            {
                displayedValuesAndButtons.Add(formattedValues[i + startItemIndex]);
            }
            if (btnDownShown)
                displayedValuesAndButtons.Add(new ChartIconDropDownRowCells(ChartIconDropDownRowCells.RowType.ArrowDown));

            // подготовить словарь шрифтов
            var fonts =
                displayedValuesAndButtons.Where(c => c.cells != null).SelectMany(c => c.cells.Select(cell => cell.FontStyle ?? default(FontStyle)))
                                         .Distinct()
                                         .ToDictionary(
                                             s => s, s => s == default(FontStyle) ? CellFont : new Font(CellFont, s));
            // нарисовать обычные ячейки с текстом
            using (var brushes = new BrushesStorage())
            {
                // фон
                var brush = brushes.GetBrush(clCellBack);
                g.FillRectangle(brush, 0, 0, Width - 1, Height - 1);

                // ячейки
                for (var i = 0; i < displayedValuesAndButtons.Count; i++)
                {
                    DrawCell(g, fonts, i == selectedCellIndex, brushes, i, displayedValuesAndButtons[i], rowsDisplayed);
                }

                // скроллинг
                scrollPadRect = null;
                if (btnDownShown || btnUpShown)
                    DrawScrollBar(g, brushes);
            }
        }
コード例 #9
0
ファイル: DropDownList.cs プロジェクト: johnmensen/TradeSharp
        private void DrawBack(Graphics g, bool highlighted, BrushesStorage brushes, int y)
        {
            if (!highlighted) return;

            // подсветить ячейку
            var top = y * cellHeight;
            var brush = brushes.GetBrush(clCellBackHl);
            var area = new Rectangle(0, top, Width - 1, cellHeight - 1);
            g.FillRectangle(brush, area);

            // обвести
            using (var pen = new Pen(ClCellFontHl))
            {
                g.DrawRectangle(pen, area);
            }
        }
コード例 #10
0
ファイル: DropDownList.cs プロジェクト: johnmensen/TradeSharp
        private void DrawArrowUpDown(Graphics g, bool highlighted, BrushesStorage brushes, bool up, int cy,
            int itemsLeft)
        {
            var cx = Width / 2;
            const int aSzM = 3, sSzL = 3;
            var points = up
                             ? new[] { new Point(cx, cy - aSzM), new Point(cx + aSzM, cy + sSzL), new Point(cx - aSzM, cy + sSzL) }
                             : new[] { new Point(cx, cy + aSzM), new Point(cx + aSzM, cy - sSzL), new Point(cx - aSzM, cy - sSzL) };
            var brush = brushes.GetBrush(!highlighted ? ClCellFont : ClCellFontHl);
            g.FillPolygon(brush, points);

            // справа подписать - сколько осталось
            g.DrawString(itemsLeft.ToString(), CellFont, brush, cx + aSzM + 3, cy, new StringFormat
                {
                    LineAlignment = StringAlignment.Center
                });
        }