//Konstruktor
        public Spielfeld(System.Windows.Forms.Form Form, int aFieldCountX, int aFieldCountY, int aFieldSize, int aLocationX, int aLocationY)
        {
            LocationX   = aLocationX;
            LocationY   = aLocationY;
            FieldSize   = aFieldSize;
            FieldCountX = aFieldCountX;
            FieldCountY = aFieldCountY;

            PenPlayground = new System.Drawing.Pen(System.Drawing.Color.White, 2);
            formGraphic   = Form.CreateGraphics();
            formGraphic.Clear(System.Drawing.Color.Blue);
            int LocationEndX = LocationX + FieldCountX * FieldSize;
            int LocationEndY = LocationY + FieldCountY * FieldSize;

            // X Reihe
            for (int i = 0; i < FieldCountY + 1; i++)
            {
                formGraphic.DrawLine(PenPlayground, LocationX, LocationY + i * FieldSize, LocationEndX, LocationY + i * FieldSize);
            }
            // Y Reihe
            for (int i = 0; i < FieldCountX + 1; i++)
            {
                formGraphic.DrawLine(PenPlayground, LocationX + i * FieldSize, LocationY, LocationX + i * FieldSize, LocationEndY);
            }
        }
예제 #2
0
        //렌더링(화면에 진짜로 그리기)
        void Render()
        {
            try
            {
                form.Invoke(new Action(delegate()
                {
                    try
                    {
                        Graphics form_g = form.CreateGraphics();
                        g.Graphics.ResetClip();
                        g.Render(form_g);
                        form_g.Dispose();
                        this.getGraphics.Clear(backcolor);
                    }
                    catch (Exception e)
                    {
                    }
                }));

                Work();
            }
            catch (Exception e)
            {
            }
        }
예제 #3
0
        /// <summary>
        /// 준비할 그래픽버퍼의 사이즈 조절
        /// </summary>
        /// <param name="form">이 그래픽버퍼를 사용할 윈폼</param>
        public void setGraphicSize(System.Windows.Forms.Form form)
        {
            Graphics gg = form.CreateGraphics();

            sub_g = BufferedGraphicsManager.Current.Allocate(gg, form.ClientRectangle);
            gg.Dispose();
        }
예제 #4
0
        public static DPI GetDpi(System.Windows.Forms.Form form)
        {
            float dx, dy;

            System.Drawing.Graphics g = form.CreateGraphics();
            try
            {
                dx = g.DpiX;
                dy = g.DpiY;

                while ((int)dx % 5 != 0)
                {
                    dx++;
                }
                while ((int)dy % 5 != 0)
                {
                    dy++;
                }
            }
            catch (Exception)
            {
                dx = 100;
                dy = 100;
            }
            finally
            {
                g.Dispose();
            }
            return(new DPI()
            {
                DpiX = dx, DpiY = dy
            });
        }
예제 #5
0
        /// <summary>
        /// Returns a bitmap of the current form.
        /// </summary>
        /// <returns>Returns a bitmap of the current form</returns>
        public static Bitmap ApplicationThumbnail(System.Windows.Forms.Form form)
        {
            Graphics myGraphics     = form.CreateGraphics();
            Size     s              = form.Size;
            Bitmap   memoryImage    = new Bitmap(s.Width, s.Height, myGraphics);
            Graphics memoryGraphics = Graphics.FromImage(memoryImage);

            memoryGraphics.CopyFromScreen(form.Location.X, form.Location.Y, 0, 0, s);
            return(memoryImage);
        }
