コード例 #1
0
        //public Bitmap GetWholeImage(ImageDocument img)
        //{

        //    if (img == null)
        //        return null;

        //    //      InitialImage(img);


        //    Bitmap bitmap = (Bitmap)img.Image;
        //    // BufferedGraphics bmyBuffer = null;
        //    try
        //    {

        //        Bitmap bmp = new System.Drawing.Bitmap((int)(img.Image.Width), (int)(img.Image.Height));

        //        //double widthZoomed = this.htfImageTool1.Width;
        //        //double heigthZoomed = this.htfImageTool1.Height;


        //        //    #endregion Added by rm
        //        Rectangle drawRect = new Rectangle(0, 0, bitmap.Width, bitmap.Height);



        //        Graphics g = Graphics.FromImage(bmp);
        //        //    // g.DrawImage(img.Image, this.panel1.DisplayRectangle, drawRect, GraphicsUnit.Pixel);

        //        g.DrawImage(bitmap, drawRect, drawRect, GraphicsUnit.Pixel);

        //        if (img != null)
        //        {

        //            if (img.layers != null)
        //            {
        //                foreach (Layer layer in img.layers)
        //                {
        //                    if (layer.elements != null)
        //                    {
        //                        foreach (Element el in layer.elements)
        //                        {

        //                            if (el.Tag == null && el.Stream != null && el.Stream.Length > 10)
        //                            {
        //                                try
        //                                {
        //                                    System.IO.MemoryStream ms = new System.IO.MemoryStream(el.Stream);
        //                                    try
        //                                    {
        //                                        System.Drawing.Image myImage = System.Drawing.Image.FromStream(ms);
        //                                        el.Tag = myImage;
        //                                    }
        //                                    catch
        //                                    {

        //                                    }

        //                                    ms.Dispose();
        //                                }
        //                                catch
        //                                { }
        //                            }

        //                            if (el.Tag != null && el.Tag is Image)
        //                            {
        //                                Image TEmpimg = (Image)el.Tag;
        //                                //      TEmpimg.Save("c:\\pppp.jpg");
        //                                //                            int x = 0;
        //                                //                            if (this.htfImageTool1.DisplayRectangle.Size.Width > img.Image.Width * Zoom)
        //                                //                                x = (int)((this.panel1.DisplayRectangle.Size.Width - img.Image.Width * Zoom) / 2);

        //                                //                            int y = 0;
        //                                //                            if (this.htfImageTool1.DisplayRectangle.Size.Height > img.Image.Height * Zoom)
        //                                //                                y = (int)((this.htfImageTool1.DisplayRectangle.Size.Height - img.Image.Height * Zoom) / 2);


        //                                GraphicsUnit gu = GraphicsUnit.Pixel;
        //                                // g.DrawImage(TEmpimg, new Rectangle((int)(el.LocationX * htfImageTool1.Zoom) + x, (int)(el.LocationY * htfImageTool1.Zoom) + y, (int)(TEmpimg.Width * htfImageTool1.Zoom), (int)(TEmpimg.Height * htfImageTool1.Zoom)), TEmpimg.GetBounds(ref gu), GraphicsUnit.Pixel);
        //                                g.DrawImage(TEmpimg, new Rectangle((int)(el.LocationX), (int)(el.LocationY), (int)(TEmpimg.Width), (int)(TEmpimg.Height)), TEmpimg.GetBounds(ref gu), GraphicsUnit.Pixel);
        //                                //                        }
        //                                //                        else if (el.Stream != null)
        //                                //                        {

        //                            }

        //                        }
        //                    }
        //                }
        //            }
        //        }

        //        g.Dispose();
        //        //System.IO.MemoryStream ms1 = new System.IO.MemoryStream();
        //        //bmp.Save(ms1, System.Drawing.Imaging.ImageFormat.Jpeg);
        //        //ms1.Dispose();
        //        return bmp;
        //        // return bitmap;

        //    }
        //    catch (Exception ex)
        //    {
        //        //    if (bmyBuffer != null)
        //        //        bmyBuffer.Dispose();
        //        return (Bitmap)img.Image;
        //        //return null;
        //    }


        //}

        void frmPrint_PrintPage(object sender, PrintDocEventArgs e)
        {
            if (PrintPage != null)
            {
                PrintPage(sender, e);
            }
        }
コード例 #2
0
        public void OnPrintedImages(PrintDocEventArgs e)
        {
            EventHandler <PrintDocEventArgs> handler = PrintedImages;

            if (handler != null)
            {
                handler(this, e);
            }
        }
コード例 #3
0
        public void OnStartPrint(PrintDocEventArgs e)
        {
            EventHandler <PrintDocEventArgs> handler = StartPrint;

            if (handler != null)
            {
                handler(this, e);
            }
        }
コード例 #4
0
        public void Print()
        {
            if (StartPrint != null)
            {
                StartPrint(this, null);
            }


            var frmPrint = new frmPrintPreView();

            frmPrint.CurrentTools     = CurrentImageTools;
            frmPrint.PrintPage       += frmPrint_PrintPage;
            frmPrint.NeedImage       += frmPrint_NeedImage;
            frmPrint.CurrentViewImage = Current as ImageDocument;


            if (BeforPrintPage != null)
            {
                var ev = new ImageEventArg(frmPrint.CurrentViewImage);
                BeforPrintPage(this, ev);
            }


            frmPrint.AllImage = this;


            //for (int i = 0; i < Count; i++)
            //{
            //    var img = this[i] as ImageDocument;

            //    frmPrint.AllImage.Add(img);
            //}

            if (frmPrint.ShowDialog() == DialogResult.OK)
            {
                if (PrintedImages != null)
                {
                    try
                    {
                        var ep = new PrintDocEventArgs(frmPrint.PrintedIndex, frmPrint.PrintDocument.DocumentName, frmPrint.PrintDocument.PrinterSettings.PrinterName);
                        PrintedImages(this, ep);
                    }
                    catch
                    { }
                }
            }

            frmPrint.Dispose();
        }
コード例 #5
0
 void BindingSource_PrintPage(object sender, PrintDocEventArgs e)
 {
     OnPrintPage(e);
 }
コード例 #6
0
 void BindingSource_StartPrint(object sender, PrintDocEventArgs e)
 {
     OnStartPrint(e);
 }
コード例 #7
0
 void BindingSource_PrintedImages(object sender, PrintDocEventArgs e)
 {
     OnPrintedImages(e);
 }