Exemplo n.º 1
0
        private void button_copy_Click(object sender, EventArgs e)
        {
            HostsProfile hp       = getProfileByIndex(listBox_hosts.SelectedIndex);
            var          formCopy = new FormCopy(string.Format("Copy {0} to which file ?", hp.profileName), hp.profileName + "_Copy");
            var          result   = formCopy.ShowDialog(this);

            if (result == DialogResult.OK && !string.IsNullOrEmpty(formCopy.FileName))
            {
                if (checkForDuplicates(formCopy.FileName))
                {
                    MessageBox.Show("Error: '" + formCopy.FileName + "' is already an existing profile name");
                }
                else
                {
                    HostsProfile newHp = new HostsProfile();

                    foreach (Domain d in hp.domains)
                    {
                        newHp.domains.Add(d);
                    }

                    newHp.profileName = formCopy.FileName;
                    newHp.isCurrent   = false;
                    profiles.Add(newHp);
                    updateListBox();
                    //m_HostsProvider.CopyHosts((string)listHosts.SelectedItem, formCopy.FileName);
                    //LogInfo("Copied {0} to {1}\r\n", listHosts.SelectedItem, formCopy.FileName);
                    //RefreshList();
                }
            }
        }
Exemplo n.º 2
0
 private void toolStrip_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
 {
     if (e.ClickedItem == btnExit)
     {
         Application.Exit();
     }
     if (e.ClickedItem == btnUseAsHosts && listHosts.SelectedItem != null)
     {
         UseAsHosts((string)listHosts.SelectedItem);
     }
     if (e.ClickedItem == btnCopy && listHosts.SelectedItem != null)
     {
         var formCopy = new FormCopy(string.Format(Resources.CopyToWhichFile, listHosts.SelectedItem));
         var result   = formCopy.ShowDialog(this);
         if (result == DialogResult.OK && !string.IsNullOrEmpty(formCopy.FileName))
         {
             m_HostsProvider.CopyHosts((string)listHosts.SelectedItem, formCopy.FileName);
             LogInfo(Resources.CopyedTo, listHosts.SelectedItem, formCopy.FileName);
             RefreshList();
         }
     }
     if (e.ClickedItem == btnDelete && listHosts.SelectedItem != null)
     {
         if (MessageBox.Show(string.Format(Resources.ReallyDelete, listHosts.SelectedItem), string.Empty, MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes)
         {
             m_HostsProvider.DeleteHosts((string)listHosts.SelectedItem);
             LogInfo(Resources.DeletedString, listHosts.SelectedItem);
             RefreshList();
         }
     }
     if (e.ClickedItem == btnViewEdit && listHosts.SelectedItem != null)
     {
         m_HostsProvider.LaunchEditor((string)listHosts.SelectedItem);
     }
     if (e.ClickedItem == btnOpenFolder)
     {
         m_HostsProvider.OpenFolder();
     }
 }
Exemplo n.º 3
0
        private void button_new_Click(object sender, EventArgs e)
        {
            var formCopy = new FormCopy("Enter new profile name");
            var result   = formCopy.ShowDialog(this);

            if (result == DialogResult.OK && !string.IsNullOrEmpty(formCopy.FileName))
            {
                if (checkForDuplicates(formCopy.FileName))
                {
                    MessageBox.Show("Error: '" + formCopy.FileName + "' is already an existing profile name");
                }
                else
                {
                    HostsProfile newHp = new HostsProfile();
                    newHp.profileName = formCopy.FileName;
                    newHp.isCurrent   = false;
                    profiles.Add(newHp);
                    //m_HostsProvider.CopyHosts((string)listHosts.SelectedItem, formCopy.FileName);
                    //LogInfo("Copied {0} to {1}\r\n", listHosts.SelectedItem, formCopy.FileName);
                    updateListBox();
                }
            }
        }