using FastReport.Utils;
using System.Drawing;
namespace FastReport
{
///
/// Represents the base class for the report style or the highlight condition.
///
public partial class StyleBase : IFRSerializable
{
#region Private Fields
private bool applyBorder;
private bool applyFill;
private bool applyFont;
private bool applyTextFill;
private Border border;
private FillBase fill;
private Font font;
private FillBase textFill;
#endregion Private Fields
#region Public Properties
///
/// Gets or sets a value determines that the border must be applied.
///
public bool ApplyBorder
{
get { return applyBorder; }
set { applyBorder = value; }
}
///
/// Gets or sets a value determines that the fill must be applied.
///
public bool ApplyFill
{
get { return applyFill; }
set { applyFill = value; }
}
///
/// Gets or sets a value determines that the font must be applied.
///
public bool ApplyFont
{
get { return applyFont; }
set { applyFont = value; }
}
///
/// Gets or sets a value determines that the text fill must be applied.
///
public bool ApplyTextFill
{
get { return applyTextFill; }
set { applyTextFill = value; }
}
///
/// Gets or sets a border.
///
public Border Border
{
get { return border; }
set { border = value; }
}
///
/// Gets or sets a fill.
///
public FillBase Fill
{
get { return fill; }
set { fill = value; }
}
///
/// Gets or sets a font.
///
public Font Font
{
get { return font; }
set { font = value; }
}
///
/// Gets or sets a text fill.
///
public FillBase TextFill
{
get { return textFill; }
set { textFill = value; }
}
#endregion Public Properties
#region Public Constructors
///
/// Initializes a new instance of the class with default settings.
///
public StyleBase()
{
Border = new Border();
Fill = new SolidFill();
TextFill = new SolidFill(Color.Black);
Font = GetDefaultFontInternal();
}
#endregion Public Constructors
#region Public Methods
///
/// Assigns values from another source.
///
/// Source to assign from.
public virtual void Assign(StyleBase source)
{
Border = source.Border.Clone();
Fill = source.Fill.Clone();
TextFill = source.TextFill.Clone();
Font = source.Font;
ApplyBorder = source.ApplyBorder;
ApplyFill = source.ApplyFill;
ApplyTextFill = source.ApplyTextFill;
ApplyFont = source.ApplyFont;
}
///
/// Deserializes the style.
///
/// Reader object.
///
/// This method is for internal use only.
///
public void Deserialize(FRReader reader)
{
reader.ReadProperties(this);
Fill.Deserialize(reader, "Fill");
TextFill.Deserialize(reader, "TextFill");
}
///
/// Serializes the style.
///
/// Writer object.
///
/// This method is for internal use only.
///
public virtual void Serialize(FRWriter writer)
{
StyleBase c = writer.DiffObject as StyleBase;
Border.Serialize(writer, "Border", c.Border);
Fill.Serialize(writer, "Fill", c.Fill);
TextFill.Serialize(writer, "TextFill", c.TextFill);
if ((writer.SerializeTo != SerializeTo.Preview || !Font.Equals(c.Font)) && writer.ItemName != "inherited")
writer.WriteValue("Font", Font);
if (ApplyBorder != c.ApplyBorder)
writer.WriteBool("ApplyBorder", ApplyBorder);
if (ApplyFill != c.ApplyFill)
writer.WriteBool("ApplyFill", ApplyFill);
if (ApplyTextFill != c.ApplyTextFill)
writer.WriteBool("ApplyTextFill", ApplyTextFill);
if (ApplyFont != c.ApplyFont)
writer.WriteBool("ApplyFont", ApplyFont);
}
#endregion Public Methods
}
}