コード例 #1
0
ファイル: ParaphControl.cs プロジェクト: code-mtnit/WPFSM
        //private void UpdateElement(Element el)
        //{
        //    //foreach (Layer ly in CurrentImage.layers.m_Col)
        //    //{
        //    //    foreach(ele
        //    //}
        //}

        //public void AddImage(System.Drawing.Image img, Point location)
        //{
        //   drawingPanel1.AddImage(img , location);


        //    tsbtnCurser.Checked = true;

        //}


        //public void AddText(string text, Point location)
        //{

        //}

        public Layers getElements()
        {
            Layers lys = new Layers();

            if (this.CurrentImage.layers != null && this.CurrentImage.layers.Count > 1)
            {
                foreach (Layer ly in this.CurrentImage.layers)
                {
                }
            }
            else
            {
                Layer    ly   = new Layer();
                Elements elms = new Elements();

                foreach (Sbn.FramWork.Drawing.Shape film in this.drawingPanel1.Shapes)
                {
                    if (!(film is Sbn.AdvancedControls.Imaging.SbnPaint.BodyBackground))
                    {
                        Element el = new Element();
                        Sbn.AdvancedControls.Imaging.SbnPaint.Image img = new Sbn.AdvancedControls.Imaging.SbnPaint.Image();
                        Image  img2;
                        double ll = Math.Truncate(this.drawingPanel1.ZoomFactor * 100000);
                        float  tt = (float)(100000 / ll);

                        if (film is Sbn.AdvancedControls.Imaging.SbnPaint.Image)
                        {
                            img  = (Sbn.AdvancedControls.Imaging.SbnPaint.Image)film;
                            img2 = img.Bitmap;
                        }
                        else
                        {
                            img2 = img.getImageFromShape(film, 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)(film.Location.X - this.drawingPanel1.BackgroundLayer.Location.X);
                        int y = (int)(film.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;

                        ms.Close();
                        ms.Dispose();

                        elms.Add(el);
                    }
                }

                ly.elements = elms;
                lys.Add(ly);
            }



            return(lys);
        }
コード例 #2
0
ファイル: ParaphControl.cs プロジェクト: code-mtnit/WPFSM
        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
            {
            }
        }