Esempio n. 1
0
        private void OldPassphrase_Load(object sender, EventArgs e)
        {
            IList <GnuKey> keys = Globals.OutlookGnuPG.GetKeys();

            KeyBox.DataSource    = keys;
            KeyBox.DisplayMember = "KeyDisplay";
            KeyBox.ValueMember   = "Key";

            if (KeyBox.Items.Count <= 0)
            {
                // No keys available, no use in showing this dialog at all
                Hide();
                return;
            }

            int boxHeight = (keys.Count > 10) ? KeyBox.ItemHeight * 10 : KeyBox.ItemHeight * keys.Count;

            KeyBox.Height = boxHeight + 5;
            Height        = boxHeight + 90;

            // Enlarge dialog to fit the longest key
            using (Graphics g = CreateGraphics())
            {
                int maxSize = Width;
                foreach (GnuKey key in keys)
                {
                    int textWidth = (int)g.MeasureString(key.KeyDisplay, KeyBox.Font).Width + 50;
                    if (textWidth > maxSize)
                    {
                        maxSize = textWidth;
                    }
                }
                Width = maxSize;
                CenterToScreen();
            }

            for (int i = 0; i < KeyBox.Items.Count; i++)
            {
                GnuKey recipient = (GnuKey)KeyBox.Items[i];
#if DISABLED
                KeyBox.SetItemChecked(i, _defaultKeys.Contains(recipient.Key));
#else
                // Update to support CN from X.400 mail address format.
                // Enable item if the associated key starts with one of the available _defaultKeys (hence a prefix match).
                KeyBox.SetItemChecked(i,
                                      null != _defaultKeys.Find(delegate(string gnuKey) { return(recipient.Key.StartsWith(gnuKey)); }));
#endif
            }
        }
Esempio n. 2
0
    public IList<GnuKey> GetKeys()
    {
      GnuPGKeyCollection privateKeys = _gnuPg.GetKeys();

      List<GnuKey> keys = new List<GnuKey>();
      foreach (GnuPGKey privateKey in privateKeys)
      {
#if VS2008
        keys.Add(new GnuKey
        {
          Key = privateKey.UserId,
          KeyDisplay = string.Format("{0} <{1}>", privateKey.UserName, privateKey.UserId)
        });
#else
        GnuKey k = new GnuKey();
        k.Key = privateKey.UserId;
        k.KeyDisplay = string.Format("{0} <{1}>", privateKey.UserName, privateKey.UserId);
        keys.Add(k);
#endif
      }

      return keys;
    }
Esempio n. 3
0
        public IList<GnuKey> GetKeys()
        {
            GnuPGKeyCollection privateKeys = _gnuPg.GetKeys();

              List<GnuKey> keys = new List<GnuKey>();
              foreach (GnuPGKey privateKey in privateKeys)
              {
            #if VS2008
            keys.Add(new GnuKey
            {
              Key = privateKey.UserId,
              KeyDisplay = string.Format("{0} <{1}>", privateKey.UserName, privateKey.UserId)
            });
            #else
            GnuKey k = new GnuKey();
            k.Key = privateKey.UserId;
            k.KeyDisplay = string.Format("{0} <{1}>", privateKey.UserName, privateKey.UserId);
            keys.Add(k);
            #endif
              }

              return keys;
        }