Imports System.Drawing Imports DevExpress.Utils.Svg Imports EnvelopeGenerator.Common.Constants Public Class Helpers ''' ''' Encodes the EnvelopeUUID and the ReceiverSignature into an EnvelopeKey ''' ''' ''' ''' The EnvelopeKey Public Shared Function EncodeEnvelopeReceiverId(pEnvelopeUuid As String, pReceiverSignature As String) As String Dim oString = $"{pEnvelopeUuid}::{pReceiverSignature}" Dim oBytes = System.Text.Encoding.UTF8.GetBytes(oString) Dim oBase64String = Convert.ToBase64String(oBytes) Return oBase64String End Function ''' ''' Decodes the EnvelopeKey and returns the EnvelopeUUID and the ReceiverSignature ''' ''' The EnvelopeKey ''' A tuple containing EnvelopeUUID and Receiver Signature Public Shared Function DecodeEnvelopeReceiverId(pEnvelopeReceiverId As String) As Tuple(Of String, String) Dim oBytes = Convert.FromBase64String(pEnvelopeReceiverId) Dim oString = System.Text.Encoding.UTF8.GetString(oBytes) Dim oSplit = oString.Split(New String() {"::"}, StringSplitOptions.None) Return New Tuple(Of String, String)(oSplit(0), oSplit(1)) End Function Public Shared Function GetEnvelopeURL(pHost As String, pEnvelopeUuid As String, pReceiverSignature As String) As String Dim oEnvelopeUserReference As String = EncodeEnvelopeReceiverId(pEnvelopeUuid, pReceiverSignature) Dim oURL As String = String.Format("{0}/EnvelopeKey/{1}", pHost.Trim(), oEnvelopeUserReference) Return oURL End Function Public Shared Function ColorTypeToColor(pColorType As ColorType) As Color Select Case pColorType Case ColorType.ReceiverColor1 Return Color.Blue Case ColorType.ReceiverColor2 Return Color.Maroon Case ColorType.ReceiverColor3 Return Color.LightSeaGreen Case ColorType.ReceiverColor4 Return Color.LimeGreen Case ColorType.ReceiverColor5 Return Color.Magenta Case ColorType.ReceiverColor6 Return Color.MediumSpringGreen Case ColorType.ReceiverColor7 Return Color.OrangeRed Case ColorType.ReceiverColor8 Return Color.DodgerBlue Case ColorType.ReceiverColor9 Return Color.Purple Case ColorType.ReceiverColor10 Return Color.Gold End Select End Function Public Shared Function GetColorCircle(pBaseImage As SvgImage, pColor As Color) As SvgImage Dim oColoredImage As SvgImage = pBaseImage. Clone(Sub(el As SvgElement, table As Hashtable) If TypeOf el Is SvgCircle Then el.Styles.Clear() table("StyleName") = String.Empty table("Fill") = ColorTranslator.ToHtml(pColor) End If End Sub) Return oColoredImage End Function Public Shared Function IsValidEmailAddress(pEmailAddress As String) As Boolean Try Dim oAddress = New System.Net.Mail.MailAddress(pEmailAddress) Return oAddress.Address = pEmailAddress Catch ex As Exception Return False End Try End Function End Class