示例#1
0
        private void EnsureDropFileCreated()
        {
            var fileExtension = GraphExportOptions.GetDefaultFileNameExtension(_graphExportOptions.DropFileImageFormat);

            _graphDocumentDropdownFileName = System.IO.Path.Combine(System.IO.Path.GetTempPath(), "AltaxoClipboardImage" + fileExtension);
            if (System.IO.File.Exists(_graphDocumentDropdownFileName))
            {
                try
                {
                    System.IO.File.Delete(_graphDocumentDropdownFileName);
                }
                catch (Exception)
                {
                    _graphDocumentDropdownFileName = null;
                    return;
                }
            }

            if (_graphExportOptions.DropFileImageFormat == System.Drawing.Imaging.ImageFormat.Emf)
            {
                if (!(null != _graphDocumentMetafileImage))
                {
                    throw new InvalidOperationException(nameof(_graphDocumentMetafileImage) + " should be != null");
                }

                var clonedMF = (System.Drawing.Imaging.Metafile)_graphDocumentMetafileImage.Clone(); // have to clone metafile because after calling GetHenhmetafile() metafile would be destroyed
                DataObjectHelper.SaveMetafileToDisk(clonedMF.GetHenhmetafile(), _graphDocumentDropdownFileName);
            }
            else if (_graphExportOptions.DropFileImageFormat == System.Drawing.Imaging.ImageFormat.Wmf)
            {
                using (var rgbBitmap = GraphDocumentExportActions.ConvertBitmapToPixelFormat(_graphDocumentBitmapImage, System.Drawing.Imaging.PixelFormat.Format24bppRgb, _graphExportOptions.BackgroundColorForFormatsWithoutAlphaChannel))
                {
                    var scaledDocSize = _graphDocumentSize * _graphExportOptions.OutputScalingFactor;
                    using (var enhancedMetafile = GraphDocumentExportActions.RenderAsEnhancedMetafileBitmapFormat(rgbBitmap, scaledDocSize))
                    {
                        var hEmf  = enhancedMetafile.GetHenhmetafile();
                        var bytes = DataObjectHelper.ConvertEnhancedMetafileToWindowsMetafileBytes(hEmf);
                        var placeableHeaderBytes = DataObjectHelper.GetWmfPlaceableHeaderBytes(scaledDocSize);

                        using (var stream = new System.IO.FileStream(_graphDocumentDropdownFileName, System.IO.FileMode.Create, System.IO.FileAccess.Write, System.IO.FileShare.Read))
                        {
                            stream.Write(placeableHeaderBytes, 0, placeableHeaderBytes.Length);
                            stream.Write(bytes, 0, bytes.Length);
                        }
                    }
                }
            }
            else // bitmap format
            {
                var bitmapToSave =
                    _graphExportOptions.DropFileBitmapPixelFormat == _graphDocumentBitmapImage.PixelFormat ?
                    _graphDocumentBitmapImage :
                    GraphDocumentExportActions.ConvertBitmapToPixelFormat(_graphDocumentBitmapImage, _graphExportOptions.DropFileBitmapPixelFormat, _graphExportOptions.BackgroundColorForFormatsWithoutAlphaChannel);

                bitmapToSave.Save(_graphDocumentDropdownFileName, _graphExportOptions.DropFileImageFormat);
            }
        }
        private static string InternalAddClipboardDropDownList(Altaxo.Gui.IClipboardSetDataObject dao, System.Drawing.Bitmap bmp, GraphExportOptions options)
        {
            string filepath = System.IO.Path.GetTempPath();
            string filename = filepath + "AltaxoGraphCopyPage" + options.GetDefaultFileNameExtension();

            ;
            if (System.IO.File.Exists(filename))
            {
                System.IO.File.Delete(filename);
            }

            bmp.Save(filename, options.ImageFormat);

            var coll = new System.Collections.Specialized.StringCollection
            {
                filename
            };

            dao.SetFileDropList(coll);

            return(filename);
        }
示例#3
0
        /// <summary>Shows the multi file export dialog and exports the graphs, using the <see cref="GraphExportOptions"/> that are stored in this class.</summary>
        /// <param name="documents">List with graph documents to export.</param>
        public static void ShowExportMultipleGraphsDialog(IEnumerable <Graph.GraphDocumentBase> documents)
        {
            var mrData = new MultiRenameData();

            MultiRenameDocuments.RegisterCommonDocumentShortcuts(mrData);
            mrData.RegisterStringShortcut("E", (o, i) => _graphExportOptionsToFile.GetDefaultFileNameExtension(), "File extension (depends on the image type that was chosen before");

            mrData.RegisterRenameActionHandler(DoExportGraphs);

            mrData.AddObjectsToRename(documents);

            mrData.RegisterListColumn("FullName", MultiRenameDocuments.GetFullName);
            mrData.RegisterListColumn("File name", null);
            mrData.RegisterListColumn("Creation date", MultiRenameDocuments.GetCreationDateString);

            mrData.DefaultPatternString = "[SN][E]";

            var mrController = new MultiRenameController();

            mrController.InitializeDocument(mrData);
            Current.Gui.ShowDialog(mrController, "Export multiple graphs");
        }
		private static string InternalAddClipboardDropDownList(Altaxo.Gui.IClipboardSetDataObject dao, System.Drawing.Bitmap bmp, GraphExportOptions options)
		{
			string filepath = System.IO.Path.GetTempPath();
			string filename = filepath + "AltaxoGraphCopyPage" + options.GetDefaultFileNameExtension(); ;
			if (System.IO.File.Exists(filename))
				System.IO.File.Delete(filename);

			bmp.Save(filename, options.ImageFormat);

			System.Collections.Specialized.StringCollection coll = new System.Collections.Specialized.StringCollection();
			coll.Add(filename);
			dao.SetFileDropList(coll);

			return filename;
		}