Esempio n. 1
0
        public override Geometry GetGeometry()
        {
            GeometryGroup group = new GeometryGroup();

            for (int a = 0; a < Texts.Count; a++)
            {
                if (!string.IsNullOrEmpty(Texts[a]))
                {
                    FormattedText formattedText = NewFormattedText(Texts[a]);
                    double        locx          = 0;
                    double        locy          = 0;
                    Rect          bounds        = ShapeComponent.GetGeometry().GetRenderBounds(new Pen(), 0, ToleranceType.Absolute);
                    double        width         = bounds.Width;
                    double        height        = bounds.Height;
                    if (a % 2 == 0)
                    {
                        locx = (width / 2) - (formattedText.Width / 2);
                    }
                    if (a % 2 == 1)
                    {
                        locy = (height / 2) - (formattedText.Height / 2);
                    }
                    if (a % 4 == 2)
                    {
                        locy = width - formattedText.Height;
                    }
                    if (a % 4 == 1)
                    {
                        locx = height - formattedText.Width;
                    }
                    group.Children.Add(formattedText.BuildGeometry(new Point(locx, locy)));
                }
            }
            return(group);
        }
Esempio n. 2
0
        public GeometryGroup GetGeometryGroup()
        {
            GeometryGroup group = new GeometryGroup();

            group.Children.Add(GetGeometry());
            group.Children.Add(ShapeComponent.GetGeometry());
            return(group);
        }
Esempio n. 3
0
 private void SetNewGeometry()
 {
     Geometry = new GeometryGroup();
     //List<ShapeComponent> Nongroupshapes = GetShapesOfGroup();
     foreach (ShapeComponent component in Shapes)
     {
         if (component is InternalShape shape)
         {
             Geometry.Children.Add(shape.GetGeometry(shape.Location.X - Location.X, shape.Location.Y - Location.Y, shape.Width, shape.Height));
         }
         else if (component is ShapeGroup group)
         {
             if (group.Location.X > Location.X)
             {
                 group.Location = new Point(Location.X + 0.0001, group.Location.Y);
             }
             if (group.Location.Y > Location.Y)
             {
                 group.Location = new Point(group.Location.X, Location.Y + 0.0001);
             }
             if (group.Location.X > Location.X || group.Location.Y > Location.Y)
             {
                 group.SetNewGeometry();
             }
             foreach (var item in group.Geometry.Children)
             {
                 Geometry.Children.Add(item);
             }
         }
         else if (component is TextDecorator decorator)
         {
             //if (decorator.Location.X > Location.X)
             //{
             //    decorator.Location = new Point((decorator.Location.X - (decorator.Location.X - Location.X)) + 2, decorator.Location.Y);
             //}
             //if (decorator.Location.Y > Location.Y)
             //{
             //    decorator.Location = new Point(decorator.Location.X, (decorator.Location.Y - (decorator.Location.Y - Location.Y)) + 2);
             //}
             //if (decorator.Location.X > Location.X || decorator.Location.Y > Location.Y)
             //{
             //    decorator.SetNewGeometry();
             //}
             //foreach (var item in decorator.GetGeometryGroup().Children)
             //{
             //    Geometry.Children.Add(item);
             //}
             ShapeComponent decoratedShape = decorator.ShapeComponent;
             Geometry.Children.Add(decoratedShape.GetGeometry(decoratedShape.Location.X - Location.X, decoratedShape.Location.Y - Location.Y, decoratedShape.Width, decoratedShape.Height));
             Geometry texts = decorator.GetGeometry();
             texts.Transform = new TranslateTransform(decoratedShape.Location.X - Location.X, decoratedShape.Location.Y - Location.Y);
             Geometry.Children.Add(texts);
         }
     }
 }