예제 #6
0
        /// <summary>
        /// 윈폼에 맞게 인스턴스 설정
        /// </summary>
        /// <param name="form">이 더블버퍼링을 사용할 윈폼 지정</param>
        public void setInstance(System.Windows.Forms.Form form)
        {
            Graphics gg = form.CreateGraphics();

            g = BufferedGraphicsManager.Current.Allocate(gg, form.ClientRectangle);
            gg.Dispose();

            //렌더링(화면에 진짜로 그리기)
            void Render()
            {
                try
                {
                    form.Invoke(new Action(delegate()
                    {
                        try
                        {
                            Graphics g = form.CreateGraphics();
                            DoubleBuffering.getinstance().getBuffered.Render(g);
                            g.Dispose();
                        }
                        catch (Exception e)
                        {
                        }
                    }));

                    Work();
                }
                catch (Exception e)
                {
                }
            }

            //여기서부터 타이머 설정
            //8ms마다 Render라는 함수 실행
            Threading_Timer_v0 thread_FrameRender = new Threading_Timer_v0();

            thread_FrameRender.setCallback(new Action(delegate() {
                //callback_Draw();
                Render();
            }));
            thread_FrameRender.setInterval(8);
            thread_FrameRender.Start();
        }
        public void VisualStyleRenderer_GetMargins()
        {
            var renderer = new VisualStyleRenderer(VisualStyleElement.Button.PushButton.Normal);

            using (var form = new System.Windows.Forms.Form())
                using (var graphics = form.CreateGraphics())
                {
                    // GetMargins should not throw an exception.
                    // See https://github.com/dotnet/winforms/issues/526.
                    renderer.GetMargins(graphics, MarginProperty.SizingMargins);
                }
        }
예제 #8
0
        public static string ConvertTwipsToYPixels(string twipsStr)
        {
            System.Windows.Forms.Form dummyForm    = new System.Windows.Forms.Form();
            System.Drawing.Graphics   formGraphics = dummyForm.CreateGraphics();

            float dpiy = formGraphics.DpiY;

            double twips = Double.Parse(twipsStr);

            int product = (int)Math.Round((twips * (1.0 / 1440.0) * dpiy), 0);

            return(product.ToString());
        }
예제 #9
0
        public void DrawAll(System.Windows.Forms.Form form)
        {
            System.Drawing.Graphics canvas = form.CreateGraphics();
            canvas.Clear(form.BackColor);

            foreach (Shape element in figures)
            {
                element.Draw(canvas);
                System.Threading.Thread.Sleep(500);
            }

            canvas.Dispose();
        }
        public static Bitmap CaptureScreen(System.Windows.Forms.Form form, int topMargin = 60, int leftMargin = 8, int rightMargin = 8, int bottomMarbin = 8)
        {
            Graphics myGraphics     = form.CreateGraphics();
            Size     s              = form.Size;
            Bitmap   memoryImage    = new Bitmap(s.Width, s.Height, myGraphics);
            Graphics memoryGraphics = Graphics.FromImage(memoryImage);

            memoryGraphics.CopyFromScreen(form.Location.X, form.Location.Y, 0, 0, s);

            // Clone a portion of the Bitmap object.
            Rectangle cloneRect = new Rectangle(leftMargin, topMargin, s.Width - leftMargin - rightMargin, s.Height - topMargin - bottomMarbin);

            return(memoryImage.Clone(cloneRect, memoryImage.PixelFormat));
        }
예제 #11
0
파일: Win32.dpi.cs 프로젝트: picoe/Eto
		public static uint GetDpi(this System.Windows.Forms.Screen screen)
		{
			if (!MonitorDpiSupported)
			{
				// fallback to slow method if we can't get the dpi from the system
				using (var form = new System.Windows.Forms.Form { Bounds = screen.Bounds })
				using (var graphics = form.CreateGraphics())
				{
					return (uint)graphics.DpiY;
				}
			}

			var pnt = new System.Drawing.Point(screen.Bounds.Left + 1, screen.Bounds.Top + 1);
			var mon = MonitorFromPoint(pnt, MONITOR.DEFAULTTONEAREST);
			uint dpiX, dpiY;
			GetDpiForMonitor(mon, MDT.EFFECTIVE_DPI, out dpiX, out dpiY);
			return dpiX;
		}
