本文整理汇总了C#中HashSet2类的典型用法代码示例。如果您正苦于以下问题:C# HashSet2类的具体用法?C# HashSet2怎么用?C# HashSet2使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
HashSet2类属于命名空间,在下文中一共展示了HashSet2类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RemoveLayers
/// <summary>
/// Removes layers from a PDF document </summary>
/// <param name="reader"> a PdfReader containing a PDF document </param>
/// <param name="layers"> a sequence of names of OCG layers </param>
/// <exception cref="IOException"> </exception>
public virtual void RemoveLayers(PdfReader reader, params string[] layers) {
int n = reader.NumberOfPages;
for (int i = 1; i <= n; i++)
reader.SetPageContent(i, reader.GetPageContent(i));
ICollection<string> ocgs = new HashSet2<string>();
for (int i = 0; i < layers.Length; i++) {
ocgs.Add(layers[i]);
}
OCGParser parser = new OCGParser(ocgs);
for (int i = 1; i <= n; i++) {
PdfDictionary page = reader.GetPageN(i);
Parse(parser, page);
page.Remove(PdfName.PIECEINFO);
RemoveAnnots(page, ocgs);
RemoveProperties(page, ocgs);
}
PdfDictionary root = reader.Catalog;
PdfDictionary ocproperties = root.GetAsDict(PdfName.OCPROPERTIES);
if (ocproperties != null) {
RemoveOCGsFromArray(ocproperties, PdfName.OCGS, ocgs);
PdfDictionary d = ocproperties.GetAsDict(PdfName.D);
if (d != null) {
RemoveOCGsFromArray(d, PdfName.ON, ocgs);
RemoveOCGsFromArray(d, PdfName.OFF, ocgs);
RemoveOCGsFromArray(d, PdfName.LOCKED, ocgs);
RemoveOCGsFromArray(d, PdfName.RBGROUPS, ocgs);
RemoveOCGsFromArray(d, PdfName.ORDER, ocgs);
RemoveOCGsFromArray(d, PdfName.AS, ocgs);
}
PdfArray ocgsArray = ocproperties.GetAsArray(PdfName.OCGS);
if (ocgsArray != null && ocgsArray.IsEmpty()) {
root.Remove(PdfName.OCPROPERTIES);
if (PdfName.USEOC.Equals(root.GetAsName(PdfName.PAGEMODE))) {
root.Remove(PdfName.PAGEMODE);
}
}
}
reader.RemoveUnusedObjects();
}
示例2: SetAppearance
virtual public void SetAppearance(PdfName ap, string state, PdfTemplate template) {
PdfDictionary dicAp = (PdfDictionary)Get(PdfName.AP);
if (dicAp == null)
dicAp = new PdfDictionary();
PdfDictionary dic;
PdfObject obj = dicAp.Get(ap);
if (obj != null && obj.IsDictionary())
dic = (PdfDictionary)obj;
else
dic = new PdfDictionary();
dic.Put(new PdfName(state), template.IndirectReference);
dicAp.Put(ap, dic);
Put(PdfName.AP, dicAp);
if (!form)
return;
if (templates == null)
templates = new HashSet2<PdfTemplate>();
templates.Add(template);
}
示例3: CheckLayer
protected override void CheckLayer(PdfWriter writer, int key, Object obj1) {
if (obj1 is IPdfOCG) {
} else if (obj1 is PdfOCProperties) {
PdfOCProperties properties = (PdfOCProperties)obj1;
List<PdfDictionary> configsList = new List<PdfDictionary>();
PdfDictionary d = GetDirectDictionary(properties.Get(PdfName.D));
if (d != null)
configsList.Add(d);
PdfArray configs = GetDirectArray(properties.Get(PdfName.CONFIGS));
if (configs != null) {
for (int i = 0; i < configs.Size; i++) {
PdfDictionary config = GetDirectDictionary(configs[i]);
if (config != null)
configsList.Add(config);
}
}
HashSet2<PdfObject> ocgs = new HashSet2<PdfObject>();
PdfArray ocgsArray = GetDirectArray(properties.Get(PdfName.OCGS));
if (ocgsArray != null)
for (int i = 0; i < ocgsArray.Size; i++)
ocgs.Add(ocgsArray[i]);
HashSet2<String> names = new HashSet2<String>();
HashSet2<PdfObject> order = new HashSet2<PdfObject>();
foreach (PdfDictionary config in configsList) {
PdfString name = config.GetAsString(PdfName.NAME);
if (name == null) {
throw new PdfAConformanceException(MessageLocalization.GetComposedMessage("optional.content.configuration.dictionary.shall.contain.name.entry"));
}
String name1 = name.ToUnicodeString();
if (names.Contains(name1)) {
throw new PdfAConformanceException(MessageLocalization.GetComposedMessage("value.of.name.entry.shall.be.unique.amongst.all.optional.content.configuration.dictionaries"));
}
names.Add(name1);
if (config.Contains(PdfName.AS)) {
throw new PdfAConformanceException(MessageLocalization.GetComposedMessage("the.as.key.shall.not.appear.in.any.optional.content.configuration.dictionary"));
}
PdfArray orderArray = GetDirectArray(config.Get(PdfName.ORDER));
if (orderArray != null)
FillOrderRecursively(orderArray, order);
}
if (order.Count != ocgs.Count) {
throw new PdfAConformanceException(MessageLocalization.GetComposedMessage("order.array.shall.contain.references.to.all.ocgs"));
}
ocgs.RetainAll(order);
if (order.Count != ocgs.Count) {
throw new PdfAConformanceException(MessageLocalization.GetComposedMessage("order.array.shall.contain.references.to.all.ocgs"));
}
} else {
}
}
示例4: ApplyDashPattern
private static Path ApplyDashPattern(Path path, LineDashPattern lineDashPattern) {
HashSet2<int> modifiedSubpaths = new HashSet2<int>(path.ReplaceCloseWithLine());
Path dashedPath = new Path();
int currentSubpath = 0;
foreach (Subpath subpath in path.Subpaths) {
IList<Point2D> subpathApprox = subpath.GetPiecewiseLinearApproximation();
if (subpathApprox.Count > 1) {
dashedPath.MoveTo((float) subpathApprox[0].GetX(), (float) subpathApprox[0].GetY());
float remainingDist = 0;
bool remainingIsGap = false;
for (int i = 1; i < subpathApprox.Count; ++i) {
Point2D nextPoint = null;
if (remainingDist != 0) {
nextPoint = GetNextPoint(subpathApprox[i - 1], subpathApprox[i], remainingDist);
remainingDist = ApplyDash(dashedPath, subpathApprox[i - 1], subpathApprox[i], nextPoint, remainingIsGap);
}
while ((Util.compare(remainingDist, 0) == 0) && !dashedPath.CurrentPoint.Equals(subpathApprox[i])) {
LineDashPattern.DashArrayElem currentElem = lineDashPattern.Next();
nextPoint = GetNextPoint(nextPoint ?? subpathApprox[i - 1], subpathApprox[i], currentElem.Value);
remainingDist = ApplyDash(dashedPath, subpathApprox[i - 1], subpathApprox[i], nextPoint, currentElem.IsGap);
remainingIsGap = currentElem.IsGap;
}
}
// If true, then the line closing the subpath was explicitly added (see Path.ReplaceCloseWithLine).
// This causes a loss of a visual effect of line join style parameter, so in this clause
// we simply add overlapping dash (or gap, no matter), which continues the last dash and equals to
// the first dash (or gap) of the path.
if (modifiedSubpaths.Contains(currentSubpath)) {
lineDashPattern.Reset();
LineDashPattern.DashArrayElem currentElem = lineDashPattern.Next();
Point2D nextPoint = GetNextPoint(subpathApprox[0], subpathApprox[1], currentElem.Value);
ApplyDash(dashedPath, subpathApprox[0], subpathApprox[1], nextPoint, currentElem.IsGap);
}
}
// According to PDF spec. line dash pattern should be restarted for each new subpath.
lineDashPattern.Reset();
++currentSubpath;
}
return dashedPath;
}
示例5: FillOrderRecursively
private void FillOrderRecursively(PdfArray orderArray, HashSet2<PdfObject> order) {
for (int i = 0; i < orderArray.Size; i++) {
PdfArray orderChild = GetDirectArray(orderArray[i]);
if (orderChild == null) {
order.Add(orderArray[i]);
} else {
FillOrderRecursively(orderChild, order);
}
}
}
示例6: MergeTextDecorationRules
private String MergeTextDecorationRules(String oldRule, String newRule) {
if (CSS.Value.NONE.Equals(newRule))
return newRule;
HashSet2<String> attrSet = new HashSet2<String>();
if (oldRule != null)
foreach (String attr in new Regex(@"\s+").Split(oldRule))
attrSet.Add(attr);
if (newRule != null)
foreach (String attr in new Regex(@"\s+").Split(newRule))
attrSet.Add(attr);
StringBuilder resultantStr = new StringBuilder();
foreach (String attr in attrSet) {
if (attr.Equals(CSS.Value.NONE) || attr.Equals(CSS.Value.INHERIT))
continue;
if (resultantStr.Length > 0)
resultantStr.Append(' ');
resultantStr.Append(attr);
}
return resultantStr.Length == 0 ? null : resultantStr.ToString();
}
示例7: PdfCleanUpContentOperator
static PdfCleanUpContentOperator() {
pathPaintingOperators = new HashSet2<string>(strokeOperators);
pathPaintingOperators.AddAll(nwFillOperators);
pathPaintingOperators.AddAll(eoFillOperators);
pathPaintingOperators.Add("n");
}
示例8: TrueTypeFontSubSet
/** Creates a new TrueTypeFontSubSet
* @param directoryOffset The offset from the start of the file to the table directory
* @param fileName the file name of the font
* @param glyphsUsed the glyphs used
* @param includeCmap <CODE>true</CODE> if the table cmap is to be included in the generated font
*/
public TrueTypeFontSubSet(string fileName, RandomAccessFileOrArray rf, HashSet2<int> glyphsUsed, int directoryOffset, bool includeCmap, bool includeExtras) {
this.fileName = fileName;
this.rf = rf;
this.glyphsUsed = glyphsUsed;
this.includeCmap = includeCmap;
this.includeExtras = includeExtras;
this.directoryOffset = directoryOffset;
glyphsInList = new List<int>(glyphsUsed);
}
示例9: PdfAChecker
internal PdfAChecker(PdfAConformanceLevel conformanceLevel) {
keysForCheck = InitKeysForCheck();
this.conformanceLevel = conformanceLevel;
}