There are several graphs made on the basis of D3 with different names (plotter1, plotter2 ...), each located on its tab. The task is to save all the graphics. The graphic has the SaveScreenshot method (string path), which saves the graphic along the specified path. However, this method saves only the graph image that was last displayed on the screen. Thus, if we opened the window and did not click the tabs themselves, only the first graph shown will be saved, instead of the others there will be black squares. Please advise how to properly save these graphs without the need for the user to click on each graph.
1 answer
This is because you did not separate the content from the presentation.
Saving according to the mind does not need screenshots of the presentation, but content (that is, the data from which this graph is obtained). How and when WPF shows your schedule should not be important or interesting at all.
If for some reason you need to save the image, you still need to generate it at the model level, and not to save a screenshot. The screenshot is not the quality, resolution, there may be extra artifacts.
Do it right, there will be no problems.
- oneThe plotted graph must be saved as an image. The problem is that D3 does not allow to generate a picture at the model level. - Dmitry Zheleznyakov
- @DmitryZheleznyakov: Hmm. This is problem. Maybe then they are not good enough for your purposes? The library should be able to generate content at the model level. Well or let's try to arrange workaround. Look at the controls, what is their size? Subscribe to Loaded and see if this event has arrived. - VladD
- The problem, as it turned out, is sitting even deeper. The library categorically refuses to work adequately with preservation if there is more than 1 graph on the form, regardless of their distribution. When you try to save a screenshot of any graphics other than the first one that appears, an ArgumentException is thrown from the library. As a result, I remade the form for displaying only one graphic at a time, later I will use another library. - Dmitry Zheleznyakov
- @DmitryZheleznyakov: Hmm. And if you draw a graph on an invisible form? (For example, in general in another thread?) - VladD
- oneIn general, he did. In the left stream I create the form, I load, I create the schedule on it, I save the schedule, I close the form. And so for each desired schedule. - Dmitry Zheleznyakov
|