/// <summary> /// Returns a value that indicates whether the specified object is an /// <see cref="TextLayer"/> object that is equivalent to /// this <see cref="TextLayer"/> object. /// </summary> /// <param name="obj"> /// The object to test. /// </param> /// <returns> /// True if the given object is an <see cref="TextLayer"/> object that is equivalent to /// this <see cref="TextLayer"/> object; otherwise, false. /// </returns> public override bool Equals(object obj) { TextLayer textLayer = obj as TextLayer; if (textLayer == null) { return(false); } return(this.Text == textLayer.Text && this.FontColor == textLayer.FontColor && this.FontFamily.Equals(textLayer.FontFamily) && this.FontSize == textLayer.FontSize && this.Style == textLayer.Style && this.DropShadow == textLayer.DropShadow && this.Opacity == textLayer.Opacity && this.Position == textLayer.Position); }
/// <summary> /// Adds a text based watermark to the current image. /// </summary> /// <param name="textLayer"> /// The <see cref="T:ImageProcessor.Imaging.TextLayer"/> containing the properties necessary to add /// the text based watermark to the image. /// </param> /// <returns> /// The current instance of the <see cref="T:ImageProcessor.ImageFactory"/> class. /// </returns> public ImageFactory Watermark(TextLayer textLayer) { if (this.ShouldProcess) { Watermark watermark = new Watermark { DynamicParameter = textLayer }; this.CurrentImageFormat.ApplyProcessor(watermark.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) { this.SortOrder = int.MaxValue; Match match = this.RegexPattern.Match(queryString); if (match.Success) { this.SortOrder = match.Index; NameValueCollection queryCollection = HttpUtility.ParseQueryString(queryString); TextLayer textLayer = new TextLayer { Text = this.ParseText(queryCollection), Position = this.ParsePosition(queryCollection), FontColor = this.ParseColor(queryCollection), FontSize = this.ParseFontSize(queryCollection), FontFamily = this.ParseFontFamily(queryCollection), Style = this.ParseFontStyle(queryCollection), DropShadow = this.ParseDropShadow(queryCollection), Vertical = this.ParseVertical(queryCollection), RightToLeft = this.ParseRightToLeft(queryCollection) }; textLayer.Opacity = this.ParseOpacity(queryCollection, textLayer.FontColor); this.Processor.DynamicParameter = textLayer; } return this.SortOrder; }
/// <summary> /// Adds a text based watermark to the current image. /// </summary> /// <param name="textLayer"> /// The <see cref="T:ImageProcessor.Imaging.TextLayer"/> containing the properties necessary to add /// the text based watermark to the image. /// </param> /// <returns> /// The current instance of the <see cref="T:ImageProcessor.ImageFactory"/> class. /// </returns> public ImageFactory Watermark(TextLayer textLayer) { if (this.ShouldProcess) { Watermark watermark = new Watermark { DynamicParameter = textLayer }; this.Image = watermark.ProcessImage(this); } return this; }
/// <summary> /// Returns the correct flags for the given text layer. /// </summary> /// <param name="textLayer"> /// The <see cref="TextLayer"/> to return the flags for. /// </param> /// <returns> /// The <see cref="StringFormatFlags"/>. /// </returns> private StringFormatFlags? GetFlags(TextLayer textLayer) { if (textLayer.Vertical && textLayer.RightToLeft) { return StringFormatFlags.DirectionVertical | StringFormatFlags.DirectionRightToLeft; } if (textLayer.Vertical) { return StringFormatFlags.DirectionVertical; } if (textLayer.RightToLeft) { return StringFormatFlags.DirectionRightToLeft; } return null; }
/// <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; TextLayer textLayer = new TextLayer(); string toParse = match.Value; textLayer.Text = this.ParseText(toParse); textLayer.Position = this.ParsePosition(toParse); textLayer.TextColor = this.ParseColor(toParse); textLayer.FontSize = this.ParseFontSize(toParse); textLayer.Font = this.ParseFontFamily(toParse); textLayer.Style = this.ParseFontStyle(toParse); textLayer.Opacity = this.ParseOpacity(toParse); textLayer.DropShadow = this.ParseDropShadow(toParse); this.DynamicParameter = textLayer; } index += 1; } } return this.SortOrder; }