コード例 #1
0
        public void ReplaceInitialImage(Image image, bool preserveSize, bool addNewIfNotFound)
        {
            this.InitialImageAsFilePath = null;
            this.InitialImageAsPngBytes = null;
            this.InitialImage           = image;

            //CommandDelete command = new CommandDelete(drawArea.TheLayers);

            var indexAndInitialImage = drawArea.GetInitialImageGraphic();

            if (indexAndInitialImage != null)
            {
                if (!preserveSize)
                {
                    indexAndInitialImage.Value.Value.rectangle.Width  = image.Width;
                    indexAndInitialImage.Value.Value.rectangle.Height = image.Height;
                }
                //TODO: compress theImage here
                indexAndInitialImage.Value.Value.TheImage = (Bitmap)image;

                drawArea.Invalidate();
                //drawArea.TheLayers[0].Graphics.RemoveAt(indexAndInitialImage.Value.Key);
                //drawArea.Refresh();
                //drawArea.AddCommandToHistory(command);
            }
            else
            {
                if (addNewIfNotFound)
                {
                    drawArea.LoadInitialImage(InitialImage, InitialImageAsFilePath, InitialImageAsPngBytes, null);
                }
            }

            //	drawArea.LoadInitialImage(this.InitialImage, null, null, indexAndInitialImage==null?null:indexAndInitialImage.Value.Value.Clone() as DrawImage);
        }