/// <summary>
 /// Default constructor
 /// </summary>
 /// <param name="parent">Our parent Cryptnos form</param>
 /// <param name="encoding">The current text encoding setting</param>
 /// <param name="showTooltips">A boolean value specifying whether or not to show
 /// tooltip help.</param>
 /// <param name="debug">Whether or not debug mode is enabled</param>
 /// <param name="disableUpdateCheck">Whether or not to disable the update check</param>
 /// <param name="keepOnTop">Whether or not to keep Cryptnos on top of other windows</param>
 /// <param name="showMasterPassword">Whether or not Cryptnos should show or obscure the master passphrase</param>
 /// <param name="clearPasswordsOnFocusLoss">Whether or not Cryptnos should clear the master passphrase and generated
 /// password when the main form loses focus</param>
 public AdvancedSettingsDialog(MainForm parent, Encoding encoding, bool showTooltips, bool debug,
     bool disableUpdateCheck, bool keepOnTop, bool showMasterPassword,
     bool clearPasswordsOnFocusLoss)
 {
     InitializeComponent();
     // Keep track of our parent form:
     this.parent = parent;
     // Set up the encoding's drop-down box.  Note the try/catch block; this is a
     // kludge to prevent this bit of code from blowing up under Mono.  Apparently
     // there is a bug in their implementation of Encoding.GetEncodings() that
     // returns a bunch of invalid encodings for the platform.  The try/catch
     // block, while inelegant, should populate the drop-down box with only valid
     // encodings for the platform.  See: https://bugzilla.xamarin.com/show_bug.cgi?id=8117
     foreach (EncodingInfo encodingInfo in Encoding.GetEncodings())
     {
         try { cmbTextEncodings.Items.Add(encodingInfo.GetEncoding()); }
         catch { }
     }
     cmbTextEncodings.DisplayMember = "WebName";
     // Select the text encoding currently selected:
     this.encoding = encoding;
     cmbTextEncodings.SelectedItem = encoding;
     // Show the default encoding for the system, mostly for debugging purposes:
     lblDefaultEncoding.Text += Encoding.Default.WebName;
     // Get the debug and update check settings and check or uncheck the appropriate
     // boxes:
     this.debug = debug;
     this.disableUpdateCheck = disableUpdateCheck;
     this.showMasterPassword = showMasterPassword;
     this.clearPasswordsOnFocusLoss = clearPasswordsOnFocusLoss;
     chkDebug.Checked = debug;
     chkDisableUpdateCheck.Checked = disableUpdateCheck;
     chkShowMasterPassphrase.Checked = showMasterPassword;
     chkClearPasswordOnFocusLoss.Checked = clearPasswordsOnFocusLoss;
     // The "keep on top" setting:
     this.keepOnTop = keepOnTop;
     chkKeepOnTop.Checked = keepOnTop;
     this.TopMost = keepOnTop;
     toolTip1.Active = showTooltips;
 }
Ejemplo 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();
     }
 }
 /// <summary>
 /// The ExportSitesForm constructor.
 /// </summary>
 /// <param name="sites">An object array containing the strings of the site tokens,
 /// which should be taken from the Sites combo box on the main Cryptnos form.</param>
 /// <param name="showTooltips">A boolean value specifying whether or not to show
 /// tooltip help.</param>
 /// <param name="keepOnTop">Keep Cryptnos on top of other windows</param>
 public ExportSitesForm(object[] sites, bool showTooltips, bool keepOnTop, MainForm caller)
 {
     // The normal initializaition:
     InitializeComponent();
     // Populate the site list box.  The sites array should contain a bunch of strings
     // corresponding to the items in the Sites combo box on the main form.  For our
     // purposes, it technically doesn't matter if they're strings or not, but that's
     // what we'll be getting and passing back out.  However, since both the combo box
     // and list box Items properties return ObjectCollection objects, it's easier to
     // just use the ObjectCollection.CopyTo() method to get an object array to deal
     // with.
     foreach (Object site in sites)
     {
         lbSiteList.Items.Add(site);
     }
     // By default, make the Export All option be enabled:
     rbExportAll.Checked = true;
     rbExportSome.Checked = false;
     lbSiteList.Enabled = false;
     // Populate the site drop-down on the QR code tab:
     cmboExportSiteQR.Items.AddRange(sites);
     // Turn tooltips on or off depending on the value passed in from the main form:
     toolTip1.Active = showTooltips;
     TopMost = keepOnTop;
     this.caller = caller;
 }