private void LoadPhoto()
    {
        _photoLayer.VObjects.Clear();

        if (!string.IsNullOrEmpty(this.BackgroundImage))
        {
            if (File.Exists(this.BackgroundImage))
            {
                Size  imageSize;
                float hRes, vRes;
                Common.GetImageSize(this.BackgroundImage, out imageSize, out hRes, out vRes);
                _canvasViewer.Canvas.WorkspaceHeight = Common.ConvertPixelsToPoints(vRes, imageSize.Height);
                _canvasViewer.Canvas.WorkspaceWidth  = Common.ConvertPixelsToPoints(hRes, imageSize.Width);

                //we change canvas size, so we need update zoom to save ZoomMode
                _canvasViewer.ZoomMode = _canvasViewer.ZoomMode;

                ImageVObject vo = new ImageVObject(new FileInfo(this.BackgroundImage));
                vo.BorderWidth = 0;
                vo.Locked      = true;
                Aurigma.GraphicsMill.AjaxControls.VectorObjects.Math.RotatedRectangleF r = vo.Rectangle;
                r.Width      = _canvasViewer.Canvas.WorkspaceWidth;
                r.Height     = _canvasViewer.Canvas.WorkspaceHeight;
                r.Location   = new Aurigma.GraphicsMill.AjaxControls.VectorObjects.Math.PointF(0, 0);
                vo.Rectangle = r;
                _photoLayer.VObjects.Insert(0, vo);
            }
            else
            {
                throw new FileNotFoundException("Image file not found.", this.BackgroundImage);
            }
        }
    }
        protected override IVObject CreateObject(System.Drawing.RectangleF destinationRectangle)
        {
            IVObject obj = null;

            try
            {
                obj = new ImageVObject(_bitmap, _scaleToActualSize, 0, 0);
                System.Drawing.RectangleF bounds = obj.GetTransformedVObjectBounds();

                if (destinationRectangle.Width != 0 && destinationRectangle.Height != 0)
                {
                    float scaleX = (float)destinationRectangle.Width / bounds.Width,
                          scaleY = (float)destinationRectangle.Height / bounds.Height;

                    obj.Transform.Scale(scaleX, scaleY, System.Drawing.Drawing2D.MatrixOrder.Append);
                }

                obj.Transform.Translate(destinationRectangle.Left, destinationRectangle.Top, System.Drawing.Drawing2D.MatrixOrder.Append);
            }
            catch
            {
                obj = null;
            }

            return(obj);
        }
 public ImageVObjectData(ImageVObject obj)
     : base(obj)
 {
     RmtUrl = obj.RemoteUrl;
     SrcId  = obj.SourceFileId;
     SrcH   = obj.SourceImageHeight;
     SrcW   = obj.SourceImageWidth;
     HR     = obj.SourceImageHorizontalResolution;
     VR     = obj.SourceImageVerticalResolution;
     DI     = obj.NeedToDownloadImage;
     SAS    = obj.TakeIntoAccountImageDpi;
     T      = obj.Transform;
     P      = obj.ControlPoints;
 }
示例#4
0
        private void ReadImageAttributes(ImageVObject vObject, SvgVoImage svg)
        {
            ReadContentAttributes(vObject, svg);

            var internalStorageImageId = svg.Src;

            if (internalStorageImageId != null && _fileStorage.FileExists(internalStorageImageId))
            {
                string vObjectStorageId = internalStorageImageId;
                using (var imageStream = _fileStorage.GetReadStream(internalStorageImageId))
                    Configuration.FileCache.AddFileWithId(vObjectStorageId, imageStream, true);

                vObject.LoadImage(vObjectStorageId, false, false);
            }
        }
示例#5
0
        private void WriteImageAttributes(SvgVoImage svg, ImageVObject vObject)
        {
            WriteContentAttributes(svg, vObject);

            var fileId = vObject.SourceFileId;

            if (fileId != null && Configuration.FileCache.FileExists(fileId))
            {
                if (!_fileStorage.FileExists(fileId))
                {
                    using (var fileStream = Configuration.FileCache.GetReadStream(fileId, true))
                        _fileStorage.AddFileWithId(fileId, fileStream);
                }

                svg.Src = fileId;
            }
        }
