ExportForm.cs 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. using Dongke.IBOSS.PRD.Basics.BaseControls;
  2. using System;
  3. using System.Drawing;
  4. using System.IO;
  5. using System.Windows.Forms;
  6. public class MinimalExportForm : FormBase
  7. {
  8. private string _filePath;
  9. public MinimalExportForm(string filePath)
  10. {
  11. _filePath = filePath;
  12. InitializeForm();
  13. }
  14. private void InitializeForm()
  15. {
  16. this.Text = "导出完成";
  17. this.Size = new Size(400, 250);
  18. this.StartPosition = FormStartPosition.CenterScreen;
  19. Panel panel = new Panel
  20. {
  21. Dock = DockStyle.Fill,
  22. Padding = new Padding(20)
  23. };
  24. // 成功图标
  25. Label lblSuccess = new Label
  26. {
  27. Text = "✓",
  28. Font = new Font("Arial", 24, FontStyle.Bold),
  29. ForeColor = Color.Green,
  30. Location = new Point(20, 20),
  31. AutoSize = true
  32. };
  33. // 成功消息
  34. Label lblMessage = new Label
  35. {
  36. Text = "数据导出成功!",
  37. Font = new Font("微软雅黑", 11, FontStyle.Bold),
  38. Location = new Point(60, 25),
  39. AutoSize = true
  40. };
  41. // 文件路径(简化显示)
  42. string displayPath = _filePath;
  43. if (_filePath.Length > 40)
  44. {
  45. displayPath = "..." + _filePath.Substring(_filePath.Length - 40);
  46. }
  47. Label lblPath = new Label
  48. {
  49. Text = displayPath,
  50. Location = new Point(20, 70),
  51. Size = new Size(350, 20),
  52. ForeColor = Color.DarkBlue
  53. };
  54. // 操作按钮
  55. Button btnOpen = new Button
  56. {
  57. Text = "打开文件",
  58. Size = new Size(80, 30),
  59. Location = new Point(80, 100)
  60. };
  61. btnOpen.Click += (s, e) => OpenFile();
  62. Button btnFolder = new Button
  63. {
  64. Text = "打开文件夹",
  65. Size = new Size(80, 30),
  66. Location = new Point(170, 100)
  67. };
  68. btnFolder.Click += (s, e) => OpenFolder();
  69. Button btnClose = new Button
  70. {
  71. Text = "关闭",
  72. Size = new Size(80, 30),
  73. Location = new Point(260, 100)
  74. };
  75. btnClose.Click += (s, e) => this.Close();
  76. panel.Controls.Add(lblSuccess);
  77. panel.Controls.Add(lblMessage);
  78. panel.Controls.Add(lblPath);
  79. panel.Controls.Add(btnOpen);
  80. panel.Controls.Add(btnFolder);
  81. panel.Controls.Add(btnClose);
  82. this.Controls.Add(panel);
  83. }
  84. private void OpenFile()
  85. {
  86. if (File.Exists(_filePath))
  87. {
  88. System.Diagnostics.Process.Start(_filePath);
  89. }
  90. }
  91. private void OpenFolder()
  92. {
  93. if (File.Exists(_filePath))
  94. {
  95. string argument = $"/select, \"{_filePath}\"";
  96. System.Diagnostics.Process.Start("explorer.exe", argument);
  97. }
  98. }
  99. private void InitializeComponent()
  100. {
  101. this.SuspendLayout();
  102. //
  103. // MinimalExportForm
  104. //
  105. this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
  106. this.ClientSize = new System.Drawing.Size(284, 263);
  107. this.Name = "MinimalExportForm";
  108. this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
  109. this.Text = "导出";
  110. this.ResumeLayout(false);
  111. this.PerformLayout();
  112. }
  113. }