public override void ParseGroupCode(int groupcode, string value) { base.ParseGroupCode(groupcode, value); if (groupcode >= 10 && groupcode <= 33) { int idx = groupcode % 10; int component = groupcode / 10; switch (component) { case 1: Corners[idx].X = double.Parse(value); break; case 2: Corners[idx].Y = double.Parse(value); break; case 3: Corners[idx].Z = double.Parse(value); break; } } else if (groupcode == 70) { Flags = (FlagsEnum)Enum.Parse(typeof(FlagsEnum), value); } }
public void assert_enum_member_does_not_throw_if_flag_enumeration_values_are_valid() { var validValues = new FlagsEnum[] { FlagsEnum.One, FlagsEnum.Two, FlagsEnum.Four, FlagsEnum.None }; ArgumentHelper.AssertEnumMember(FlagsEnum.None, "test", validValues); ArgumentHelper.AssertEnumMember(FlagsEnum.One, "test", validValues); ArgumentHelper.AssertEnumMember(FlagsEnum.Two, "test", validValues); ArgumentHelper.AssertEnumMember(FlagsEnum.Four, "test", validValues); ArgumentHelper.AssertEnumMember(FlagsEnum.One | FlagsEnum.Two, "test", validValues); ArgumentHelper.AssertEnumMember(FlagsEnum.One | FlagsEnum.Four, "test", validValues); ArgumentHelper.AssertEnumMember(FlagsEnum.One | FlagsEnum.Two | FlagsEnum.Four, "test", validValues); }
/** * <summary>Creates the font descriptor.</summary> */ private PdfReference Load_CreateFontDescriptor(OpenFontParser parser) { PdfDictionary fontDescriptor = new PdfDictionary(); { OpenFontParser.FontMetrics metrics = parser.Metrics; // Type. fontDescriptor[PdfName.Type] = PdfName.FontDescriptor; // FontName. fontDescriptor[PdfName.FontName] = BaseDataObject[PdfName.BaseFont]; // Flags [PDF:1.6:5.7.1]. FlagsEnum flags = 0; if (metrics.IsFixedPitch) { flags |= FlagsEnum.FixedPitch; } if (metrics.IsCustomEncoding) { flags |= FlagsEnum.Symbolic; } else { flags |= FlagsEnum.Nonsymbolic; } fontDescriptor[PdfName.Flags] = PdfInteger.Get(Convert.ToInt32(flags)); // FontBBox. fontDescriptor[PdfName.FontBBox] = new Rectangle( new SKPoint(metrics.XMin * metrics.UnitNorm, metrics.YMin * metrics.UnitNorm), new SKPoint(metrics.XMax * metrics.UnitNorm, metrics.YMax * metrics.UnitNorm) ).BaseDataObject; // ItalicAngle. fontDescriptor[PdfName.ItalicAngle] = PdfReal.Get(metrics.ItalicAngle); // Ascent. fontDescriptor[PdfName.Ascent] = PdfReal.Get( metrics.STypoAscender == 0 ? metrics.Ascender * metrics.UnitNorm : (metrics.STypoLineGap == 0 ? metrics.SCapHeight : metrics.STypoAscender) * metrics.UnitNorm ); // Descent. fontDescriptor[PdfName.Descent] = PdfReal.Get( metrics.STypoDescender == 0 ? metrics.Descender * metrics.UnitNorm : metrics.STypoDescender * metrics.UnitNorm ); // CapHeight. fontDescriptor[PdfName.CapHeight] = PdfReal.Get(metrics.SCapHeight * metrics.UnitNorm); // StemV. /* * NOTE: '100' is just a rule-of-thumb value, 'cause I've still to solve the * 'cvt' table puzzle (such a harsh headache!) for TrueType fonts... * TODO:IMPL TrueType and CFF stemv real value to extract!!! */ fontDescriptor[PdfName.StemV] = PdfInteger.Get(100); // FontFile. fontDescriptor[PdfName.FontFile2] = File.Register(new PdfStream(new bytes::Buffer(parser.FontData.ToByteArray()))); } return(File.Register(fontDescriptor)); }
public string UnoundFuncWithEnumParameter(LongEnum p1, FlagsEnum p2) { return "UnboundFuncWithEnumParameters(" + p1 + "," + p2 + ")"; }
public string GetFlagsEnum(FlagsEnum id) { ThrowIfInsideThrowsController(); return id.ToString(); }
public int GetFlagValuesAsInt(FlagsEnum flags) { return (int)flags; }
public MyClassWithCstr(StandardEnum standard, NumberedEnum numbered, FlagsEnum flags, ManualSetupEnum manual, IgnoredEnum ignored) { this.Standard = standard; this.Numbered = numbered; this.Flags = flags; this.Manual = manual; this.Ignored = ignored; }
public static bool FastEquals(this FlagsEnum value, FlagsEnum other) { return(value == other); }
public int SetFlagsEnum(FlagsEnum val) => (int)val;
public bool GetFlag(FlagsEnum Flag) { if ((rflags & (ulong)Flag) == 0) return false; else return true; }
private void SetFlag(FlagsEnum Flag) { rflags |= (ulong)Flag; }
private void ComplementFlag(FlagsEnum Flag) { rflags = rflags ^ (ulong)Flag; }
private void ClearFlag(FlagsEnum Flag) { rflags &= ~(ulong)Flag; }
public void CompareEnums() { var sRegular = RegularEnum.Running.ToString(); string sEnhanced = StatusEnum.Running; string sFlags = FlagsEnum.Four; var iRegular = (int)RegularEnum.Running; int iEnhanced = StatusEnum.Running; int iFlags = FlagsEnum.Four; // String to Enum regularEnum = (RegularEnum)Enum.Parse(typeof(RegularEnum), sRegular); regularEnum = Enum.Parse <RegularEnum>(sRegular); enhancedEnum = sEnhanced; flagsEnum = sFlags; // Int to Enum regularEnum = (RegularEnum)iRegular; enhancedEnum = iEnhanced; flagsEnum = iFlags; // Flag Manipulation regularEnum = RegularEnum.Stopped | RegularEnum.Error; flagsEnum = FlagsEnum.Four | FlagsEnum.Eight; regularEnum.HasFlag(RegularEnum.Stopped); flagsEnum.HasFlag(FlagsEnum.Four); // regularEnum.HasFlag(2); // Compile Error flagsEnum.HasFlag(2); // Valid check // Errors on conversion: Configurable to be NULL / throw exception. Func <RegularEnum> regularAct = () => regularEnum = (RegularEnum)55; // Assigns 55 regularAct.Should() .NotThrow(); regularEnum.Should() .Be(55); regularAct = () => regularEnum = (RegularEnum)Enum.Parse(typeof(RegularEnum), "Running1"); // throws ArgumentException regularAct.Should() .Throw <ArgumentException>(); Func <StatusEnum> enhancedAct = () => enhancedEnum = 55; // returns null; enhancedAct.Should() .NotThrow(); enhancedEnum.Should() .BeNull(); enhancedAct = () => enhancedEnum = "Running1"; // returns null; enhancedAct.Should() .NotThrow(); enhancedEnum.Should() .BeNull(); StatusEnum.ThrowOnError = true; enhancedAct = () => enhancedEnum = 55; // throws InvalidOperationException enhancedAct.Should() .Throw <InvalidOperationException>(); enhancedAct = () => enhancedEnum = "Running1"; // throws InvalidOperationException enhancedAct.Should() .Throw <InvalidOperationException>(); }
public void MapHasFlag([IncludeDataSources(TestProvName.AllSQLite)] string context, [Values(FlagsEnum.Flag1, FlagsEnum.Flag3)] FlagsEnum flag) { var data = Enumerable.Range(1, 10).Select(i => new MappingTestClass { Id = i, Value = i * 10, Flags = (FlagsEnum)(i & (int)FlagsEnum.All) }) .ToArray(); using (var db = GetDataContext(context)) using (var table = db.CreateLocalTable(data)) { var query = from t in table where t.Flags.HasFlag(flag) select t; var expected = from t in data where t.Flags.HasFlag(flag) select t; AreEqualWithComparer(expected, query); } }
public string UnoundFuncWithEnumParameter(LongEnum p1, FlagsEnum p2) { return("UnboundFuncWithEnumParameters(" + p1 + "," + p2 + ")"); }
[InlineData(7, "7")] // This is expected, not "Value1 | Value2 | 4" public static void Flags(FlagsEnum enumValue, string expected) { var actual = ArgumentFormatter.Format(enumValue); Assert.Equal(expected, actual); }
public int SetFlagsEnum(FlagsEnum val) => ((Func <SampleClass, FlagsEnum, int>)CompiledWrappers[7])(this, val);
public static bool FastHasFlag(this FlagsEnum value, FlagsEnum flag) { return((value & flag) == flag); }
protected override void LoadEncoding( ) { OpenFontParser parser; { PdfDictionary descriptor = Descriptor; if (descriptor.ContainsKey(PdfName.FontFile2)) // Embedded TrueType font file (without 'glyf' table). { PdfStream fontFileStream = (PdfStream)descriptor.Resolve(PdfName.FontFile2); parser = new OpenFontParser(fontFileStream.Body); } else if (descriptor.ContainsKey(PdfName.FontFile3)) { PdfStream fontFileStream = (PdfStream)descriptor.Resolve(PdfName.FontFile3); PdfName fontFileSubtype = (PdfName)fontFileStream.Header[PdfName.Subtype]; if (fontFileSubtype.Equals(PdfName.OpenType)) // Embedded OpenFont/TrueType font file (with 'glyf' table). { parser = new OpenFontParser(fontFileStream.Body); } else // Unknown. { throw new NotSupportedException("Unknown embedded font file format: " + fontFileSubtype); } } else { parser = null; } } if (parser != null) // Embedded font file. { // Glyph indexes. glyphIndexes = parser.GlyphIndexes; if (codes != null && parser.Metrics.IsCustomEncoding) { /* * NOTE: In case of symbolic font, * glyph indices are natively mapped to character codes, * so they must be remapped to Unicode whenever possible * (i.e. when ToUnicode stream is available). */ Dictionary <int, int> unicodeGlyphIndexes = new Dictionary <int, int>(); foreach (KeyValuePair <int, int> glyphIndexEntry in glyphIndexes) { int code; if (!codes.TryGetValue(new ByteArray(new byte[] { (byte)(int)glyphIndexEntry.Key }), out code)) { continue; } unicodeGlyphIndexes[code] = glyphIndexEntry.Value; } glyphIndexes = unicodeGlyphIndexes; } } PdfDataObject encodingObject = BaseDataObject.Resolve(PdfName.Encoding); FlagsEnum flags = Flags; if ((flags & FlagsEnum.Symbolic) != 0 || ((flags & FlagsEnum.Nonsymbolic) == 0 && encodingObject == null)) // Symbolic. { symbolic = true; if (glyphIndexes == null) { /* * NOTE: In case no font file is available, we have to synthesize its metrics * from existing entries. */ glyphIndexes = new Dictionary <int, int>(); PdfArray glyphWidthObjects = (PdfArray)BaseDataObject.Resolve(PdfName.Widths); if (glyphWidthObjects != null) { int code = ((PdfInteger)BaseDataObject[PdfName.FirstChar]).RawValue; foreach (PdfDirectObject glyphWidthObject in glyphWidthObjects) { if (((PdfInteger)glyphWidthObject).RawValue > 0) { glyphIndexes[code] = code; } code++; } } } if (this.codes == null) { Dictionary <ByteArray, int> codes = new Dictionary <ByteArray, int>(); foreach (KeyValuePair <int, int> glyphIndexEntry in glyphIndexes) { if (glyphIndexEntry.Value > 0) { int glyphCharCode = glyphIndexEntry.Key; byte[] charCode = new byte[] { (byte)glyphCharCode }; codes[new ByteArray(charCode)] = glyphCharCode; } } this.codes = new BiDictionary <ByteArray, int>(codes); } } else // Nonsymbolic. { symbolic = false; if (this.codes == null) { Dictionary <ByteArray, int> codes; if (encodingObject == null) // Default encoding. { codes = Encoding.Get(PdfName.StandardEncoding).GetCodes(); } else if (encodingObject is PdfName) // Predefined encoding. { codes = Encoding.Get((PdfName)encodingObject).GetCodes(); } else // Custom encoding. { PdfDictionary encodingDictionary = (PdfDictionary)encodingObject; // 1. Base encoding. PdfName baseEncodingName = (PdfName)encodingDictionary[PdfName.BaseEncoding]; if (baseEncodingName == null) // Default base encoding. { codes = Encoding.Get(PdfName.StandardEncoding).GetCodes(); } else // Predefined base encoding. { codes = Encoding.Get(baseEncodingName).GetCodes(); } // 2. Differences. LoadEncodingDifferences(encodingDictionary, codes); } this.codes = new BiDictionary <ByteArray, int>(codes); } if (glyphIndexes == null) { /* * NOTE: In case no font file is available, we have to synthesize its metrics * from existing entries. */ glyphIndexes = new Dictionary <int, int>(); PdfArray glyphWidthObjects = (PdfArray)BaseDataObject.Resolve(PdfName.Widths); if (glyphWidthObjects != null) { ByteArray charCode = new ByteArray( new byte[] { (byte)(int)((PdfInteger)BaseDataObject[PdfName.FirstChar]).RawValue } ); foreach (PdfDirectObject glyphWidthObject in glyphWidthObjects) { if (((IPdfNumber)glyphWidthObject).DoubleValue > 0) { int code; if (codes.TryGetValue(charCode, out code)) { glyphIndexes[code] = (int)charCode.Data[0]; } } charCode.Data[0]++; } } } } }
public string GetFlagValuesAsString(FlagsEnum flags) { return flags.ToString(); }
public void SetFlagsEnum(FlagsEnum flagsEnum) { this.flagsEnum = flagsEnum; }
public bool GetNullableFlagsEnum(FlagsEnum? flagsEnum) { if (flagsEnum != null) { return true; } Assert.True(ModelState.IsValid); return false; }
public static void ShouldBeEquivalentTo(this FlagsEnum flagEnum, params FlagsEnum[] becauseArgs) => flagEnum.ToValues().ToArray().Should().BeEquivalentTo(becauseArgs);
private void ShowText( BlockComposer composer, PdfName fontName, double fontSize ) { PrimitiveComposer baseComposer = composer.BaseComposer; ContentScanner scanner = baseComposer.Scanner; RectangleF textBox = scanner.ContentContext.Box; if (scanner.State.Font == null) { /* * NOTE: A zero value for size means that the font is to be auto-sized: its size is computed as * a function of the height of the annotation rectangle. */ if (fontSize == 0) { fontSize = textBox.Height * 0.65; } baseComposer.SetFont(fontName, fontSize); } string text = (string)Value; FlagsEnum flags = Flags; if ((flags & FlagsEnum.Comb) == FlagsEnum.Comb && (flags & FlagsEnum.FileSelect) == 0 && (flags & FlagsEnum.Multiline) == 0 && (flags & FlagsEnum.Password) == 0) { int maxLength = MaxLength; if (maxLength > 0) { textBox.Width /= maxLength; for (int index = 0, length = text.Length; index < length; index++) { composer.Begin( textBox, XAlignmentEnum.Center, YAlignmentEnum.Middle ); composer.ShowText(text[index].ToString()); composer.End(); textBox.X += textBox.Width; } return; } } textBox.X += 2; textBox.Width -= 4; YAlignmentEnum yAlignment; if ((flags & FlagsEnum.Multiline) == FlagsEnum.Multiline) { yAlignment = YAlignmentEnum.Top; textBox.Y += (float)(fontSize * .35); textBox.Height -= (float)(fontSize * .7); } else { yAlignment = YAlignmentEnum.Middle; } composer.Begin( textBox, Justification.ToXAlignment(), yAlignment ); composer.ShowText(text); composer.End(); }
public FlagsEnum GetFlagsEnum(FlagsEnum flagsEnum) { return(flagsEnum); }
public string BoundFuncWithEnumParametersOnCollectionOfRoutingCustomer(SimpleEnum simpleEnum, FlagsEnum flagsEnum) { return "BoundFuncWithEnumParameters(" + simpleEnum + "," + flagsEnum + ")"; }
public string BoundFuncWithEnumParametersOnCollectionOfRoutingCustomer(SimpleEnum simpleEnum, FlagsEnum flagsEnum) { return("BoundFuncWithEnumParameters(" + simpleEnum + "," + flagsEnum + ")"); }
public FlagsEnum GetFlagsEnum(FlagsEnum flagsEnum) { return flagsEnum; }
public string GetFlagsEnum(FlagsEnum id) { ThrowIfInsideThrowsController(); return(id.ToString()); }