示例#1
0
        internal static void Launch(IDesktopWindow desktopWindow, List <IClipboardItem> clipboardItems)
        {
            Platform.CheckForNullReference(desktopWindow, "desktopWindow");
            Platform.CheckForNullReference(clipboardItems, "clipboardItems");

            if (_multipleImageExporter != null)
            {
                desktopWindow.ShowMessageBox(SR.MessageImageExportStillRunning, MessageBoxActions.Ok);
                return;
            }

            int numberOfImagesToExport = GetNumberOfImagesToExport(clipboardItems);

            Platform.CheckPositive(numberOfImagesToExport, "numberOfImagesToExport");

            string title = SR.TitleExportImages;

            if (numberOfImagesToExport == 1)
            {
                title = SR.TitleExportSingleImage;
            }

            //initialize the component.
            ImageExportComponent component = new ImageExportComponent();

            component.ItemsToExport          = clipboardItems;
            component.NumberOfImagesToExport = numberOfImagesToExport;

            // give the width and height values from the first image to be exported
            if (clipboardItems.Count > 0)
            {
                object item = clipboardItems[0].Item;
                if (item is IImageGraphicProvider)
                {
                    IImageGraphicProvider imageGraphicProvider = (IImageGraphicProvider)item;
                    component.Height = imageGraphicProvider.ImageGraphic.Rows;
                    component.Width  = imageGraphicProvider.ImageGraphic.Columns;
                }
                else if (item is IDisplaySet)
                {
                    foreach (IPresentationImage image in ((IDisplaySet)item).PresentationImages)
                    {
                        if (image is IImageGraphicProvider)
                        {
                            IImageGraphicProvider imageGraphicProvider = (IImageGraphicProvider)image;
                            component.Height = imageGraphicProvider.ImageGraphic.Rows;
                            component.Width  = imageGraphicProvider.ImageGraphic.Columns;
                            break;
                        }
                    }
                }
            }

            if (ApplicationComponentExitCode.Accepted != LaunchAsDialog(desktopWindow, component, title))
            {
                return;
            }

            component.Export();
        }
示例#2
0
            public MultipleImageExporter(ImageExportComponent exportComponent)
            {
                _exportComponent = exportComponent;

                _fileNamingStrategy = new MultipleImageExportFileNamingStrategy(_exportComponent.ExportFilePath);
                _imagesToDispose    = new List <IPresentationImage>();
            }
示例#3
0
 public void Export()
 {
     try
     {
         List <IClipboardItem> selectedClipboardItems = new List <IClipboardItem>(this.Context.SelectedClipboardItems);
         ImageExportComponent.Launch(this.Context.DesktopWindow, selectedClipboardItems);
     }
     catch (Exception e)
     {
         ExceptionHandler.Report(e, SR.MessageExportFailed, Context.DesktopWindow);
     }
 }