示例#1
0
        /// <inheritdoc cref="ICanvas"/>
        public ICanvas DrawImage(string imageFile, PointPair box)
        {
            // Validates the arguments.
            ValidationUtil.RequireFileExist(imageFile);
            if (!FileUtil.IsImageFile(imageFile))
            {
                throw new ArgumentException($"imageFile({imageFile}) is not an image.");
            }

            ValidationUtil.RequireNonNull(box);

            // Calculates the dimensions.
            var rect  = box.ToRectangle(currentDrawingSpace);
            var image = XImage.FromFile(imageFile);

            currentGfx.DrawImage(image, rect.X, rect.Y, rect.Width, rect.Height);
            return(this);
        }
        public void Test_RequireFileExist_Null()
        {
            string file = null;

            ValidationUtil.RequireFileExist(file);
        }
        public void Test_RequireFileExist_NoExist()
        {
            string file = ResourcesPath("no-exist-file");

            ValidationUtil.RequireFileExist(file);
        }
        public void Test_RequireFileExist_Exist()
        {
            string file = ResourcesPath("test-text-file.txt");

            ValidationUtil.RequireFileExist(file);
        }