On the other hand if I call the Print Preview method inside my loop it brings up multiple dialogues but I want only one. Is there an option in Lightning Charts to do it. Here is my full code. I am getting a Dictionary of charts where key is the single chart.
Code: Select all
private void PrintAllCharts(Dictionary<LightningChartUserControl, string> charts)
{
try
{
if (PrinterSettings.InstalledPrinters.Count == 0)
{
Xceed.Wpf.Toolkit.MessageBox.Show(System.Windows.Application.Current.TryFindResource("SetUpPrinter").ToString(),
"Default printer not found", MessageBoxButton.OK, MessageBoxImage.Error);
return;
}
for (int i = 0; i < charts.Count; i++)
{
KeyValuePair<LightningChartUserControl, string> kp = charts.ElementAt(i);
kp.Key.Chart.Print(ImageType.Vector, false, true, false, kp.Value, string.Empty, true, new Thickness(0, 20, 0, 0));
}
PrinterSettings settings = new PrinterSettings();
Xceed.Wpf.Toolkit.MessageBox.Show(string.Format(System.Windows.Application.Current.TryFindResource("PrintSuccessful").ToString(),settings.PrinterName),
"Print Successful", MessageBoxButton.OK);
}
catch (Exception ex)
{
SystemDebugLogLogger.LogError(ex);
}
}