예제 #1
0
        public GraphDocument(GraphDocument from)
        {
            this._changedEventSuppressor = new EventSuppressor(this.EhChangedEventResumes);
            this._pageBounds             = from._pageBounds;
            this._printableBounds        = from._printableBounds;
            _creationTime = _lastChangeTime = DateTime.UtcNow;
            this._notes   = from._notes;


            // Clone also the table properties (deep copy)
            if (from._graphProperties != null)
            {
                foreach (string key in from._graphProperties.Keys)
                {
                    ICloneable val = from._graphProperties[key] as ICloneable;
                    if (null != val)
                    {
                        this.SetGraphProperty(key, val.Clone());
                    }
                }
            }

            // the order is important here: clone the layers only before setting the printable graph bounds and other
            // properties, otherwise some errors will happen
            this._layers = (XYPlotLayerCollection)from._layers.Clone();
            this._layers.ParentObject = this;
        }
예제 #2
0
            public object Deserialize(object o, Altaxo.Serialization.Xml.IXmlDeserializationInfo info, object parent)
            {
                GraphDocument s = null != o ? (GraphDocument)o : new GraphDocument();

                Deserialize(s, info, parent);
                return(s);
            }
예제 #3
0
 /// <summary>Initializes a new instance of the <see cref="GraphViewLayout"/> class.</summary>
 /// <param name="isAutoZoomActive">If set to <c>true</c> auto zoom is active.</param>
 /// <param name="zoomFactor">The zoom factor.</param>
 /// <param name="graphDocument">The graph document.</param>
 /// <param name="viewPortsUpperLeftInRootLayerCoord">Vector from the upper left corner of the graph to the upper left corner of the view port.</param>
 public GraphViewLayout(bool isAutoZoomActive, double zoomFactor, GraphDocument graphDocument, PointD2D viewPortsUpperLeftInRootLayerCoord)
 {
     _isAutoZoomActive = isAutoZoomActive;
     _zoomFactor       = zoomFactor;
     _positionOfViewportsUpperLeftCornerInRootLayerCoordinates = viewPortsUpperLeftInRootLayerCoord;
     _graphDocument = graphDocument;
 }
예제 #4
0
        /// <summary>
        /// Adds a new render task.
        /// </summary>
        /// <param name="owner">The owner. This is any object that is able to uniquely identify the render task.</param>
        /// <param name="doc">The graph document to render.</param>
        /// <param name="renderingAction">The rendering action. This action is called when the provided graph document should be rendered.</param>
        public void AddTask(object owner, GraphDocument doc, Action <GraphDocument, object> renderingAction)
        {
            var task = new GraphDocumentRenderTask(this, owner, doc, renderingAction);

            _tasksWaiting.TryAddLast(owner, task);
            TryStartWaitingTasks();
        }
예제 #5
0
            public GraphDocumentRenderTask(
                GraphDocumentRenderManager parent,
                object token,
                GraphDocument doc,
                Action <GraphDocument, object> renderingAction
                )
            {
                if (null == parent)
                {
                    throw new ArgumentNullException(nameof(parent));
                }
                if (null == token)
                {
                    throw new ArgumentNullException(nameof(token));
                }
                if (null == doc)
                {
                    throw new ArgumentNullException(nameof(doc));
                }
                if (null == renderingAction)
                {
                    throw new ArgumentNullException(nameof(renderingAction));
                }

                _parent    = parent;
                Owner      = token;
                Document   = doc;
                _rendering = renderingAction;
            }
예제 #6
0
        /// <summary>
        /// Creates a new layer with right y axis, which is linked to the same position with top x axis and right y axis.
        /// </summary>
        public static void CreateNewLayerLinkedRightY(this GraphDocument doc, IEnumerable <int> linklayernumber)
        {
            var context  = doc.GetPropertyHierarchy();
            var newlayer = CreateNewLayerAtSamePosition(doc, linklayernumber);

            newlayer.AxisStyles.CreateDefault(new CSLineID(1, 1), context);
        }
예제 #7
0
        /// <summary>
        /// Prints the document on the currently active printer (no Gui interaction). An exception will be thrown
        /// if something fails during printing.
        /// </summary>
        /// <param name="doc">The graph document to print.</param>
        public static void Print(this GraphDocument doc)
        {
            var       printTask = new GraphDocumentPrintTask(doc);
            Exception ex        = null;

            try
            {
                Current.PrintingService.PrintDocument.PrintPage         += printTask.EhPrintPage;
                Current.PrintingService.PrintDocument.QueryPageSettings += printTask.EhQueryPageSettings;

                //Current.PrintingService.PrintDocument.PrintPage += new System.Drawing.Printing.PrintPageEventHandler(ctrl.EhPrintPage);
                Current.PrintingService.PrintDocument.Print();
            }
            catch (Exception exx)
            {
                ex = exx;
            }
            finally
            {
                Current.PrintingService.PrintDocument.PrintPage         -= printTask.EhPrintPage;
                Current.PrintingService.PrintDocument.QueryPageSettings -= printTask.EhQueryPageSettings;
            }

            if (null != ex)
            {
                throw ex;
            }
        }