예제 #12
0
 public void test(Image t)
 {
     MWNumericArray d = (MWNumericArray)t.image;
     double[,] i_d = (double[,])d.ToArray(MWArrayComponent.Real);
     Bitmap bmp = new Bitmap(t.Height, t.Width);
     for (int i = 0; i < t.Height; i++)
     {
         for (int j = 0; j < t.Width; j++)
         {
             byte pixel = (byte)(i_d[j, i] * 255);
             Color color = Color.FromArgb(255, pixel, pixel, pixel);
             bmp.SetPixel(i, j, color);
         }
     }
     System.Windows.Forms.Form TestForm = new System.Windows.Forms.Form();
     TestForm.Size = new System.Drawing.Size(t.Width + 20, t.Height + 40);
     Graphics g = TestForm.CreateGraphics();
     g.DrawImage(bmp, 0, 0);
     TestForm.ShowDialog();
 }
예제 #13
0
        public static uint GetDpi(this System.Windows.Forms.Screen screen)
        {
            if (!MonitorDpiSupported)
            {
                // fallback to slow method if we can't get the dpi from the system
                using (var form = new System.Windows.Forms.Form {
                    Bounds = screen.Bounds
                })
                    using (var graphics = form.CreateGraphics())
                    {
                        return((uint)graphics.DpiY);
                    }
            }

            var  pnt = new System.Drawing.Point(screen.Bounds.Left + 1, screen.Bounds.Top + 1);
            var  mon = MonitorFromPoint(pnt, MONITOR.DEFAULTTONEAREST);
            uint dpiX, dpiY;

            GetDpiForMonitor(mon, MDT.EFFECTIVE_DPI, out dpiX, out dpiY);
            return(dpiX);
        }
예제 #14
0
        private const string DEC_STRING_SAMPLE   = "255";                                                         //用于计算布局的十进制字符串样本

        /// <summary>
        /// 计算出单行各字符相对于行起始位置的位移量(包含ASCII和HEX两种模式下的位移)
        /// 2017年07月19日,我们要添加十进制DEC模式下的位移
        /// </summary>
        public static void CalculateRowsBytesRelativeLayout()
        {
            try
            {
                ROW_BYTES_LOCATIONS = new VisualPoint[ROW_MAX_BYTES_AMOUNT];
                System.Windows.Forms.Form aForm = new System.Windows.Forms.Form();
                Graphics g           = aForm.CreateGraphics();
                SizeF    hex_sizeF   = g.MeasureString(HEX_STRING_SAMPLE, ROW_FONT);
                SizeF    ascii_sizeF = g.MeasureString(ASCII_STRING_SAMPLE, ROW_FONT);

                SizeF dec_sizeF = g.MeasureString(DEC_STRING_SAMPLE, ROW_FONT);          //2017/07/19  十进制
                Size  dec_size  = new Size((int)dec_sizeF.Width, (int)dec_sizeF.Height); //2017/07/19 十进制

                Size hex_size   = new Size((int)hex_sizeF.Width, (int)hex_sizeF.Height);
                Size ascii_size = new Size((int)ascii_sizeF.Width, (int)ascii_sizeF.Height);



                for (int i = 0; i < ROW_MAX_BYTES_AMOUNT; i++)
                {
                    VisualPoint byte_point  = new VisualPoint();
                    Point       ascii_point = new Point(0, 0);
                    Point       hex_point   = new Point(0, 0);
                    Point       dec_point   = new Point(0, 0);//2017/07/19 十进制

                    ascii_point.X = i * (ascii_size.Width + ROW_BYTES_INTERVAL_HORIZON);
                    hex_point.X   = i * (hex_size.Width + ROW_BYTES_INTERVAL_HORIZON);
                    dec_point.X   = i * (dec_size.Width + ROW_BYTES_INTERVAL_HORIZON);//2017/07/19 十进制

                    byte_point.PointAscii = ascii_point;
                    byte_point.PointHex   = hex_point;
                    byte_point.PointDec   = dec_point;//2017/07/19 十进制

                    ROW_BYTES_LOCATIONS[i] = byte_point;
                }
            }
            catch
            {
            }
        }
