SymDef CreateLineTextSymdef(string name, int ocadID, OcadLineTextSymbol ocadSym) { SymColor fontColor; bool bold, italic; TextSymDef symdef; float fontSize; float charSpacing; float wordSpacing; TextSymDefAlignment fontAlign; fontColor = GetColor(ocadSym.FontColor); italic = ocadSym.Italic; bold = (ocadSym.Weight >= 500); if (ocadSym.Alignment == 1) fontAlign = TextSymDefAlignment.Center; else if (ocadSym.Alignment == 2) fontAlign = TextSymDefAlignment.Right; else if (ocadSym.Alignment == 3) fontAlign = TextSymDefAlignment.Justified; else fontAlign = TextSymDefAlignment.Left; // ocadSym.FontSize is in 10ths of a point. Convert to mm. fontSize = ocadSym.FontSize / 720F * 25.4F; charSpacing = ocadSym.CharSpace / 100F; wordSpacing = ocadSym.WordSpace / 100F; symdef = new TextSymDef(name, ocadID); symdef.SetFont(ocadSym.FontName, fontSize, bold, italic, fontColor, fontSize, 0F, 0F, 0F, null, charSpacing, wordSpacing, fontAlign); // handle framing. ReadFraming(ocadSym.FrMode, ocadSym.FrFlags, ocadSym.FrColor, ocadSym.FrWidth, ocadSym.FrSize, ocadSym.FrOfX, ocadSym.FrOfY, 0, 0, 0, 0, symdef); return symdef; }
static public OcadSymbol Read(BinaryReader reader, int version) { int Size; int Sym = 0; short Otp; byte SymTp = 0; if (version <= 8) { Size = reader.ReadInt16(); Sym = reader.ReadInt16(); Otp = reader.ReadInt16(); SymTp = reader.ReadByte(); } else { Size = reader.ReadInt32(); Sym = reader.ReadInt32(); Otp = reader.ReadByte(); } byte Flags = reader.ReadByte(); OcadSymbol sym; if (Otp == 1) { sym = new OcadPointSymbol(); } else if (Otp == 2 && SymTp == 0) sym = new OcadLineSymbol(); else if (Otp == 2 && SymTp == 1) sym = new OcadLineTextSymbol(); else if (Otp == 3) sym = new OcadAreaSymbol(); else if (Otp == 4) sym = new OcadTextSymbol(); else if (Otp == 5 || Otp == 7) sym = new OcadRectSymbol(); else if (Otp == 6) sym = new OcadLineTextSymbol(); else { Debug.Assert(false); return null; } sym.Size = Size; sym.Sym = Sym; sym.Otp = Otp; sym.SymTp = SymTp; sym.Flags = Flags; if (version <= 8) sym.Extent = reader.ReadInt16(); sym.Selected = (reader.ReadByte() != 0) ? true : false; sym.Status = reader.ReadByte(); if (version <= 8) { sym.Tool = reader.ReadInt16(); sym.FrWidth = reader.ReadInt16(); } else { sym.Tool = reader.ReadByte(); sym.CsMode = reader.ReadByte(); sym.CsObjType = reader.ReadByte(); sym.CsCdFlags = reader.ReadByte(); sym.Extent = reader.ReadInt32(); } sym.FilePos = reader.ReadInt32(); if (version <= 8) { sym.ColorSet = Util.ReadByteArray(reader, 32); } else { sym.Group = reader.ReadInt16(); sym.nColors = reader.ReadInt16(); sym.ColorsUsed = new short[sym.nColors]; for (int i = 0; i < 14; ++i) { short colorId = reader.ReadInt16(); if (i < sym.nColors) sym.ColorsUsed[i] = colorId; } } sym.Description = Util.ReadDelphiString(reader, 31); sym.IconBits = Util.ReadByteArray(reader, (version <= 8) ? 264 : 484); sym.ReadExtra(reader, version); return sym; }