public CableSymbol(CableInfo cableInfo, E3Text text, Orientation orientation)
 {
     this.cableInfo = cableInfo;
     this.orientation = orientation;
     CableId = cableInfo.Id;
     ovalLength = 0;
     smallFontHeight = 2;
     bigFontHeight = 3;
     isCircle = true;
     E3Font smallFont = new E3Font(height: smallFontHeight);
     E3Font bigFont = new E3Font(height: 3);
     nameTextWidth = text.GetTextLength(cableInfo.Name, bigFont);
     typeTextWidth = text.GetTextLength(cableInfo.Type, smallFont);
     lengthTextWidth = text.GetTextLength(cableInfo.Length, smallFont);
     Size = GetSize();
 }
 public SymbolPin(string name, string signal, E3Text text, E3Font font)
 {
     Name = name;
     Signal = signal;
     CableIds = new List<int>();
     SignalTextWidth = text.GetTextLength(signal, font);
     SignalTextWidth = (SignalTextWidth % 1 > 0) ? (int)(SignalTextWidth + 1) : SignalTextWidth;
 }
 public AssignmentReferenceSymbol(string assignment, int id, int cableId, E3Text text)
 {
     this.id = id;
     triangleHeight = 4;
     triangleBaseLength = 2;
     descriptionVerticalMargin = 2;
     description ="В "+ assignment;
     font = new E3Font();
     double descriptionLength = text.GetTextLength(description, font);
     height = triangleHeight + descriptionVerticalMargin + font.height;
     margin = Math.Max(triangleBaseLength, descriptionLength) / 2;
     cableIds = new List<int>() { cableId };
     CableLayout cableLayout = new CableLayout(cableId, Level.Bottom);
     cableLayout.AddOffset(new Point(0,0));
     CableLayoutById = new Dictionary<int, CableLayout>() { {cableId, cableLayout} };
 }
 private double GetPinsHeight(List<SymbolPin> pins, E3Text text)
 {
     double offset = 2;
     return (pins.Count > 0) ? RoundUp(pins.Max(p => text.GetTextLength(p.Name, smallFont)) + offset) : 0;
 }
 private List<int> DrawPins(Sheet sheet, Graphic graphic, E3Text text, List<SymbolPin> pins, double pinsHeight, double pinsWidth, int sheetId, double xLeft, double pinBottom, double pinTop, Level position)
 {
     List<int> graphicIds = new List<int>(pins.Count * 2 + 1);
     double pinLeft = sheet.MoveRight(xLeft, (Size.Width - pinsWidth) / 2);
     foreach (SymbolPin pin in pins)
     {
         double pinRight = sheet.MoveRight(pinLeft, gridStep);
         int pinOutlineId = graphic.CreateRectangle(sheetId, pinLeft, pinBottom, pinRight, pinTop);
         graphicIds.Add(pinOutlineId);
         double textWidth = text.GetTextLength(pin.Name, smallFont);
         double xPinText = sheet.MoveRight(sheet.MoveRight(pinLeft, halfGridStep), smallFont.height / 2 - 0.2);
         double yPinText = sheet.MoveUp(pinBottom, (pinsHeight - textWidth) / 2);
         graphicIds.Add(text.CreateVerticalText(sheetId, pin.Name, xPinText, yPinText, smallFont));
         int signalTextId = DrawSignalAndSetConnectionPoint(pin, position, sheet, text, sheetId, pinBottom, pinTop, pinLeft);
         graphicIds.Add(signalTextId);
         pinLeft = pinRight;
     }
     return graphicIds;
 }
 private List<int> CreateTerminalSymbol(Sheet sheet, E3Text text, Graphic graphic, int sheetId, Point position)
 {
     List<int> groupIds;
     E3Font smallFont = new E3Font(height:2.5, alignment: Alignment.Left);
     int outlineId = CreateOutline(sheet, graphic, sheetId, position);
     double offset = 0.5;
     double xText = sheet.MoveRight(sheet.MoveRight(position.X, halfGridStep), smallFont.height / 2 - 0.2);
     if (!String.IsNullOrEmpty(Assignment))
     {
         double yAssignmentText = sheet.MoveUp(position.Y, offset);
         groupIds = new List<int>(3);
         groupIds.Add(text.CreateVerticalText(sheetId, Assignment, xText, yAssignmentText, smallFont));
     }
     else
         groupIds = new List<int>(2);
     groupIds.Add(outlineId);
     nameWidth = text.GetTextLength(Name, smallFont);
     double top = sheet.MoveUp(position.Y, Size.Height);
     double yText = sheet.MoveDown(top, offset + nameWidth);
     groupIds.Add(text.CreateVerticalText(sheetId, Name, xText, yText, smallFont));
     foreach (SymbolPin topPin in topPins)
     {
         int signalTextId = DrawSignalAndSetConnectionPoint(topPin, Level.Top, sheet, text, sheetId, position.Y, top, position.X);
         groupIds.Add(signalTextId);
     }
     foreach (SymbolPin bottomPin in bottomPins)
     {
         int signalTextId = DrawSignalAndSetConnectionPoint(bottomPin, Level.Bottom, sheet, text, sheetId, position.Y, top, position.X);
         groupIds.Add(signalTextId);
     }
     return groupIds;
 }
 public void SetPinsAndHeightAndNameWidth(Dictionary<int, DeviceConnection> deviceConnectionById, Dictionary<int, DeviceSymbol> deviceSymbolById, E3Text text)
 {
     GetPins(deviceConnectionById, deviceSymbolById, text);
     double height;
     if (isTerminal)
         height = 25;
     else
     {
         nameWidth = text.GetTextLength(Name, bigFont);
         topPinsHeight = GetPinsHeight(topPins, text);
         bottomPinsHeight = GetPinsHeight(bottomPins, text);
         height = topPinsHeight + bottomPinsHeight + RoundUp(bigFont.height) + 4;
     }
     Size = new Size(0, height);
 }