using System.Drawing;
using System.ComponentModel;
using FastReport.Utils;
using System.Drawing.Design;
namespace FastReport
{
///
/// Represents a single highlight condition used by the property
/// of the .
///
public class HighlightCondition : StyleBase
{
#region Fields
private string expression;
private bool visible;
#endregion
#region Properties
///
/// Gets or sets a highlight expression.
///
///
/// This property can contain any valid boolean expression. If value of this expression is true,
/// the fill and font settings will be applied to the TextObject.
///
[Editor("FastReport.TypeEditors.ExpressionEditor, FastReport", typeof(UITypeEditor))]
public string Expression
{
get { return expression; }
set { expression = value; }
}
///
/// Gets or sets the visibility flag.
///
///
/// If this property is set to false, the Text object will be hidden if the
/// condition is met.
///
public bool Visible
{
get { return visible; }
set { visible = value; }
}
#endregion
#region Public Methods
///
public override void Serialize(FRWriter writer)
{
HighlightCondition c = writer.DiffObject as HighlightCondition;
writer.ItemName = "Condition";
if (Expression != c.Expression)
writer.WriteStr("Expression", Expression);
if (Visible != c.Visible)
writer.WriteBool("Visible", Visible);
base.Serialize(writer);
}
///
public override void Assign(StyleBase source)
{
base.Assign(source);
Expression = (source as HighlightCondition).Expression;
Visible = (source as HighlightCondition).Visible;
}
///
/// Creates exact copy of this condition.
///
/// A copy of this condition.
public HighlightCondition Clone()
{
HighlightCondition result = new HighlightCondition();
result.Assign(this);
return result;
}
///
public override bool Equals(object obj)
{
HighlightCondition c = obj as HighlightCondition;
return c != null && Expression == c.Expression && Border.Equals(c.Border) && Fill.Equals(c.Fill) &&
TextFill.Equals(c.TextFill) && Font.Equals(c.Font) && Visible == c.Visible &&
ApplyBorder == c.ApplyBorder && ApplyFill == c.ApplyFill && ApplyTextFill == c.ApplyTextFill &&
ApplyFont == c.ApplyFont;
}
///
public override int GetHashCode()
{
return base.GetHashCode();
}
#endregion
///
/// Initializes a new instance of the class with default settings.
///
public HighlightCondition()
{
Expression = "";
TextFill = new SolidFill(Color.Red);
Visible = true;
ApplyBorder = false;
ApplyFill = false;
ApplyTextFill = true;
ApplyFont = false;
}
}
}