예제 #15
0
        static void TestImage()
        {
            Hearthstone_Deck_Tracker.Hearthstone.Card card  = new Hearthstone_Deck_Tracker.Hearthstone.Card(HearthDb.Cards.Collectible[HearthDb.CardIds.Collectible.Druid.AncientOfWar]);
            System.Windows.Media.Imaging.BitmapImage  image = Hearthstone_Deck_Tracker.Utility.ImageCache.GetCardImage(card);
            System.Drawing.Bitmap     bitmap = Hearthstone_Deck_Tracker.Utility.ImageCache.GetCardBitmap(card);
            System.Windows.Forms.Form pForm  = new System.Windows.Forms.Form();
            pForm.Show();
            pForm.Size = new System.Drawing.Size(200, 200);
            System.Drawing.Graphics pGraphics = pForm.CreateGraphics();
            pGraphics.ScaleTransform(1.0f, 0.5f);

            Font       pFont  = new Font("Arial", 16);
            SolidBrush pBrush = new SolidBrush(Color.Black);
            PointF     pPoint = new PointF(0.0f, 0.0f);

            pGraphics.DrawImage(bitmap, 0, 0);
            pGraphics.DrawString(card.Name, pFont, pBrush, pPoint);
            System.Drawing.Size size = bitmap.Size;
            string opClass           = Hearthstone_Deck_Tracker.API.Core.Game.Opponent.Class;

            pGraphics.Clear(System.Drawing.Color.Cyan);
        }
예제 #16
0
        private void AddOpaqueInkOverlay(double size, Image img)
        {
            //add the opaque ink overlay
            if ((opaqueInk != null) && (opaqueInk.Strokes.Count > 0))
            {
                /// draw the slide data on a temporary graphics object in a temporary form
                System.Windows.Forms.Form tempForm = new System.Windows.Forms.Form();
                Graphics          screenGraphics   = tempForm.CreateGraphics();
                DibGraphicsBuffer dib          = new DibGraphicsBuffer();
                Graphics          tempGraphics = dib.RequestBuffer(screenGraphics, img.Width, img.Height);

                //Add the background color
                //First see if there is a Slide BG, if not, try the Deck.  Otherwise, use transparent.
                tempGraphics.DrawImage(img, 0, 0);

                //System.Drawing.Drawing2D.GraphicsState oldState = tempGraphics.Save();

                Microsoft.Ink.Renderer renderer = new Microsoft.Ink.Renderer();
                Matrix transformation           = new Matrix();
                renderer.GetViewTransform(ref transformation);
                transformation.Scale(((float)img.Width / 500f) * (float)size,
                                     ((float)img.Height / 500f) * (float)size);
                renderer.SetViewTransform(transformation);

                renderer.Draw(tempGraphics, opaqueInk.Strokes);

                //tempGraphics.Restore(oldState);

                Graphics toSave = Graphics.FromImage(img);
                dib.PaintBuffer(toSave, 0, 0);

                toSave.Dispose();
                tempGraphics.Dispose();
                dib.Dispose();
                screenGraphics.Dispose();
                tempForm.Dispose();
            }
        }
예제 #17
0
        public static string ConvertTwipsToXPixels(string twipsStr)
        {
            if (String.IsNullOrEmpty(twipsStr))
            {
                return("");
            }
            System.Windows.Forms.Form dummyForm    = new System.Windows.Forms.Form();
            System.Drawing.Graphics   formGraphics = dummyForm.CreateGraphics();

            float dpiy = formGraphics.DpiY;

            double twips = Double.Parse(twipsStr);

            if (twips < 0)
            {
                twips = 0; // VB6 has huge negative numbers sometimes.  idk what this means
            }
            int product = (int)Math.Round((twips * (1.0 / 1440.0) * dpiy), 0);

            formGraphics.Dispose();
            dummyForm.Dispose();

            return(product.ToString());
        }
