Exemple #1
0
        public PhotoLayer getClip()
        {
            PhotoLayer pl = new PhotoLayer();

            if (Layer.Children.Contains(sImg))
            {
                Rect            r  = sImg.Clip.Rect;
                WriteableBitmap cb = DrawGraphic.getImageArea(r, sImg);
                pl.setPhoto(cb, ScalePercent, sImg.Clip);
            }
            else
            {
                pl.setPhoto(Photo.Source as WriteableBitmap, ScalePercent);
            }
            return(pl);
        }
Exemple #2
0
        //public void select(GeometryGroup gg)//依据一组gg添加一个选区
        //{//在该图层上面复制一个图像,然后设置一个clip
        //    Image si = new Image();
        //    si.Height = Photo.Height;
        //    si.Width = Photo.Width;
        //    gg.FillRule = FillRule.EvenOdd;
        //    PathFigure pf=null;

        //    WriteableBitmap wb = new WriteableBitmap(Photo.Source);

        //}

        public PhotoLayer getCopy()
        {
            PhotoLayer t = new PhotoLayer();

            t.setPhoto(Photo.Source as WriteableBitmap, ScalePercent);
            foreach (UIElement ui in canvasTempObject.Children)
            {
                Type ut = ui.GetType();
                if (ut.Name == "Rectangle")
                {
                    Rectangle tr = new Rectangle();
                    t.Layer.Children.Add(tr);
                    tr.Fill   = ((Rectangle)ui).Fill;
                    tr.Stroke = ((Rectangle)ui).Stroke;
                    tr.Width  = ((Rectangle)ui).Width;
                    tr.Height = ((Rectangle)ui).Height;
                    Canvas.SetLeft(tr, Canvas.GetLeft(ui));
                    Canvas.SetTop(tr, Canvas.GetTop(ui));
                }
                if (ut.Name == "Ellipse")
                {
                    Ellipse tr = new Ellipse();
                    t.Layer.Children.Add(tr);
                    tr.Fill   = ((Ellipse)ui).Fill;
                    tr.Stroke = ((Ellipse)ui).Stroke;
                    tr.Width  = ((Ellipse)ui).Width;
                    tr.Height = ((Ellipse)ui).Height;
                    Canvas.SetLeft(tr, Canvas.GetLeft(ui));
                    Canvas.SetTop(tr, Canvas.GetTop(ui));
                }
                if (ut.Name == "Path")
                {
                    Path         tr = new Path();
                    PathGeometry tp = new PathGeometry();
                    PathGeometry sp = ((Path)ui).Data as PathGeometry;

                    foreach (PathFigure pf in sp.Figures)
                    {
                        PathFigure tpf = new PathFigure();
                        tp.Figures.Add(tpf);
                        tpf.StartPoint = new Point(pf.StartPoint.X, pf.StartPoint.Y);
                        tpf.IsClosed   = pf.IsClosed;
                        tpf.IsFilled   = pf.IsFilled;
                        foreach (PathSegment ps in pf.Segments)
                        {
                            Type pathtype = ps.GetType();
                            if (pathtype.Name == "LineSegment")
                            {
                                LineSegment ls = new LineSegment();
                                ls.Point = new Point(((LineSegment)ps).Point.X, ((LineSegment)ps).Point.Y);
                                tpf.Segments.Add(ls);
                            }
                            if (pathtype.Name == "ArcSegment")
                            {
                                ArcSegment ls = new ArcSegment();
                                ls.Point          = new Point(((LineSegment)ps).Point.X, ((LineSegment)ps).Point.Y);
                                ls.RotationAngle  = ((ArcSegment)ps).RotationAngle;
                                ls.Size           = new Size(((ArcSegment)ps).Size.Width, ((ArcSegment)ps).Size.Height);
                                ls.SweepDirection = ((ArcSegment)ps).SweepDirection;
                                tpf.Segments.Add(ls);
                            }
                        }
                    }
                    tr.Data = tp;
                    t.Layer.Children.Add(tr);
                    tr.Fill   = ((Path)ui).Fill;
                    tr.Stroke = ((Path)ui).Stroke;
                    tr.Width  = ((Path)ui).Width;
                    tr.Height = ((Path)ui).Height;
                    Canvas.SetLeft(tr, Canvas.GetLeft(ui));
                    Canvas.SetTop(tr, Canvas.GetTop(ui));
                }
            }
            return(t);
        }