Пример #1
0
        public static creativeElement moveObject(creativeElement currentCreativeElement, string direction,
                                                 int gridHeigth, int gridWidth, double verschiebung, int scalingFactor, int einspannungsGrenzen)
        {
            PathGeometry actualPathGeometry        = currentCreativeElement.pathGeometry;
            PathGeometry actualFillingPathGeometry = currentCreativeElement.fillingPathGeometry;


            Rect   safetyRect = Converter.GetMinimalMaxRect(actualPathGeometry, 0);
            double top        = safetyRect.Bottom; //inverted because of inverted grid
            double bottom     = safetyRect.Top;    //inverted because of inverted grid
            double right      = safetyRect.Right;
            double left       = safetyRect.Left;

            if (direction == "up" && top + verschiebung <= gridHeigth - (einspannungsGrenzen * scalingFactor))
            {
                actualPathGeometry = Converter.TranslatePathGeometry(actualPathGeometry, 0.0, +verschiebung);
                currentCreativeElement.pathGeometry = actualPathGeometry;
                if (currentCreativeElement.filled)
                {
                    currentCreativeElement.fill();
                }
            }
            else if (direction == "down" && bottom - verschiebung >= (einspannungsGrenzen * scalingFactor))
            {
                actualPathGeometry = Converter.TranslatePathGeometry(actualPathGeometry, 0.0, -verschiebung);
                currentCreativeElement.pathGeometry = actualPathGeometry;
                if (currentCreativeElement.filled)
                {
                    currentCreativeElement.fill();
                }
            }
            else if (direction == "left" && left - verschiebung >= (einspannungsGrenzen * scalingFactor))
            {
                actualPathGeometry = Converter.TranslatePathGeometry(actualPathGeometry, -verschiebung, 0.0);
                currentCreativeElement.pathGeometry = actualPathGeometry;
                if (currentCreativeElement.filled)
                {
                    currentCreativeElement.fill();
                }
            }
            else if (direction == "right" && right + verschiebung <= gridWidth - (einspannungsGrenzen * scalingFactor))
            {
                actualPathGeometry = Converter.TranslatePathGeometry(actualPathGeometry, +verschiebung, 0.0);
                currentCreativeElement.pathGeometry = actualPathGeometry;
                if (currentCreativeElement.filled)
                {
                    currentCreativeElement.fill();
                }
            }
            return(currentCreativeElement);
        }
Пример #2
0
        public static creativeElement changeSize(creativeElement currentCreativeElement, bool increase, int height, int width, double increaseDecreaseFactor, int scalingFactor, int einspannungsGrenzen)
        {
            PathGeometry    oldPathGeometry    = currentCreativeElement.pathGeometry;
            PathGeometry    newPathGeometry    = oldPathGeometry;
            creativeElement newCreativeElement = new creativeElement(currentCreativeElement.filled, currentCreativeElement.name, currentCreativeElement.textElement, currentCreativeElement.text, currentCreativeElement.abstandZwischenLinien, currentCreativeElement.winkel, currentCreativeElement.scalingFactor, currentCreativeElement.offset, newPathGeometry);

            Rect   safetyRect = Converter.GetMinimalMaxRect(oldPathGeometry, 0);
            double top        = safetyRect.Bottom; //inverted because of inverted grid
            double bottom     = safetyRect.Top;    //inverted because of inverted grid
            double right      = safetyRect.Right;
            double left       = safetyRect.Left;

            if (increase)
            {
                /*  old stuff
                 * //1) x-Stretch, 2) rotate 3) neigung 4) y-Stretch 5) x-Verschiebung 6) y-Verschiebung
                 * //actualPathGeometry.Transform = Transform.Parse("1.1, 0, 0, 1.1, 0, 0");
                 * transform = new ScaleTransform(1.05, 1.05);
                 * newPathGeometry = Geometry.Combine(actualPathGeometry, emptyGeometry, GeometryCombineMode.Union, transform);
                 */

                newPathGeometry = Converter.ScalingPathGeometry(oldPathGeometry, 1.0 + increaseDecreaseFactor);
                newCreativeElement.pathGeometry = newPathGeometry;

                //check whether new geometry is too big for grid
                if (pathGeometryToBig(newPathGeometry, height, width, scalingFactor, einspannungsGrenzen))
                {
                    return(currentCreativeElement);
                }
                else
                {
                    if (newCreativeElement.filled)
                    {
                        newCreativeElement.fill();
                    }
                }
            }
            else //decrease
            {
                newCreativeElement.pathGeometry = Converter.ScalingPathGeometry(currentCreativeElement.pathGeometry, 1.0 - increaseDecreaseFactor);
                if (newCreativeElement.filled)
                {
                    newCreativeElement.fill();
                }
            }



            return(newCreativeElement);
        }
Пример #3
0
 public static creativeElement fillObject(creativeElement currentCreativeElement)
 {
     //fill the boy
     //creativeElement newCreativeElement;
     return(currentCreativeElement);
 }