Exemple #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;
            }
        }
Exemple #2
0
        private void button7_Click(object sender, EventArgs e)
        {
            _toSave = textBox1.Lines;
            HostsHelper.SaveHosts(_toSave);

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

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

            if (HostsHelper.GetReadOnly())
            {
                savebtn.Enabled = false;
            }
        }
Exemple #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();
            }
        }
Exemple #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();
        }
Exemple #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();
        }
Exemple #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]);
                }
            }
        }
Exemple #9
0
 private void linkLabel4_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
 {
     HostsHelper.RestoreDefaultHosts();
     GetHostsEntries();
 }
Exemple #10
0
 private void linkLabel2_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
 {
     HostsHelper.LocateHosts();
 }