コード例 #1
0
        /// <summary>
        /// Returns a value that indicates whether the specified object is an
        /// <see cref="RotateLayer"/> object that is equivalent to
        /// this <see cref="RotateLayer"/> object.
        /// </summary>
        /// <param name="obj">
        /// The object to test.
        /// </param>
        /// <returns>
        /// True if the given object  is an <see cref="RotateLayer"/> object that is equivalent to
        /// this <see cref="RotateLayer"/> object; otherwise, false.
        /// </returns>
        public override bool Equals(object obj)
        {
            RotateLayer rotate = obj as RotateLayer;

            if (rotate == null)
            {
                return(false);
            }

            return(this.Angle == rotate.Angle && this.BackgroundColor == rotate.BackgroundColor);
        }
コード例 #2
0
        public void TestRotateRegex()
        {
            const string Querystring = "rotate=270";
            RotateLayer expected = new RotateLayer(270, Color.Transparent);

            Rotate rotate = new Rotate();
            rotate.MatchRegexIndex(Querystring);

            RotateLayer actual = rotate.DynamicParameter;

            Assert.AreEqual(expected, actual);
        }
コード例 #3
0
        /// <summary>
        /// Rotates the current image by the given angle.
        /// </summary>
        /// <param name="rotateLayer">
        /// The <see cref="T:ImageProcessor.Imaging.RotateLayer"/> containing the properties to rotate the image.
        /// </param>
        /// <returns>
        /// The current instance of the <see cref="T:ImageProcessor.ImageFactory"/> class.
        /// </returns>
        public ImageFactory Rotate(RotateLayer rotateLayer)
        {
            if (this.ShouldProcess)
            {
                // Sanitize the input.
                if (rotateLayer.Angle > 360 || rotateLayer.Angle < 0)
                {
                    rotateLayer.Angle = 0;
                }

                Rotate rotate = new Rotate { DynamicParameter = rotateLayer };

                this.Image = rotate.ProcessImage(this);
            }

            return this;
        }
コード例 #4
0
ファイル: Rotate.cs プロジェクト: rosrosros/ImageProcessor
        /// <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;

                        RotateLayer rotateLayer;

                        string toParse = match.Value;

                        if (toParse.Contains("bgcolor"))
                        {
                            rotateLayer = new RotateLayer(this.ParseAngle(toParse), this.ParseColor(toParse));
                        }
                        else
                        {
                            int degrees;
                            int.TryParse(match.Value.Split('=')[1], out degrees);

                            rotateLayer = new RotateLayer(degrees);
                        }

                        this.DynamicParameter = rotateLayer;
                    }

                    index += 1;
                }
            }

            return this.SortOrder;
        }
コード例 #5
0
        public void TestRotateRegex()
        {
            const string Querystring = "rotate=270";
            RotateLayer expected = new RotateLayer(270, Color.Transparent);

            Rotate rotate = new Rotate();
            rotate.MatchRegexIndex(Querystring);

            RotateLayer actual = rotate.DynamicParameter;

            // Can't use are equal on rotatelayer for some reason so test the two properties.
            Assert.AreEqual(expected.Angle, actual.Angle);
            Assert.AreEqual(expected.BackgroundColor, actual.BackgroundColor);
        }