Devexpress.chartcontro controls to save pictures and print pictures

Source: Internet
Author: User

        Private voidPictureBox1_Click (Objectsender, EventArgs e) {            ////Instantiate a print objectPrintDocument print =NewPrintDocument (); //Print EventPrint. PrintPage + =NewPrintpageeventhandler (print_printpage); //Start printingPrintDialog PD =NewPrintDialog (); if(PD. ShowDialog () = =DialogResult.OK) {//Print. PrinterSettings.DefaultPageSettings.Landscape = true;Print.            Print (); }            //Delete the pictures saved locally after printingPrint. EndPrint + =NewPrinteventhandler (Print_endprint); }        /// <summary>        ///Labhemodialysis generated graphs are saved locally, and get/// </summary>        /// <returns></returns>        PrivateImage get_image () {Bitmap bmp; if(Str_itemname.contains ("/"))            {                stringStr_itemnamerelapce = Str_itemname.replace ("/",""); Labhemodialysis.exporttoimage (@"C +"+ Str_itemnamerelapce +". Jpeg", System.Drawing.Imaging.ImageFormat.Jpeg); BMP=NewBitmap (@"C +"+ Str_itemnamerelapce +". Jpeg"); }            Else {                //Save to C driveLabhemodialysis.exporttoimage (@"C +"+ Str_itemname +". Jpeg", System.Drawing.Imaging.ImageFormat.Jpeg); //get pictures from C driveBMP =NewBitmap (@"C +"+ Str_itemname +". Jpeg"); }           returnbmp; }        //Delete a locally saved picture        Private voidDelete_image () {System.IO.FileInfo file=NewSystem.IO.FileInfo (@"C +"+ Str_itemname +". Jpeg"); if(file. Exists) {file.            Delete (); }          }        Private voidPrint_endprint (Objectsender, PrintEventArgs e)        {delete_image (); }       Private voidPrint_printpage (Objectsender, PrintPageEventArgs e) {Image img=Get_image (); Image Rotataimage= Rotate ((Bitmap) img, -); E.graphics.drawimage (Rotataimage,0,0); }       /// <summary>       ///rotate the image in a counterclockwise direction/// </summary>       /// <param name= "B" >Bitmap Stream</param>       /// <param name= "angle" >angle of rotation [0,360] (front desk)</param>       /// <returns></returns>       PrivateBitmap Rotate (Bitmap B,intangle) {Angle= Angle% the; //radians Conversion           DoubleRadian = angle * Math.PI/180.0; Doublecos =Math.Cos (Radian); DoubleSin =Math.sin (Radian); //the width and height of the original           intW =B.width; inth =B.height; intW = (int) (Math.max (Math.Abs (w * cos-h * sin), math.abs (w * cos + h *sin)); intH = (int) (Math.max (Math.Abs (w * sin-h * cos), math.abs (w * sin + H *cos)); //Target BitmapBitmap Dsimage =NewBitmap (W, H); System.Drawing.Graphics g=System.Drawing.Graphics.FromImage (dsimage); G.interpolationmode=System.Drawing.Drawing2D.InterpolationMode.Bilinear; G.smoothingmode=System.Drawing.Drawing2D.SmoothingMode.HighQuality; //Calculate offsetPoint Offset =NewPoint (W-W)/2, (H-H)/2); //to construct an image display area: Align the center of the image with the center of the windowRectangle rect =NewRectangle (Offset.x, Offset.y, W, h); Point Center=NewPoint (rect. X + rect. Width/2, Rect. Y + rect. Height/2); G.translatetransform (center. X, center.           Y); G.rotatetransform ( the-angle); //restores the panning of the image in both horizontal and vertical directionsG.translatetransform (-center. X,-Center.           Y);           G.drawimage (b, rect); //all transformations to the drawingG.resettransform ();           G.save ();           G.dispose (); //dsimage.save ("Yuancd.jpg", System.Drawing.Imaging.ImageFormat.Jpeg);           returnDsimage; }     

        Private stringPrintname;//the name of the print        Private voidBoxsava_click (Objectsender, EventArgs e) {SaveFileDialog SF=NewSaveFileDialog (); sf. Filter="Image Files (*.jpeg,*.gif) |*.jpeg;*.gif"; sf. Title="Trend Map Export"; sf. FileName= str_itemname+"("+datetime.now+")"+"Trend Chart"; Printname=SF.            FileName; if(SF. ShowDialog () = =DialogResult.OK) {labhemodialysis.exporttoimage (sf.            FileName, System.Drawing.Imaging.ImageFormat.Jpeg); }        }

Devexpress.chartcontro controls to save pictures and print pictures

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.