コード例 #1
0
 private void bCertSelection_Click(object sender, EventArgs e)
 {
     using (X509CertificatePicker dialog = new X509CertificatePicker(this.storeName, this.storeLocation))
     {
         this.Cursor      = Cursors.WaitCursor;
         this.certificate = dialog.PickCertificate(this.Handle);
         this.Cursor      = Cursors.Default;
         if (this.certificate != null)
         {
             txCertificate.Text = this.certificate.SubjectName.Name;
         }
     }
 }
コード例 #2
0
        /// <summary>
        /// Edits the specified object's value using the editor style indicated by the <see cref="M:System.Drawing.Design.UITypeEditor.GetEditStyle"></see> method.
        /// </summary>
        /// <param name="context">An <see cref="T:System.ComponentModel.ITypeDescriptorContext"></see> that can be used to gain additional context information.</param>
        /// <param name="provider">An <see cref="T:System.IServiceProvider"></see> that this editor can use to obtain services.</param>
        /// <param name="value">The object to edit.</param>
        /// <returns>
        /// The new value of the object. If the value of the object has not changed, this should return the same object it was passed.
        /// </returns>
        public override object EditValue(ITypeDescriptorContext context, 
            IServiceProvider provider, object value)
        {
            IUIService svc = (IUIService)provider.GetService(typeof(IUIService));
            IDictionaryService dictService = (IDictionaryService) provider.GetService(typeof(IDictionaryService));

            StoreName storeName = (StoreName) dictService.GetValue(storeNameArgument);
            StoreLocation storeLocation = (StoreLocation)dictService.GetValue(storeLocationArgument);
            X509FindType findType = (X509FindType)dictService.GetValue(findTypeArgument);

            using (X509CertificatePicker certPicker = new
            X509CertificatePicker(storeName, storeLocation))
            {
                X509Certificate2 selectedCert = certPicker.PickCertificate(
                    svc != null ? svc.GetDialogOwnerWindow().Handle : IntPtr.Zero);
                if (selectedCert != null)
                {
                    return X509CertificateHelper.GetFindValue(findType, selectedCert);
                }
                else
                {
                    return null;
                }
            }
        }
コード例 #3
0
 private void bCertSelection_Click(object sender, EventArgs e)
 {
     using (X509CertificatePicker dialog = new X509CertificatePicker(this.storeName, this.storeLocation))
     {
         this.Cursor = Cursors.WaitCursor;
         this.certificate = dialog.PickCertificate(this.Handle);
         this.Cursor = Cursors.Default;
         if(this.certificate != null)
         {
             txCertificate.Text = this.certificate.SubjectName.Name;
         }
     }
 }