예제 #8
0
            public virtual void Serialize(object obj, Altaxo.Serialization.Xml.IXmlSerializationInfo info)
            {
                GraphDocument s = (GraphDocument)obj;

                // info.AddBaseValueEmbedded(s,typeof(GraphDocument).BaseType);
                // now the data of our class
                info.AddValue("Name", s._name);
                info.AddValue("PageBounds", s._pageBounds);
                info.AddValue("PrintableBounds", s._printableBounds);
                info.AddValue("Layers", s._layers);

                // new in version 1 - Add graph properties
                int numberproperties = s._graphProperties == null ? 0 : s._graphProperties.Keys.Count;

                info.CreateArray("TableProperties", numberproperties);
                if (s._graphProperties != null)
                {
                    foreach (string propkey in s._graphProperties.Keys)
                    {
                        if (propkey.StartsWith("tmp/"))
                        {
                            continue;
                        }
                        info.CreateElement("e");
                        info.AddValue("Key", propkey);
                        object val = s._graphProperties[propkey];
                        info.AddValue("Value", info.IsSerializable(val) ? val : null);
                        info.CommitElement();
                    }
                }
                info.CommitArray();
            }
예제 #9
0
 public override void Deserialize(GraphDocument s, Altaxo.Serialization.Xml.IXmlDeserializationInfo info, object parent)
 {
     base.Deserialize(s, info, parent);
     s._graphIdentifier = info.GetString("GraphIdentifier");
     s._notes.Text      = info.GetString("Notes");
     s._creationTime    = info.GetDateTime("CreationTime").ToUniversalTime();
     s._lastChangeTime  = info.GetDateTime("LastChangeTime").ToUniversalTime();
 }
        /// <summary>Creates an instance of this class from a single <see cref="Altaxo.Graph.Gdi.GraphDocument"/>.</summary>
        /// <param name="doc">The graph document.</param>
        /// <returns>An instance of this class. The graph document is analyzed and all underlying tables of the plot items of the graph document are collected.</returns>
        public static ExchangeTablesOfPlotItemsDocument CreateFromGraph(Altaxo.Graph.Gdi.GraphDocument doc)
        {
            var result = new ExchangeTablesOfPlotItemsDocument();

            doc.VisitDocumentReferences(result.CollectDataTableFromProxyVisit);
            result.CollectPlotItemsForGraph(doc);
            return(result);
        }
예제 #11
0
        /// <summary>
        /// Copies the current graph as an bitmap image to the clipboard in native bmp format.
        /// </summary>
        /// <param name="doc">Graph to copy to the clipboard.</param>
        /// <param name="dpiResolution">Resolution of the bitmap in dpi. Determines the pixel size of the bitmap.</param>
        /// <param name="backbrush">Brush used to fill the background of the image. Can be <c>null</c>.</param>
        /// <param name="pixelformat">Specify the pixelformat here.</param>
        public static void CopyToClipboardAsBitmap(this GraphDocument doc, int dpiResolution, BrushX backbrush, PixelFormat pixelformat)
        {
            var dao = Current.Gui.GetNewClipboardDataObject();

            System.Drawing.Bitmap bitmap = GraphDocumentExportActions.RenderAsBitmap(doc, backbrush, pixelformat, dpiResolution, dpiResolution);
            dao.SetImage(bitmap);
            Current.Gui.SetClipboardDataObject(dao);
        }
예제 #12
0
 /// <summary>
 /// Saves the graph as an bitmap file into the file <paramref name="filename"/>.
 /// </summary>
 /// <param name="doc">The graph document to export.</param>
 /// <param name="filename">The filename of the file to save the bitmap into.</param>
 /// <param name="imageFormat">The format of the destination image.</param>
 /// <param name="backbrush">Brush used to fill the background of the image. Can be <c>null</c>.</param>
 /// <param name="pixelformat">Specify the pixelformat here.</param>
 /// <param name="sourceDpiResolution">Resolution in dpi used to render the graph into the bitmap.</param>
 /// <param name="destinationDpiResolution">Resolution that is set in the parameters of the bitmap. This determines the physical size of the bitmap.</param>
 /// <returns>The dimensions of the bitmap in pixels.</returns>
 public static (int pixelX, int pixelY) RenderAsBitmapToFile(this GraphDocument doc, string filename, System.Drawing.Imaging.ImageFormat imageFormat, BrushX backbrush, PixelFormat pixelformat, double sourceDpiResolution, double destinationDpiResolution)
 {
     using (System.IO.Stream str = new System.IO.FileStream(filename, System.IO.FileMode.CreateNew, System.IO.FileAccess.Write, System.IO.FileShare.Read))
     {
         var result = RenderAsBitmapToStream(doc, str, imageFormat, backbrush, pixelformat, sourceDpiResolution, destinationDpiResolution);
         str.Close();
         return(result);
     }
 }
