Esempio n. 1
0
        public static void PaintBackground(this Altaxo.Worksheet.ColumnStyle thiss, DrawingContext dc, RectangleD2D cellRectangle, bool bSelected)
        {
            var cellRect = cellRectangle.ToWpf();

            if (bSelected)
            {
                dc.DrawRectangle(thiss.DefaultSelectedBackgroundBrush.ToWpf(), null, cellRect);
            }
            else
            {
                dc.DrawRectangle(thiss.BackgroundBrush.ToWpf(), null, cellRect);
            }

            dc.DrawLine(thiss.CellBorder.ToWpf(), cellRect.BottomLeft, cellRect.BottomRight);
            dc.DrawLine(thiss.CellBorder.ToWpf(), cellRect.BottomRight, cellRect.TopRight);
        }
Esempio n. 2
0
        private static void ColumnHeaderStyle_Paint(Altaxo.Worksheet.ColumnHeaderStyle thiss, object drawingContext, RectangleD2D cellRect, int nRow, Altaxo.Data.DataColumn data, bool bSelected)
        {
            var  dc            = (DrawingContext)drawingContext;
            Rect cellRectangle = cellRect.ToWpf();

            thiss.PaintBackground(dc, cellRect, bSelected);

            var    dataColCol    = (Altaxo.Data.DataColumnCollection)AbsoluteDocumentPath.GetRootNodeImplementing(data, typeof(Altaxo.Data.DataColumnCollection));
            string columnnumber  = dataColCol.GetColumnNumber(data).ToString();
            string kindandgroup  = string.Format("({0}{1})", dataColCol.GetColumnKind(data).ToString(), dataColCol.GetColumnGroup(data));
            var    font          = WpfFontManager.ToWpf(thiss.TextFont);
            var    fontSize      = (thiss.TextFont.Size * 96) / 72;
            var    fontheight    = font.FontFamily.LineSpacing * fontSize;
            var    nameRectangle = cellRectangle;

            nameRectangle.Height = Math.Max(fontheight, cellRectangle.Height - fontheight);
            var numRectangle = cellRectangle;

            numRectangle.Height = fontheight;
            numRectangle.Y      = Math.Max(cellRectangle.Y + cellRectangle.Height - fontheight, cellRectangle.Y);

            var txtBrush = bSelected ? thiss.DefaultSelectedTextBrush.ToWpf() : thiss.TextBrush.ToWpf();

            FormattedText t;

            t = new FormattedText(columnnumber, System.Globalization.CultureInfo.InvariantCulture, FlowDirection.LeftToRight, font, fontSize, txtBrush)
            {
                MaxTextWidth  = numRectangle.Width,
                TextAlignment = TextAlignment.Left
            };
            dc.DrawText(t, numRectangle.Location);

            t = new FormattedText(kindandgroup, System.Globalization.CultureInfo.InvariantCulture, FlowDirection.LeftToRight, font, fontSize, txtBrush)
            {
                MaxTextWidth  = numRectangle.Width,
                TextAlignment = TextAlignment.Right
            };
            dc.DrawText(t, numRectangle.Location);

            t = new FormattedText(data.Name, System.Globalization.CultureInfo.InvariantCulture, FlowDirection.LeftToRight, font, fontSize, txtBrush)
            {
                MaxTextWidth  = nameRectangle.Width,
                TextAlignment = TextAlignment.Center
            };
            dc.DrawText(t, nameRectangle.Location);
        }
Esempio n. 3
0
        private static void GeneralText_Paint(Altaxo.Worksheet.ColumnStyle thiss, object drawingContext, RectangleD2D cellRect, string textToDraw, TextAlignment alignment, bool bSelected)
        {
            var  dc            = (DrawingContext)drawingContext;
            Rect cellRectangle = cellRect.ToWpf();

            thiss.PaintBackground(dc, cellRect, bSelected);

            var font     = WpfFontManager.ToWpf(thiss.TextFont);
            var fontSize = (thiss.TextFont.Size * 96) / 72;
            var txtBrush = bSelected ? thiss.DefaultSelectedTextBrush.ToWpf() : thiss.TextBrush.ToWpf();

            FormattedText t;

            t = new FormattedText(textToDraw, System.Globalization.CultureInfo.InvariantCulture, FlowDirection.LeftToRight, font, fontSize, txtBrush)
            {
                MaxTextWidth  = cellRect.Width,
                TextAlignment = alignment,
                Trimming      = TextTrimming.CharacterEllipsis
            };
            dc.DrawText(t, cellRectangle.Location);
        }
Esempio n. 4
0
        private static void RowHeaderStyle_Paint(Altaxo.Worksheet.RowHeaderStyle thiss, object drawingContext, RectangleD2D cellRect, int nRow, Altaxo.Data.DataColumn data, bool bSelected)
        {
            var  dc            = (DrawingContext)drawingContext;
            Rect cellRectangle = cellRect.ToWpf();

            thiss.PaintBackground(dc, cellRect, bSelected);

            string text = "[" + nRow + "]";

            var font     = WpfFontManager.ToWpf(thiss.TextFont);
            var fontSize = (thiss.TextFont.Size * 96) / 72;
            var txtBrush = bSelected ? thiss.DefaultSelectedTextBrush.ToWpf() : thiss.TextBrush.ToWpf();

            FormattedText t;

            t = new FormattedText(text, System.Globalization.CultureInfo.InvariantCulture, FlowDirection.LeftToRight, font, fontSize, txtBrush)
            {
                MaxTextWidth  = cellRectangle.Width,
                TextAlignment = TextAlignment.Center
            };
            dc.DrawText(t, cellRectangle.Location); // ("[" + nRow + "]", _textFont, _textBrush, cellRectangle, _textFormat);
        }