Exemplo n.º 1
0
 void img_ShapeChanged(Sbn.FramWork.Drawing.IShape shape, object changing)
 {
 }
Exemplo n.º 2
0
        void img_ShapeMouseUp(Sbn.FramWork.Drawing.IShape shape, Sbn.FramWork.Drawing.IDocument document, MouseEventArgs e)
        {
            try
            {
                if (shape is Sbn.AdvancedControls.Imaging.SbnPaint.Image)
                {
                    Sbn.AdvancedControls.Imaging.SbnPaint.Image img = (Sbn.AdvancedControls.Imaging.SbnPaint.Image)shape;
                    Element el = (Element)img.Tag;// (Element)img.Bitmap.Tag;

                    Image  img2;
                    double ll = Math.Truncate(this.drawingPanel1.ZoomFactor * 100000);
                    float  tt = (float)(100000 / ll);


                    //Bitmap bmp = new Bitmap((int)shape.Dimension.Width, (int)shape.Dimension.Height);

                    //System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(bmp);
                    //RectangleF rect = new RectangleF(0, 0, bmp.Width, bmp.Height);
                    //GraphicsUnit ff = GraphicsUnit.Pixel;
                    //RectangleF Destrect;
                    //if (img.Bitmap != null)
                    //{
                    //    Destrect = img.Bitmap.GetBounds(ref ff);
                    //    g.DrawImage(img.Bitmap, Destrect);
                    //}
                    //else
                    //{
                    //   // Destrect = selectedShape.Geometric.GetBounds();
                    //    // g.DrawImage(selectedShape.Appearance.Image, rect);
                    //}



                    if (shape is Sbn.AdvancedControls.Imaging.SbnPaint.Image)
                    {
                        img  = (Sbn.AdvancedControls.Imaging.SbnPaint.Image)shape;
                        img2 = img.Bitmap;
                        // img2 = bmp;// shape.Appearance.Image;
                    }
                    else
                    {
                        img2 = img.getImageFromShape(img, this.drawingPanel1.ZoomFactor);
                    }

                    ((Bitmap)img2).MakeTransparent(Color.White);
                    System.IO.MemoryStream ms = new MemoryStream();
                    img2.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
                    el.Stream = new byte[ms.Length];
                    el.Stream = ms.GetBuffer();
                    //System.IO.MemoryStream ms2 = new System.IO.MemoryStream(strem);
                    //System.Drawing.Image myImage = System.Drawing.Image.FromStream(ms2);
                    //myImage.Save("c:\\temp.png", System.Drawing.Imaging.ImageFormat.Png);
                    //Bitmap bm = new Bitmap(img2);
                    int x = (int)(shape.Location.X - this.drawingPanel1.BackgroundLayer.Location.X);
                    int y = (int)(shape.Location.Y - this.drawingPanel1.BackgroundLayer.Location.Y);
                    el.LocationX = (long)(x * tt); // this.ucPaint1.drawingPanel1.HorizontalScroll.Value + film.Location.X;
                    el.LocationY = (long)(y * tt); // this.ucPaint1.drawingPanel1.VerticalScroll.Value + film.Location.Y;
                    el.Tag       = img2;
                    img2.Tag     = el;
                    ms.Close();
                    ms.Dispose();
                }
            }
            catch
            {
            }
        }