Beispiel #1
0
        private void copyToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Image image;

            if (display.SelectedShapes.Count > 0)
            {
                image = display.Diagram.CreateImage(ImageFileFormat.EmfPlus, display.SelectedShapes);
            }
            else
            {
                image = display.Diagram.CreateImage(ImageFileFormat.EmfPlus, null);
            }

            Clipboard.Clear();
            if (image is Metafile)
            {
                EmfHelper.PutEnhMetafileOnClipboard(this.Handle, (Metafile)image);
            }
            else
            {
                Clipboard.SetImage(image);
            }
            image.Dispose();
            image = null;
        }
        private void ExportImage()
        {
            // Update file extension
            if (string.IsNullOrEmpty(Path.GetExtension(filePath)))
            {
                SetFilePath(filePath + GetFileExtension(imageFormat));
            }
            // Check if the file path changed since last export
            if (filePathChanged && !CanOverwriteFile(filePath))
            {
                return;
            }

            if (image == null)
            {
                CreateImage();
            }
            if (image != null)
            {
                switch (imageFormat)
                {
                case ImageFileFormat.Emf:
                case ImageFileFormat.EmfPlus:
                    if (exportToClipboard)
                    {
                        EmfHelper.PutEnhMetafileOnClipboard(this.Handle, (Metafile)image.Clone());
                    }
                    else
                    {
                        GdiHelpers.SaveImageToFile(image, filePath, imageFormat, compressionQuality);
                    }
                    break;

                case ImageFileFormat.Bmp:
                case ImageFileFormat.Gif:
                case ImageFileFormat.Jpeg:
                case ImageFileFormat.Png:
                case ImageFileFormat.Tiff:
                    if (exportToClipboard)
                    {
                        Clipboard.SetImage((Image)image.Clone());
                    }
                    else
                    {
                        GdiHelpers.SaveImageToFile(image, filePath, imageFormat, compressionQuality);
                    }
                    break;

                case ImageFileFormat.Svg:
                    throw new NotImplementedException();

                default:
                    throw new NShapeUnsupportedValueException(imageFormat);
                }
            }
            filePathChanged = false;
        }
Beispiel #3
0
        private void ExportImage()
        {
            if (image == null)
            {
                CreateImage();
            }
            if (image != null)
            {
                switch (imageFormat)
                {
                case ImageFileFormat.Emf:
                case ImageFileFormat.EmfPlus:
                    if (exportToClipboard)
                    {
                        EmfHelper.PutEnhMetafileOnClipboard(this.Handle, (Metafile)image.Clone());
                    }
                    else
                    {
                        GdiHelpers.SaveImageToFile(image, filePath, imageFormat, compressionQuality);
                    }
                    break;

                case ImageFileFormat.Bmp:
                case ImageFileFormat.Gif:
                case ImageFileFormat.Jpeg:
                case ImageFileFormat.Png:
                case ImageFileFormat.Tiff:
                    if (exportToClipboard)
                    {
                        Clipboard.SetImage((Image)image.Clone());
                    }
                    else
                    {
                        GdiHelpers.SaveImageToFile(image, filePath, imageFormat, compressionQuality);
                    }
                    break;

                case ImageFileFormat.Svg:
                    throw new NotImplementedException();

                default: throw new NShapeUnsupportedValueException(imageFormat);
                }
            }
        }