App.xaml.cs 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. using FastReport;
  2. using FastReport.Utils;
  3. using System.Windows;
  4. namespace Designer
  5. {
  6. public partial class App : Application
  7. {
  8. private void Application_Startup(object sender, StartupEventArgs e)
  9. {
  10. this.ShutdownMode = ShutdownMode.OnExplicitShutdown;
  11. Config.DesignerSettings.ShowInTaskbar = true;
  12. Config.DesignerSettings.EmbeddedPreview = true;
  13. Config.ReportSettings.ShowPerformance = true;
  14. #if NETCOREAPP
  15. // RoslynPad as a code editor (available in net6.0-windows target)
  16. FastReport.WPF.RoslynPad.SyntaxEditor.Register();
  17. #endif
  18. using (var report = new Report())
  19. {
  20. string fileName = "";
  21. bool preview = false;
  22. foreach (var arg in e.Args)
  23. {
  24. if (arg.IndexOf("/preview") != -1)
  25. {
  26. preview = true;
  27. }
  28. else if (arg.IndexOf("/savepath=") != -1)
  29. {
  30. int i = arg.IndexOf('=');
  31. string path = arg.Substring(i + 1).Trim('"');
  32. Config.SaveFolder = path;
  33. }
  34. else
  35. {
  36. fileName = arg;
  37. }
  38. }
  39. if (!string.IsNullOrEmpty(fileName))
  40. report.Load(fileName);
  41. if (preview)
  42. {
  43. //report.Prepare();
  44. //report.ShowPrepared();
  45. report.ShowAsync();
  46. }
  47. else
  48. {
  49. report.Design();
  50. }
  51. }
  52. this.Shutdown();
  53. }
  54. }
  55. }