Example #1
0
        public IImage InsertImage(string path, int width, int height, int?position = null)
        {
            if (position.HasValue && (position < 0 || position > _documentItems.Count))
            {
                throw new IndexOutOfRangeException($"Wrong position: {position}");
            }

            string newPath = _imageHandler.AddImage(path);

            if (newPath == "")
            {
                throw new Exception($"Wrong path: {position}");
            }

            IImage image = new Image(width, height, newPath, _history, _imageHandler);

            _history.AddAndExecuteCommand(new InsertImageCommand(_documentItems, image, position));

            return(image);
        }