public void AdjustRectangle(ref RectangleD2D r, StringAlignment horz, StringAlignment vert) { switch (vert) { case StringAlignment.Near: break; case StringAlignment.Center: r.Y -= 0.5 * r.Height; break; case StringAlignment.Far: r.Y -= r.Height; break; } switch (horz) { case StringAlignment.Near: break; case StringAlignment.Center: r.X -= 0.5 * r.Width; break; case StringAlignment.Far: r.X -= r.Width; break; } }
public RectangleD2D MeasureItem(System.Drawing.Graphics g, RectangleD2D innerArea) { innerArea.Inflate(_shadowLength / 2, _shadowLength / 2); innerArea.Width += _shadowLength; innerArea.Height += _shadowLength; return(innerArea); }
public void Draw(Graphics g, BrushX brush, RectangleD2D innerArea) { innerArea.Inflate(_shadowLength / 2, _shadowLength / 2); // Padding var outerArea = innerArea; outerArea.Inflate(_shadowLength, _shadowLength); brush.SetEnvironment(outerArea, BrushX.GetEffectiveMaximumResolution(g, 1)); g.FillRectangle(brush, (RectangleF)outerArea); var twhite = new SolidBrush(Color.FromArgb(128, 255, 255, 255)); var oA = (RectangleF)outerArea; var iA = (RectangleF)innerArea; g.FillPolygon(twhite, new PointF[] { new PointF(oA.Left, oA.Top), // upper left point new PointF(oA.Right, oA.Top), // go to the right new PointF(iA.Right, iA.Top), // go 45 deg left down in the upper right corner new PointF(iA.Left, iA.Top), // upper left corner of the inner rectangle new PointF(iA.Left, iA.Bottom), // lower left corner of the inner rectangle new PointF(oA.Left, oA.Bottom) // lower left corner }); var tblack = new SolidBrush(Color.FromArgb(128, 0, 0, 0)); g.FillPolygon(tblack, new PointF[] { new PointF(oA.Right, oA.Bottom), new PointF(oA.Right, oA.Top), new PointF(iA.Right, iA.Top), new PointF(iA.Right, iA.Bottom), // upper left corner of the inner rectangle new PointF(iA.Left, iA.Bottom), // lower left corner of the inner rectangle new PointF(oA.Left, oA.Bottom) // lower left corner }); }
public override void Paint(Graphics g, IPaintContext paintContext) { if (null == _cachedLayerSegment) // _privLayer should be set before in FixupInternalDataStructures { PaintErrorInvalidLayerType(g, paintContext); return; } if (_background == null) { _axisStyle.Paint(g, paintContext, _cachedLayerSegment, _cachedLayerSegment.GetAxisStyleInformation); } else { // if we have a background, we paint in a dummy bitmap in order to measure all items // the real painting is done later on after painting the background. using (var bmp = new Bitmap(4, 4)) { using (var gg = Graphics.FromImage(bmp)) { _axisStyle.Paint(gg, paintContext, _cachedLayerSegment, _cachedLayerSegment.GetAxisStyleInformation); } } } _cachedPath = _axisStyle.AxisLineStyle.GetObjectPath(_cachedLayerSegment, true); // calculate size information RectangleD2D bounds1 = _cachedPath.GetBounds(); if (_axisStyle.AreMinorLabelsEnabled) { var path = _axisStyle.MinorLabelStyle.GetSelectionPath(); if (path.PointCount > 0) { _cachedPath.AddPath(path, false); RectangleD2D bounds2 = path.GetBounds(); bounds1.ExpandToInclude(bounds2); } } if (_axisStyle.AreMajorLabelsEnabled) { var path = _axisStyle.MajorLabelStyle.GetSelectionPath(); if (path.PointCount > 0) { _cachedPath.AddPath(path, false); RectangleD2D bounds2 = path.GetBounds(); bounds1.ExpandToInclude(bounds2); } } ((ItemLocationDirectAutoSize)_location).SetSizeInAutoSizeMode(bounds1.Size, false); // size here is important only for selection, thus we set size silently if (_background != null) { bounds1.Expand(_backgroundPadding); _background.Draw(g, bounds1); _axisStyle.Paint(g, paintContext, _cachedLayerSegment, _cachedLayerSegment.GetAxisStyleInformation); } }
public bool IsCovering(RectangleD2D rect, MatrixD2D additionalTransform) { PointD2D pt; pt = _transformation.TransformPoint(additionalTransform.TransformPoint(new PointD2D(rect.X, rect.Y))); if (!_hittedAreaInPageCoord.Contains(pt)) { return(false); } pt = _transformation.TransformPoint(additionalTransform.TransformPoint(new PointD2D(rect.Right, rect.Y))); if (!_hittedAreaInPageCoord.Contains(pt)) { return(false); } pt = _transformation.TransformPoint(additionalTransform.TransformPoint(new PointD2D(rect.X, rect.Bottom))); if (!_hittedAreaInPageCoord.Contains(pt)) { return(false); } pt = _transformation.TransformPoint(additionalTransform.TransformPoint(new PointD2D(rect.Right, rect.Bottom))); if (!_hittedAreaInPageCoord.Contains(pt)) { return(false); } return(true); }
public void Draw(System.Drawing.Graphics g, BrushX brush, RectangleD2D innerArea) { if (brush != null) { brush.SetEnvironment(innerArea, BrushX.GetEffectiveMaximumResolution(g, 1)); g.FillRectangle(brush, (RectangleF)innerArea); } }
public override void Paint(System.Type dctype, object dc, RectangleD2D cellRectangle, int nRow, Altaxo.Data.DataColumn data, bool bSelected) { if (RegisteredPaintMethods.TryGetValue(dctype, out var action)) { action(this, dc, cellRectangle, nRow, data, bSelected); } else { throw new NotImplementedException("Paint method is not implemented for context type " + dc.GetType().ToString()); } }
private void DrawRectangleFromLTRB(Graphics g, PointD2D a, PointD2D b) { var rect = RectangleD2D.FromLTRB(a.X, a.Y, b.X, b.Y); Pen pen = Pens.Blue; g.DrawLine(pen, (float)a.X, (float)a.Y, (float)b.X, (float)a.Y); g.DrawLine(pen, (float)b.X, (float)a.Y, (float)b.X, (float)b.Y); g.DrawLine(pen, (float)b.X, (float)b.Y, (float)a.X, (float)b.Y); g.DrawLine(pen, (float)a.X, (float)b.Y, (float)a.X, (float)a.Y); // g.DrawRectangle(Pens.Blue,rect.X,rect.Y,rect.Width,rect.Height); }
/// <summary> /// Adjusts the position and auto size of this group shape according to the contained elements. Must be called after changing any of the contained elements. /// </summary> public void AdjustPosition() { RectangleD2D bounds = RectangleD2D.Empty; bool boundsInitialized = false; foreach (var e in _groupedObjects) { var p1 = new PointD2D(0, 0); var p2 = new PointD2D(1, 0); var p3 = new PointD2D(0, 1); var p4 = new PointD2D(1, 1); p1 = e.RelativeLocalToAbsoluteParentCoordinates(p1); p2 = e.RelativeLocalToAbsoluteParentCoordinates(p2); p3 = e.RelativeLocalToAbsoluteParentCoordinates(p3); p4 = e.RelativeLocalToAbsoluteParentCoordinates(p4); if (boundsInitialized) { bounds.ExpandToInclude(p1); } else { bounds = new RectangleD2D(p1.X, p1.Y, 0, 0); boundsInitialized = true; } bounds.ExpandToInclude(p2); bounds.ExpandToInclude(p3); bounds.ExpandToInclude(p4); } if (bounds != Bounds) { // adjust position in this way that bounds.X and bounds.Y get zero var dx = bounds.X; var dy = bounds.Y; foreach (var e in _groupedObjects) { e.ShiftPosition(-dx, -dy); } ShiftPosition(dx, dy); ((ItemLocationDirectAutoSize)_location).SetSizeInAutoSizeMode(bounds.Size, false); bounds.Location = new PointD2D(0, 0); UpdateTransformationMatrix(); } }
/// <summary> /// Gets the bounds of the root layer. /// </summary> /// <returns></returns> private RectangleD2D GetBounds() { var s = _rootLayer.Size; var p1 = _rootLayer.TransformCoordinatesFromHereToParent(new PointD2D(0, 0)); var p2 = _rootLayer.TransformCoordinatesFromHereToParent(new PointD2D(s.X, 0)); var p3 = _rootLayer.TransformCoordinatesFromHereToParent(new PointD2D(0, s.Y)); var p4 = _rootLayer.TransformCoordinatesFromHereToParent(new PointD2D(s.X, s.Y)); var r = new RectangleD2D(p1, PointD2D.Empty); r.ExpandToInclude(p2); r.ExpandToInclude(p3); r.ExpandToInclude(p4); return(r); }
/// <summary> /// Overrides the logic for determining the size of the dialog window. See remarks for details. /// </summary> /// <param name="availableSize"></param> /// <returns></returns> /// <remarks> /// There are two changes from the default behaviour: /// <para>(i) when the dialog is loaded, the size is adjusted so that it is not bigger than /// the available working area on the screen. If the initial position of the dialog is chosen so that the right lower corner of the dialog would be outside /// of the working area, it is adjusted so that it is inside the working area.</para> /// <para> /// If during the dialog is showed the size of the content changed, the dialog box size is adjusted so that the lower right corner of the dialog window would /// always be inside the working area. This does not apply if the user had manually changed the size of the dialog box before. /// </para> /// /// </remarks> protected override Size MeasureOverride(Size availableSize) { _workArea = Current.Gui.GetScreenInformation(Left, Top); var thisWindowPresentationSource = PresentationSource.FromVisual(this); var m = thisWindowPresentationSource.CompositionTarget.TransformToDevice; var thisDpiWidthFactor = m.M11; var thisDpiHeightFactor = m.M22; // TODO is this working for arrangments of monitors with different dpi settings, too? _workArea = new RectangleD2D(_workArea.X / thisDpiWidthFactor, _workArea.Y / thisDpiHeightFactor, _workArea.Width / thisDpiWidthFactor, _workArea.Height / thisDpiHeightFactor); if (!IsLoaded) // when the dialog is initially loaded { // adjust the size of the dialog box so that is is maximum the size of the working area if (availableSize.Height > _workArea.Height) { availableSize.Height = _workArea.Height; } if (availableSize.Width > _workArea.Width) { availableSize.Width = _workArea.Width; } } else if (SizeToContent == System.Windows.SizeToContent.WidthAndHeight) // when the content size changed and the user had not manually resized the box { // adjust the size of the dialog box so that it fits inside of the working area (without changing the position of the dialog if (Top + availableSize.Height > _workArea.Bottom) { availableSize.Height = _workArea.Bottom - Top; } if (Left + availableSize.Width > _workArea.Right) { availableSize.Width = _workArea.Right - Left; } } if (availableSize.Height < 0) { availableSize.Height = 0; } if (availableSize.Width < 0) { availableSize.Width = 0; } return(base.MeasureOverride(availableSize)); }
protected void MeasureBackground(Graphics g, double textWidth, double textHeight) { var fontInfo = FontInfo.Create(g, _font); double widthOfOne_n = Glyph.MeasureString(g, "n", _font).X; double widthOfThree_M = Glyph.MeasureString(g, "MMM", _font).X; double distanceXL = 0; // left distance bounds-text double distanceXR = 0; // right distance text-bounds double distanceYU = 0; // upper y distance bounding rectangle-string double distanceYL = 0; // lower y distance if (_background != null) { // the distance to the sides should be like the character n distanceXL = 0.25 * widthOfOne_n; // left distance bounds-text distanceXR = distanceXL; // right distance text-bounds distanceYU = fontInfo.cyDescent; // upper y distance bounding rectangle-string distanceYL = 0; // lower y distance } var size = new PointD2D((textWidth + distanceXL + distanceXR), (textHeight + distanceYU + distanceYL)); _cachedExtendedTextBounds = new RectangleD2D(PointD2D.Empty, size); var textRectangle = new RectangleD2D(new PointD2D(-distanceXL, -distanceYU), size); if (_background != null) { var backgroundRect = _background.MeasureItem(g, textRectangle); _cachedExtendedTextBounds.Offset(textRectangle.X - backgroundRect.X, textRectangle.Y - backgroundRect.Y); size = backgroundRect.Size; distanceXL = -backgroundRect.Left; distanceXR = (backgroundRect.Right - textWidth); distanceYU = -backgroundRect.Top; distanceYL = (backgroundRect.Bottom - textHeight); } //var xanchor = _location.PivotX.GetValueRelativeTo(size.X); //var yanchor = _location.PivotY.GetValueRelativeTo(size.Y); // this._leftTop = new PointD2D(-xanchor, -yanchor); ((ItemLocationDirectAutoSize)_location).SetSizeInAutoSizeMode(size, false); _cachedTextOffset = new PointD2D(distanceXL, distanceYU); }
/// <summary> /// Gets the absolute enclosing rectangle, taking into account ScaleX, ScaleY, Rotation and Shear (SSRS). /// </summary> /// <returns>The enclosing rectangle in absolute values.</returns> public RectangleD2D GetAbsoluteEnclosingRectangle() { var m = new MatrixD2D(); m.SetTranslationRotationShearxScale(AbsolutePivotPositionX, AbsolutePivotPositionY, -Rotation, ShearX, ScaleX, ScaleY); m.TranslatePrepend(AbsoluteVectorPivotToLeftUpper.X, AbsoluteVectorPivotToLeftUpper.Y); var s = AbsoluteSize; var p1 = m.TransformPoint(new PointD2D(0, 0)); var p2 = m.TransformPoint(new PointD2D(s.X, 0)); var p3 = m.TransformPoint(new PointD2D(0, s.Y)); var p4 = m.TransformPoint(new PointD2D(s.X, s.Y)); var r = new RectangleD2D(p1, PointD2D.Empty); r.ExpandToInclude(p2); r.ExpandToInclude(p3); r.ExpandToInclude(p4); return(r); }
/// <summary> /// Handles the mouse move event. /// </summary> /// <param name="position">Mouse position.</param> /// <param name="e">MouseEventArgs as provided by the view.</param> /// <returns>The next mouse state handler that should handle mouse events.</returns> public override void OnMouseMove(PointD2D position, MouseEventArgs e) { base.OnMouseMove(position, e); if (null != ActiveGrip) { PointD2D graphCoord = _grac.ConvertMouseToRootLayerCoordinates(position); ActiveGrip.MoveGrip(graphCoord); _wereObjectsMoved = true; _grac.RenderOverlay(); } else if (e.LeftButton == MouseButtonState.Pressed) { var diffPos = position - _positionLastMouseDownInMouseCoordinates; var oldRect = _rectangleSelectionArea_GraphCoordinates; if (null != _rectangleSelectionArea_GraphCoordinates || Math.Abs(diffPos.X) >= System.Windows.SystemParameters.MinimumHorizontalDragDistance || Math.Abs(diffPos.Y) >= System.Windows.SystemParameters.MinimumHorizontalDragDistance) { if (null == _rectangleSelectionArea_GraphCoordinates) { (_grac.ViewObject as IGraphView).CaptureMouseOnCanvas(); } var pt1 = _grac.ConvertMouseToRootLayerCoordinates(_positionLastMouseDownInMouseCoordinates); var rect = new RectangleD2D(pt1, PointD2D.Empty); rect.ExpandToInclude(_grac.ConvertMouseToRootLayerCoordinates(position)); _rectangleSelectionArea_GraphCoordinates = rect; } if (null != _rectangleSelectionArea_GraphCoordinates) { _grac.RenderOverlay(); } } }
public void Draw(System.Drawing.Graphics g, BrushX brush, RectangleD2D innerArea) { BrushX shadowBrush = null; if (object.ReferenceEquals(brush, _brush)) { if (null == _cachedShadowBrush) { _cachedShadowBrush = GetShadowBrush(brush); _cachedShadowBrush.ParentObject = this; } shadowBrush = _cachedShadowBrush; } else { shadowBrush = GetShadowBrush(brush); } innerArea.Inflate(_shadowLength / 2, _shadowLength / 2); // please note: m_Bounds is already extended to the shadow // first the shadow shadowBrush.SetEnvironment(innerArea, BrushX.GetEffectiveMaximumResolution(g, 1)); // shortCuts to floats var iArea = (RectangleF)innerArea; float shadowLength = (float)_shadowLength; g.TranslateTransform(shadowLength, shadowLength); g.FillRectangle(shadowBrush, iArea); g.TranslateTransform(-shadowLength, -shadowLength); brush.SetEnvironment(innerArea, BrushX.GetEffectiveMaximumResolution(g, 1)); g.FillRectangle(brush, iArea); g.DrawRectangle(Pens.Black, iArea.Left, iArea.Top, iArea.Width, iArea.Height); }
/// <summary> /// Paints part of the worksheet to the drawing context. Row and column header are always threaten as visible here. /// </summary> /// <param name="dc">Drawing context.</param> /// <param name="layout">Worksheet layout.</param> /// <param name="viewSize">Width and height of the viewing area (Pixel or Wpf coordinates).</param> /// <param name="clipRectangle">Bounds of the clipping region. Only that parts of the worksheet that are visible within the clipping region are drawn.</param> /// <param name="selectedDataColumns">Selected data columns.</param> /// <param name="selectedDataRows">Selected data rows.</param> /// <param name="selectedPropertyColumns">Selected property columns.</param> /// <param name="selectedPropertyRows">Selected property rows.</param> /// <param name="horzScrollPos">Horizontal scroll position (0 = first column visible).</param> /// <param name="vertScrollPos">Vertical scroll position (0 = first data column visible, negative values: one or more property columns visible).</param> public static void PaintTableArea( Graphics dc, Altaxo.Worksheet.WorksheetLayout layout, Size viewSize, RectangleD2D clipRectangle, IAscendingIntegerCollection selectedDataColumns, IAscendingIntegerCollection selectedDataRows, IAscendingIntegerCollection selectedPropertyColumns, IAscendingIntegerCollection selectedPropertyRows, int horzScrollPos, int vertScrollPos ) { var dataTable = layout.DataTable; bool bDrawColumnHeader = false; int firstTableRowToDraw = WA.GetFirstVisibleTableRow(clipRectangle.Top, layout, vertScrollPos); int numberOfTableRowsToDraw = WA.GetVisibleTableRows(clipRectangle.Top, clipRectangle.Bottom, layout, vertScrollPos); int firstPropertyColumnToDraw = WA.GetFirstVisiblePropertyColumn(clipRectangle.Top, layout, vertScrollPos); int numberOfPropertyColumnsToDraw = WA.GetVisiblePropertyColumns(clipRectangle.Top, clipRectangle.Bottom, layout, vertScrollPos); bool bAreColumnsSelected = selectedDataColumns.Count > 0; bool bAreRowsSelected = selectedDataRows.Count > 0; bool bAreCellsSelected = bAreRowsSelected || bAreColumnsSelected; bool bArePropertyColsSelected = selectedPropertyColumns.Count > 0; bool bArePropertyRowsSelected = selectedPropertyRows.Count > 0; bool bArePropertyCellsSelected = ArePropertyCellsSelected(dataTable, selectedPropertyColumns, selectedPropertyRows); int yShift = 0; var cellRectangle = new RectangleD2D(); double left, width; if (clipRectangle.Top < layout.ColumnHeaderStyle.Height) { bDrawColumnHeader = true; } // if neccessary, draw the row header (the most left column) if (clipRectangle.Left < layout.RowHeaderStyle.Width) { cellRectangle.Height = layout.ColumnHeaderStyle.Height; cellRectangle.Width = layout.RowHeaderStyle.Width; cellRectangle.X = 0; // if visible, draw the top left corner of the table if (bDrawColumnHeader) { cellRectangle.Y = 0; layout.RowHeaderStyle.PaintBackground(dc, (Rectangle)cellRectangle, false); } // if visible, draw property column header items yShift = WA.GetTopCoordinateOfPropertyColumn(firstPropertyColumnToDraw, layout, vertScrollPos); cellRectangle.Height = layout.PropertyColumnHeaderStyle.Height; for (int nPropCol = firstPropertyColumnToDraw, nInc = 0; nInc < numberOfPropertyColumnsToDraw; nPropCol++, nInc++) { cellRectangle.Y = yShift + nInc * layout.PropertyColumnHeaderStyle.Height; bool bPropColSelected = bArePropertyColsSelected && selectedPropertyColumns.Contains(nPropCol); layout.PropertyColumnHeaderStyle.Paint(dc, (Rectangle)cellRectangle, nPropCol, dataTable.PropCols[nPropCol], bPropColSelected); } } // draw the table row Header Items yShift = WA.GetTopCoordinateOfTableRow(firstTableRowToDraw, layout, vertScrollPos); cellRectangle.Height = layout.RowHeaderStyle.Height; for (int nRow = firstTableRowToDraw, nInc = 0; nInc < numberOfTableRowsToDraw; nRow++, nInc++) { cellRectangle.Y = yShift + nInc * layout.RowHeaderStyle.Height; layout.RowHeaderStyle.Paint(dc, (Rectangle)cellRectangle, nRow, null, bAreRowsSelected && selectedDataRows.Contains(nRow)); } if (clipRectangle.Bottom >= layout.ColumnHeaderStyle.Height || clipRectangle.Right >= layout.RowHeaderStyle.Width) { int firstColToDraw = WA.GetFirstAndNumberOfVisibleColumn(clipRectangle.Left, clipRectangle.Right, layout, horzScrollPos, out var numberOfColumnsToDraw); // draw the property columns for (int nPropCol = firstPropertyColumnToDraw, nIncPropCol = 0; nIncPropCol < numberOfPropertyColumnsToDraw; nPropCol++, nIncPropCol++) { Altaxo.Worksheet.ColumnStyle cs = layout.PropertyColumnStyles[dataTable.PropCols[nPropCol]]; bool bPropColSelected = bArePropertyColsSelected && selectedPropertyColumns.Contains(nPropCol); bool bPropColIncluded = bArePropertyColsSelected ? bPropColSelected : true; // Property cells are only included if the column is explicite selected cellRectangle.Y = WA.GetTopCoordinateOfPropertyColumn(nPropCol, layout, vertScrollPos); cellRectangle.Height = layout.PropertyColumnHeaderStyle.Height; for (int nCol = firstColToDraw, nIncCol = 0; nIncCol < numberOfColumnsToDraw; nCol++, nIncCol++) { if (nCol == firstColToDraw) { WA.GetXCoordinatesOfColumn(nCol, layout, horzScrollPos, out left, out width); cellRectangle.X = left; cellRectangle.Width = width; } else { cellRectangle.X += cellRectangle.Width; cellRectangle.Width = layout.DataColumnStyles[dataTable.DataColumns[nCol]].WidthD; } bool bPropRowSelected = bArePropertyRowsSelected && selectedPropertyRows.Contains(nCol); bool bPropRowIncluded = bArePropertyRowsSelected ? bPropRowSelected : true; cs.Paint(dc, (Rectangle)cellRectangle, nCol, dataTable.PropCols[nPropCol], bArePropertyCellsSelected && bPropColIncluded && bPropRowIncluded); } } // draw the cells for (int nCol = firstColToDraw, nIncCol = 0; nIncCol < numberOfColumnsToDraw; nCol++, nIncCol++) { Altaxo.Worksheet.ColumnStyle cs = layout.DataColumnStyles[dataTable.DataColumns[nCol]]; if (nCol == firstColToDraw) { WA.GetXCoordinatesOfColumn(nCol, layout, horzScrollPos, out left, out width); cellRectangle.X = left; cellRectangle.Width = width; } else { cellRectangle.X += cellRectangle.Width; cellRectangle.Width = cs.WidthD; } bool bColumnSelected = bAreColumnsSelected && selectedDataColumns.Contains(nCol); bool bDataColumnIncluded = bAreColumnsSelected ? bColumnSelected : true; bool bPropertyRowSelected = bArePropertyRowsSelected && selectedPropertyRows.Contains(nCol); if (bDrawColumnHeader) // must the column Header been drawn? { cellRectangle.Height = layout.ColumnHeaderStyle.Height; cellRectangle.Y = 0; layout.ColumnHeaderStyle.Paint(dc, (Rectangle)cellRectangle, 0, dataTable[nCol], bColumnSelected || bPropertyRowSelected); } yShift = WA.GetTopCoordinateOfTableRow(firstTableRowToDraw, layout, vertScrollPos); cellRectangle.Height = layout.RowHeaderStyle.Height; for (int nRow = firstTableRowToDraw, nIncRow = 0; nIncRow < numberOfTableRowsToDraw; nRow++, nIncRow++) { bool bRowSelected = bAreRowsSelected && selectedDataRows.Contains(nRow); bool bDataRowIncluded = bAreRowsSelected ? bRowSelected : true; cellRectangle.Y = yShift + nIncRow * layout.RowHeaderStyle.Height; cs.Paint(dc, (Rectangle)cellRectangle, nRow, dataTable[nCol], bAreCellsSelected && bDataColumnIncluded && bDataRowIncluded); } } } }
public static void Paint(this Altaxo.Worksheet.ColumnStyle thiss, DrawingContext dc, RectangleD2D cellRectangle, int nRow, Altaxo.Data.DataColumn data, bool bSelected) { thiss.Paint(typeof(DrawingContext), dc, cellRectangle, nRow, data, bSelected); }
public void Draw(System.Drawing.Graphics g, RectangleD2D innerArea) { Draw(g, _brush, innerArea); }
public static System.Drawing.RectangleF ToSysDraw(this RectangleD2D rect) { return(new System.Drawing.RectangleF((float)rect.X, (float)rect.Y, (float)rect.Width, (float)rect.Height)); }
public abstract void Paint(System.Type dctype, object dc, RectangleD2D cellRectangle, int nRow, Altaxo.Data.DataColumn data, bool bSelected);
protected void MeasureBackground(Graphics g, double textWidth, double textHeight) { var fontInfo = FontInfo.Create(g, _font); double widthOfOne_n = Glyph.MeasureString(g, "n", _font).X; double widthOfThree_M = Glyph.MeasureString(g, "MMM", _font).X; double distanceXL = 0; // left distance bounds-text double distanceXR = 0; // right distance text-bounds double distanceYU = 0; // upper y distance bounding rectangle-string double distanceYL = 0; // lower y distance if (this._background != null) { // the distance to the sides should be like the character n distanceXL = 0.25 * widthOfOne_n; // left distance bounds-text distanceXR = distanceXL; // right distance text-bounds distanceYU = fontInfo.cyDescent; // upper y distance bounding rectangle-string distanceYL = 0; // lower y distance } PointD2D size = new PointD2D((textWidth + distanceXL + distanceXR), (textHeight + distanceYU + distanceYL)); _cachedExtendedTextBounds = new RectangleD2D(PointD2D.Empty, size); RectangleD2D textRectangle = new RectangleD2D(new PointD2D(-distanceXL, -distanceYU), size); if (this._background != null) { var backgroundRect = this._background.MeasureItem(g, textRectangle); _cachedExtendedTextBounds.Offset(textRectangle.X - backgroundRect.X, textRectangle.Y - backgroundRect.Y); size = backgroundRect.Size; distanceXL = -backgroundRect.Left; distanceXR = (backgroundRect.Right - textWidth); distanceYU = -backgroundRect.Top; distanceYL = (backgroundRect.Bottom - textHeight); } //var xanchor = _location.PivotX.GetValueRelativeTo(size.X); //var yanchor = _location.PivotY.GetValueRelativeTo(size.Y); // this._leftTop = new PointD2D(-xanchor, -yanchor); ((ItemLocationDirectAutoSize)_location).SetSizeInAutoSizeMode(size, false); this._cachedTextOffset = new PointD2D(distanceXL, distanceYU); }
/// <summary> /// Constructor. /// </summary> /// <param name="hitAreaPageCoord">Page coordinates (unit: points).</param> /// <param name="pageScale">Current zoom factor, i.e. ration between displayed size on the screen and given size.</param> public HitTestRectangularData(RectangleD2D hitAreaPageCoord, double pageScale) { _hittedAreaInPageCoord = hitAreaPageCoord; _pageScale = pageScale; _transformation = new MatrixD2D(); }
public RectangleD2D MeasureItem(System.Drawing.Graphics g, RectangleD2D innerArea) { return(innerArea); }
public void Draw(Graphics g, BrushX brush, RectangleD2D innerArea) { throw new NotImplementedException(); }
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); }
/// <summary> /// Copy constructor. /// </summary> /// <param name="from">Another HitTestData object to copy from.</param> public HitTestRectangularData(HitTestRectangularData from) { _hittedAreaInPageCoord = from._hittedAreaInPageCoord; _pageScale = from._pageScale; _transformation = new MatrixD2D(from._transformation); }
public void Paint(Graphics g, IPlotArea layer, int axisnumber) { if (!_showGrid) { return; } Scale axis = layer.Scales[axisnumber]; TickSpacing ticking = layer.Scales[axisnumber].TickSpacing; var layerRect = new RectangleD2D(PointD2D.Empty, layer.Size); if (_showZeroOnly) { var var = new Altaxo.Data.AltaxoVariant(0.0); double rel = axis.PhysicalVariantToNormal(var); _majorPen.SetEnvironment(layerRect, BrushX.GetEffectiveMaximumResolution(g, 1)); if (rel >= 0 && rel <= 1) { if (axisnumber == 0) { layer.CoordinateSystem.DrawIsoline(g, MajorPen, new Logical3D(rel, 0), new Logical3D(rel, 1)); } else { layer.CoordinateSystem.DrawIsoline(g, MajorPen, new Logical3D(0, rel), new Logical3D(1, rel)); } //layer.DrawIsoLine(g, MajorPen, axisnumber, rel, 0, 1); } } else { double[] ticks; if (_showMinor) { _minorPen.SetEnvironment(layerRect, BrushX.GetEffectiveMaximumResolution(g, 1)); ticks = ticking.GetMinorTicksNormal(axis); for (int i = 0; i < ticks.Length; ++i) { if (axisnumber == 0) { layer.CoordinateSystem.DrawIsoline(g, MinorPen, new Logical3D(ticks[i], 0), new Logical3D(ticks[i], 1)); } else { layer.CoordinateSystem.DrawIsoline(g, MinorPen, new Logical3D(0, ticks[i]), new Logical3D(1, ticks[i])); } //layer.DrawIsoLine(g, MinorPen, axisnumber, ticks[i], 0, 1); } } MajorPen.SetEnvironment(layerRect, BrushX.GetEffectiveMaximumResolution(g, 1)); ticks = ticking.GetMajorTicksNormal(axis); for (int i = 0; i < ticks.Length; ++i) { if (axisnumber == 0) { layer.CoordinateSystem.DrawIsoline(g, MajorPen, new Logical3D(ticks[i], 0), new Logical3D(ticks[i], 1)); } else { layer.CoordinateSystem.DrawIsoline(g, MajorPen, new Logical3D(0, ticks[i]), new Logical3D(1, ticks[i])); } //layer.DrawIsoLine(g, MajorPen, axisnumber, ticks[i], 0, 1); } } }
/// <summary> /// Paints the axis style labels. /// </summary> /// <param name="g">Graphics environment.</param> /// <param name="coordSyst">The coordinate system. Used to get the path along the axis.</param> /// <param name="scale">Scale.</param> /// <param name="tickSpacing">If not <c>null</c>, this parameter provides a custom tick spacing that is used instead of the default tick spacing of the scale.</param> /// <param name="styleInfo">Information about begin of axis, end of axis.</param> /// <param name="outerDistance">Distance between axis and labels.</param> /// <param name="useMinorTicks">If true, minor ticks are shown.</param> public virtual void Paint(Graphics g, G2DCoordinateSystem coordSyst, Scale scale, TickSpacing tickSpacing, CSAxisInformation styleInfo, double outerDistance, bool useMinorTicks) { _cachedAxisStyleInfo = styleInfo; CSLineID styleID = styleInfo.Identifier; Scale raxis = scale; TickSpacing ticking = tickSpacing; _enclosingPath.Reset(); _enclosingPath.FillMode = FillMode.Winding; // with Winding also overlapping rectangles are selected GraphicsPath helperPath = new GraphicsPath(); Matrix math = new Matrix(); Logical3D r0 = styleID.GetLogicalPoint(styleInfo.LogicalValueAxisOrg); Logical3D r1 = styleID.GetLogicalPoint(styleInfo.LogicalValueAxisEnd); PointD2D outVector; Logical3D outer; var dist_x = outerDistance; // Distance from axis tick point to label var dist_y = outerDistance; // y distance from axis tick point to label // dist_x += this._font.SizeInPoints/3; // add some space to the horizontal direction in order to separate the chars a little from the ticks // next statement is necessary to have a consistent string length both // on 0 degree rotated text and rotated text // without this statement, the text is fitted to the pixel grid, which // leads to "steps" during scaling g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias; double[] relpositions; AltaxoVariant[] ticks; if (useMinorTicks) { relpositions = ticking.GetMinorTicksNormal(raxis); ticks = ticking.GetMinorTicksAsVariant(); } else { relpositions = ticking.GetMajorTicksNormal(raxis); ticks = ticking.GetMajorTicksAsVariant(); } if (!_suppressedLabels.IsEmpty) { List<AltaxoVariant> filteredTicks = new List<AltaxoVariant>(); List<double> filteredRelPositions = new List<double>(); for (int i = 0; i < ticks.Length; i++) { if (_suppressedLabels.ByValues.Contains(ticks[i])) continue; if (_suppressedLabels.ByNumbers.Contains(i)) continue; if (_suppressedLabels.ByNumbers.Contains(i - ticks.Length)) continue; filteredTicks.Add(ticks[i]); filteredRelPositions.Add(relpositions[i]); } ticks = filteredTicks.ToArray(); relpositions = filteredRelPositions.ToArray(); } IMeasuredLabelItem[] labels = _labelFormatting.GetMeasuredItems(g, _font, _stringFormat, ticks); double emSize = _font.Size; CSAxisSide labelSide = null != _labelSide ? _labelSide.Value : styleInfo.PreferredLabelSide; for (int i = 0; i < ticks.Length; i++) { double r = relpositions[i]; if (!Altaxo.Calc.RMath.IsInIntervalCC(r, -1000, 1000)) continue; outer = coordSyst.GetLogicalDirection(styleID.ParallelAxisNumber, labelSide); PointD2D tickorg = coordSyst.GetNormalizedDirection(r0, r1, r, outer, out outVector); PointD2D tickend = tickorg + outVector * outerDistance; PointD2D msize = labels[i].Size; PointD2D morg = tickend; if (_automaticRotationShift) { double alpha = _rotation * Math.PI / 180 - Math.Atan2(outVector.Y, outVector.X); double shift = msize.Y * 0.5 * Math.Abs(Math.Sin(alpha)) + (msize.X + _font.Size / 2) * 0.5 * Math.Abs(Math.Cos(alpha)); morg = morg + outVector * shift; } else { morg = morg.WithXPlus(outVector.X * _font.Size / 3); } RectangleD2D mrect = new RectangleD2D(morg, msize); if (_automaticRotationShift) AdjustRectangle(ref mrect, StringAlignment.Center, StringAlignment.Center); else AdjustRectangle(ref mrect, _horizontalAlignment, _verticalAlignment); math.Reset(); math.Translate((float)morg.X, (float)morg.Y); if (this._rotation != 0) { math.Rotate((float)-this._rotation); } math.Translate((float)(mrect.X - morg.X + emSize * _xOffset), (float)(mrect.Y - morg.Y + emSize * _yOffset)); System.Drawing.Drawing2D.GraphicsState gs = g.Save(); g.MultiplyTransform(math); if (this._backgroundStyle != null) _backgroundStyle.Draw(g, new RectangleD2D(PointD2D.Empty, msize)); _brush.SetEnvironment(new RectangleD2D(PointD2D.Empty, msize), BrushX.GetEffectiveMaximumResolution(g, 1)); labels[i].Draw(g, _brush, new PointF(0, 0)); g.Restore(gs); // Restore the graphics state helperPath.Reset(); helperPath.AddRectangle(new RectangleF(PointF.Empty, (SizeF)msize)); helperPath.Transform(math); _enclosingPath.AddPath(helperPath, true); } }
public void Draw(System.Drawing.Graphics g, RectangleD2D innerArea) { g.FillRectangle(Brushes.Black, (float)innerArea.Left, (float)innerArea.Top, (float)innerArea.Width, (float)innerArea.Height); }
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); }
/// <summary> /// Paints the axis style labels. /// </summary> /// <param name="g">Graphics environment.</param> /// <param name="coordSyst">The coordinate system. Used to get the path along the axis.</param> /// <param name="scale">Scale.</param> /// <param name="tickSpacing">If not <c>null</c>, this parameter provides a custom tick spacing that is used instead of the default tick spacing of the scale.</param> /// <param name="styleInfo">Information about begin of axis, end of axis.</param> /// <param name="outerDistance">Distance between axis and labels.</param> /// <param name="useMinorTicks">If true, minor ticks are shown.</param> public virtual void Paint(Graphics g, G2DCoordinateSystem coordSyst, Scale scale, TickSpacing tickSpacing, CSAxisInformation styleInfo, double outerDistance, bool useMinorTicks) { _cachedAxisStyleInfo = styleInfo; CSLineID styleID = styleInfo.Identifier; Scale raxis = scale; TickSpacing ticking = tickSpacing; _enclosingPath.Reset(); _enclosingPath.FillMode = FillMode.Winding; // with Winding also overlapping rectangles are selected var helperPath = new GraphicsPath(); var math = new Matrix(); Logical3D r0 = styleID.GetLogicalPoint(styleInfo.LogicalValueAxisOrg); Logical3D r1 = styleID.GetLogicalPoint(styleInfo.LogicalValueAxisEnd); Logical3D outer; var dist_x = outerDistance; // Distance from axis tick point to label var dist_y = outerDistance; // y distance from axis tick point to label // dist_x += this._font.SizeInPoints/3; // add some space to the horizontal direction in order to separate the chars a little from the ticks // next statement is necessary to have a consistent string length both // on 0 degree rotated text and rotated text // without this statement, the text is fitted to the pixel grid, which // leads to "steps" during scaling g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias; double[] relpositions; AltaxoVariant[] ticks; if (useMinorTicks) { relpositions = ticking.GetMinorTicksNormal(raxis); ticks = ticking.GetMinorTicksAsVariant(); } else { relpositions = ticking.GetMajorTicksNormal(raxis); ticks = ticking.GetMajorTicksAsVariant(); } if (!_suppressedLabels.IsEmpty) { var filteredTicks = new List <AltaxoVariant>(); var filteredRelPositions = new List <double>(); for (int i = 0; i < ticks.Length; i++) { if (_suppressedLabels.ByValues.Contains(ticks[i])) { continue; } if (_suppressedLabels.ByNumbers.Contains(i)) { continue; } if (_suppressedLabels.ByNumbers.Contains(i - ticks.Length)) { continue; } filteredTicks.Add(ticks[i]); filteredRelPositions.Add(relpositions[i]); } ticks = filteredTicks.ToArray(); relpositions = filteredRelPositions.ToArray(); } IMeasuredLabelItem[] labels = _labelFormatting.GetMeasuredItems(g, _font, _stringFormat, ticks); double emSize = _font.Size; CSAxisSide labelSide = null != _labelSide ? _labelSide.Value : styleInfo.PreferredLabelSide; for (int i = 0; i < ticks.Length; i++) { double r = relpositions[i]; if (!Altaxo.Calc.RMath.IsInIntervalCC(r, -1000, 1000)) { continue; } outer = coordSyst.GetLogicalDirection(styleID.ParallelAxisNumber, labelSide); PointD2D tickorg = coordSyst.GetNormalizedDirection(r0, r1, r, outer, out var outVector); PointD2D tickend = tickorg + outVector * outerDistance; PointD2D msize = labels[i].Size; PointD2D morg = tickend; if (_automaticRotationShift) { double alpha = _rotation * Math.PI / 180 - Math.Atan2(outVector.Y, outVector.X); double shift = msize.Y * 0.5 * Math.Abs(Math.Sin(alpha)) + (msize.X + _font.Size / 2) * 0.5 * Math.Abs(Math.Cos(alpha)); morg = morg + outVector * shift; } else { morg = morg.WithXPlus(outVector.X * _font.Size / 3); } var mrect = new RectangleD2D(morg, msize); if (_automaticRotationShift) { AdjustRectangle(ref mrect, StringAlignment.Center, StringAlignment.Center); } else { AdjustRectangle(ref mrect, _horizontalAlignment, _verticalAlignment); } math.Reset(); math.Translate((float)morg.X, (float)morg.Y); if (_rotation != 0) { math.Rotate((float)-_rotation); } math.Translate((float)(mrect.X - morg.X + emSize * _xOffset), (float)(mrect.Y - morg.Y + emSize * _yOffset)); System.Drawing.Drawing2D.GraphicsState gs = g.Save(); g.MultiplyTransform(math); if (_backgroundStyle != null) { _backgroundStyle.Draw(g, new RectangleD2D(PointD2D.Empty, msize)); } _brush.SetEnvironment(new RectangleD2D(PointD2D.Empty, msize), BrushX.GetEffectiveMaximumResolution(g, 1)); labels[i].Draw(g, _brush, new PointF(0, 0)); g.Restore(gs); // Restore the graphics state helperPath.Reset(); helperPath.AddRectangle(new RectangleF(PointF.Empty, (SizeF)msize)); helperPath.Transform(math); _enclosingPath.AddPath(helperPath, true); } }
public static Rect ToWpf(this RectangleD2D rect) { return(new Rect(rect.X, rect.Y, rect.Width, rect.Height)); }
/// <summary> /// Paints part of the worksheet to the drawing context. Row and column header are always threaten as visible here. /// </summary> /// <param name="dc">Drawing context.</param> /// <param name="layout">Worksheet layout.</param> /// <param name="viewSize">Width and height of the viewing area (Pixel or Wpf coordinates).</param> /// <param name="clipRectangle">Bounds of the clipping region. Only that parts of the worksheet that are visible within the clipping region are drawn.</param> /// <param name="selectedDataColumns">Selected data columns.</param> /// <param name="selectedDataRows">Selected data rows.</param> /// <param name="selectedPropertyColumns">Selected property columns.</param> /// <param name="selectedPropertyRows">Selected property rows.</param> /// <param name="horzScrollPos">Horizontal scroll position (0 = first column visible).</param> /// <param name="vertScrollPos">Vertical scroll position (0 = first data column visible, negative values: one or more property columns visible).</param> public static void PaintTableArea( Graphics dc, Altaxo.Worksheet.WorksheetLayout layout, Size viewSize, RectangleD2D clipRectangle, IAscendingIntegerCollection selectedDataColumns, IAscendingIntegerCollection selectedDataRows, IAscendingIntegerCollection selectedPropertyColumns, IAscendingIntegerCollection selectedPropertyRows, int horzScrollPos, int vertScrollPos ) { var dataTable = layout.DataTable; bool bDrawColumnHeader = false; int firstTableRowToDraw = WA.GetFirstVisibleTableRow(clipRectangle.Top, layout, vertScrollPos); int numberOfTableRowsToDraw = WA.GetVisibleTableRows(clipRectangle.Top, clipRectangle.Bottom, layout, vertScrollPos); int firstPropertyColumnToDraw = WA.GetFirstVisiblePropertyColumn(clipRectangle.Top, layout, vertScrollPos); int numberOfPropertyColumnsToDraw = WA.GetVisiblePropertyColumns(clipRectangle.Top, clipRectangle.Bottom, layout, vertScrollPos); bool bAreColumnsSelected = selectedDataColumns.Count > 0; bool bAreRowsSelected = selectedDataRows.Count > 0; bool bAreCellsSelected = bAreRowsSelected || bAreColumnsSelected; bool bArePropertyColsSelected = selectedPropertyColumns.Count > 0; bool bArePropertyRowsSelected = selectedPropertyRows.Count > 0; bool bArePropertyCellsSelected = ArePropertyCellsSelected(dataTable, selectedPropertyColumns, selectedPropertyRows); int yShift = 0; var cellRectangle = new RectangleD2D(); double left, width; if (clipRectangle.Top < layout.ColumnHeaderStyle.Height) { bDrawColumnHeader = true; } // if neccessary, draw the row header (the most left column) if (clipRectangle.Left < layout.RowHeaderStyle.Width) { cellRectangle.Height = layout.ColumnHeaderStyle.Height; cellRectangle.Width = layout.RowHeaderStyle.Width; cellRectangle.X = 0; // if visible, draw the top left corner of the table if (bDrawColumnHeader) { cellRectangle.Y = 0; layout.RowHeaderStyle.PaintBackground(dc, (Rectangle)cellRectangle, false); } // if visible, draw property column header items yShift = WA.GetTopCoordinateOfPropertyColumn(firstPropertyColumnToDraw, layout, vertScrollPos); cellRectangle.Height = layout.PropertyColumnHeaderStyle.Height; for (int nPropCol = firstPropertyColumnToDraw, nInc = 0; nInc < numberOfPropertyColumnsToDraw; nPropCol++, nInc++) { cellRectangle.Y = yShift + nInc * layout.PropertyColumnHeaderStyle.Height; bool bPropColSelected = bArePropertyColsSelected && selectedPropertyColumns.Contains(nPropCol); layout.PropertyColumnHeaderStyle.Paint(dc, (Rectangle)cellRectangle, nPropCol, dataTable.PropCols[nPropCol], bPropColSelected); } } // draw the table row Header Items yShift = WA.GetTopCoordinateOfTableRow(firstTableRowToDraw, layout, vertScrollPos); cellRectangle.Height = layout.RowHeaderStyle.Height; for (int nRow = firstTableRowToDraw, nInc = 0; nInc < numberOfTableRowsToDraw; nRow++, nInc++) { cellRectangle.Y = yShift + nInc * layout.RowHeaderStyle.Height; layout.RowHeaderStyle.Paint(dc, (Rectangle)cellRectangle, nRow, null, bAreRowsSelected && selectedDataRows.Contains(nRow)); } if (clipRectangle.Bottom >= layout.ColumnHeaderStyle.Height || clipRectangle.Right >= layout.RowHeaderStyle.Width) { int numberOfColumnsToDraw; int firstColToDraw = WA.GetFirstAndNumberOfVisibleColumn(clipRectangle.Left, clipRectangle.Right, layout, horzScrollPos, out numberOfColumnsToDraw); // draw the property columns for (int nPropCol = firstPropertyColumnToDraw, nIncPropCol = 0; nIncPropCol < numberOfPropertyColumnsToDraw; nPropCol++, nIncPropCol++) { Altaxo.Worksheet.ColumnStyle cs = layout.PropertyColumnStyles[dataTable.PropCols[nPropCol]]; bool bPropColSelected = bArePropertyColsSelected && selectedPropertyColumns.Contains(nPropCol); bool bPropColIncluded = bArePropertyColsSelected ? bPropColSelected : true; // Property cells are only included if the column is explicite selected cellRectangle.Y = WA.GetTopCoordinateOfPropertyColumn(nPropCol, layout, vertScrollPos); cellRectangle.Height = layout.PropertyColumnHeaderStyle.Height; for (int nCol = firstColToDraw, nIncCol = 0; nIncCol < numberOfColumnsToDraw; nCol++, nIncCol++) { if (nCol == firstColToDraw) { WA.GetXCoordinatesOfColumn(nCol, layout, horzScrollPos, out left, out width); cellRectangle.X = left; cellRectangle.Width = width; } else { cellRectangle.X += cellRectangle.Width; cellRectangle.Width = layout.DataColumnStyles[dataTable.DataColumns[nCol]].WidthD; } bool bPropRowSelected = bArePropertyRowsSelected && selectedPropertyRows.Contains(nCol); bool bPropRowIncluded = bArePropertyRowsSelected ? bPropRowSelected : true; cs.Paint(dc, (Rectangle)cellRectangle, nCol, dataTable.PropCols[nPropCol], bArePropertyCellsSelected && bPropColIncluded && bPropRowIncluded); } } // draw the cells for (int nCol = firstColToDraw, nIncCol = 0; nIncCol < numberOfColumnsToDraw; nCol++, nIncCol++) { Altaxo.Worksheet.ColumnStyle cs = layout.DataColumnStyles[dataTable.DataColumns[nCol]]; if (nCol == firstColToDraw) { WA.GetXCoordinatesOfColumn(nCol, layout, horzScrollPos, out left, out width); cellRectangle.X = left; cellRectangle.Width = width; } else { cellRectangle.X += cellRectangle.Width; cellRectangle.Width = cs.WidthD; } bool bColumnSelected = bAreColumnsSelected && selectedDataColumns.Contains(nCol); bool bDataColumnIncluded = bAreColumnsSelected ? bColumnSelected : true; bool bPropertyRowSelected = bArePropertyRowsSelected && selectedPropertyRows.Contains(nCol); if (bDrawColumnHeader) // must the column Header been drawn? { cellRectangle.Height = layout.ColumnHeaderStyle.Height; cellRectangle.Y = 0; layout.ColumnHeaderStyle.Paint(dc, (Rectangle)cellRectangle, 0, dataTable[nCol], bColumnSelected || bPropertyRowSelected); } yShift = WA.GetTopCoordinateOfTableRow(firstTableRowToDraw, layout, vertScrollPos); cellRectangle.Height = layout.RowHeaderStyle.Height; for (int nRow = firstTableRowToDraw, nIncRow = 0; nIncRow < numberOfTableRowsToDraw; nRow++, nIncRow++) { bool bRowSelected = bAreRowsSelected && selectedDataRows.Contains(nRow); bool bDataRowIncluded = bAreRowsSelected ? bRowSelected : true; cellRectangle.Y = yShift + nIncRow * layout.RowHeaderStyle.Height; cs.Paint(dc, (Rectangle)cellRectangle, nRow, dataTable[nCol], bAreCellsSelected && bDataColumnIncluded && bDataRowIncluded); } } } }
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); }