HostsEditorForm.cs 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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 Optimizer
  11. {
  12. public partial class HostsEditorForm : Form
  13. {
  14. string[] _toSave = null;
  15. public HostsEditorForm()
  16. {
  17. InitializeComponent();
  18. Options.ApplyTheme(this);
  19. if (HostsHelper.GetReadOnly())
  20. {
  21. savebtn.Enabled = false;
  22. }
  23. }
  24. private void HostsEditor_Load(object sender, EventArgs e)
  25. {
  26. foreach (string line in HostsHelper.ReadHosts())
  27. {
  28. textBox1.Text += line + HostsHelper.NewLine;
  29. }
  30. textBox1.Focus();
  31. }
  32. private void button1_Click(object sender, EventArgs e)
  33. {
  34. this.Close();
  35. }
  36. private void button7_Click(object sender, EventArgs e)
  37. {
  38. _toSave = textBox1.Lines;
  39. HostsHelper.SaveHosts(_toSave);
  40. this.Close();
  41. }
  42. }
  43. }