예제 #13
0
 public static (int pixelsX, int pixelsY) RenderToFile(this GraphDocument doc, string filename, GraphExportOptions options)
 {
     using (System.IO.Stream str = new System.IO.FileStream(filename, System.IO.FileMode.CreateNew, System.IO.FileAccess.Write, System.IO.FileShare.Read))
     {
         var result = RenderToStream(doc, str, options);
         str.Close();
         return(result);
     }
 }
예제 #14
0
            public override void Serialize(object obj, Altaxo.Serialization.Xml.IXmlSerializationInfo info)
            {
                base.Serialize(obj, info);
                GraphDocument s = (GraphDocument)obj;

                info.AddValue("GraphIdentifier", s._graphIdentifier);
                info.AddValue("Notes", s._notes);
                info.AddValue("CreationTime", s._creationTime.ToLocalTime());
                info.AddValue("LastChangeTime", s._lastChangeTime.ToLocalTime());
            }
예제 #15
0
        private IGraphController CreateNewGraph_Unsynchronized(Altaxo.Graph.Gdi.GraphDocument graph)
        {
            if (graph == null)
            {
                graph = Altaxo.Graph.Gdi.GraphTemplates.TemplateWithXYPlotLayerWithG2DCartesicCoordinateSystem.CreateGraph(
                    PropertyExtensions.GetPropertyContextOfProjectFolder(ProjectFolder.RootFolderName), null, ProjectFolder.RootFolderName, false);
            }

            return((IGraphController)OpenOrCreateViewContentForDocument_Unsynchronized(graph));
        }
예제 #16
0
 public void Deserialize(GraphDocument s, Altaxo.Serialization.Xml.IXmlDeserializationInfo info, object parent)
 {
     s._name            = info.GetString("Name");
     s._graphIdentifier = info.GetString("GraphIdentifier");
     s._creationTime    = info.GetDateTime("CreationTime").ToUniversalTime();
     s._lastChangeTime  = info.GetDateTime("LastChangeTime").ToUniversalTime();
     s._notes.Text      = info.GetString("Notes");
     s.RootLayer        = (HostLayer)info.GetValue("RootLayer", s);
     s.PropertyBag      = (Main.Properties.PropertyBag)info.GetValue("Properties", s);
 }
예제 #17
0
        /// <summary>
        /// Pastes a layer on the clipboard as new layer after the layer at index <paramref name="currentActiveLayerNumber"/>.
        /// </summary>
        /// <param name="doc">Graph document to paste to.</param>
        /// <param name="currentActiveLayerNumber">Index of the layer after which to paste the layer from the clipboard.</param>
        public static void PasteFromClipboardAsNewLayerAfterLayerNumber(this GraphDocument doc, IEnumerable <int> currentActiveLayerNumber)
        {
            object o     = ClipboardSerialization.GetObjectFromClipboard("Altaxo.Graph.GraphLayerAsXml");
            var    layer = o as XYPlotLayer;

            if (null != layer)
            {
                doc.RootLayer.InsertAfter(currentActiveLayerNumber, layer);
            }
        }
예제 #18
0
        /// <summary>
        /// Try to paste the entire GraphDocument from the clipboard using the specified paste options.
        /// </summary>
        /// <param name="doc">The graph document to paste into.</param>
        /// <param name="options">The options used for paste into that graph.</param>
        public static void PasteFromClipboard(this GraphDocument doc, GraphCopyOptions options)
        {
            object from = ClipboardSerialization.GetObjectFromClipboard("Altaxo.Graph.GraphDocumentAsXml");

            if (from is GraphDocument)
            {
                doc.CopyFrom((GraphDocument)from, options);
                doc.OnUserRescaledAxes();
            }
        }
예제 #19
0
        public static void PasteFromClipboardAsNewLayer(this GraphDocument doc)
        {
            object o     = ClipboardSerialization.GetObjectFromClipboard("Altaxo.Graph.GraphLayerAsXml");
            var    layer = o as XYPlotLayer;

            if (null != layer)
            {
                doc.RootLayer.Layers.Add(layer);
            }
        }
예제 #20
0
        /// <summary>
        /// Pastes a layer on the clipboard as new layer after the layer at index <paramref name="currentActiveLayerNumber"/>.
        /// </summary>
        /// <param name="doc">Graph document to paste to.</param>
        /// <param name="currentActiveLayerNumber">Index of the layer after which to paste the layer from the clipboard.</param>
        public static void PasteFromClipboardAsNewChildLayerOfLayerNumber(this GraphDocument doc, IEnumerable <int> currentActiveLayerNumber)
        {
            object o     = ClipboardSerialization.GetObjectFromClipboard("Altaxo.Graph.GraphLayerAsXml");
            var    layer = o as XYPlotLayer;

            if (null != layer)
            {
                var parentLayer = doc.RootLayer.ElementAt(currentActiveLayerNumber);
                parentLayer.Layers.Insert(0, layer);
            }
        }
