示例#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);
		}
示例#2
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);
			t.MaxTextWidth = cellRectangle.Width;
			t.TextAlignment = TextAlignment.Center;
			dc.DrawText(t, cellRectangle.Location); // ("[" + nRow + "]", _textFont, _textBrush, cellRectangle, _textFormat);
		}
示例#3
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);

			Altaxo.Data.DataColumnCollection 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);
			t.MaxTextWidth = numRectangle.Width;
			t.TextAlignment = TextAlignment.Left;
			dc.DrawText(t, numRectangle.Location);

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

			t = new FormattedText(data.Name, System.Globalization.CultureInfo.InvariantCulture, FlowDirection.LeftToRight, font, fontSize, txtBrush);
			t.MaxTextWidth = nameRectangle.Width;
			t.TextAlignment = TextAlignment.Center;
			dc.DrawText(t, nameRectangle.Location);
		}
示例#4
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);
			t.MaxTextWidth = cellRect.Width;
			t.TextAlignment = alignment;
			t.Trimming = TextTrimming.CharacterEllipsis;
			dc.DrawText(t, cellRectangle.Location);
		}