예제 #18
0
        //Initialize
        public virtual void Initialize(System.Windows.Forms.Form form)
        {   //Windows form
            this.form = form;
            // set up graphics device
            System.Drawing.Graphics graph = form.CreateGraphics();
            graph.CompositingMode    = System.Drawing.Drawing2D.CompositingMode.SourceCopy;
            graph.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighSpeed;
            graph.InterpolationMode  = System.Drawing.Drawing2D.InterpolationMode.Low;
            graph.PixelOffsetMode    = System.Drawing.Drawing2D.PixelOffsetMode.None;
            graph.SmoothingMode      = System.Drawing.Drawing2D.SmoothingMode.HighSpeed;
            //Set up buffer
            currenContext = System.Drawing.BufferedGraphicsManager.Current;
            backBuffer    = currenContext.Allocate(graph, form.DisplayRectangle);
            backBuffer.Graphics.CompositingMode    = System.Drawing.Drawing2D.CompositingMode.SourceCopy;
            backBuffer.Graphics.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighSpeed;
            backBuffer.Graphics.InterpolationMode  = System.Drawing.Drawing2D.InterpolationMode.Low;
            backBuffer.Graphics.PixelOffsetMode    = System.Drawing.Drawing2D.PixelOffsetMode.None;
            backBuffer.Graphics.SmoothingMode      = System.Drawing.Drawing2D.SmoothingMode.HighSpeed;


            //Set frequencies based on refresh rate (60 or 30);
            if (Game.TargetElapsedTime.TotalMilliseconds > 30)
            {                                                     //30Hz
                s1p1On = 1; s1p1Off = 2; s1p2On = 2; s1p2Off = 2; //8.5Hz
                s2p1On = 2; s2p1Off = 3; s2p2On = 2; s2p2Off = 3; //6Hz
                s3p1On = 2; s3p1Off = 2; s3p2On = 2; s3p2Off = 2; //7.5Hz
                s4p1On = 2; s4p1Off = 2; s4p2On = 2; s4p2Off = 3; //6.667Hz
            }
            else
            {                                                     //60Hz
                s1p1On = 3; s1p1Off = 4; s1p2On = 3; s1p2Off = 4; //8.5Hz
                s2p1On = 5; s2p1Off = 5; s2p2On = 5; s2p2Off = 5; //6Hz
                s3p1On = 4; s3p1Off = 4; s3p2On = 4; s3p2Off = 4; //7.5Hz
                s4p1On = 4; s4p1Off = 5; s4p2On = 4; s4p2Off = 5; //6.667Hz
            }
        }