예제 #21
0
        /// <summary>
        /// Shows the copy page options dialog and stores the result as the static field <see cref="P:ClipboardRenderingOptions.CopyPageOptions"/> here in this class
        /// </summary>
        /// <param name="doc">Ignored. Can be set to null.</param>
        /// <returns>True when the dialog was successfully closed, false otherwise.</returns>
        public static bool ShowCopyPageOptionsDialog(this GraphDocument doc)
        {
            object resultobj = ClipboardRenderingOptions.CopyPageOptions;

            if (Current.Gui.ShowDialog(ref resultobj, "Set copy page options"))
            {
                ClipboardRenderingOptions.CopyPageOptions = (ClipboardRenderingOptions)resultobj;
                return(true);
            }
            return(false);
        }
예제 #22
0
            public void Serialize(object obj, Altaxo.Serialization.Xml.IXmlSerializationInfo info)
            {
                GraphDocument s = (GraphDocument)obj;

                // info.AddBaseValueEmbedded(s,typeof(GraphDocument).BaseType);
                // now the data of our class
                info.AddValue("Name", s._name);
                info.AddValue("PageBounds", s._pageBounds);
                info.AddValue("PrintableBounds", s._printableBounds);
                info.AddValue("Layers", s._layers);
            }
예제 #23
0
        public static Metafile RenderAsEnhancedMetafileVectorFormat(this GraphDocument doc, GraphExportOptions options, string filename)
        {
            Metafile mf;

            using (System.IO.Stream stream = new System.IO.FileStream(filename, System.IO.FileMode.CreateNew, System.IO.FileAccess.Write, System.IO.FileShare.Read))
            {
                mf = RenderAsEnhancedMetafileVectorFormat(doc, options, stream);
                stream.Close();
            }
            return(mf);
        }
예제 #24
0
        /// <summary>
        /// Saves the graph as an bitmap file into the file <paramref name="filename"/>.
        /// </summary>
        /// <param name="doc">The graph document to export.</param>
        /// <param name="dpiResolution">Resolution of the bitmap in dpi. Determines the pixel size of the bitmap.</param>
        /// <param name="backbrush">Brush used to fill the background of the image. Can be <c>null</c>.</param>
        /// <param name="pixelformat">Specify the pixelformat here.</param>
        /// <param name="filename">The filename of the file to save the bitmap into.</param>
        public static Metafile RenderAsEnhancedMetafileVectorFormat(this GraphDocument doc, double dpiResolution, BrushX backbrush, PixelFormat pixelformat, string filename)
        {
            Metafile mf;

            using (System.IO.Stream str = new System.IO.FileStream(filename, System.IO.FileMode.CreateNew, System.IO.FileAccess.Write, System.IO.FileShare.Read))
            {
                mf = RenderAsEnhancedMetafileVectorFormat(doc, dpiResolution, 1, backbrush, pixelformat, str);
                str.Close();
            }
            return(mf);
        }
예제 #25
0
 /// <summary>
 /// This command will rescale all axes in all layers
 /// </summary>
 public static void OnUserRescaledAxes(this GraphDocument doc)
 {
     doc.RootLayer.ExecuteFromTopmostChildToRoot(
         (layer) =>
     {
         var xylayer = layer as XYPlotLayer;
         if (null != xylayer)
         {
             xylayer.OnUserRescaledAxes();
         }
     });
 }
예제 #26
0
        public static void ShowRenameDialog(this GraphDocument doc)
        {
            var tvctrl = new Altaxo.Gui.Common.TextValueInputController(doc.Name, "Enter a name for the graph:")
            {
                Validator = new GraphRenameValidator(doc)
            };

            if (Current.Gui.ShowDialog(tvctrl, "Rename graph", false))
            {
                doc.Name = tvctrl.InputText.Trim();
            }
        }
예제 #27
0
        /// <summary>
        /// Saves the graph as an bitmap file into the stream <paramref name="stream"/>.
        /// </summary>
        /// <param name="doc">The graph document to export.</param>
        /// <param name="stream">The stream to save the metafile into.</param>
        /// <param name="imageFormat">The format of the destination image.</param>
        /// <param name="backbrush">Brush used to fill the background of the image. Can be <c>null</c>.</param>
        /// <param name="pixelformat">Specify the pixelformat here.</param>
        /// <param name="sourceDpiResolution">Resolution at which the graph is rendered to a bitmap.</param>
        /// <param name="destinationDpiResolution">Resolution of the resulting bitmap. This determines the physical size of the bitmap.</param>
        /// <returns>The dimensions of the bitmap in pixels.</returns>
        public static (int pixelsX, int pixelsY) RenderAsBitmapToStream(this GraphDocument doc, System.IO.Stream stream, System.Drawing.Imaging.ImageFormat imageFormat, BrushX backbrush, PixelFormat pixelformat, double sourceDpiResolution, double destinationDpiResolution)
        {
            System.Drawing.Bitmap bitmap = RenderAsBitmap(doc, backbrush, pixelformat, sourceDpiResolution, destinationDpiResolution);

            bitmap.Save(stream, imageFormat);

            var result = (bitmap.Width, bitmap.Height);

            bitmap.Dispose();

            return(result);
        }
