/// <summary> /// Draw the border using draw event arguments and specified bounding rectangle. /// </summary> /// <param name="e">Draw event arguments.</param> /// <param name="rect">Bounding rectangle.</param> /// <remarks> /// This method is for internal use only. /// </remarks> public void Draw(FRPaintEventArgs e, RectangleF rect) { IGraphics g = e.Graphics; rect.X *= e.ScaleX; rect.Y *= e.ScaleY; rect.Width *= e.ScaleX; rect.Height *= e.ScaleY; if (Shadow) { //int d = (int)Math.Round(ShadowWidth * e.ScaleX); //Pen pen = e.Cache.GetPen(ShadowColor, d, DashStyle.Solid); //g.DrawLine(pen, rect.Right + d / 2, rect.Top + d, rect.Right + d / 2, rect.Bottom); //g.DrawLine(pen, rect.Left + d, rect.Bottom + d / 2, rect.Right + d, rect.Bottom + d / 2); float d = ShadowWidth * e.ScaleX; Brush brush = e.Cache.GetBrush(ShadowColor); g.FillRectangle(brush, rect.Left + d, rect.Bottom, rect.Width, d); g.FillRectangle(brush, rect.Right, rect.Top + d, d, rect.Height); } if (Lines != BorderLines.None) { // draw full frame as a rectangle with solid line only. Non-solid lines // should be drawn separately to avoid overlapping effect if (Lines == BorderLines.All && LeftLine.Equals(TopLine) && LeftLine.Equals(RightLine) && LeftLine.Equals(BottomLine) && LeftLine.Style == LineStyle.Solid) { Pen pen = e.Cache.GetPen(LeftLine.Color, (int)Math.Round(LeftLine.Width * e.ScaleX), LeftLine.DashStyle); g.DrawRectangle(pen, rect.Left, rect.Top, rect.Width, rect.Height); } else { if ((Lines & BorderLines.Left) != 0) { LeftLine.Draw(e, rect.Left, rect.Top, rect.Left, rect.Bottom, true, (Lines & BorderLines.Top) != 0, (Lines & BorderLines.Bottom) != 0); } if ((Lines & BorderLines.Right) != 0) { RightLine.Draw(e, rect.Right, rect.Top, rect.Right, rect.Bottom, false, (Lines & BorderLines.Top) != 0, (Lines & BorderLines.Bottom) != 0); } if ((Lines & BorderLines.Top) != 0) { TopLine.Draw(e, rect.Left, rect.Top, rect.Right, rect.Top, true, (Lines & BorderLines.Left) != 0, (Lines & BorderLines.Right) != 0); } if ((Lines & BorderLines.Bottom) != 0) { BottomLine.Draw(e, rect.Left, rect.Bottom, rect.Right, rect.Bottom, false, (Lines & BorderLines.Left) != 0, (Lines & BorderLines.Right) != 0); } } } }
/// <inheritdoc/> public override bool Equals(object obj) { Border b = obj as Border; return(b != null && Lines == b.Lines && LeftLine.Equals(b.LeftLine) && TopLine.Equals(b.TopLine) && RightLine.Equals(b.RightLine) && BottomLine.Equals(b.BottomLine) && Shadow == b.Shadow && ShadowColor == b.ShadowColor && ShadowWidth == b.ShadowWidth); }
/// <summary> /// Serializes the border. /// </summary> /// <param name="writer">Writer object.</param> /// <param name="prefix">Border property name.</param> /// <param name="c">Another Border to compare with.</param> /// <remarks> /// This method is for internal use only. /// </remarks> public void Serialize(FRWriter writer, string prefix, Border c) { if (Shadow != c.Shadow) { writer.WriteBool(prefix + ".Shadow", Shadow); } if (ShadowWidth != c.ShadowWidth) { writer.WriteFloat(prefix + ".ShadowWidth", ShadowWidth); } if (ShadowColor != c.ShadowColor) { writer.WriteValue(prefix + ".ShadowColor", ShadowColor); } if (!SimpleBorder) { if (Lines != c.Lines) { writer.WriteValue(prefix + ".Lines", Lines); } if (Lines != BorderLines.None || Color != Color.Black) { if (LeftLine.Equals(RightLine) && LeftLine.Equals(TopLine) && LeftLine.Equals(BottomLine) && c.LeftLine.Equals(c.RightLine) && c.LeftLine.Equals(c.TopLine) && c.LeftLine.Equals(c.BottomLine)) { LeftLine.Serialize(writer, prefix, c.LeftLine); } else { LeftLine.Serialize(writer, prefix + ".LeftLine", c.LeftLine); TopLine.Serialize(writer, prefix + ".TopLine", c.TopLine); RightLine.Serialize(writer, prefix + ".RightLine", c.RightLine); BottomLine.Serialize(writer, prefix + ".BottomLine", c.BottomLine); } } } else { LeftLine.Serialize(writer, prefix, c.LeftLine); } }