Ejemplo n.º 1
0
        public override bool Tidy(SnapModes mode, Page page)
        {
            // By default this isn't enabled - is only usable if the overriding class adds Tidy to the Allows return value
            switch (mode)
            {
            case SnapModes.Grid:
                switch (page.Paper.PaperType)
                {
                case Paper.Papers.Plain:
                    return(false);                                    // cannot tidy up to an isometric grid
                }
                break;

            case SnapModes.Shape:                     // will be attempted below
                break;

            default:
                return(false);                        // mainly intended for angle; where the shape is by definition aligned on the grid
            }
            List <PointF> points = new List <PointF>();

            points.AddRange(m_Bounds.GetPoints());
            Lined.TidyVertices(points, this, mode, page, 3);
            // but that might not have created an orthogonal rectangle.  So calculate the complete rectangle bounding these.  For tidying to grid
            // that should just return the same points again
            m_Bounds = RectangleF.Empty;
            Geometry.Extend(ref m_Bounds, points);
            return(true);
        }
Ejemplo n.º 2
0
        public override bool Tidy(SnapModes mode, Page page)
        {
            List <PointF> vertices = new List <PointF>(Vertices);           // function below needs a list not an array
            bool          changed  = Lined.TidyVertices(vertices, this, mode, page, 1);

            if (changed)
            {
                Vertices = vertices.ToArray();
                m_Bounds = RectangleF.Empty;
                ClearTextCache();
            }
            return(changed);
        }
Ejemplo n.º 3
0
        public override bool Tidy(SnapModes mode, Page page)
        {
            List <PointF> col        = new List <PointF>(Vertices);
            float         transverse = Geometry.DistanceBetween(Vertices[1], Vertices[2]);     // the transverse distance

            if (!Lined.TidyVertices(col, this, mode, page, 3))
            {
                return(false);
            }
            // make sure it is rectangular again!...
            // the base class tidies the points independently and could end up with a parallelogram, this ensures that it remains a rectangle.  Copied from rectangle, but removing part of it which snapped the transverse size (not so applicable here we probably want to maintain the ratio for images?)
            Vertices = col.ToArray();
            int direction = Geometry.TurnDirection(Vertices[0], Vertices[1], Vertices[2]);

            Vertices[2] = Vertices[1] + Vertices[0].VectorTo(Vertices[1]).Perpendicular(direction).ChangeLength(transverse);
            Vertices[3] = Vertices[0] + Vertices[1].VectorTo(Vertices[2]);
            m_Bounds    = CalculateBounds();
            return(true);
            // This doesn't perform very well when aligning with other shapes; the initial function will tidy the individual points, but usually one will become misaligned again
            // when correcting the rectangle.  It would be better to do a proper moving snap, but I'm not sure if it's really worth the effort
        }