예제 #28
0
		public static void ShowMasterCurveCreationDialog(GraphDocument doc)
		{
			string error;
			Altaxo.Data.MasterCurveCreation.Options opt = new Data.MasterCurveCreation.Options();
			if (null != (error = FillDataListFromGraphDocument(doc, opt.ColumnGroups)))
			{
				Current.Gui.ErrorMessageBox(error);
				return;
			}

			Current.Gui.ShowDialog(ref opt, "Create master curve", false);
		}
예제 #29
0
        public bool InitializeDocument(params object[] args)
        {
            if (args == null || args.Length == 0 || !(args[0] is Altaxo.Graph.Gdi.GraphDocument))
            {
                return(false);
            }

            _doc = (Altaxo.Graph.Gdi.GraphDocument)args[0];

            Initialize(true);

            return(true);
        }
예제 #30
0
        /// <summary>
        /// Shows the dialog to set the print options for this document.
        /// </summary>
        /// <param name="doc">The graph document to set the print options for.</param>
        /// <returns>True if user closed the dialog with OK, false if user cancelled the dialog.</returns>
        public static bool ShowPrintOptionsDialog(this GraphDocument doc)
        {
            var    options   = doc.PrintOptions == null ? new SingleGraphPrintOptions() : (SingleGraphPrintOptions)doc.PrintOptions.Clone();
            object resultobj = options;

            if (Current.Gui.ShowDialog(ref resultobj, "Set print options"))
            {
                var result = (SingleGraphPrintOptions)resultobj;
                doc.PrintOptions = result;
                return(true);
            }
            return(false);
        }
예제 #31
0
		/// <summary>
		/// Tries to extract from the graph document
		/// </summary>
		/// <param name="doc"></param>
		/// <param name="groupList"></param>
		/// <returns></returns>
		private static string FillDataListFromGraphDocument(GraphDocument doc, List<List<DoubleColumn>> groupList)
		{
			if (doc.RootLayer.Layers.Count == 0)
				return "Plot contains no layers and therefore no plot items";

			for (int i = 0; i < doc.RootLayer.Layers.Count; i++)
			{
				var xylayer = doc.RootLayer.Layers[i] as XYPlotLayer;
				if (null != xylayer)
					FillDataListFromLayer(xylayer, groupList);
			}

			return null;
		}
 /// <summary>Collects all plot items for a single <see cref="Altaxo.Graph.Gdi.GraphDocument"/>.</summary>
 /// <param name="doc">The graph document to collect the plot items from..</param>
 private void CollectPlotItemsForGraph(Altaxo.Graph.Gdi.GraphDocument doc)
 {
     foreach (var layer in doc.RootLayer.TakeFromHereToFirstLeaves().OfType <XYPlotLayer>())
     {
         var pis = layer.PlotItems.Flattened;
         foreach (var pi in pis)
         {
             if (!_itemsToChange.Contains(pi))
             {
                 _itemsToChange.Add(pi);
             }
         }
     }
 }
예제 #33
0
		public GraphDocumentLinkedComObject(GraphDocument graphDocument, ProjectFileComObject fileComObject, ComManager comManager)
			: base(comManager)
		{
			ComDebug.ReportInfo("{0} constructor.", this.GetType().Name);

			_dataAdviseHolder = new ManagedDataAdviseHolder();
			_oleAdviseHolder = new ManagedOleAdviseHolderFM();

			Document = graphDocument;

			if (null != fileComObject)
			{
				fileComObject.FileMonikerChanged += EhFileMonikerChanged;
				EhFileMonikerChanged(fileComObject.FileMoniker);
			}
		}
예제 #34
0
      public virtual void Deserialize(GraphDocument s, Altaxo.Serialization.Xml.IXmlDeserializationInfo info, object parent)
      {
        //  info.GetBaseValueEmbedded(s,typeof(GraphDocument).BaseType,parent);
        s._name            =  info.GetString("Name"); 
        s._pageBounds      = (RectangleF)info.GetValue("PageBounds",s);
        s._printableBounds = (RectangleF)info.GetValue("PrintableBounds",s);

        s._layers          = (XYPlotLayerCollection)info.GetValue("LayerList",s);
        s._layers.ParentObject = s;
        s._layers.SetPrintableGraphBounds(s._printableBounds, false);

        // new in version 1 - Add graph properties
        int numberproperties = info.OpenArray(); // "GraphProperties"
        for(int i=0;i<numberproperties;i++)
        {
          info.OpenElement(); // "e"
          string propkey = info.GetString("Key");
          object propval = info.GetValue("Value",parent);
          info.CloseElement(); // "e"
          s.SetGraphProperty(propkey,propval);
        }
        info.CloseArray(numberproperties);
      }
