MainForm.cs 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. using System;
  2. using System.Windows.Forms;
  3. using EfDbCommentGenerator.Core;
  4. namespace EfDbCommentGenerator
  5. {
  6. public partial class MainForm : Form
  7. {
  8. public MainForm()
  9. {
  10. InitializeComponent();
  11. InitUi();
  12. }
  13. private void InitUi()
  14. {
  15. Text = Application.ProductName;
  16. }
  17. private void MainForm_Shown(object sender, System.EventArgs e)
  18. {
  19. #if DEMO
  20. richTextBox1.Text = MetaMapper.Generate(Application.ExecutablePath);
  21. #else
  22. string asm;
  23. if (Program.CliArgs.Length == 0)
  24. {
  25. var dlg = new OpenFileDialog
  26. {
  27. Multiselect = false
  28. };
  29. if (dlg.ShowDialog() == DialogResult.OK)
  30. {
  31. asm = dlg.FileName;
  32. }
  33. else
  34. {
  35. this.Close();
  36. return;
  37. }
  38. }
  39. else
  40. {
  41. asm = Program.CliArgs[0];
  42. }
  43. try
  44. {
  45. richTextBox1.Text = MetaMapper.Generate(asm);
  46. }
  47. catch (Exception ex)
  48. {
  49. richTextBox1.Text = ex.ToString();
  50. }
  51. #endif
  52. }
  53. private void richTextBox1_MouseDoubleClick(object sender, MouseEventArgs e)
  54. {
  55. richTextBox1.SelectAll();
  56. }
  57. }
  58. }