本文整理匯總了C#中BaseColor類的典型用法代碼示例。如果您正苦於以下問題:C# BaseColor類的具體用法?C# BaseColor怎麽用?C# BaseColor使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
BaseColor類屬於命名空間,在下文中一共展示了BaseColor類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: LineSeparator
/**
* Creates a new instance of the LineSeparator class.
* @param lineWidth the thickness of the line
* @param percentage the width of the line as a percentage of the available page width
* @param color the color of the line
* @param align the alignment
* @param offset the offset of the line relative to the current baseline (negative = under the baseline)
*/
public LineSeparator(float lineWidth, float percentage, BaseColor lineColor, int align, float offset) {
this.lineWidth = lineWidth;
this.percentage = percentage;
this.lineColor = lineColor;
this.alignment = align;
this.offset = offset;
}
示例2: PlaceBarcode
/** Places the barcode in a <CODE>PdfContentByte</CODE>. The
* barcode is always placed at coodinates (0, 0). Use the
* translation matrix to move it elsewhere.<p>
* The bars and text are written in the following colors:<p>
* <P><TABLE BORDER=1>
* <TR>
* <TH><P><CODE>barColor</CODE></TH>
* <TH><P><CODE>textColor</CODE></TH>
* <TH><P>Result</TH>
* </TR>
* <TR>
* <TD><P><CODE>null</CODE></TD>
* <TD><P><CODE>null</CODE></TD>
* <TD><P>bars and text painted with current fill color</TD>
* </TR>
* <TR>
* <TD><P><CODE>barColor</CODE></TD>
* <TD><P><CODE>null</CODE></TD>
* <TD><P>bars and text painted with <CODE>barColor</CODE></TD>
* </TR>
* <TR>
* <TD><P><CODE>null</CODE></TD>
* <TD><P><CODE>textColor</CODE></TD>
* <TD><P>bars painted with current color<br>text painted with <CODE>textColor</CODE></TD>
* </TR>
* <TR>
* <TD><P><CODE>barColor</CODE></TD>
* <TD><P><CODE>textColor</CODE></TD>
* <TD><P>bars painted with <CODE>barColor</CODE><br>text painted with <CODE>textColor</CODE></TD>
* </TR>
* </TABLE>
* @param cb the <CODE>PdfContentByte</CODE> where the barcode will be placed
* @param barColor the color of the bars. It can be <CODE>null</CODE>
* @param textColor the color of the text. It can be <CODE>null</CODE>
* @return the dimensions the barcode occupies
*/
public override Rectangle PlaceBarcode(PdfContentByte cb, BaseColor barColor, BaseColor textColor) {
if (supp.Font != null)
supp.BarHeight = ean.BarHeight + supp.Baseline - supp.Font.GetFontDescriptor(BaseFont.CAPHEIGHT, supp.Size);
else
supp.BarHeight = ean.BarHeight;
Rectangle eanR = ean.BarcodeSize;
cb.SaveState();
ean.PlaceBarcode(cb, barColor, textColor);
cb.RestoreState();
cb.SaveState();
cb.ConcatCTM(1, 0, 0, 1, eanR.Width + n, eanR.Height - ean.BarHeight);
supp.PlaceBarcode(cb, barColor, textColor);
cb.RestoreState();
return this.BarcodeSize;
}
示例3: UncoloredPattern
protected internal UncoloredPattern(PdfPatternPainter p, BaseColor color, float tint) : base(p) {
this.color = color;
this.tint = tint;
}
示例4: SaveColor
private void SaveColor(BaseColor color, bool fill) {
if (IsTagged()) {
if (inText) {
if (fill) {
state.textColorFill = color;
} else {
state.textColorStroke = color;
}
} else {
if (fill) {
state.colorFill = color;
} else {
state.colorStroke = color;
}
}
}
else {
if (fill) {
state.colorFill = color;
}
else {
state.colorStroke = color;
}
}
}
示例5: SetPatternStroke
/** Sets the stroke color to an uncolored pattern.
* @param p the pattern
* @param color the color of the pattern
*/
public virtual void SetPatternStroke(PdfPatternPainter p, BaseColor color) {
if (ExtendedColor.GetType(color) == ExtendedColor.TYPE_SEPARATION)
SetPatternStroke(p, color, ((SpotColor)color).Tint);
else
SetPatternStroke(p, color, 0);
}
示例6: SetColorStroke
/** Sets the stroke color. <CODE>color</CODE> can be an
* <CODE>ExtendedColor</CODE>.
* @param color the color
*/
public virtual void SetColorStroke(BaseColor value) {
int type = ExtendedColor.GetType(value);
switch (type) {
case ExtendedColor.TYPE_GRAY: {
SetGrayStroke(((GrayColor)value).Gray);
break;
}
case ExtendedColor.TYPE_CMYK: {
CMYKColor cmyk = (CMYKColor)value;
SetCMYKColorStrokeF(cmyk.Cyan, cmyk.Magenta, cmyk.Yellow, cmyk.Black);
break;
}
case ExtendedColor.TYPE_SEPARATION: {
SpotColor spot = (SpotColor)value;
SetColorStroke(spot.PdfSpotColor, spot.Tint);
break;
}
case ExtendedColor.TYPE_PATTERN: {
PatternColor pat = (PatternColor)value;
SetPatternStroke(pat.Painter);
break;
}
case ExtendedColor.TYPE_SHADING: {
ShadingColor shading = (ShadingColor)value;
SetShadingStroke(shading.PdfShadingPattern);
break;
}
case ExtendedColor.TYPE_DEVICEN: {
DeviceNColor devicen = (DeviceNColor) value;
SetColorStroke(devicen.PdfDeviceNColor, devicen.Tints);
break;
}
case ExtendedColor.TYPE_LAB: {
LabColor lab = (LabColor) value;
SetColorStroke(lab.LabColorSpace, lab.L, lab.A, lab.B);
break;
}
default:
SetRGBColorStroke(value.R, value.G, value.B);
break;
}
}
示例7: PlaceBarcode
/** Places the barcode in a <CODE>PdfContentByte</CODE>. The
* barcode is always placed at coodinates (0, 0). Use the
* translation matrix to move it elsewhere.<p>
* The bars and text are written in the following colors:<p>
* <P><TABLE BORDER=1>
* <TR>
* <TH><P><CODE>barColor</CODE></TH>
* <TH><P><CODE>textColor</CODE></TH>
* <TH><P>Result</TH>
* </TR>
* <TR>
* <TD><P><CODE>null</CODE></TD>
* <TD><P><CODE>null</CODE></TD>
* <TD><P>bars and text painted with current fill color</TD>
* </TR>
* <TR>
* <TD><P><CODE>barColor</CODE></TD>
* <TD><P><CODE>null</CODE></TD>
* <TD><P>bars and text painted with <CODE>barColor</CODE></TD>
* </TR>
* <TR>
* <TD><P><CODE>null</CODE></TD>
* <TD><P><CODE>textColor</CODE></TD>
* <TD><P>bars painted with current color<br>text painted with <CODE>textColor</CODE></TD>
* </TR>
* <TR>
* <TD><P><CODE>barColor</CODE></TD>
* <TD><P><CODE>textColor</CODE></TD>
* <TD><P>bars painted with <CODE>barColor</CODE><br>text painted with <CODE>textColor</CODE></TD>
* </TR>
* </TABLE>
* @param cb the <CODE>PdfContentByte</CODE> where the barcode will be placed
* @param barColor the color of the bars. It can be <CODE>null</CODE>
* @param textColor the color of the text. It can be <CODE>null</CODE>
* @return the dimensions the barcode occupies
*/
public override Rectangle PlaceBarcode(PdfContentByte cb, BaseColor barColor, BaseColor textColor) {
if (barColor != null)
cb.SetColorFill(barColor);
byte[] bars = GetBarsPostnet(code);
byte flip = 1;
if (codeType == PLANET) {
flip = 0;
bars[0] = 0;
bars[bars.Length - 1] = 0;
}
float startX = 0;
for (int k = 0; k < bars.Length; ++k) {
cb.Rectangle(startX, 0, x - inkSpreading, bars[k] == flip ? barHeight : size);
startX += n;
}
cb.Fill();
return this.BarcodeSize;
}
示例8: PlaceBarcode
public virtual void PlaceBarcode(PdfContentByte cb, BaseColor foreground, float moduleHeight, float moduleWidth) {
PaintCode();
int stride = (bitColumns + 7)/8;
cb.SetColorFill(foreground);
for (int k = 0; k < codeRows; ++k) {
int p = k*stride;
for (int j = 0; j < bitColumns; ++j) {
int b = outBits[p + j/8] & 0xff;
b <<= j%8;
if ((b & 0x80) != 0) {
cb.Rectangle(j*moduleWidth, (codeRows - k - 1)*moduleHeight, moduleWidth, moduleHeight);
}
}
}
cb.Fill();
}
示例9: SetColorFill
/** Sets the fill color. <CODE>color</CODE> can be an
* <CODE>ExtendedColor</CODE>.
* @param color the color
*/
public virtual void SetColorFill(BaseColor value) {
int type = ExtendedColor.GetType(value);
switch (type) {
case ExtendedColor.TYPE_GRAY: {
SetGrayFill(((GrayColor)value).Gray);
break;
}
case ExtendedColor.TYPE_CMYK: {
CMYKColor cmyk = (CMYKColor)value;
SetCMYKColorFillF(cmyk.Cyan, cmyk.Magenta, cmyk.Yellow, cmyk.Black);
break;
}
case ExtendedColor.TYPE_SEPARATION: {
SpotColor spot = (SpotColor)value;
SetColorFill(spot.PdfSpotColor, spot.Tint);
break;
}
case ExtendedColor.TYPE_PATTERN: {
PatternColor pat = (PatternColor)value;
SetPatternFill(pat.Painter);
break;
}
case ExtendedColor.TYPE_SHADING: {
ShadingColor shading = (ShadingColor)value;
SetShadingFill(shading.PdfShadingPattern);
break;
}
default:
SetRGBColorFill(value.R, value.G, value.B);
break;
}
}
示例10: OutputColorNumbers
/** Outputs the color values to the content.
* @param color The color
* @param tint the tint if it is a spot color, ignored otherwise
*/
internal void OutputColorNumbers(BaseColor color, float tint) {
PdfWriter.CheckPdfIsoConformance(writer, PdfIsoKeys.PDFISOKEY_COLOR, color);
int type = ExtendedColor.GetType(color);
switch (type) {
case ExtendedColor.TYPE_RGB:
content.Append((float)(color.R) / 0xFF);
content.Append(' ');
content.Append((float)(color.G) / 0xFF);
content.Append(' ');
content.Append((float)(color.B) / 0xFF);
break;
case ExtendedColor.TYPE_GRAY:
content.Append(((GrayColor)color).Gray);
break;
case ExtendedColor.TYPE_CMYK: {
CMYKColor cmyk = (CMYKColor)color;
content.Append(cmyk.Cyan).Append(' ').Append(cmyk.Magenta);
content.Append(' ').Append(cmyk.Yellow).Append(' ').Append(cmyk.Black);
break;
}
case ExtendedColor.TYPE_SEPARATION:
content.Append(tint);
break;
default:
throw new Exception(MessageLocalization.GetComposedMessage("invalid.color.type"));
}
}
示例11: PlaceBarcode
virtual public void PlaceBarcode(PdfContentByte cb, BaseColor foreground, float moduleHeight, float moduleWidth) {
int w = width + 2*ws;
int h = height + 2*ws;
int stride = (w + 7)/8;
int ptr = 0;
cb.SetColorFill(foreground);
for (int k = 0; k < h; ++k) {
int p = k*stride;
for (int j = 0; j < w; ++j) {
int b = image[p + j/8] & 0xff;
b <<= j%8;
if ((b & 0x80) != 0) {
cb.Rectangle(j*moduleWidth, (h - k - 1)*moduleHeight, moduleWidth, moduleHeight);
}
}
}
cb.Fill();
}
示例12: RestoreColor
private void RestoreColor(BaseColor color, bool fill) {
if (IsTagged()) {
if (color is UncoloredPattern) {
UncoloredPattern c = (UncoloredPattern)color;
if (fill)
SetPatternFill(c.Painter, c.color, c.tint);
else
SetPatternStroke(c.Painter, c.color, c.tint);
} else {
if (fill)
SetColorFill(color);
else
SetColorStroke(color);
}
}
}
示例13: CompareColors
private bool CompareColors(BaseColor c1, BaseColor c2) {
if (c1 == null && c2 == null)
return true;
if (c1 == null || c2 == null)
return false;
if (c1 is ExtendedColor)
return c1.Equals(c2);
return c2.Equals(c1);
}
示例14: PlaceBarcode
/** Places the barcode in a <CODE>PdfContentByte</CODE>. The
* barcode is always placed at coodinates (0, 0). Use the
* translation matrix to move it elsewhere.<p>
* The bars and text are written in the following colors:<p>
* <P><TABLE BORDER=1>
* <TR>
* <TH><P><CODE>barColor</CODE></TH>
* <TH><P><CODE>textColor</CODE></TH>
* <TH><P>Result</TH>
* </TR>
* <TR>
* <TD><P><CODE>null</CODE></TD>
* <TD><P><CODE>null</CODE></TD>
* <TD><P>bars and text painted with current fill color</TD>
* </TR>
* <TR>
* <TD><P><CODE>barColor</CODE></TD>
* <TD><P><CODE>null</CODE></TD>
* <TD><P>bars and text painted with <CODE>barColor</CODE></TD>
* </TR>
* <TR>
* <TD><P><CODE>null</CODE></TD>
* <TD><P><CODE>textColor</CODE></TD>
* <TD><P>bars painted with current color<br>text painted with <CODE>textColor</CODE></TD>
* </TR>
* <TR>
* <TD><P><CODE>barColor</CODE></TD>
* <TD><P><CODE>textColor</CODE></TD>
* <TD><P>bars painted with <CODE>barColor</CODE><br>text painted with <CODE>textColor</CODE></TD>
* </TR>
* </TABLE>
* @param cb the <CODE>PdfContentByte</CODE> where the barcode will be placed
* @param barColor the color of the bars. It can be <CODE>null</CODE>
* @param textColor the color of the text. It can be <CODE>null</CODE>
* @return the dimensions the barcode occupies
*/
public override Rectangle PlaceBarcode(PdfContentByte cb, BaseColor barColor, BaseColor textColor) {
string fullCode;
if (codeType == CODE128_RAW) {
int idx = code.IndexOf('\uffff');
if (idx < 0)
fullCode = "";
else
fullCode = code.Substring(idx + 1);
}
else if (codeType == CODE128_UCC)
fullCode = GetHumanReadableUCCEAN(code);
else
fullCode = RemoveFNC1(code);
float fontX = 0;
if (font != null) {
fontX = font.GetWidthPoint(fullCode = altText != null ? altText : fullCode, size);
}
string bCode;
if (codeType == CODE128_RAW) {
int idx = code.IndexOf('\uffff');
if (idx >= 0)
bCode = code.Substring(0, idx);
else
bCode = code;
}
else {
bCode = GetRawText(code, codeType == CODE128_UCC);
}
int len = bCode.Length;
float fullWidth = (len + 2) * 11 * x + 2 * x;
float barStartX = 0;
float textStartX = 0;
switch (textAlignment) {
case Element.ALIGN_LEFT:
break;
case Element.ALIGN_RIGHT:
if (fontX > fullWidth)
barStartX = fontX - fullWidth;
else
textStartX = fullWidth - fontX;
break;
default:
if (fontX > fullWidth)
barStartX = (fontX - fullWidth) / 2;
else
textStartX = (fullWidth - fontX) / 2;
break;
}
float barStartY = 0;
float textStartY = 0;
if (font != null) {
if (baseline <= 0)
textStartY = barHeight - baseline;
else {
textStartY = -font.GetFontDescriptor(BaseFont.DESCENT, size);
barStartY = textStartY + baseline;
}
}
byte[] bars = GetBarsCode128Raw(bCode);
bool print = true;
if (barColor != null)
cb.SetColorFill(barColor);
for (int k = 0; k < bars.Length; ++k) {
float w = bars[k] * x;
//.........這裏部分代碼省略.........
示例15: Encode
/**
* Converts a <CODE>BaseColor</CODE> into a HTML representation of this <CODE>BaseColor</CODE>.
*
* @param color the <CODE>BaseColor</CODE> that has to be converted.
* @return the HTML representation of this <COLOR>BaseColor</COLOR>
*/
public static String Encode(BaseColor color) {
StringBuilder buffer = new StringBuilder("#");
if (color.R < 16) {
buffer.Append('0');
}
buffer.Append(System.Convert.ToString(color.R, 16));
if (color.G < 16) {
buffer.Append('0');
}
buffer.Append(System.Convert.ToString(color.G, 16));
if (color.B < 16) {
buffer.Append('0');
}
buffer.Append(System.Convert.ToString(color.B, 16));
return buffer.ToString();
}