예제 #35
0
		public static void PasteFromClipboardAsTemplateForLayer(GraphDocument doc, IEnumerable<int> layerNumber, GraphCopyOptions options)
		{
			object o = ClipboardSerialization.GetObjectFromClipboard("Altaxo.Graph.GraphLayerAsXml");
			if (null == o)
				return;
			XYPlotLayer layer = o as XYPlotLayer;
			if (null != layer)
			{
				doc.RootLayer.ElementAt(layerNumber).CopyFrom(layer, options);
				doc.OnUserRescaledAxes();
			}
		}
예제 #36
0
		/// <summary>
		/// Renders the graph document as enhanced metafile in vector format.
		/// </summary>
		/// <param name="doc">graph document.</param>
		/// <param name="sourceDpiResolution">The resolution in dpi of the source.</param>
		/// <param name="outputScalingFactor">Output scaling factor. If less than 1, the image will appear smaller than originally, if greater than 1, the image will appear larger than originally.</param>
		/// <param name="backgroundBrush">The background brush. This argument can be null, or the brush can be transparent.</param>
		/// <param name="pixelFormat">Optional: Only used if the graphics context can not be created from a printer document. Pixel format of the bitmap that is used in this case to construct the graphics context.</param>
		/// <param name="stream">Optional: stream. If given, the metafile is rendered into the given stream.</param>
		/// <returns>The rendered enhanced metafile (vector format).</returns>
		public static Metafile RenderAsEnhancedMetafileVectorFormat(GraphDocument doc, double sourceDpiResolution, double outputScalingFactor, BrushX backgroundBrush = null, PixelFormat pixelFormat = PixelFormat.Format32bppArgb, System.IO.Stream stream = null)
		{
			var mystream = null != stream ? stream : new MemoryStream();
			try
			{
				RenderAsEnhancedMetafileVectorFormatToStream(doc, mystream, sourceDpiResolution, outputScalingFactor, backgroundBrush, pixelFormat);
				return new Metafile(mystream);
			}
			finally
			{
				if (null == stream) // only if stream is null, i.e. we had created a new Memorystream
					mystream.Dispose(); // we should dispose this MemoryStream
			}
		}
예제 #37
0
		/// <summary>
		/// Renders the graph document as enhanced metafile in vector format.
		/// </summary>
		/// <param name="doc">graph document.</param>
		/// <param name="stream">The stream the metafile is rendered to.</param>
		/// <param name="sourceDpiResolution">The resolution in dpi of the source.</param>
		/// <param name="outputScalingFactor">Output scaling factor. If less than 1, the image will appear smaller than originally, if greater than 1, the image will appear larger than originally.</param>
		/// <param name="backgroundBrush">The background brush. This argument can be null, or the brush can be transparent.</param>
		/// <param name="pixelFormat">Optional: Only used if the graphics context can not be created from a printer document. Pixel format of the bitmap that is used in this case to construct the graphics context.</param>
		public static void RenderAsEnhancedMetafileVectorFormatToStream(GraphDocument doc, System.IO.Stream stream, double sourceDpiResolution, double outputScalingFactor, BrushX backgroundBrush = null, PixelFormat pixelFormat = PixelFormat.Format32bppArgb)
		{
			var renderingProc = new Action<Graphics>(
					(grfxMetafile) =>
					{
						if (backgroundBrush != null)
						{
							backgroundBrush.SetEnvironment(new RectangleD2D(0, 0, doc.Size.X, doc.Size.Y), sourceDpiResolution);
							grfxMetafile.FillRectangle(backgroundBrush, new RectangleF(0, 0, (float)doc.Size.X, (float)doc.Size.Y));
						}

#if DIAGNOSTICLINERENDERING
				{
					grfxMetafile.DrawLine(Pens.Black, 0, 0, fDocSizeX * 2, fDocSizeY * 1.3f);

					grfxMetafile.DrawLine(Pens.Black, 0, 0, fDocSizeX, fDocSizeY);
					grfxMetafile.DrawLine(Pens.Black, 0, fDocSizeY, fDocSizeX, 0);
					grfxMetafile.DrawLine(Pens.Black, 0, 0, fDocSizeX / 4, fDocSizeY / 2);
					grfxMetafile.DrawLine(Pens.Black, 0, fDocSizeY, fDocSizeX / 4, fDocSizeY / 2);
					grfxMetafile.DrawLine(Pens.Black, fDocSizeX * 0.75f, fDocSizeY / 2, fDocSizeX, 0);
					grfxMetafile.DrawLine(Pens.Black, fDocSizeX * 0.75f, fDocSizeY / 2, fDocSizeX, fDocSizeY);
				}
#endif

						doc.Paint(grfxMetafile, true);
					});

			RenderAsEnhancedMetafileToStream(renderingProc, stream, doc.Size, sourceDpiResolution, outputScalingFactor, pixelFormat);
		}
