FormAuthorize.cs 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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.Windows.Forms;
  9. namespace HslCommunication.BasicFramework
  10. {
  11. /// <summary>
  12. /// 用来测试版软件授权的窗口
  13. /// </summary>
  14. public partial class FormAuthorize : Form
  15. {
  16. /// <summary>
  17. /// 实例化授权注册窗口
  18. /// </summary>
  19. /// <param name="authorize"></param>
  20. /// <param name="aboutCode">提示关于怎么获取注册码的信息</param>
  21. /// <param name="encrypt">加密的方法</param>
  22. public FormAuthorize(SoftAuthorize authorize,string aboutCode,Func<string,string> encrypt)
  23. {
  24. InitializeComponent();
  25. softAuthorize = authorize;
  26. AboutCode = aboutCode;
  27. Encrypt = encrypt;
  28. }
  29. private SoftAuthorize softAuthorize = null;
  30. private void FormAuthorize_Load(object sender, EventArgs e)
  31. {
  32. textBox1.Text = softAuthorize.GetMachineCodeString();
  33. }
  34. private void userButton1_Click(object sender, EventArgs e)
  35. {
  36. if (softAuthorize.CheckAuthorize(textBox2.Text, Encrypt))
  37. {
  38. DialogResult = DialogResult.OK;
  39. }
  40. else
  41. {
  42. MessageBox.Show("注册码不正确");
  43. }
  44. }
  45. Func<string, string> Encrypt = null;
  46. private string AboutCode { get; set; } = "";
  47. private void linkLabel1_Click(object sender, EventArgs e)
  48. {
  49. MessageBox.Show(AboutCode);
  50. }
  51. }
  52. }