예제 #19
0
        private void DrawSlide2( DeckTraversalModel traversal, int index, System.Drawing.Rectangle displayBounds, System.Drawing.Graphics g )
        {
            float width_scale = g.DpiX / 100f;
            float height_scale = g.DpiY / 100f;

            Rectangle bounds = new Rectangle( 0, 0, (int)(displayBounds.Width * 3f), (int)(displayBounds.Height * 3f) );

            // Create an image using temporary graphics and graphics buffer object
            Bitmap imageForPrinting = new Bitmap( bounds.Width, bounds.Height );
            using( Graphics graphicsImage = Graphics.FromImage( imageForPrinting ) ) {
                using( DibGraphicsBuffer dib = new DibGraphicsBuffer() ) {
                    // Create temporary screen Graphics
                    System.Windows.Forms.Form tempForm = new System.Windows.Forms.Form();
                    Graphics screenGraphics = tempForm.CreateGraphics();

                    // Create temporary Graphics from the Device Independent Bitmap
                    using( Graphics graphicsTemp = dib.RequestBuffer( screenGraphics, imageForPrinting.Width, imageForPrinting.Height ) ) {

                        // Save the old state
                        System.Drawing.Drawing2D.GraphicsState oldState;

                        using( Synchronizer.Lock( traversal.SyncRoot ) ) {
                            using( Synchronizer.Lock( traversal.Deck.SyncRoot ) ) {
                                using( Synchronizer.Lock( traversal.Deck.TableOfContents.SyncRoot ) ) {
                                    TableOfContentsModel.Entry entry = traversal.Deck.TableOfContents.Entries[index];
                                    using( Synchronizer.Lock( entry.Slide.SyncRoot ) ) {

                                        //Draw the background color
                                        //First see if there is a Slide BG, if not, try the Deck. Otherwise, use transparent.
                                        if( entry.Slide.BackgroundColor != Color.Empty ) {
                                            graphicsTemp.Clear( entry.Slide.BackgroundColor );
                                        } else if( traversal.Deck.DeckBackgroundColor != Color.Empty ) {
                                            graphicsTemp.Clear( traversal.Deck.DeckBackgroundColor );
                                        } else {
                                            graphicsTemp.Clear( Color.Transparent );
                                        }

                                        //Get the Slide content and draw it
                                        oldState = graphicsTemp.Save();
                                        Model.Presentation.SlideModel.SheetCollection sheets = entry.Slide.ContentSheets;
                                        for( int i = 0; i < sheets.Count; i++ ) {
                                            SlideDisplayModel display = new SlideDisplayModel( graphicsTemp, null );

                                            Rectangle rect = new Rectangle( 0, 0, bounds.Width, bounds.Height );
                                            Rectangle slide = new Rectangle( rect.X, rect.Y, rect.Width, rect.Height );
                                            float zoom = 1f;
                                            if( entry.Slide != null ) {
                                                slide = entry.Slide.Bounds;
                                                zoom = entry.Slide.Zoom;
                                            }

                                            System.Drawing.Drawing2D.Matrix pixel, ink;
                                            display.FitSlideToBounds( System.Windows.Forms.DockStyle.Fill, rect, zoom, ref slide, out pixel, out ink );
                                            using( Synchronizer.Lock( display.SyncRoot ) ) {
                                                display.Bounds = slide;
                                                display.PixelTransform = pixel;
                                                display.InkTransform = ink;
                                            }

                                            Viewer.Slides.SheetRenderer r = Viewer.Slides.SheetRenderer.ForStaticSheet( display, sheets[i] );
                                            r.Paint( new System.Windows.Forms.PaintEventArgs( graphicsTemp, bounds ) );
                                            r.Dispose();
                                        }

                                    }
                                }
                            }
                        }

                        //Restore the Old State
                        graphicsTemp.Restore( oldState );

                        // Use the buffer to paint onto the final image
                        dib.PaintBuffer( graphicsImage, 0, 0 );

                        // Draw this image onto the printer graphics,
                        // adjusting for printer margins
                        g.DrawImage( imageForPrinting, displayBounds );

                        //Cleanup
                        graphicsTemp.Dispose();
                        screenGraphics.Dispose();
                        tempForm.Dispose();
                        dib.Dispose();
                        graphicsImage.Dispose();
                        imageForPrinting.Dispose();
                    }
                }
            }
        }
