示例#1
0
        public EmbeddedPicture MakeEmbeddedPicture(Type type, string resource, double x1, double y1,
                                                   double x2, double y2)
        {
            PictureImage newImg = new PictureImage(type, resource);

            foreach (PictureImage img in AvailableImages)
            {
                if (img.bitmap.Equals(newImg.bitmap))
                {
                    return(new EmbeddedPicture(img, MakePoint(x1, y1), MakePoint(x2, y2)));
                }
            }
            newImg.id = (AvailableImages.Count);
            AvailableImages.Add(newImg);
            return(new EmbeddedPicture(newImg, MakePoint(x1, y1), MakePoint(x2, y2)));
        }
示例#2
0
        private Shape ShapeFromDict(Dictionary <string, string> valDict)
        {
            switch (valDict["shape"])
            {
            case "point":
                return(MakePoint(int.Parse(valDict["x"]), int.Parse(valDict["y"])));

            case "line":
                return(MakeLine(int.Parse(valDict["x1"]), int.Parse(valDict["y1"]),
                                int.Parse(valDict["x2"]), int.Parse(valDict["y2"])));

            case "ellipse":
                return(MakeEllipse(int.Parse(valDict["x"]), int.Parse(valDict["y"]),
                                   int.Parse(valDict["horizradius"]), int.Parse(valDict["vertradius"])));

            case "circle":
                return(MakeCircle(int.Parse(valDict["x"]), int.Parse(valDict["y"]), int.Parse(valDict["radius"])));

            case "rectangle":
                return(MakeRectangle(int.Parse(valDict["x1"]), int.Parse(valDict["y1"]),
                                     int.Parse(valDict["x2"]), int.Parse(valDict["y2"])));

            case "square":
                return(MakeSquare(int.Parse(valDict["cornerx"]), int.Parse(valDict["cornery"]),
                                  int.Parse(valDict["sidelength"])));

            case "triangle":
                return(MakeTriangle(int.Parse(valDict["x1"]), int.Parse(valDict["y1"]),
                                    int.Parse(valDict["x2"]), int.Parse(valDict["y2"]),
                                    int.Parse(valDict["x3"]), int.Parse(valDict["y3"])));

            case "embeddedpicture":
                PictureImage targetImage = AvailableImages.Find(image => image.id == int.Parse(valDict["imageid"]));
                return(new EmbeddedPicture(targetImage, int.Parse(valDict["x1"]), int.Parse(valDict["y1"]),
                                           int.Parse(valDict["x2"]), int.Parse(valDict["y2"])));

            default:
                throw new ShapeException("Invalid shape name");
            }
            ;
        }
示例#3
0
 public EmbeddedPicture(PictureImage image, double x1, double y1, double x2, double y2)
 {
     Image       = image;
     ImageBounds = new Rectangle(new Point(x1, y1), new Point(x2, y2));
 }
示例#4
0
 public EmbeddedPicture(PictureImage image, Point point1, Point point2)
 {
     Image       = image;
     ImageBounds = new Rectangle(point1, point2);
 }