Exemplo n.º 1
0
 /// <summary>
 /// The main constructor
 /// </summary>
 /// <param name="caller">A reference to the main Cryptnos window</param>
 /// <param name="importedSites">A <see cref="List"/> of <see cref="SiteParameters"/> imported
 /// from a file. This is our starting list from which the user will select which sites to
 /// import</param>
 /// <param name="debug">Whether or not we are in debug mode</param>
 /// <param name="keepOnTop">Whether or not this window should remain on top of other windows</param>
 /// <param name="showToolTips">Whether or not to show tool tip help</param>
 public ImportDialog(MainForm caller, List <SiteParameters> importedSites, bool debug, bool keepOnTop,
                     bool showToolTips)
 {
     // Initialize the window and grab local copies of all our inputs:
     InitializeComponent();
     this.caller     = caller;
     sitesFromFile   = importedSites;
     this.debug      = debug;
     this.TopMost    = keepOnTop;
     toolTip1.Active = showToolTips;
     // By default, disable the Import button until something has been selected:
     btnImport.Enabled = false;
     // If we got any sites from the import file, populate the site list here.  We will display the
     // list as checkboxes so the user can pick and choose which sites they want to import.  We also
     // want to indicate which sites will overwrite existing sites by coloring them red.
     if (importedSites != null && importedSites.Count > 0)
     {
         // First, get the list of existing sites from the caller:
         string[] existingSites = caller.GetSiteList();
         // Loop through the sites imported from the file:
         foreach (SiteParameters site in importedSites)
         {
             // Create the checkbox for this site:
             ListViewItem item = new ListViewItem(site.Site);
             // If the site already exists, color the text for this item red.  Otherwise, we'll
             // default to the regular color (most likely black).
             if (SiteAlreadyExists(existingSites, site.Site))
             {
                 item.ForeColor = Color.Red;
             }
             // Add the item to the list box:
             listSitesInFile.Items.Add(item);
         }
     }
     // This should never happen, but if we didn't get any useful sites to work with, complain and
     // close the form:
     else
     {
         MessageBox.Show("No sites were found in the selected file", "Error", MessageBoxButtons.OK,
                         MessageBoxIcon.Error);
         DialogResult = DialogResult.Cancel;
         Hide();
     }
 }
Exemplo n.º 2
0
 /// <summary>
 /// The main constructor
 /// </summary>
 /// <param name="caller">A reference to the main Cryptnos window</param>
 /// <param name="importedSites">A <see cref="List"/> of <see cref="SiteParameters"/> imported
 /// from a file. This is our starting list from which the user will select which sites to
 /// import</param>
 /// <param name="debug">Whether or not we are in debug mode</param>
 /// <param name="keepOnTop">Whether or not this window should remain on top of other windows</param>
 /// <param name="showToolTips">Whether or not to show tool tip help</param>
 public ImportDialog(MainForm caller, List<SiteParameters> importedSites, bool debug, bool keepOnTop,
     bool showToolTips)
 {
     // Initialize the window and grab local copies of all our inputs:
     InitializeComponent();
     this.caller = caller;
     sitesFromFile = importedSites;
     this.debug = debug;
     this.TopMost = keepOnTop;
     toolTip1.Active = showToolTips;
     // By default, disable the Import button until something has been selected:
     btnImport.Enabled = false;
     // If we got any sites from the import file, populate the site list here.  We will display the
     // list as checkboxes so the user can pick and choose which sites they want to import.  We also
     // want to indicate which sites will overwrite existing sites by coloring them red.
     if (importedSites != null && importedSites.Count > 0)
     {
         // First, get the list of existing sites from the caller:
         string[] existingSites = caller.GetSiteList();
         // Loop through the sites imported from the file:
         foreach (SiteParameters site in importedSites)
         {
             // Create the checkbox for this site:
             ListViewItem item = new ListViewItem(site.Site);
             // If the site already exists, color the text for this item red.  Otherwise, we'll
             // default to the regular color (most likely black).
             if (SiteAlreadyExists(existingSites, site.Site))
                 item.ForeColor = Color.Red;
             // Add the item to the list box:
             listSitesInFile.Items.Add(item);
         }
     }
     // This should never happen, but if we didn't get any useful sites to work with, complain and
     // close the form:
     else
     {
         MessageBox.Show("No sites were found in the selected file", "Error", MessageBoxButtons.OK,
                     MessageBoxIcon.Error);
         DialogResult = DialogResult.Cancel;
         Hide();
     }
 }