Esempio n. 1
0
        private void button47_Click(object sender, EventArgs e)
        {
            if ((txtIP.Text != string.Empty) && (txtDomain.Text != string.Empty))
            {
                string ip                = txtIP.Text.Trim();
                string domain            = txtDomain.Text.Trim();
                string recommendeddomain = string.Empty;

                if (!domain.StartsWith("www."))
                {
                    recommendeddomain = "www." + domain;
                }
                else
                {
                    recommendeddomain = domain.Replace("www.", string.Empty).Trim();
                }

                HostsHelper.AddEntry(HostsHelper.SanitizeEntry(ip) + " " + HostsHelper.SanitizeEntry(domain));

                if (!string.IsNullOrEmpty(recommendeddomain))
                {
                    HostsHelper.AddEntry(HostsHelper.SanitizeEntry(ip) + " " + HostsHelper.SanitizeEntry(recommendeddomain));
                }

                GetHostsEntries();

                txtIP.Clear();
                txtDomain.Clear();

                chkBlock.Checked = false;
            }
        }
Esempio n. 2
0
        private void button7_Click(object sender, EventArgs e)
        {
            _toSave = textBox1.Lines;
            HostsHelper.SaveHosts(_toSave);

            this.Close();
        }
Esempio n. 3
0
        private void HostsEditor_Load(object sender, EventArgs e)
        {
            foreach (string line in HostsHelper.ReadHosts())
            {
                textBox1.Text += line + HostsHelper.NewLine;
            }

            textBox1.Focus();
        }
Esempio n. 4
0
        public HostsEditorForm()
        {
            InitializeComponent();
            Options.ApplyTheme(this);

            if (HostsHelper.GetReadOnly())
            {
                savebtn.Enabled = false;
            }
        }
Esempio n. 5
0
        private void button42_Click(object sender, EventArgs e)
        {
            if (hl.SelectedItems.Count == 1)
            {
                string temp = hl.SelectedItem.ToString().Replace(" : ", " ");
                HostsHelper.RemoveEntry(temp);

                GetHostsEntries();
            }
        }
Esempio n. 6
0
        private void HostsEditor_Load(object sender, EventArgs e)
        {
            //foreach (string line in HostsHelper.ReadHosts())
            //{
            //    textBox1.Text += line + HostsHelper.NewLine;
            //}

            textBox1.Text = HostsHelper.ReadHostsFast();

            textBox1.Focus();
        }
Esempio n. 7
0
        internal void RemoveAllHostsEntries()
        {
            List <string> collection = new List <string>();

            foreach (string item in hl.Items)
            {
                collection.Add(item.Replace(" : ", " "));
            }

            HostsHelper.RemoveAllEntries(collection);
            GetHostsEntries();
        }
Esempio n. 8
0
        private void GetHostsEntries()
        {
            entries = HostsHelper.GetEntries();
            hl.Items.Clear();

            for (int i = 0; i < entries.Count; i++)
            {
                if (!string.IsNullOrEmpty(entries[i]))
                {
                    hl.Items.Add(entries[i]);
                }
            }
        }
Esempio n. 9
0
 private void linkLabel4_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
 {
     HostsHelper.RestoreDefaultHosts();
     GetHostsEntries();
 }
Esempio n. 10
0
 private void linkLabel2_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
 {
     HostsHelper.LocateHosts();
 }