public void CopyFrom(XYPlotLayer from)
    {
      using (IDisposable updateLock = BeginUpdate())
      {
        // XYPlotLayer style
        //this.LayerBackground = from._layerBackground == null ? null : (LayerBackground)from._layerBackground.Clone();

        // size, position, rotation and scale
        this.Location = from._location.Clone();
        this._cachedLayerSize = from._cachedLayerSize;
        this._cachedLayerPosition = from._cachedLayerPosition;
        this._cachedPrintableGraphBounds = from._cachedPrintableGraphBounds;

        this.CoordinateSystem = (G2DCoordinateSystem)from.CoordinateSystem.Clone();


        // axis related

        this.LinkedScales = (LinkedScaleCollection)from._linkedScales.Clone();

        this._dataClipping = from._dataClipping;

        this.GridPlanes = from._gridPlanes.Clone();

        // Styles

        this.AxisStyles = (AxisStyleCollection)from._axisStyles.Clone();

        this.Legends = from._legends == null ? new GraphicCollection() : new GraphicCollection(from._legends);

        // XYPlotLayer specific
        this.LinkedLayerLink = from._linkedLayer.ClonePathOnly(this);

        this.GraphObjects = null == from._graphObjects ? null : new GraphicCollection(from._graphObjects);

        this.PlotItems = null == from._plotItems ? null : new PlotItemCollection(this, from._plotItems);


        _cachedForwardMatrix = new Matrix();
        _cachedReverseMatrix = new Matrix();
        CalculateMatrix();

        OnChanged(); // make sure that the change event is called
      }

      this._parent = from._parent; // outside the update, because clone operations should not cause an update of the old parent

    }
Exemple #2
0
		/// <summary>
		/// Internal copy from operation. It is presumed, that the events are already suspended. Additionally,
		/// it is not neccessary to call the OnChanged event, since this is called in the calling routine.
		/// </summary>
		/// <param name="obj">The object (layer) from which to copy.</param>
		/// <param name="options">Copy options.</param>
		protected override void InternalCopyFrom(HostLayer obj, Gdi.GraphCopyOptions options)
		{
			base.InternalCopyFrom(obj, options); // base copy, but keep in mind that InternalCopyGraphItems is overridden in this class

			var from = obj as XYZPlotLayer;
			if (null == from)
				return;

			if (0 != (options & Gdi.GraphCopyOptions.CopyLayerScales))
			{
				this.CoordinateSystem = from.CoordinateSystem; // immutable

				this.Scales = (ScaleCollection)from._scales.Clone();
				this._dataClipping = from._dataClipping;
			}

			if (0 != (options & Gdi.GraphCopyOptions.CopyLayerGrid))
			{
				this.GridPlanes = from._gridPlanes.Clone();
			}

			// Styles

			if (0 != (options & Gdi.GraphCopyOptions.CopyLayerAxes))
			{
				this.AxisStyles = (AxisStyleCollection)from._axisStyles.Clone();
			}

			// Plot items
			if (0 != (options & Gdi.GraphCopyOptions.CopyLayerPlotItems))
			{
				this.PlotItems = null == from._plotItems ? null : new PlotItemCollection(this, from._plotItems, true);
			}
			else if (0 != (options & Gdi.GraphCopyOptions.CopyLayerPlotStyles))
			{
				// TODO apply the styles from from._plotItems to the PlotItems here
				this.PlotItems.CopyFrom(from._plotItems, options);
			}
		}