예제 #38
0
			public GraphRenameValidator(GraphDocument graphdoc)
				: base("The graph's name must not be empty! Please enter a valid name.")
			{
				_doc = graphdoc;
			}
예제 #39
0
 /// <summary>
 /// Creates a GraphController which shows the <see cref="GraphDocument"/> <paramref name="graphdoc"/>.    
 /// </summary>
 /// <param name="graphdoc">The graph which holds the graphical elements.</param>
 public SDGraphViewContent(GraphDocument graphdoc)
   : this(graphdoc,false)
 {
 }
예제 #40
0
 /// <summary>
 /// Creates a GraphController which shows the <see cref="GraphDocument"/> <paramref name="graphdoc"/>.
 /// </summary>
 /// <param name="graphdoc">The graph which holds the graphical elements.</param>
 /// <param name="bDeserializationConstructor">If true, this is a special constructor used only for deserialization, where no graphdoc needs to be supplied.</param>
 protected SDGraphViewContent(GraphDocument graphdoc, bool bDeserializationConstructor)
   : this(new GraphController(graphdoc))
 {
 }
예제 #41
0
    public GraphDocument(GraphDocument from)
    {
      this._changedEventSuppressor = new EventSuppressor(this.EhChangedEventResumes);
      this._pageBounds = from._pageBounds;
      this._printableBounds = from._printableBounds;
      _creationTime = _lastChangeTime = DateTime.UtcNow;
      this._notes = from._notes;


      // Clone also the table properties (deep copy)
      if(from._graphProperties!=null)
      {
        foreach(string key in from._graphProperties.Keys)
        {
          ICloneable val = from._graphProperties[key] as ICloneable;
          if(null!=val)
            this.SetGraphProperty(key,val.Clone());
        }
      }

      // the order is important here: clone the layers only before setting the printable graph bounds and other
      // properties, otherwise some errors will happen
      this._layers = (XYPlotLayerCollection)from._layers.Clone();
      this._layers.ParentObject = this;

    }
예제 #42
0
 /// <summary>
 /// Creates a GraphController which shows the <see cref="GraphDocument"/> <paramref name="graphdoc"/>.
 /// </summary>
 /// <param name="graphdoc">The graph which holds the graphical elements.</param>
 /// <param name="bDeserializationConstructor">If true, this is a special constructor used only for deserialization, where no graphdoc needs to be supplied.</param>
 protected SDGraphController(GraphDocument graphdoc, bool bDeserializationConstructor)
   : base(graphdoc, bDeserializationConstructor)
 {
 }
예제 #43
0
 public GraphRenameValidator(GraphDocument graphdoc, GraphController ctrl)
   : base("The graph's name must not be empty! Please enter a valid name.")
 {
   _doc = graphdoc;
   _controller = ctrl;
 }
예제 #44
0
		/// <summary>
		/// Renders the graph document as bitmap with default PixelFormat.Format32bppArgb.
		/// </summary>
		/// <param name="doc">The graph document used.</param>
		/// <param name="exportOptions">The clipboard export options.</param>
		/// <param name="pixelFormat">The pixel format for the bitmap. Default is PixelFormat.Format32bppArgb.</param>
		/// <returns>The rendered enhanced metafile.</returns>
		public static Bitmap RenderAsBitmap(GraphDocument doc, EmbeddedObjectRenderingOptions exportOptions, PixelFormat pixelFormat = PixelFormat.Format32bppArgb)
		{
			BrushX opaqueGround = null;
			if (!GraphExportOptions.HasPixelFormatAlphaChannel(pixelFormat))
				opaqueGround = new BrushX(exportOptions.BackgroundColorForFormatsWithoutAlphaChannel);

			var result = RenderAsBitmap(doc, opaqueGround, exportOptions.BackgroundBrush, pixelFormat, exportOptions.SourceDpiResolution, exportOptions.SourceDpiResolution / exportOptions.OutputScalingFactor);

			if (null != opaqueGround)
				opaqueGround.Dispose();

			return result;
		}
예제 #45
0
    /// <summary>
    /// Creates a GraphController which shows the <see cref="GraphDocument"/> <paramref name="graphdoc"/>.
    /// </summary>
    /// <param name="graphdoc">The graph which holds the graphical elements.</param>
    /// <param name="bDeserializationConstructor">If true, this is a special constructor used only for deserialization, where no graphdoc needs to be supplied.</param>
    public GraphController(GraphDocument graphdoc, bool bDeserializationConstructor)
    {
      SetMemberVariablesToDefault();
    
      if(null!=graphdoc)
        this.Doc = graphdoc;
      else if(null==graphdoc && !bDeserializationConstructor)
        throw new ArgumentNullException("graphdoc","GraphDoc must not be null");

      this.InitializeMenu();

      if(null!=Doc && 0==Doc.Layers.Count)
        Doc.CreateNewLayerNormalBottomXLeftY();
    }
