Licences.cs 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10. namespace Welling_Motor_Debug_Tool
  11. {
  12. public partial class Licences : Form
  13. {
  14. public Licences()
  15. {
  16. InitializeComponent();
  17. }
  18. private void Licences_Load(object sender, EventArgs e)
  19. {
  20. textBox_CPU_ID.Text = PC_Information.GetCPUSerialNumber();
  21. textBox_LicencePath.Text = "";
  22. }
  23. private void button_LicenceSelect_Click(object sender, EventArgs e)
  24. {
  25. // 创建并配置OpenFileDialog
  26. OpenFileDialog openFileDialog = new OpenFileDialog
  27. {
  28. InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop), // 初始目录
  29. Filter = "许可文件(*.lic)|*.lic", // 文件过滤器
  30. FilterIndex = 1, // 默认过滤器索引
  31. RestoreDirectory = true // 关闭对话框后恢复当前目录
  32. };
  33. // 显示对话框并检查用户是否选择了文件
  34. if (openFileDialog.ShowDialog() == DialogResult.OK)
  35. {
  36. // 获取选中文件的路径
  37. string filePath = openFileDialog.FileName;
  38. // 在文本框中显示文件路径
  39. textBox_LicencePath.Text = filePath;
  40. }
  41. }
  42. private void button_LicenceEnter_Click(object sender, EventArgs e)
  43. {
  44. this.Close();
  45. }
  46. }
  47. }