public void ExpandToInclude(RectangleD2D rect) { ExpandToInclude(rect.LeftTop); ExpandToInclude(rect.LeftBottom); ExpandToInclude(rect.RightTop); ExpandToInclude(rect.RightBottom); }
/// <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(this.Left, this.Top); if (!this.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 (this.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 (this.Top + availableSize.Height > _workArea.Bottom) availableSize.Height = _workArea.Bottom - this.Top; if (this.Left + availableSize.Width > _workArea.Right) availableSize.Width = _workArea.Right - this.Left; } if (availableSize.Height < 0) availableSize.Height = 0; if (availableSize.Width < 0) availableSize.Width = 0; return base.MeasureOverride(availableSize); }
public object Deserialize(object o, Altaxo.Serialization.Xml.IXmlDeserializationInfo info, object parent) { RectangleD2D s = null != o ? (RectangleD2D)o : new RectangleD2D(); s.X = info.GetDouble("X"); s.Y = info.GetDouble("Y"); s.Width = info.GetDouble("Width"); s.Height = info.GetDouble("Height"); return(s); }
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> /// Creates a rectangle that includes all the provided points. /// </summary> /// <param name="points">The points that the rectangle should include.</param> /// <returns>The rectangle that includes all the provided points.</returns> /// <exception cref="System.ArgumentException">Enumeration is empty!</exception> public static RectangleD2D NewRectangleIncludingAllPoints(IEnumerable <PointD2D> points) { var en = points.GetEnumerator(); if (!en.MoveNext()) { throw new ArgumentException("Enumeration is empty!", nameof(points)); } var result = new RectangleD2D(en.Current, PointD2D.Empty); while (en.MoveNext()) { result.ExpandToInclude(en.Current); } return(result); }
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); }
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); }
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); SolidBrush twhite = new SolidBrush(Color.FromArgb(128, 255, 255, 255)); RectangleF oA = (RectangleF)outerArea; RectangleF 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 }); SolidBrush 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 }); }
/// <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.CaptureMouse(); } 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) { if (brush != null) { brush.SetEnvironment(innerArea, BrushX.GetEffectiveMaximumResolution(g, 1)); g.FillRectangle(brush, (RectangleF)innerArea); } }
public void Draw(System.Drawing.Graphics g, RectangleD2D innerArea) { Draw(g, _brush, innerArea); }
/// <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); } this.ShiftPosition(dx, dy); ((ItemLocationDirectAutoSize)_location).SetSizeInAutoSizeMode(bounds.Size, false); bounds.Location = new PointD2D(0, 0); UpdateTransformationMatrix(); } }
public RectangleD2D MeasureItem(System.Drawing.Graphics g, RectangleD2D innerArea) { innerArea.Inflate(3.0 * _shadowLength / 2, 3.0 * _shadowLength / 2); return innerArea; }
/// <summary> /// Calculates the dimensions of the greatest (by area) rectangle included in an outer rectangle, where the inner rectangle is rotated/sheared/scaled. /// </summary> /// <param name="outerRectangle">The outer rectangle.</param> /// <param name="sx">SX component of the transformation matrix that is applied to the inner rectangle.</param> /// <param name="rx">RX component of the transformation matrix that is applied to the inner rectangle.</param> /// <param name="ry">RY component of the transformation matrix that is applied to the inner rectangle.</param> /// <param name="sy">SY component of the transformation matrix that is applied to the inner rectangle.</param> /// <returns>The inner rectangle with the greatest area that fits (when transformed with the transformation elements) into the outer rectangle. /// The position of the returned rectangle is calculated so that it centers into the outer rectangle.</returns> /// <exception cref="System.ArgumentOutOfRangeException"> /// X-Size of outer rectangle must be > 0 /// or /// Y-Size of outer rectangle must be > 0 /// </exception> public static RectangleD2D GetIncludedTransformedRectangle(this RectangleD2D outerRectangle, double sx, double rx, double ry, double sy) { PointD2D outerRectangleSize = outerRectangle.Size; if (!(outerRectangleSize.X > 0)) throw new ArgumentOutOfRangeException("X-Size of outer rectangle must be > 0"); if (!(outerRectangleSize.Y > 0)) throw new ArgumentOutOfRangeException("Y-Size of outer rectangle must be > 0"); double a = Math.Abs(sx); double b = Math.Abs(rx); double c = Math.Abs(ry); double d = Math.Abs(sy); double maxArea = 0; double sizeX = 0, sizeY = 0; double x, y, area; { // solution 1, which touches all walls double bcMad = b * c - a * d; if (bcMad != 0) { x = (b * outerRectangleSize.Y - d * outerRectangleSize.X) / bcMad; y = (c * outerRectangleSize.X - a * outerRectangleSize.Y) / bcMad; area = x * y; if (maxArea < area) { maxArea = area; sizeX = x; sizeY = y; } } } { // solution2 (which does not touch the left and right walls of the outer retangle var eps2 = outerRectangleSize.X - outerRectangleSize.Y * (b * c + a * d) / (2 * c * d); if (eps2 >= 0 && eps2 < outerRectangleSize.X) { area = outerRectangleSize.Y * outerRectangleSize.Y / (4 * c * d); x = outerRectangleSize.Y / (2 * c); y = outerRectangleSize.Y / (2 * d); if (maxArea < area) { maxArea = area; sizeX = x; sizeY = y; } } } { // solution3 (which does not touch the top and bottom walls of the outer rectangle var eps3 = outerRectangleSize.Y - outerRectangleSize.X * (b * c + a * d) / (2 * a * b); if (eps3 >= 0 && eps3 < outerRectangleSize.Y) { area = outerRectangleSize.X * outerRectangleSize.X / (4 * a * b); x = outerRectangleSize.X / (2 * a); y = outerRectangleSize.X / (2 * b); if (maxArea < area) { maxArea = area; sizeX = x; sizeY = y; } } } RectangleD2D innerRect = new RectangleD2D(); innerRect.ExpandToInclude(new PointD2D(sx * sizeX + rx * sizeY, ry * sizeX + sy * sizeY)); innerRect.ExpandToInclude(new PointD2D(sx * sizeX, ry * sizeX)); innerRect.ExpandToInclude(new PointD2D(rx * sizeY, sy * sizeY)); var outerMiddle = outerRectangle.CenterCenter; var innerMiddle = innerRect.CenterCenter; return new RectangleD2D((outerMiddle.X - innerMiddle.X), (outerMiddle.Y - innerMiddle.Y), sizeX, sizeY); }
public void Draw(System.Drawing.Graphics g, RectangleD2D innerArea) { g.FillRectangle(Brushes.White, (float)innerArea.Left, (float)innerArea.Top, (float)innerArea.Width, (float)innerArea.Height); }
public override void Paint(System.Type dctype, object dc, RectangleD2D cellRectangle, int nRow, Altaxo.Data.DataColumn data, bool bSelected) { Action<DateTimeColumnStyle, object, RectangleD2D, int, Altaxo.Data.DataColumn, bool> action; if (RegisteredPaintMethods.TryGetValue(dctype, out action)) action(this, dc, cellRectangle, nRow, data, bSelected); else throw new NotImplementedException("Paint method is not implemented for context type " + dc.GetType().ToString()); }
/// <summary> /// Sets the environment for the creation of the pen's brush. /// </summary> /// <param name="boundingRectangle">Bounding rectangle used for gradient textures.</param> /// <param name="maxEffectiveResolution">Maximum effective resolution in Dpi. This information is neccessary for repeatable texture brushes. You can calculate this using <see cref="M:BrushX.GetMaximumEffectiveResolution"/></param> /// <returns>True if changes to the pen's brush were made. False otherwise.</returns> public bool SetEnvironment(RectangleD2D boundingRectangle, double maxEffectiveResolution) { bool changed = false; if (_brush != null) { changed |= _brush.SetEnvironment(boundingRectangle, maxEffectiveResolution); } if (changed && null != _cachedPen) _cachedPen.Brush = _brush.Brush; return changed; }
private static void DateTimeColumnStyle_Paint(Altaxo.Worksheet.DateTimeColumnStyle thiss, object drawingContext, RectangleD2D cellRect, int nRow, Altaxo.Data.DataColumn data, bool bSelected) { DateTime t = ((Altaxo.Data.DateTimeColumn)data)[nRow]; string myString = (t.Kind == DateTimeKind.Unspecified || t.Kind == DateTimeKind.Local) ? t.ToString("yyyy-MM-dd HH:mm:ss.FFFFFFF") : t.ToString("o"); GeneralText_Paint(thiss, drawingContext, cellRect, myString, TextAlignment.Right, bSelected); }
private static void TextColumnStyle_Paint(Altaxo.Worksheet.TextColumnStyle thiss, object drawingContext, RectangleD2D cellRect, int nRow, Altaxo.Data.DataColumn data, bool bSelected) { string myString = data[nRow].ToString(); GeneralText_Paint(thiss, drawingContext, cellRect, myString, TextAlignment.Right, bSelected); }
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); }
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); }
/// <summary> /// Calculates the dimensions of the greatest (by area) rectangle included in an outer rectangle, where the inner rectangle is rotated/sheared/scaled. /// </summary> /// <param name="outerRectangle">The outer rectangle.</param> /// <param name="sx">SX component of the transformation matrix that is applied to the inner rectangle.</param> /// <param name="rx">RX component of the transformation matrix that is applied to the inner rectangle.</param> /// <param name="ry">RY component of the transformation matrix that is applied to the inner rectangle.</param> /// <param name="sy">SY component of the transformation matrix that is applied to the inner rectangle.</param> /// <returns>The inner rectangle with the greatest area that fits (when transformed with the transformation elements) into the outer rectangle. /// The position of the returned rectangle is calculated so that it centers into the outer rectangle.</returns> /// <exception cref="System.ArgumentOutOfRangeException"> /// X-Size of outer rectangle must be > 0 /// or /// Y-Size of outer rectangle must be > 0 /// </exception> public static RectangleD2D GetIncludedTransformedRectangle(this RectangleD2D outerRectangle, double sx, double rx, double ry, double sy) { PointD2D outerRectangleSize = outerRectangle.Size; if (!(outerRectangleSize.X > 0)) { throw new ArgumentOutOfRangeException("X-Size of outer rectangle must be > 0"); } if (!(outerRectangleSize.Y > 0)) { throw new ArgumentOutOfRangeException("Y-Size of outer rectangle must be > 0"); } double a = Math.Abs(sx); double b = Math.Abs(rx); double c = Math.Abs(ry); double d = Math.Abs(sy); double maxArea = 0; double sizeX = 0, sizeY = 0; double x, y, area; { // solution 1, which touches all walls double bcMad = b * c - a * d; if (bcMad != 0) { x = (b * outerRectangleSize.Y - d * outerRectangleSize.X) / bcMad; y = (c * outerRectangleSize.X - a * outerRectangleSize.Y) / bcMad; area = x * y; if (maxArea < area) { maxArea = area; sizeX = x; sizeY = y; } } } { // solution2 (which does not touch the left and right walls of the outer retangle var eps2 = outerRectangleSize.X - outerRectangleSize.Y * (b * c + a * d) / (2 * c * d); if (eps2 >= 0 && eps2 < outerRectangleSize.X) { area = outerRectangleSize.Y * outerRectangleSize.Y / (4 * c * d); x = outerRectangleSize.Y / (2 * c); y = outerRectangleSize.Y / (2 * d); if (maxArea < area) { maxArea = area; sizeX = x; sizeY = y; } } } { // solution3 (which does not touch the top and bottom walls of the outer rectangle var eps3 = outerRectangleSize.Y - outerRectangleSize.X * (b * c + a * d) / (2 * a * b); if (eps3 >= 0 && eps3 < outerRectangleSize.Y) { area = outerRectangleSize.X * outerRectangleSize.X / (4 * a * b); x = outerRectangleSize.X / (2 * a); y = outerRectangleSize.X / (2 * b); if (maxArea < area) { maxArea = area; sizeX = x; sizeY = y; } } } var innerRect = new RectangleD2D(); innerRect.ExpandToInclude(new PointD2D(sx * sizeX + rx * sizeY, ry * sizeX + sy * sizeY)); innerRect.ExpandToInclude(new PointD2D(sx * sizeX, ry * sizeX)); innerRect.ExpandToInclude(new PointD2D(rx * sizeY, sy * sizeY)); var outerMiddle = outerRectangle.CenterCenter; var innerMiddle = innerRect.CenterCenter; return(new RectangleD2D((outerMiddle.X - innerMiddle.X), (outerMiddle.Y - innerMiddle.Y), sizeX, sizeY)); }
/// <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( DrawingContext dc, Altaxo.Worksheet.WorksheetLayout layout, Size viewSize, Rect clipRectangle, IAscendingIntegerCollection selectedDataColumns, IAscendingIntegerCollection selectedDataRows, IAscendingIntegerCollection selectedPropertyColumns, IAscendingIntegerCollection selectedPropertyRows, int horzScrollPos, int vertScrollPos ) { dc.PushClip(new RectangleGeometry(new Rect(0, 0, viewSize.Width, viewSize.Height))); 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, 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, 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, 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, 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, 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, cellRectangle, nRow, dataTable[nCol], bAreCellsSelected && bDataColumnIncluded && bDataRowIncluded); } } } }
/// <summary> /// Creates a rectangle that includes all the provided points. /// </summary> /// <param name="points">The points that the rectangle should include.</param> /// <returns>The rectangle that includes all the provided points.</returns> /// <exception cref="System.ArgumentException">Enumeration is empty!</exception> public static RectangleD2D NewRectangleIncludingAllPoints(IEnumerable<PointD2D> points) { var en = points.GetEnumerator(); if (!en.MoveNext()) throw new ArgumentException("Enumeration is empty!", nameof(points)); var result = new RectangleD2D(en.Current, PointD2D.Empty); while (en.MoveNext()) { result.ExpandToInclude(en.Current); } return result; }
/// <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() { MatrixD2D m = new MatrixD2D(); m.SetTranslationRotationShearxScale(AbsolutePivotPositionX, AbsolutePivotPositionY, -Rotation, ShearX, ScaleX, ScaleY); m.TranslatePrepend(AbsoluteVectorPivotToLeftUpper.X, AbsoluteVectorPivotToLeftUpper.Y); var s = this.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; }
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; }
/// <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; }
/// <summary> /// Copy constructor. /// </summary> /// <param name="from">Another HitTestData object to copy from.</param> public HitTestRectangularData(HitTestRectangularData from) { _hittedAreaInPageCoord = from._hittedAreaInPageCoord; this._pageScale = from._pageScale; this._transformation = new MatrixD2D(from._transformation); }
public void Draw(Graphics g, BrushX brush, RectangleD2D innerArea) { throw new NotImplementedException(); }
public void Draw(System.Drawing.Graphics g, RectangleD2D innerArea) { g.DrawRectangle(Pens.Black, (float)innerArea.Left, (float)innerArea.Top, (float)innerArea.Width, (float)innerArea.Height); }
public void Paint(Graphics g, IPlotArea layer, int axisnumber) { if (!_showGrid) return; Scale axis = layer.Scales[axisnumber]; TickSpacing ticking = layer.Scales[axisnumber].TickSpacing; RectangleD2D layerRect = new RectangleD2D(PointD2D.Empty, layer.Size); if (_showZeroOnly) { Altaxo.Data.AltaxoVariant 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); } } }
public void FindGraphObjectInRootLayerRectangle(RectangleD2D rectRootLayerCoordinates, out List<IHitTestObject> foundObjects) { foundObjects = new List<IHitTestObject>(); var hitData = new HitTestRectangularData(rectRootLayerCoordinates, this.ZoomFactor); RootLayer.HitTest(hitData, foundObjects); }