/// <summary> /// Returns a value that indicates whether the specified object is an /// <see cref="RoundedCornerLayer"/> object that is equivalent to /// this <see cref="RoundedCornerLayer"/> object. /// </summary> /// <param name="obj"> /// The object to test. /// </param> /// <returns> /// True if the given object is an <see cref="RoundedCornerLayer"/> object that is equivalent to /// this <see cref="RoundedCornerLayer"/> object; otherwise, false. /// </returns> public override bool Equals(object obj) { RoundedCornerLayer rounded = obj as RoundedCornerLayer; if (rounded == null) { return(false); } return(this.Radius == rounded.Radius && this.BackgroundColor == rounded.BackgroundColor && this.TopLeft == rounded.TopLeft && this.TopRight == rounded.TopRight && this.BottomLeft == rounded.BottomLeft && this.BottomRight == rounded.BottomRight); }
/// <summary> /// The position in the original string where the first character of the captured substring was found. /// </summary> /// <param name="queryString">The query string to search.</param> /// <returns> /// The zero-based starting position in the original string where the captured substring was found. /// </returns> public int MatchRegexIndex(string queryString) { this.SortOrder = int.MaxValue; Match match = this.RegexPattern.Match(queryString); if (match.Success) { this.SortOrder = match.Index; NameValueCollection queryCollection = HttpUtility.ParseQueryString(queryString); RoundedCornerLayer roundedCornerLayer = new RoundedCornerLayer( QueryParamParser.Instance.ParseValue<int>(queryCollection["roundedcorners"]), this.ParseCorner(queryCollection, "tl"), this.ParseCorner(queryCollection, "tr"), this.ParseCorner(queryCollection, "bl"), this.ParseCorner(queryCollection, "br")); this.Processor.DynamicParameter = roundedCornerLayer; } return this.SortOrder; }
/// <summary> /// Adds rounded corners to the current image. /// </summary> /// <param name="roundedCornerLayer"> /// The <see cref="T:ImageProcessor.Imaging.RoundedCornerLayer"/> containing the properties to round corners on the image. /// </param> /// <returns> /// The current instance of the <see cref="T:ImageProcessor.ImageFactory"/> class. /// </returns> public ImageFactory RoundedCorners(RoundedCornerLayer roundedCornerLayer) { if (this.ShouldProcess) { if (roundedCornerLayer.Radius < 0) { roundedCornerLayer.Radius = 0; } RoundedCorners roundedCorners = new RoundedCorners { DynamicParameter = roundedCornerLayer }; this.CurrentImageFormat.ApplyProcessor(roundedCorners.ProcessImage, this); } return this; }
public void TestRoundedCornersRegex() { const string Querystring = "roundedcorners=30"; RoundedCornerLayer expected = new RoundedCornerLayer(30, true, true, true, true); RoundedCorners roundedCorners = new RoundedCorners(); roundedCorners.MatchRegexIndex(Querystring); RoundedCornerLayer actual = roundedCorners.DynamicParameter; Assert.AreEqual(expected, actual); }
/// <summary> /// Adds rounded corners to the current image. /// </summary> /// <param name="roundedCornerLayer"> /// The <see cref="T:ImageProcessor.Imaging.RoundedCornerLayer"/> containing the properties to round corners on the image. /// </param> /// <returns> /// The current instance of the <see cref="T:ImageProcessor.ImageFactory"/> class. /// </returns> public ImageFactory RoundedCorners(RoundedCornerLayer roundedCornerLayer) { if (this.ShouldProcess) { if (roundedCornerLayer.Radius < 0) { roundedCornerLayer.Radius = 0; } RoundedCorners roundedCorners = new RoundedCorners { DynamicParameter = roundedCornerLayer }; this.Image = roundedCorners.ProcessImage(this); } return this; }
/// <summary> /// The position in the original string where the first character of the captured substring was found. /// </summary> /// <param name="queryString"> /// The query string to search. /// </param> /// <returns> /// The zero-based starting position in the original string where the captured substring was found. /// </returns> public int MatchRegexIndex(string queryString) { int index = 0; // Set the sort order to max to allow filtering. this.SortOrder = int.MaxValue; foreach (Match match in this.RegexPattern.Matches(queryString)) { if (match.Success) { if (index == 0) { // Set the index on the first instance only. this.SortOrder = match.Index; RoundedCornerLayer roundedCornerLayer; string toParse = match.Value; if (toParse.Contains("bgcolor")) { roundedCornerLayer = new RoundedCornerLayer(this.ParseRadius(toParse), this.ParseColor(toParse), this.ParseCorner(TopLeftRegex, toParse), this.ParseCorner(TopRightRegex, toParse), this.ParseCorner(BottomLeftRegex, toParse), this.ParseCorner(BottomRightRegex, toParse)); } else { int radius; int.TryParse(match.Value.Split('=')[1], out radius); roundedCornerLayer = new RoundedCornerLayer(radius, this.ParseCorner(TopLeftRegex, toParse), this.ParseCorner(TopRightRegex, toParse), this.ParseCorner(BottomLeftRegex, toParse), this.ParseCorner(BottomRightRegex, toParse)); } this.DynamicParameter = roundedCornerLayer; } index += 1; } } return this.SortOrder; }
/// <summary> /// Adds rounded corners to the current image. /// </summary> /// <param name="radius"> /// The radius at which the corner will be rounded. /// </param> /// <returns> /// The current instance of the <see cref="T:ImageProcessor.ImageFactory"/> class. /// </returns> public ImageFactory RoundedCorners(int radius) { if (this.ShouldProcess) { if (radius < 0) { radius = 0; } RoundedCornerLayer roundedCornerLayer = new RoundedCornerLayer(radius); RoundedCorners roundedCorners = new RoundedCorners { DynamicParameter = roundedCornerLayer }; this.backupFormat.ApplyProcessor(roundedCorners.ProcessImage, this); } return this; }