I'm printing a WPF grid. As long as the data fits on one page, everything works fine. But sometimes the grid contains more data. Therefore I need to split the grid into multiple pages. Can anybody help me?
My code looks like this (visual is the grid).
var printCapabilities = printDialog.PrintQueue.GetPrintCapabilities(printDialog.PrintTicket);
var size = new Size(printCapabilities.PageImageableArea.ExtentWidth,
printCapabilities.PageImageableArea.ExtentHeight);
visual.Measure(size);
visual.Arrange(new Rect(new Point(printCapabilities.PageImageableArea.OriginWidth,
printCapabilities.PageImageableArea.OriginHeight), size));
printDialog.PrintVisual(visual, "Print ListView");
Should I try another control? I've tried WPF Toolkit DataGrid, but I couldn't manage to get it printed. I've heard something of a flow document, can this help me?
Best Regards
Oliver Hanappi
It sounds like you want to use PrintDocument instead of PrintVisual. You will probably need to implement your own DocumentPaginator class to split your grid into separate printable documents, though.
Related
My goal is to have a diagram which look like this
Each arrow should be a one dimensional chart, where point are displayed (colors and point size depends on some values)
I'm building my own chart system because I spent a few hours looking for one which allow to custom markers (size and colors, and maybe even shape) but I couldn't find one.
Actually the only one I found is dynamic data display 2.0 which is only proposed in Silverlight.
My biggest problem is the two curving chart I have to do at the top of the diagram.
I tried to use PathListBox control, but because it's a listBox, I couldn't display items at fixed X position (like using a chart).
I'm not asking for a full perfect solution, but can someone give me advices, or clues ?
How would you manage to do something like that ?
It should only be a XAML work here, because all the data are already ready in a ListCollectionView (i'm using MVVM).
Thank you !
I'm drawing certain images in WPF which will be displayed by a game (developed by a third party). I currently produce the images using a RenderTargetBitmap. Unfortunately it seems that this only supports the Ideal text formatting mode, resulting in blurry small fonts. The application is a third-party game and thus there's no way around using images.
Can I tell the RenderTargetBitmap to assume that it's drawing an image destined for one of the current montiors? Is there another way to get WPF to use the Display rendering mode for off-screen drawing?
I understand why this might seem wrong in the theoretical sense, but in practice there are reasons why I think this is not an unreasonable thing to do:
One of the things the Display mode allows is aliased text, which looks better at small sizes than the Ideal rendering, and is completely independent of monitor properties such as gamma.
A screenshot of small Display-mode text rendered in ClearType looks far better on any screen, even those with different gamma, than Ideal-mode text.
Can the WPF rendering engine do this, or do I have to fall back onto GDI? (which has no difficulties with using Aliased or ClearType rendering off-screen)
There is certainly no obvious way of doing this. I guess drawing to images was never a goal of WPF; the fact that it can actually do this fairly well most of the time must be accidental.
It seems that this works now. Could someone else verify? Here's the relevant code:
var textBlock = new TextBlock();
textBlock.Text = "Hello World";
textBlock.FontFamily = new System.Windows.Media.FontFamily("Arial");
textBlock.Background = System.Windows.Media.Brushes.Transparent;
textBlock.Foreground = System.Windows.Media.Brushes.Black;
textBlock.FontSize = 50;
// . Set Formatting Mode Works! Setting the rendering mode doesn't.
System.Windows.Media.TextOptions.SetTextFormattingMode(textBlock, System.Windows.Media.TextFormattingMode.Display);
Edit: Forgot to mention I'm using the .NET 4.5 framework
Edit2: The difference between Display and Ideal is especially noticeable at smaller font sizes.
What is the best way to manage a very large amount of images (10,000+) in WPF? This is for a 2d tile map editor similar to this : http://www.mapeditor.org/ .
At the moment i have a canvas with all tiles as an image and a list box which contains the different images to choose from. Each tile is added to the canvas as children and then stored in a list for later access. You paint into the canvas by setting the Source property of a tile to the one selected in the listbox. It works well with around 50x50 tile maps but anything above that causes loading delays, in general slow application.
Any suggestions on this? Would QT maybe be more suited instead of wpf?
Thanks in advance
Check out Implementing virtualized panel series of articles.
Virtualized panels are efficient, because:
Only the displayed elements (and a few extra around the borders to enable smooth scrolling) are in the memory (and rendered).
Elements are reused, instead of being repeatedly created and discarded - an old cell is simply filled with new content (supplied with new DataContext) and used in new location.
You might also try to use WPF's DataGrid for this, it supports virtualization out of the box and is essentially what are you trying to do.
WPF is certainly able to do this, if implemented properly (if you can do that in JavaScript, you can certainly do it in WPF as well).
I want to implement previews/thumbnails in my project, therefor i need the graphical output of a control as bitmap. I have a third party control which loads documents and displays them. Is it possible to fetch the output of an control and store it in a bitmap object without adding it to the UI? And If how?
Edit: I probably should said that before, but i don't know if that's important. The ThirdParty Control is an OCX(ActiveX control).
in a Form do:
Bitmap myBitmap = new Bitmap(button1.Width, button1.Height);
// button1.Draw..., not 'this.Draw...'!
button1.DrawToBitmap(myBitmap, button1.DisplayRectangle);
myBitmap.Save(#"C:\test.bmp");
I want to make a WPF Grid in which users can drag and drop controls from one cell to another and when the user is dragging I need to draw tips on the screen, like arrows. It's as if the tips were in ANOTHER LAYER in the screen. That is, they are not drawn IN the grid I mentioned.
The problem is: I don't know how to OVERLAP a "transparent" canvas over my Grid so that I can draw on it.
Do you experienced guys have some tip? THANKS.
I think what you are looking for are Adorners. You can read something about them here:
http://marlongrech.wordpress.com/2008/02/28/wpf-overlays-or-better-adorner/
Heres an example with a listView control, pretty good.
Heres a tut also decent.
And even a section in msdn