예제 #20
0
        private void DrawSlide2(DeckTraversalModel traversal, int index, System.Drawing.Rectangle displayBounds, System.Drawing.Graphics g)
        {
            float width_scale  = g.DpiX / 100f;
            float height_scale = g.DpiY / 100f;

            Rectangle bounds = new Rectangle(0, 0, (int)(displayBounds.Width * 3f), (int)(displayBounds.Height * 3f));

            // Create an image using temporary graphics and graphics buffer object
            Bitmap imageForPrinting = new Bitmap(bounds.Width, bounds.Height);

            using (Graphics graphicsImage = Graphics.FromImage(imageForPrinting)) {
                using (DibGraphicsBuffer dib = new DibGraphicsBuffer()) {
                    // Create temporary screen Graphics
                    System.Windows.Forms.Form tempForm = new System.Windows.Forms.Form();
                    Graphics screenGraphics            = tempForm.CreateGraphics();

                    // Create temporary Graphics from the Device Independent Bitmap
                    using (Graphics graphicsTemp = dib.RequestBuffer(screenGraphics, imageForPrinting.Width, imageForPrinting.Height)) {
                        // Save the old state
                        System.Drawing.Drawing2D.GraphicsState oldState;

                        using (Synchronizer.Lock(traversal.SyncRoot)) {
                            using (Synchronizer.Lock(traversal.Deck.SyncRoot)) {
                                using (Synchronizer.Lock(traversal.Deck.TableOfContents.SyncRoot)) {
                                    TableOfContentsModel.Entry entry = traversal.Deck.TableOfContents.Entries[index];
                                    using (Synchronizer.Lock(entry.Slide.SyncRoot)) {
                                        //Draw the background color
                                        //First see if there is a Slide BG, if not, try the Deck. Otherwise, use transparent.

                                        if (entry.Slide.BackgroundColor != Color.Empty)
                                        {
                                            graphicsTemp.Clear(entry.Slide.BackgroundColor);
                                        }
                                        else if (traversal.Deck.DeckBackgroundColor != Color.Empty)
                                        {
                                            graphicsTemp.Clear(traversal.Deck.DeckBackgroundColor);
                                        }
                                        else
                                        {
                                            graphicsTemp.Clear(Color.Transparent);
                                        }

                                        //Get the Slide content and draw it
                                        oldState = graphicsTemp.Save();
                                        Model.Presentation.SlideModel.SheetCollection sheets = entry.Slide.ContentSheets;
                                        for (int i = 0; i < sheets.Count; i++)
                                        {
                                            SlideDisplayModel display = new SlideDisplayModel(graphicsTemp, null);

                                            Rectangle rect  = new Rectangle(0, 0, bounds.Width, bounds.Height);
                                            Rectangle slide = new Rectangle(rect.X, rect.Y, rect.Width, rect.Height);
                                            float     zoom  = 1f;
                                            if (entry.Slide != null)
                                            {
                                                slide = entry.Slide.Bounds;
                                                zoom  = entry.Slide.Zoom;
                                            }

                                            System.Drawing.Drawing2D.Matrix pixel, ink;
                                            display.FitSlideToBounds(System.Windows.Forms.DockStyle.Fill, rect, zoom, ref slide, out pixel, out ink);
                                            using (Synchronizer.Lock(display.SyncRoot)) {
                                                display.Bounds         = slide;
                                                display.PixelTransform = pixel;
                                                display.InkTransform   = ink;
                                            }

                                            Viewer.Slides.SheetRenderer r = Viewer.Slides.SheetRenderer.ForStaticSheet(display, sheets[i]);
                                            r.Paint(new System.Windows.Forms.PaintEventArgs(graphicsTemp, bounds));
                                            r.Dispose();
                                        }
                                    }
                                }
                            }
                        }

                        //Restore the Old State
                        graphicsTemp.Restore(oldState);

                        // Use the buffer to paint onto the final image
                        dib.PaintBuffer(graphicsImage, 0, 0);

                        // Draw this image onto the printer graphics,
                        // adjusting for printer margins
                        g.DrawImage(imageForPrinting, displayBounds);

                        //Cleanup
                        graphicsTemp.Dispose();
                        screenGraphics.Dispose();
                        tempForm.Dispose();
                        dib.Dispose();
                        graphicsImage.Dispose();
                        imageForPrinting.Dispose();
                    }
                }
            }
        }