Example #1
0
        public PartEntityText AddTextEntity(Vector2 start, string text, bool verticalText = false)
        {
            PartEntityText entity = new PartEntityText()
            {
                Start             = start,
                Text              = text,
                EntityType        = EntityType.Text,
                ShowBoundingFrame = true,
            };

            if (verticalText)
            {
                entity.Rotation = -90;
            }
            Entities.Add(entity);
            return(entity);
        }
        public PartEntityGrainLine(Vector2 start, Vector2 end, string text, bool verticalText)
        {
            PartEntityText entityText = new PartEntityText()
            {
                Start             = start,
                Text              = text,
                EntityType        = EntityType.Text,
                ShowBoundingFrame = false,
            };

            if (verticalText)
            {
                entityText.Rotation = -90;
            }

            Start      = start;
            End        = end;
            EntityType = EntityType.GrainLine;
            Entities   = new List <PartEntity>();
            Entities.Add(entityText);
            BuildGrainLine();
        }
Example #3
0
        public PartEntityMeasurements(Vector2 startFirst, List <MeasurmentText> measurements)
        {
            Entities   = new List <PartEntity>();
            EntityType = EntityType.Text;

            Vector2     start               = startFirst;
            PartExtents boundsFirst         = new PartExtents();
            float       paddingBetweenLines = 3f;

            foreach (MeasurmentText line in measurements)
            {
                PartExtents bounds = Utils.CalcFontSizeBounds(line.TextSize, line.Text, "Arial");
                if (boundsFirst.IsEmpty())
                {
                    boundsFirst.Copy(bounds);
                }

                start += Utils.Down(bounds.Height + paddingBetweenLines);

                PartEntityText entityText = new PartEntityText()
                {
                    Start             = start,
                    End               = start + Utils.Right(bounds.Width),
                    Text              = line.Text,
                    IsItalic          = line.IsItalic,
                    IsBold            = line.IsBold,
                    TextSize          = line.TextSize,
                    EntityType        = EntityType.Text,
                    ShowBoundingFrame = false,
                };
                Entities.Add(entityText);
            }

            PartExtents extents = PartExtents.CalcPartExtents(Entities);

            Start = new Vector2(extents.MinX, extents.MinY);
            End   = new Vector2(extents.MaxX, extents.MaxY);

            float          padding = 10f;
            PartEntityLine line1   = new PartEntityLine()
            {
                Start      = Start + Utils.Up(boundsFirst.Height + paddingBetweenLines) + Utils.Left(padding / 2) + Utils.Up(padding / 2),
                End        = Start + Utils.Up(boundsFirst.Height + paddingBetweenLines) + Utils.Right(extents.Width) + Utils.Right(padding / 2) + Utils.Up(padding / 2),
                EntityType = EntityType.MeasurementLine,
            };

            Entities.Add(line1);
            PartEntityLine line2 = new PartEntityLine()
            {
                Start      = line1.End,
                End        = line1.End + Utils.Down(extents.Height + boundsFirst.Height + paddingBetweenLines) + Utils.Down(padding),
                EntityType = EntityType.MeasurementLine,
            };

            Entities.Add(line2);
            PartEntityLine line3 = new PartEntityLine()
            {
                Start      = line2.End,
                End        = line2.End + Utils.Left(extents.Width) + Utils.Left(padding),
                EntityType = EntityType.MeasurementLine,
            };

            Entities.Add(line3);
            PartEntityLine line4 = new PartEntityLine()
            {
                Start      = line3.End,
                End        = line1.Start,
                EntityType = EntityType.MeasurementLine,
            };

            Entities.Add(line4);

            extents = PartExtents.CalcPartExtents(Entities);
            Start   = new Vector2(extents.MinX, extents.MinY);
            End     = new Vector2(extents.MaxX, extents.MaxY);
        }