Jak wydrukować wykres z panela?

0

Witam,
rysuję na panelu harmonogram (coś w stylu wykresu Gantta), szukam sposobu na mozliwość wydruku tego harmonogramu (wydruk bezpośrednio z panela?), muszę zaznaczyć, że często harmonogram nie mieści się na jednym ekranie i trzeba przewijać go poziomym scrollem.
Będę wdzięczny za wszelkie sugestie...

0

Skopjuj ten wykres do bitmapy po fragmęcie wykresu - za pomocą funkcji
Canvas->CopyRect(RegionDocelowy,CanvasPanela,RegionŹródłowy);
A następnie wydrukuj bitmapę.

0
using System.Runtime.InteropServices;
using System.Drawing.Printing;

...

[DllImport("gdi32.dll")]
private static extern bool BitBlt(
        IntPtr hdcDest,
        int nXDest,
        int nYDest,
        int nWidth,
        int nHeight,
        IntPtr hdcSrc,
        int nXSrc,
        int nYSrc,
        System.Int32 dwRop
        );

private const Int32 SRCCOPY = 0xCC0020;

private Bitmap memImage;

private void PrepareImage()
{
        Graphics graphic = panel1.CreateGraphics(); //tu podajesz, ze chodzi o panel :)
        Size s = this.Size;
        memImage = new Bitmap(s.Width, s.Height, graphic);
        Graphics memGraphic = Graphics.FromImage(memImage);
        IntPtr dc1 = graphic.GetHdc();
        IntPtr dc2 = memGraphic.GetHdc();
        BitBlt(dc2, 0, 0, panel1.ClientRectangle.Width, panel1.ClientRectangle.Height,dc1, 0, 0, SRCCOPY);
        graphic.ReleaseHdc(dc1);
        memGraphic.ReleaseHdc(dc2);

}

private void printDocument1_PrintPage(object sender, PrintPageEventArgs e)
{
        e.Graphics.DrawImage(memImage,0,0);

}

a teraz drukujemy:

private void button1_Click(object sender, System.EventArgs e)
{
        PrintDocument printDocument1 = new PrintDocument();
        printDocument1.PrintPage += new PrintPageEventHandler(printDocument1_PrintPage); 
        PrepareImage();
        printDocument1.Print();

}
0

dzięki za pomoc

1 użytkowników online, w tym zalogowanych: 0, gości: 1