Exemplo n.º 1
0
        private void editToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ListViewItem selectedItem = GetSelectedEntry();

            if (selectedItem == null)
            {
                return;
            }

            String     hostname = (String)selectedItem.Tag;
            HostsEntry entry    = HostsFileManager.FindEntry(hostname);

            if (entry == null)
            {
                return;
            }

            EditDialog dialog = new EditDialog(entry);

            if (dialog.ShowDialog() == DialogResult.OK)
            {
                MarkUnsavedChanges();
                this.Refresh(false);
            }
        }
Exemplo n.º 2
0
        private void deleteToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ListViewItem selectedItem = GetSelectedEntry();

            if (selectedItem == null)
            {
                return;
            }

            String hostname = (String)selectedItem.Tag;

            HostsFileManager.DeleteEntry(hostname);
            MarkUnsavedChanges();
        }
Exemplo n.º 3
0
        public void Refresh(Boolean fromFile)
        {
            if (fromFile && HasUnsavedChanges() && MessageBox.Show("You have unsaved changes. These will be overwritten.\nProceed anyway?", "Are you sure?", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) != System.Windows.Forms.DialogResult.Yes)
            {
                return;
            }

            statusPath.Text = HostsFileManager.Filename;

            if (fromFile)
            {
                HostsFileManager.RefreshData();
                UnmarkUnsavedChanges();
            }

            SyntaxHighlighter.Highlight(HostsFileManager.GenerateHostsLines(), richTextBox1, listView1);
            listView1_SelectedIndexChanged(null, null);
        }
Exemplo n.º 4
0
        private void toggleEnabledToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ListViewItem selectedItem = GetSelectedEntry();

            if (selectedItem == null)
            {
                return;
            }

            String     hostname = (String)selectedItem.Tag;
            HostsEntry entry    = HostsFileManager.FindEntry(hostname);

            if (entry == null)
            {
                return;
            }

            entry.Enabled = !entry.Enabled;
            MarkUnsavedChanges();
        }
Exemplo n.º 5
0
 private void toolStripButton1_Click(object sender, EventArgs e)
 {
     HostsFileManager.Save();
     UnmarkUnsavedChanges();
     Refresh(true);
 }