Skip to content

Commit

Permalink
Merge pull request #645 from FastReports/sync_branch_2023.3.13
Browse files Browse the repository at this point in the history
FastReport.OpenSource 2023.3.13
  • Loading branch information
0legK authored Nov 17, 2023
2 parents 7c1a078 + c53dde1 commit fd7be0d
Show file tree
Hide file tree
Showing 11 changed files with 331 additions and 46 deletions.
2 changes: 2 additions & 0 deletions FastReport.Base/Base.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ namespace FastReport
/// Specifies a set of actions that cannot be performed on the object in the design mode.
/// </summary>
[Flags]
[TypeConverter(typeof(FastReport.TypeConverters.FlagConverter))]
public enum Restrictions
{
/// <summary>
Expand Down Expand Up @@ -60,6 +61,7 @@ public enum Restrictions
/// Specifies a set of actions that can be performed on the object in the design mode.
/// </summary>
[Flags]
[TypeConverter(typeof(FastReport.TypeConverters.FlagConverter))]
public enum Flags
{
/// <summary>
Expand Down
1 change: 1 addition & 0 deletions FastReport.Base/Gauge/Radial/RadialGauge.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public enum RadialGaugeType
/// Radial Gauge position types
/// </summary>
[Flags]
[TypeConverter(typeof(FastReport.TypeConverters.FlagConverter))]
public enum RadialGaugePosition
{
/// <summary>
Expand Down
116 changes: 88 additions & 28 deletions FastReport.Base/PictureObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,6 @@ public int GrayscaleHash
set { grayscaleHash = value; }
}


/// <summary>
/// Gets or sets the color of the image that will be treated as transparent.
/// </summary>
Expand Down Expand Up @@ -180,8 +179,6 @@ public float Transparency
}
}



/// <summary>
/// Gets or sets a value indicating that the image should be tiled.
/// </summary>
Expand All @@ -193,8 +190,6 @@ public bool Tile
set { tile = value; }
}



/// <summary>
/// Gets or sets a value indicating that the image stored in the <see cref="Image"/>
/// property should be disposed when this object is disposed.
Expand All @@ -211,15 +206,6 @@ public bool ShouldDisposeImage
set { shouldDisposeImage = value; }
}










/// <summary>
/// Gets or sets a bitmap transparent image
/// </summary>
Expand Down Expand Up @@ -314,6 +300,38 @@ private void UpdateTransparentImage()
}
}
}

#if MONO
private GraphicsPath GetRoundRectPath(RectangleF rectangleF, float radius)
{
GraphicsPath gp = new GraphicsPath();
if (radius < 1)
radius = 1;
gp.AddLine(rectangleF.X + radius, rectangleF.Y, rectangleF.Width + rectangleF.X - radius, rectangleF.Y);
gp.AddArc(rectangleF.Width + rectangleF.X - radius - 1, rectangleF.Y, radius + 1, radius + 1, 270, 90);
gp.AddLine(rectangleF.Width + rectangleF.X, rectangleF.Y + radius, rectangleF.Width + rectangleF.X, rectangleF.Height + rectangleF.Y - radius);
gp.AddArc(rectangleF.Width + rectangleF.X - radius - 1, rectangleF.Height + rectangleF.Y - radius - 1, radius + 1, radius + 1, 0, 90);
gp.AddLine(rectangleF.Width + rectangleF.X - radius, rectangleF.Height + rectangleF.Y, rectangleF.X + radius, rectangleF.Height + rectangleF.Y);
gp.AddArc(rectangleF.X, rectangleF.Height + rectangleF.Y - radius - 1, radius + 1, radius + 1, 90, 90);
gp.AddLine(rectangleF.X, rectangleF.Height + rectangleF.Y - radius, rectangleF.X, rectangleF.Y + radius);
gp.AddArc(rectangleF.X, rectangleF.Y, radius, radius, 180, 90);
gp.CloseFigure();
return gp;
}
#else
private GraphicsPath GetRoundRectPath(RectangleF rectangleF, float radius)
{
GraphicsPath gp = new GraphicsPath();
if (radius < 1)
radius = 1;
gp.AddArc(rectangleF.Width + rectangleF.X - radius - 1, rectangleF.Y, radius + 1, radius + 1, 270, 90);
gp.AddArc(rectangleF.Width + rectangleF.X - radius - 1, rectangleF.Height + rectangleF.Y - radius - 1, radius + 1, radius + 1, 0, 90);
gp.AddArc(rectangleF.X, rectangleF.Height + rectangleF.Y - radius - 1, radius + 1, radius + 1, 90, 90);
gp.AddArc(rectangleF.X, rectangleF.Y, radius, radius, 180, 90);
gp.CloseFigure();
return gp;
}
#endif
#endregion

#region Protected Methods
Expand Down Expand Up @@ -373,12 +391,16 @@ public override void DrawImage(FRPaintEventArgs e)
drawWidth,
drawHeight);

