|
using System.Drawing;
using System;
using System.ComponentModel;
namespace dwf.tool
{
public class PCellStyle : IDisposable
{
[NonSerialized()]
static FontConverter fc = new FontConverter();
protected string font = "Tahoma 8";
[NonSerialized()]
protected Font _font = null;
[NonSerialized()]
protected Font _sfont = null;
[NonSerialized()]
protected StringFormat _format;
[DefaultValue((int)0)]
protected int round = 0;
[DefaultValue(0.0)]
protected double angle = 0.0;
[DefaultValue(true)]
protected bool alternate = true;
protected CellStyleBrush backBrush = null;
protected CellStyleBrush borderBrush = null;
protected CellStyleBrush fontBrush = null;
public PCellStyle()
{
_format = new StringFormat(StringFormatFlags.DisplayFormatControl | StringFormatFlags.LineLimit);
_format.LineAlignment = StringAlignment.Center;
//_format.Trimming = StringTrimming.None;
}
public bool Alternate
{
get { return this.alternate; }
set { alternate = value; }
}
public double Angle
{
get { return this.angle; }
set { angle = value; }
}
public StringFormat Format
{
get { return _format; }
set { _format = value; }
}
public Font Font
{
get
{
if (_font == null)
_font = (Font)fc.ConvertFromInvariantString(font);
return _font;
}
set
{
if (_font != value)
{
_font = value;
font = fc.ConvertToInvariantString(_font);
}
}
}
public Font SFont
{
get { return _sfont; }
set
{
_sfont = value;
}
}
public int Round
{
get { return round; }
set { round = value; }
}
public CellStyleBrush BackBrush
{
get
{
if (backBrush == null)
backBrush = new CellStyleBrush();
return this.backBrush;
}
set
{
backBrush = value;
}
}
public CellStyleBrush BorderBrush
{
get
{
if (borderBrush == null)
borderBrush = new CellStyleBrush();
return this.borderBrush;
}
set
{
borderBrush = value;
}
}
public CellStyleBrush FontBrush
{
get
{
if (fontBrush == null)
{
fontBrush = new CellStyleBrush();
fontBrush.Color = SystemColors.ControlText;
fontBrush.SColor = SystemColors.ControlText;
fontBrush.HColor = SystemColors.ControlText;
fontBrush.PColor = SystemColors.ControlText;
fontBrush.AColor = SystemColors.ControlText;
}
return this.fontBrush;
}
set
{
fontBrush = value;
}
}
public PCellStyle Clone()
{
PCellStyle lcs = new PCellStyle();
if (backBrush != null)
lcs.backBrush = (CellStyleBrush)backBrush.Clone();
if (borderBrush != null)
lcs.borderBrush = (CellStyleBrush)borderBrush.Clone();
if (fontBrush != null)
lcs.fontBrush = (CellStyleBrush)fontBrush.Clone();
lcs.font = font;
lcs.Format = (StringFormat)_format.Clone();
lcs.Round = round;
return lcs;
}
public void Dispose()
{
if (_sfont != null)
_sfont.Dispose();
if (_font != null)
_font.Dispose();
if (_format != null)
_format.Dispose();
if (fontBrush != null)
fontBrush.Dispose();
if (borderBrush != null)
borderBrush.Dispose();
if (backBrush != null)
backBrush.Dispose();
}
public void SwapFont()
{
Font f = _font;
_font = _sfont;
_sfont = f;
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.