示例#6
0
    public static string CreateImageVObject(string imageId)
    {
        string fileName = Array.Find(Directory.GetFiles(_imageFolder, "*.jpg"),
                                     delegate(string s) { return(s.GetHashCode().ToString() == imageId); });

        if (fileName == null)
        {
            fileName = Array.Find(Directory.GetFiles(_imageFolder, "*.png"),
                                  delegate(string s) { return(s.GetHashCode().ToString() == imageId); });
        }

        ImageVObject vo = new ImageVObject(new FileInfo(fileName));

        //proportional resize to "defaultImageSize"x"defaultImageSize"
        Aurigma.GraphicsMill.AjaxControls.VectorObjects.Math.RotatedRectangleF r = vo.Rectangle;
        float dx = defaultImageSize / r.Width;
        float dy = defaultImageSize / r.Height;
        float d  = dx < dy ? dx : dy;

        r.Width  = d * r.Width;
        r.Height = d * r.Height;

        r.Location   = new Aurigma.GraphicsMill.AjaxControls.VectorObjects.Math.PointF(2, 2);
        vo.Rectangle = r;

        vo.FillColor = System.Drawing.Color.Transparent;

        //proportional resize only
        vo.Permissions.AllowArbitraryResize = false;
        vo.Permissions.AllowRotate          = false;

        // Create thumbnail to show in the layers list
        vo.Tag = GenerateThumbnail(fileName);

        return(vo.Data);
    }
示例#7
0
 internal VObject FromSvg(SvgElement svg)
 {
     if (svg is SvgVoGrid)
     {
         var vObject = new GridVObject();
         ReadGridAttributes(vObject, svg as SvgVoGrid);
         return(vObject);
     }
     else if (svg is SvgPolyline)
     {
         var vObject = new PolylineVObject();
         ReadPolylineAttributes(vObject, svg as SvgPolyline);
         return(vObject);
     }
     else if (svg is SvgVoDashLine)
     {
         var vObject = new DashedLineVObject();
         ReadDashLineAttributes(vObject, svg as SvgVoDashLine);
         return(vObject);
     }
     else if (svg is SvgLine)
     {
         var vObject = new LineVObject();
         ReadLineAttributes(vObject, svg as SvgLine);
         return(vObject);
     }
     else if (svg is SvgEllipse)
     {
         var vObject = new EllipseVObject();
         ReadEllipseAttributes(vObject, svg as SvgEllipse);
         return(vObject);
     }
     else if (svg is SvgVoSvg)
     {
         var vObject = new SvgVObject();
         ReadSvgAttributes(vObject, svg as SvgVoSvg);
         return(vObject);
     }
     else if (svg is SvgVoImage)
     {
         var vObject = new ImageVObject();
         ReadImageAttributes(vObject, svg as SvgVoImage);
         return(vObject);
     }
     else if (svg is SvgVoPlainText)
     {
         var vObject = new PlainTextVObject();
         ReadPlainTextAttributes(vObject, svg as SvgVoPlainText);
         return(vObject);
     }
     else if (svg is SvgVoCurvedText)
     {
         var vObject = new CurvedTextVObject();
         ReadCurvedTextAttributes(vObject, svg as SvgVoCurvedText);
         return(vObject);
     }
     else if (svg is SvgVoAutoScaledText)
     {
         var vObject = new AutoScaledTextVObject();
         ReadAutoScaledTextAttributes(vObject, svg as SvgVoAutoScaledText);
         return(vObject);
     }
     else if (svg is SvgVoPathBoundedText)
     {
         var vObject = new PathBoundedTextVObject();
         ReadPathBoundedTextAttributes(vObject, svg as SvgVoPathBoundedText);
         return(vObject);
     }
     else if (svg is SvgVoBoundedText)
     {
         var vObject = new BoundedTextVObject();
         ReadBoundedTextAttributes(vObject, svg as SvgVoBoundedText);
         return(vObject);
     }
     else if (svg is SvgVoPlaceholder)
     {
         var vObject = new PlaceholderVObject();
         ReadPlaceholderAttributes(vObject, (SvgVoPlaceholder)svg);
         return(vObject);
     }
     else if (svg is SvgVoRectangle)
     {
         var vObject = new RectangleVObject();
         ReadRectangleAttributes(vObject, (SvgVoRectangle)svg);
         return(vObject);
     }
     else if (svg is SvgVoShape)
     {
         var vObject = new ShapeVObject();
         ReadShapeAttributes(vObject, (SvgVoShape)svg);
         return(vObject);
     }
     else
     {
         return(null);
     }
 }