Пример #1
0
        private void RenderTextStringPrimitive(Graphics g, TextStringRecord textString)
        {
            if (textString.IsHidden || textString.Record != 4)
            {
                return;
            }

            var location = ScreenFromWorld(textString.Location.X, textString.Location.Y);

            using (var brush = new SolidBrush(textString.Color))
                using (var font = CreateFont(textString.FontId))
                {
                    StringAlignment horizontalAlignment;
                    if (textString.Justification == TextJustification.BottomLeft ||
                        textString.Justification == TextJustification.MiddleLeft ||
                        textString.Justification == TextJustification.TopLeft)
                    {
                        horizontalAlignment = StringAlignment.Near;
                    }
                    else if (textString.Justification == TextJustification.BottomCenter ||
                             textString.Justification == TextJustification.MiddleCenter ||
                             textString.Justification == TextJustification.TopCenter)
                    {
                        horizontalAlignment = StringAlignment.Center;
                    }
                    else
                    {
                        horizontalAlignment = StringAlignment.Far;
                    }

                    StringAlignment verticalAlignment;
                    if (textString.Justification == TextJustification.BottomLeft ||
                        textString.Justification == TextJustification.BottomCenter ||
                        textString.Justification == TextJustification.BottomRight)
                    {
                        verticalAlignment = StringAlignment.Far;
                    }
                    else if (textString.Justification == TextJustification.MiddleLeft ||
                             textString.Justification == TextJustification.MiddleCenter ||
                             textString.Justification == TextJustification.MiddleRight)
                    {
                        verticalAlignment = StringAlignment.Center;
                    }
                    else
                    {
                        verticalAlignment = StringAlignment.Near;
                    }

                    g.TranslateTransform(location.X, location.Y);
                    if (textString.Orientations.HasFlag(TextOrientations.Rotated))
                    {
                        g.RotateTransform(-90);
                    }
                    if (textString.Orientations.HasFlag(TextOrientations.Flipped))
                    {
                        horizontalAlignment = StringAlignment.Far - (int)horizontalAlignment;
                        verticalAlignment   = StringAlignment.Far - (int)verticalAlignment;
                    }

                    DrawingUtils.DrawString(g, textString.Text, font, brush,
                                            0, 0, horizontalAlignment, verticalAlignment, false);
                }
        }
Пример #2
0
        /// <summary>
        /// Instantiates a record according to its record type number.
        /// </summary>
        /// <param name="recordType">Integer representing the record type.</param>
        /// <returns>A new empty instance of a record primitive.</returns>
        private SchPrimitive CreateRecord(int recordType)
        {
            SchPrimitive record;

            switch (recordType)
            {
            case 1:
                record = new SchComponent();
                break;

            case 2:
                record = new PinRecord();
                break;

            case 3:
                record = new SymbolRecord();
                break;

            case 4:
                record = new TextStringRecord();
                break;

            case 5:
                record = new BezierRecord();
                break;

            case 6:
                record = new PolylineRecord();
                break;

            case 7:
                record = new PolygonRecord();
                break;

            case 8:
                record = new EllipseRecord();
                break;

            case 9:
                record = new PieChartRecord();
                break;

            case 10:
                record = new RoundedRectangleRecord();
                break;

            case 11:
                record = new EllipticalArcRecord();
                break;

            case 12:
                record = new ArcRecord();
                break;

            case 13:
                record = new LineRecord();
                break;

            case 14:
                record = new RectangleRecord();
                break;

            case 28:
            case 209:
                record = new TextFrameRecord();
                break;

            case 30:
                record = new ImageRecord();
                break;

            case 34:
                record = new Record34();
                break;

            case 41:
                record = new Record41();
                break;

            case 44:
                record = new Record44();
                break;

            case 45:
                record = new Record45();
                break;

            case 46:
                record = new Record46();
                break;

            case 48:
                record = new Record48();
                break;

            default:
                EmitWarning($"Record {recordType} not supported");
                record = new SchPrimitive();
                break;
            }

            return(record);
        }