/// <summary> /// Initializes a new instance of a <see cref="QrServerQrCodeProvider"/> with the specified /// <see cref="ErrorCorrectionLevel"/>, <see cref="Margin"/>, <see cref="QuietZone"/>, /// <see cref="BackgroundColor"/>, <see cref="ForegroundColor"/>, /// <see cref="QrServerImageFormat">ImageFormat</see> and <see cref="RemoteCertificateValidationCallback"/>. /// </summary> /// <param name="errorCorrectionLevel">The <see cref="ErrorCorrectionLevel"/> to use when generating QR codes.</param> /// <param name="margin">The <see cref="Margin"/> to be used for the QR code.</param> /// <param name="quietZone">The <see cref="QuietZone"/> to be used for the QR code.</param> /// <param name="backgroundColor">The background color to be used for the QR code.</param> /// <param name="foregroundColor">The foreground color to be used for the QR code.</param> /// <param name="imageFormat">The <see cref="QrServerImageFormat"/> of the QR code.</param> /// <param name="remoteCertificateValidationCallback"> /// The <see cref="RemoteCertificateValidationCallback"/> to use when generating QR codes. /// </param> /// <exception cref="ArgumentOutOfRangeException"> /// Thrown when an invalid <see cref="ErrorCorrectionLevel"/> or <see cref="QrServerImageFormat"/> is specified, /// <paramref name="margin"/> is less than 0 or more than 50 or <paramref name="quietZone"/> is less than 0 or /// more than 100. /// </exception> public QrServerQrCodeProvider(ErrorCorrectionLevel errorCorrectionLevel, int margin, int quietZone, Color backgroundColor, Color foregroundColor, QrServerImageFormat imageFormat, RemoteCertificateValidationCallback remoteCertificateValidationCallback) : base(baseuri, remoteCertificateValidationCallback) { if (!Enum.IsDefined(typeof(ErrorCorrectionLevel), errorCorrectionLevel)) { throw new ArgumentOutOfRangeException("errorCorrectionLevel"); } this.ErrorCorrectionLevel = errorCorrectionLevel; if (margin < 0 || margin > 50) { throw new ArgumentOutOfRangeException("margin"); } this.Margin = margin; if (quietZone < 0 || quietZone > 100) { throw new ArgumentOutOfRangeException("quietZone"); } this.QuietZone = quietZone; this.BackgroundColor = backgroundColor; this.ForegroundColor = foregroundColor; if (!Enum.IsDefined(typeof(QrServerImageFormat), imageFormat)) { throw new ArgumentOutOfRangeException("imageFormat"); } this.ImageFormat = imageFormat; }
/// <summary> /// Initializes a new instance of a <see cref="QrServerQrCodeProvider"/> with the specified /// <see cref="ErrorCorrectionLevel"/>, <see cref="Margin"/>, <see cref="QuietZone"/>, /// <see cref="BackgroundColor"/>, <see cref="ForegroundColor"/>, /// <see cref="QrServerImageFormat">ImageFormat</see> and <see cref="RemoteCertificateValidationCallback"/>. /// </summary> /// <param name="errorCorrectionLevel">The <see cref="ErrorCorrectionLevel"/> to use when generating QR codes.</param> /// <param name="margin">The <see cref="Margin"/> to be used for the QR code.</param> /// <param name="quietZone">The <see cref="QuietZone"/> to be used for the QR code.</param> /// <param name="backgroundColor">The background color to be used for the QR code.</param> /// <param name="foregroundColor">The foreground color to be used for the QR code.</param> /// <param name="imageFormat">The <see cref="QrServerImageFormat"/> of the QR code.</param> /// <param name="remoteCertificateValidationCallback"> /// The <see cref="RemoteCertificateValidationCallback"/> to use when generating QR codes. /// </param> /// <exception cref="ArgumentOutOfRangeException"> /// Thrown when an invalid <see cref="ErrorCorrectionLevel"/> or <see cref="QrServerImageFormat"/> is specified, /// <paramref name="margin"/> is less than 0 or more than 50 or <paramref name="quietZone"/> is less than 0 or /// more than 100. /// </exception> public QrServerQrCodeProvider( ErrorCorrectionLevel errorCorrectionLevel = ErrorCorrectionLevel.Low, int margin = 4, int quietZone = 1, Color?backgroundColor = null, Color?foregroundColor = null, QrServerImageFormat imageFormat = QrServerImageFormat.Png, RemoteCertificateValidationCallback remoteCertificateValidationCallback = null ) : base(baseuri, remoteCertificateValidationCallback) { if (!Enum.IsDefined(typeof(ErrorCorrectionLevel), errorCorrectionLevel)) { throw new ArgumentOutOfRangeException(nameof(errorCorrectionLevel)); } ErrorCorrectionLevel = errorCorrectionLevel; if (margin < 0 || margin > 50) { throw new ArgumentOutOfRangeException(nameof(margin)); } Margin = margin; if (quietZone < 0 || quietZone > 100) { throw new ArgumentOutOfRangeException(nameof(quietZone)); } QuietZone = quietZone; BackgroundColor = backgroundColor ?? Color.White; ForegroundColor = foregroundColor ?? Color.Black; if (!Enum.IsDefined(typeof(QrServerImageFormat), imageFormat)) { throw new ArgumentOutOfRangeException(nameof(imageFormat)); } ImageFormat = imageFormat; }
/// <summary> /// Initializes a new instance of a <see cref="QrServerQrCodeProvider"/> with the specified /// <see cref="ErrorCorrectionLevel"/>, <see cref="Margin"/>, <see cref="QuietZone"/>, /// <see cref="BackgroundColor"/>, <see cref="ForegroundColor"/>, /// <see cref="QrServerImageFormat">ImageFormat</see> and <see cref="RemoteCertificateValidationCallback"/>. /// </summary> /// <param name="errorCorrectionLevel">The <see cref="ErrorCorrectionLevel"/> to use when generating QR codes.</param> /// <param name="margin">The <see cref="Margin"/> to be used for the QR code.</param> /// <param name="quietZone">The <see cref="QuietZone"/> to be used for the QR code.</param> /// <param name="backgroundColor">The background color to be used for the QR code.</param> /// <param name="foregroundColor">The foreground color to be used for the QR code.</param> /// <param name="imageFormat">The <see cref="QrServerImageFormat"/> of the QR code.</param> /// <param name="remoteCertificateValidationCallback"> /// The <see cref="RemoteCertificateValidationCallback"/> to use when generating QR codes. /// </param> /// <exception cref="ArgumentOutOfRangeException"> /// Thrown when an invalid <see cref="ErrorCorrectionLevel"/> or <see cref="QrServerImageFormat"/> is specified, /// <paramref name="margin"/> is less than 0 or more than 50 or <paramref name="quietZone"/> is less than 0 or /// more than 100. /// </exception> public QrServerQrCodeProvider(ErrorCorrectionLevel errorCorrectionLevel, int margin, int quietZone, Color backgroundColor, Color foregroundColor, QrServerImageFormat imageFormat, RemoteCertificateValidationCallback remoteCertificateValidationCallback) : base(baseuri, remoteCertificateValidationCallback) { if (!Enum.IsDefined(typeof(ErrorCorrectionLevel), errorCorrectionLevel)) throw new ArgumentOutOfRangeException("errorCorrectionLevel"); this.ErrorCorrectionLevel = errorCorrectionLevel; if (margin < 0 || margin > 50) throw new ArgumentOutOfRangeException("margin"); this.Margin = margin; if (quietZone < 0 || quietZone > 100) throw new ArgumentOutOfRangeException("quietZone"); this.QuietZone = quietZone; this.BackgroundColor = backgroundColor; this.ForegroundColor = foregroundColor; if (!Enum.IsDefined(typeof(QrServerImageFormat), imageFormat)) throw new ArgumentOutOfRangeException("imageFormat"); this.ImageFormat = imageFormat; }
/// <summary> /// Initializes a new instance of a <see cref="QrServerQrCodeProvider"/> with the specified /// <see cref="ErrorCorrectionLevel"/>, <see cref="Margin"/>, <see cref="QuietZone"/>, /// <see cref="BackgroundColor"/>, <see cref="ForegroundColor"/>, /// <see cref="QrServerImageFormat">ImageFormat</see> and default /// <see cref="RemoteCertificateValidationCallback"/>. /// </summary> /// <param name="errorCorrectionLevel">The <see cref="ErrorCorrectionLevel"/> to use when generating QR codes.</param> /// <param name="margin">The <see cref="Margin"/> to be used for the QR code.</param> /// <param name="quietZone">The <see cref="QuietZone"/> to be used for the QR code.</param> /// <param name="backgroundColor">The background color to be used for the QR code.</param> /// <param name="foregroundColor">The foreground color to be used for the QR code.</param> /// <param name="imageFormat">The <see cref="QrServerImageFormat"/> of the QR code.</param> public QrServerQrCodeProvider(ErrorCorrectionLevel errorCorrectionLevel, int margin, int quietZone, Color backgroundColor, Color foregroundColor, QrServerImageFormat imageFormat) :this(errorCorrectionLevel, margin, quietZone, backgroundColor, foregroundColor, imageFormat, null) { }
/// <summary> /// Initializes a new instance of a <see cref="QrServerQrCodeProvider"/> with the specified /// <see cref="ErrorCorrectionLevel"/>, <see cref="Margin"/>, <see cref="QuietZone"/>, /// <see cref="BackgroundColor"/>, <see cref="ForegroundColor"/>, /// <see cref="QrServerImageFormat">ImageFormat</see> and default /// <see cref="RemoteCertificateValidationCallback"/>. /// </summary> /// <param name="errorCorrectionLevel">The <see cref="ErrorCorrectionLevel"/> to use when generating QR codes.</param> /// <param name="margin">The <see cref="Margin"/> to be used for the QR code.</param> /// <param name="quietZone">The <see cref="QuietZone"/> to be used for the QR code.</param> /// <param name="backgroundColor">The background color to be used for the QR code.</param> /// <param name="foregroundColor">The foreground color to be used for the QR code.</param> /// <param name="imageFormat">The <see cref="QrServerImageFormat"/> of the QR code.</param> public QrServerQrCodeProvider(ErrorCorrectionLevel errorCorrectionLevel, int margin, int quietZone, Color backgroundColor, Color foregroundColor, QrServerImageFormat imageFormat) : this(errorCorrectionLevel, margin, quietZone, backgroundColor, foregroundColor, imageFormat, null) { }