예제 #46
0
 /// <summary>
 /// Duplicates the Graph and the Graph view to a new one.
 /// </summary>
 /// <param name="sender">Not used.</param>
 /// <param name="e">Not used.</param>
 private void EhMenuGraphDuplicate_OnClick(object sender, System.EventArgs e)
 {
   GraphDocument newDoc = new GraphDocument(this.Doc);
   Current.ProjectService.CreateNewGraph(newDoc);
 }
예제 #47
0
		public override void Run(GraphController ctrl)
		{
			GraphDocument newDoc = new GraphDocument(ctrl.Doc);
			string newnamebase = Altaxo.Main.ProjectFolder.CreateFullName(ctrl.Doc.Name, "GRAPH");
			newDoc.Name = Current.Project.GraphDocumentCollection.FindNewName(newnamebase);
			Current.Project.GraphDocumentCollection.Add(newDoc);
			Current.ProjectService.CreateNewGraph(newDoc);
		}
예제 #48
0
		public GraphDocumentPrintTask(GraphDocument doc)
			: this(doc.RootLayer, doc.PrintOptions)
		{
		}
예제 #49
0
		/// <summary>
		/// Creates a GraphController which shows the <see cref="GraphDocument"/> <paramref name="graphdoc"/>.
		/// </summary>
		/// <param name="graphdoc">The graph which holds the graphical elements.</param>
		/// <param name="bDeserializationConstructor">If true, this is a special constructor used only for deserialization, where no graphdoc needs to be supplied.</param>
		protected SDGraphViewContent(GraphDocument graphdoc, bool bDeserializationConstructor)
			: this(new Altaxo.Gui.Graph.Gdi.Viewing.GraphControllerWpf(graphdoc))
		{
		}
예제 #50
0
파일: ComManager.cs 프로젝트: Altaxo/Altaxo
		public GraphDocumentLinkedComObject GetDocumentsComObjectForGraphDocument(GraphDocument doc)
		{
			if (null == doc)
				throw new ArgumentNullException();

			ComDebug.ReportInfo("{0}.GetDocumentsComObjectForGraphDocument Name={1}", this.GetType().Name, doc.Name);

			if (null != doc && _linkedDocumentsComObjects.ContainsKey(doc))
				return _linkedDocumentsComObjects[doc];

			// else we must create a new DocumentComObject
			var newComObject = new GraphDocumentLinkedComObject(doc, _fileComObject, this);
			_linkedDocumentsComObjects.Add(doc, newComObject);
			return newComObject;
		}
예제 #51
0
 /// <summary>
 /// Creates a GraphController which shows the <see cref="GraphDocument"/> <paramref name="graphdoc"/>.    
 /// </summary>
 /// <param name="graphdoc">The graph which holds the graphical elements.</param>
 public SDGraphController(GraphDocument graphdoc)
   : this(graphdoc,false)
 {
 }
예제 #52
0
 public override void Deserialize(GraphDocument s, Altaxo.Serialization.Xml.IXmlDeserializationInfo info, object parent)
 {
   base.Deserialize(s, info, parent);
   s._graphIdentifier = info.GetString("GraphIdentifier");
   s._notes = info.GetString("Notes");
   s._creationTime = info.GetDateTime("CreationTime").ToUniversalTime();
   s._lastChangeTime = info.GetDateTime("LastChangeTime").ToUniversalTime();
 }
예제 #53
0
		/// <summary>
		/// Renders the graph document as enhanced metafile image in vector format with the options given in <paramref name="exportOptions"/>
		/// </summary>
		/// <param name="doc">The graph document used.</param>
		/// <param name="exportOptions">The clipboard export options.</param>
		/// <param name="stream">Optional: if given, the metafile is additionally rendered into the stream.</param>
		/// <returns>The rendered enhanced metafile.</returns>
		public static Metafile RenderAsEnhancedMetafileVectorFormat(GraphDocument doc, EmbeddedObjectRenderingOptions exportOptions, System.IO.Stream stream = null)
		{
			return RenderAsEnhancedMetafileVectorFormat(doc, exportOptions.SourceDpiResolution, exportOptions.OutputScalingFactor, exportOptions.BackgroundBrush, PixelFormat.Format32bppArgb, stream);
		}
예제 #54
0
 public override void Run(Altaxo.Graph.GUI.GraphController ctrl)
 {
   GraphDocument newDoc = new GraphDocument(ctrl.Doc);
   Current.Project.GraphDocumentCollection.Add(newDoc);
   Current.ProjectService.CreateNewGraph(newDoc);
 }
예제 #55
0
		/// <summary>
		/// Creates a GraphController which shows the <see cref="GraphDocument"/> <paramref name="graphdoc"/>.
		/// </summary>
		/// <param name="graphdoc">The graph which holds the graphical elements.</param>
		public GraphControllerWpf(GraphDocument graphdoc)
			: base(graphdoc)
		{
			SetMemberVariablesToDefault();
		}