public override void AwakeFromNib() { base.AwakeFromNib(); SolutionUserDto = SolutionUserDtoOriginal.DeepCopy(); TxtName.StringValue = SolutionUserDto.Name; TxtDescription.StringValue = string.IsNullOrEmpty(SolutionUserDto.Description)?string.Empty:SolutionUserDto.Description; CbDisabled.StringValue = SolutionUserDto.Disabled ? "1" : "0"; Window.Title = SolutionUserDto.Name + " Properties"; var cert = new X509Certificate2(Encoding.ASCII.GetBytes(SolutionUserDto.Certificate.Encoded)); try { TxtIssuer.StringValue = cert.Issuer; TxtValidFrom.StringValue = cert.NotBefore.ToShortDateString(); TxtValidTo.StringValue = cert.NotAfter.ToShortDateString(); TxtDC.StringValue = cert.IssuerName.Format(true); } catch (Exception) { UtilityService.ShowAlert("Invalid X509 certificate", "Alert"); } //Events this.BtnSave.Activated += OnClickSaveButton; this.BtnClose.Activated += (object sender, EventArgs e) => { this.Close(); NSApplication.SharedApplication.StopModalWithCode(0); }; this.BtnChangeCertificate.Activated += (object sender, EventArgs e) => { var openPanel = new NSOpenPanel(); openPanel.ReleasedWhenClosed = true; openPanel.Prompt = "Select file"; var result = openPanel.RunModal(); if (result == 1) { var filePath = openPanel.Url.AbsoluteString.Replace("file://", string.Empty); var cert1 = new X509Certificate2(); try { cert1.Import(filePath); TxtIssuer.StringValue = cert1.Issuer; TxtValidFrom.StringValue = cert1.NotBefore.ToShortDateString(); TxtValidTo.StringValue = cert1.NotAfter.ToShortDateString(); TxtDC.StringValue = cert1.IssuerName.Format(true); } catch (Exception) { UtilityService.ShowAlert("Invalid X509 certificate", "Alert"); } SolutionUserDto.Certificate.Encoded = cert.ToPem(); } }; }
public override void AwakeFromNib() { base.AwakeFromNib(); SolutionUserDto = SolutionUserDtoOriginal.DeepCopy(); TxtName.StringValue = SolutionUserDto.Name; TxtDescription.StringValue = string.IsNullOrEmpty(SolutionUserDto.Description)?string.Empty:SolutionUserDto.Description; cbDisabled.StringValue = SolutionUserDto.Disabled ? "0" : "1"; _certificate = new X509Certificate2(Encoding.ASCII.GetBytes(SolutionUserDto.Certificate.Encoded)); ActionHelper.Execute(delegate() { TxtIssuer.StringValue = _certificate.Issuer; TxtValidFrom.StringValue = _certificate.NotBefore.ToShortDateString(); TxtValidTo.StringValue = _certificate.NotAfter.ToShortDateString(); TxtDn.StringValue = _certificate.IssuerName.Format(true); }); //Events this.BtnSave.Activated += OnClickSaveButton; this.BtnChangeCertificate.Activated += (object sender, EventArgs e) => { var openPanel = new NSOpenPanel(); openPanel.ReleasedWhenClosed = true; openPanel.Prompt = "Select file"; var result = openPanel.RunModal(); if (result == 1) { var filePath = openPanel.Url.AbsoluteString.Replace("file://", string.Empty); var cert1 = new X509Certificate2(); ActionHelper.Execute(delegate() { cert1.Import(filePath); TxtIssuer.StringValue = cert1.Issuer; TxtValidFrom.StringValue = cert1.NotBefore.ToShortDateString(); TxtValidTo.StringValue = cert1.NotAfter.ToShortDateString(); TxtDn.StringValue = cert1.IssuerName.Format(true); _certificate = cert1; }); SolutionUserDto.Certificate.Encoded = _certificate.ToPem(); } }; BtnViewCertificate.Activated += (object sender, EventArgs e) => { CertificateService.DisplayX509Certificate2(this, _certificate); }; BtnSave.Hidden = !IsSystemDomain; }
public object GetData() { return(_dtoOriginal.DeepCopy()); }