GraphicsPath path = new GraphicsPath();
IGraphicsState state = g.Save();
try
{
//if (Config.IsRunningOnMono) // strange behavior of mono - we need to reset clip before we set new one
g.ResetClip();
g.SetClip(drawRect);
g.ResetClip();

EstablishImageForm(path, drawLeft, drawTop, drawWidth, drawHeight);

g.SetClip(path, CombineMode.Replace);
Report report = Report;
if (report != null && report.SmoothGraphics)
{
Expand Down Expand Up @@ -411,6 +433,8 @@ public override void DrawImage(FRPaintEventArgs e)
finally
{
g.Restore(state);
g.ResetClip();
path.Dispose();
}

if (IsPrinting)
Expand Down Expand Up @@ -552,17 +576,6 @@ public override void Deserialize(FRReader reader)
}
}






//static int number = 0;





/// <summary>
/// Loads image
/// </summary>
Expand Down Expand Up @@ -602,9 +615,56 @@ protected override void ResetImageIndex()
{
imageIndex = -1;
}

/// <summary>
/// The shape of the image is set using GraphicsPath
/// </summary>
/// <param name="path"></param>
/// <param name="drawLeft"></param>
/// <param name="drawTop"></param>
/// <param name="drawWidth"></param>
/// <param name="drawHeight"></param>
public void EstablishImageForm(GraphicsPath path, float drawLeft, float drawTop, float drawWidth, float drawHeight)
{
RectangleF drawRect = new RectangleF(
drawLeft,
drawTop,
drawWidth,
drawHeight);

switch (Shape)
{
case ShapeKind.Rectangle:
path.AddRectangle(drawRect);
break;
case ShapeKind.RoundRectangle:
float min = Math.Min(drawWidth, drawHeight) / 4;
path.AddPath(GetRoundRectPath(drawRect, min), false);
break;
case ShapeKind.Ellipse:
path.AddEllipse(drawLeft, drawTop, drawWidth, drawHeight);
break;
case ShapeKind.Triangle:
PointF[] triPoints =
{
new PointF(drawLeft + drawWidth, drawTop + drawHeight), new PointF(drawLeft, drawTop + drawHeight),
new PointF(drawLeft + drawWidth / 2, drawTop), new PointF(drawLeft + drawWidth, drawTop + drawHeight)
};
path.AddPolygon(triPoints);
break;
case ShapeKind.Diamond:
PointF[] diaPoints =
{
new PointF(drawLeft + drawWidth / 2, drawTop), new PointF(drawLeft + drawWidth, drawTop + drawHeight / 2),
new PointF(drawLeft + drawWidth / 2, drawTop + drawHeight), new PointF(drawLeft, drawTop + drawHeight / 2)
};
path.AddPolygon(diaPoints);
break;
}
}
#endregion

#region Report Engine
#region Report Engine


/// <inheritdoc/>
Expand Down
18 changes: 16 additions & 2 deletions FastReport.Base/PictureObjectBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ public abstract partial class PictureObjectBase : ReportComponentBase
private bool showErrorImage;
private PictureBoxSizeMode sizeModeInternal;
private ImageAlign imageAlign;
private ShapeKind shape;

#endregion Private Fields

Expand Down Expand Up @@ -333,6 +334,17 @@ public ImageAlign ImageAlign
set { imageAlign = value; }
}

/// <summary>
/// Gets or sets a shape kind.
/// </summary>
[DefaultValue(ShapeKind.Rectangle)]
[Category("Appearance")]
public ShapeKind Shape
{
get { return shape; }
set { shape = value; }
}


#endregion Public Properties

Expand All @@ -358,6 +370,7 @@ public ImageAlign ImageAlign
public PictureObjectBase()
{
sizeModeInternal = PictureBoxSizeMode.Zoom;
shape = ShapeKind.Rectangle;
padding = new Padding();
imageLocation = "";
dataColumn = "";
Expand Down Expand Up @@ -387,6 +400,7 @@ public override void Assign(Base source)
Grayscale = src.Grayscale;
ShowErrorImage = src.ShowErrorImage;
ImageAlign = src.ImageAlign;
Shape = src.Shape;
}
}

Expand Down Expand Up @@ -668,8 +682,6 @@ private void UpdateAlign(RectangleF drawRect, ref PointF upperLeft, ref PointF u
lowerLeft.Y += offsetY;
}



/// <summary>
/// Loads image
/// </summary>
Expand Down Expand Up @@ -776,6 +788,8 @@ public override void Serialize(FRWriter writer)
writer.WriteBool("ShowErrorImage", ShowErrorImage);
if (ImageAlign != ImageAlign.None)
writer.WriteValue("ImageAlign", ImageAlign);
if (Shape != c.Shape)
writer.WriteValue("Shape", Shape);
}

#endregion Public Methods
Expand Down
Loading

0 comments on commit fd7be0d

Please sign in to comment.