Exemple #1
0
 /// <summary>
 /// Recursive method to print out all the data of a shape for file saving
 /// </summary>
 /// <returns></returns>
 private StringBuilder GetFileString(Shape.Shape shape, StringBuilder data, int depth)
 {
     for (int i = 0; i < depth; i++)
     {
         data.Append("\t");
     }
     data.Append(shape.GetType().Name.ToString());
     data.Append(" ");
     data.Append($"{shape.GetPosition().X} {shape.GetPosition().Y}");
     data.Append(" ");
     data.Append($"{shape.GetSize().Width} {shape.GetSize().Height}");
     data.Append(" ");
     data.Append($"{shape.Color.R} {shape.Color.G} {shape.Color.B}");
     data.Append("\n");
     foreach (Ornament o in shape.GetOrnaments())
     {
         for (int i = 0; i < depth; i++)
         {
             data.Append("\t");
         }
         data.Append("Ornament");
         data.Append(" ");
         data.Append(o.ornamentOrientation);
         data.Append(" ");
         data.Append($"\"{o.text}\"");
         data.Append("\n");
     }
     depth += 1;
     foreach (var child in shape.GetChildren())
     {
         seen.Add(child);
         GetFileString(child, data, depth);
     }
     return(data);
 }
Exemple #2
0
        //TODO make size not negative ever
        public override void Execute()
        {
            oldSize     = shape.GetSize();
            oldPosition = shape.GetPosition();
            switch (resizeMode)
            {
            case ResizeMode.N:
                shape.OffsetPosition(new Point(0, sizeDifference.Height));
                shape.IncreaseSize(0, sizeDifference.Height);
                break;

            case ResizeMode.S:
                shape.IncreaseSize(0, -sizeDifference.Height);
                break;

            case ResizeMode.E:
                shape.IncreaseSize(-sizeDifference.Width, 0);
                break;

            case ResizeMode.W:
                shape.OffsetPosition(new Point(sizeDifference.Width, 0));
                shape.IncreaseSize(sizeDifference.Width, 0);
                break;

            case ResizeMode.NW:
                shape.OffsetPosition(new Point(sizeDifference.Width, sizeDifference.Height));
                shape.IncreaseSize(sizeDifference.Width, sizeDifference.Height);
                break;

            case ResizeMode.NE:
                shape.OffsetPosition(new Point(0, sizeDifference.Height));
                shape.IncreaseSize(-sizeDifference.Width, sizeDifference.Height);
                break;

            case ResizeMode.SW:
                shape.OffsetPosition(new Point(sizeDifference.Width, 0));
                shape.IncreaseSize(sizeDifference.Width, -sizeDifference.Height);
                break;

            case ResizeMode.SE:
                shape.IncreaseSize(-sizeDifference.Width, -sizeDifference.Height);
                break;

            default:
                throw new NotImplementedException();
            }
        }
Exemple #3
0
        private Point CalculatePosition()
        {
            var ppos  = parent.GetPosition();
            var psize = parent.GetSize();
            var c     = (psize.Width / 2) - tb.Size.Width / 2;
            var x     = ppos.X + c;

            switch (ornamentOrientation)
            {
            case OrnamentOrientation.Top:
                return(new Point(x, ppos.Y - (tb.Size.Height / 2)));

            case OrnamentOrientation.Right:
                return(new Point((ppos.X + psize.Width) - (tb.Size.Width / 2), ppos.Y + (psize.Height / 2) - (tb.Size.Height / 2)));

            case OrnamentOrientation.Bottom:
                return(new Point(x, (ppos.Y + psize.Height + (tb.Size.Height / 2)) - tb.Size.Height));

            case OrnamentOrientation.Left:
                return(new Point(ppos.X - (tb.Size.Width / 2), ppos.Y + (psize.Height / 2) - (tb.Size.Height / 2)));
            }
            return(parent.Position);
        }