/FOCA/DNSEnumeration/PanelWebSearcherInformation.cs

https://github.com/ElevenPaths/FOCA · C# · 89 lines · 77 code · 8 blank · 4 comment · 7 complexity · 94117bd303807d79bdfba98d77898c5b MD5 · raw file

  1. using System;
  2. using System.Windows.Forms;
  3. namespace FOCA
  4. {
  5. /// <summary>
  6. /// Using a web searcher like Google or Bing the program searchs links pointing
  7. /// to the domain site to identify new subdomains.
  8. /// </summary>
  9. public partial class PanelWebSearcherInformation : UserControl
  10. {
  11. public enum Engine
  12. {
  13. GoogleWeb,
  14. GoogleAPI,
  15. BingWeb,
  16. BingAPI,
  17. DuckDuckGoWeb
  18. }
  19. private Engine _selectedEngine;
  20. public PanelWebSearcherInformation()
  21. {
  22. InitializeComponent();
  23. panelEngineBingAPIInformation.Visible = false;
  24. panelEngineBingWebInformation.Visible = false;
  25. panelEngineGoogleAPIInformation.Visible = false;
  26. panelEngineGoogleWebInformation.Visible = false;
  27. }
  28. public Engine SelectedEngine
  29. {
  30. set
  31. {
  32. _selectedEngine = value;
  33. cboEngine.Text = EngineToString(value);
  34. }
  35. get { return _selectedEngine; }
  36. }
  37. private void PanelWebSearcher_Load(object sender, EventArgs e)
  38. {
  39. FillComboboxEngine();
  40. comboBoxEngine_SelectedValueChanged(cboEngine, null);
  41. }
  42. private void FillComboboxEngine()
  43. {
  44. cboEngine.Items.Clear();
  45. foreach (Engine e in Enum.GetValues(typeof(Engine)))
  46. cboEngine.Items.Add(EngineToString(e));
  47. }
  48. private void comboBoxEngine_SelectedValueChanged(object sender, EventArgs e)
  49. {
  50. var comboBox = sender as ComboBox;
  51. if (comboBox != null)
  52. switch (comboBox.Text)
  53. {
  54. case "GoogleWeb":
  55. SelectedEngine = Engine.GoogleWeb;
  56. break;
  57. case "GoogleAPI":
  58. SelectedEngine = Engine.GoogleAPI;
  59. break;
  60. case "BingWeb":
  61. SelectedEngine = Engine.BingWeb;
  62. break;
  63. case "BingAPI":
  64. SelectedEngine = Engine.BingAPI;
  65. break;
  66. default:
  67. MessageBox.Show(@"Select a valid engine, please!", Application.ProductName, MessageBoxButtons.OK,
  68. MessageBoxIcon.Information);
  69. break;
  70. }
  71. panelEngineGoogleWebInformation.Visible = SelectedEngine == Engine.GoogleWeb;
  72. panelEngineGoogleAPIInformation.Visible = SelectedEngine == Engine.GoogleAPI;
  73. panelEngineBingWebInformation.Visible = SelectedEngine == Engine.BingWeb;
  74. panelEngineBingAPIInformation.Visible = SelectedEngine == Engine.BingAPI;
  75. }
  76. public static string EngineToString(Engine e)
  77. {
  78. return e.ToString();
  79. }
  80. }
  81. }