/// <summary> /// Creates a new layer with bottom x axis and left y axis, which is not linked. /// </summary> public void CreateNewLayerNormalBottomXLeftY() { XYPlotLayer newlayer = new XYPlotLayer(DefaultLayerPosition, DefaultLayerSize); newlayer.CreateDefaultAxes(); Layers.Add(newlayer); }
/// <summary> /// Creates a new layer with bottom x axis and left y axis, which is not linked. /// </summary> public static void CreateNewLayerNormalBottomXLeftY(this GraphDocument doc) { var context = doc.GetPropertyHierarchy(); var location = new ItemLocationDirect { PositionX = RADouble.NewRel(HostLayer.DefaultChildLayerRelativePosition.X), PositionY = RADouble.NewRel(HostLayer.DefaultChildLayerRelativePosition.Y), SizeX = RADouble.NewRel(HostLayer.DefaultChildLayerRelativeSize.X), SizeY = RADouble.NewRel(HostLayer.DefaultChildLayerRelativeSize.Y) }; var newlayer = new XYPlotLayer(doc.RootLayer, location); doc.RootLayer.Layers.Add(newlayer); newlayer.CreateDefaultAxes(context); }
/// <summary> /// Creates a new layer with bottom x axis and left y axis, which is not linked. /// </summary> public void CreateNewLayerNormalBottomXLeftY() { XYPlotLayer newlayer= new XYPlotLayer(DefaultLayerPosition,DefaultLayerSize); newlayer.CreateDefaultAxes(); Layers.Add(newlayer); }
/// <summary> /// Arranges the layers according to the provided options. /// </summary> /// <param name="activeLayer">Layer, whose siblings are about to be arranged. (Exception: If the root layer is the active layer, then the childs of the root layer will be arranged.</param> /// <param name="arrangement">The layer arrangement options (contain the information how to arrange the layers).</param> public static void ArrangeLayers(this HostLayer activeLayer, ArrangeLayersDocument arrangement) { var context = activeLayer.GetPropertyContext(); var parentLayer = activeLayer.ParentLayer ?? activeLayer; int numPresentLayers = parentLayer.Layers.Count; int numDestLayers = arrangement.NumberOfColumns * arrangement.NumberOfRows; int additionalLayers = Math.Max(0, numDestLayers - numPresentLayers); if (null == parentLayer.Grid) { parentLayer.CreateDefaultGrid(); } ArrangeGrid(arrangement, parentLayer.Grid); int nLayer = -1; for (int i = 0; i < arrangement.NumberOfRows; ++i) { for (int j = 0; j < arrangement.NumberOfColumns; ++j) { nLayer++; if (nLayer >= numPresentLayers) { var graph = Altaxo.Graph.Gdi.GraphTemplates.TemplateWithXYPlotLayerWithG2DCartesicCoordinateSystem.CreateGraph(context, Guid.NewGuid().ToString(), "", false); if (graph != null && graph.RootLayer.Layers.Count > 0) { var newLayer = (HostLayer)graph.RootLayer.Layers[0].Clone(); parentLayer.Layers.Add(newLayer); } else { var newLayer = new XYPlotLayer(parentLayer); newLayer.CreateDefaultAxes(context); parentLayer.Layers.Add(newLayer); } } var oldSize = parentLayer.Layers[nLayer].Size; parentLayer.Layers[nLayer].Location = new ItemLocationByGrid { GridColumn = 2 * j + 1, GridRow = 2 * i + 1, GridColumnSpan = 1, GridRowSpan = 1 }; var newSize = parentLayer.Layers[nLayer].Size; } } // act now on superfluous layers if (numPresentLayers > numDestLayers) { switch (arrangement.SuperfluousLayersAction) { case SuperfluousLayersAction.Remove: for (int i = numPresentLayers - 1; i >= numDestLayers; i--) { parentLayer.Layers.RemoveAt(i); } break; case SuperfluousLayersAction.OverlayFirstLayer: case SuperfluousLayersAction.OverlayLastLayer: int template = arrangement.SuperfluousLayersAction == SuperfluousLayersAction.OverlayFirstLayer ? 0 : numDestLayers - 1; var templateLayer = parentLayer.Layers[template]; for (int i = numDestLayers; i < numPresentLayers; i++) { var oldSize = parentLayer.Layers[i].Size; parentLayer.Layers[i].Location = (IItemLocation)templateLayer.Location.Clone(); var newSize = parentLayer.Layers[i].Size; } break; } } }
/// <summary> /// Arranges the layers according to the provided options. /// </summary> /// <param name="activeLayer">Layer, whose siblings are about to be arranged. (Exception: If the root layer is the active layer, then the childs of the root layer will be arranged.</param> /// <param name="arrangement">The layer arrangement options (contain the information how to arrange the layers).</param> public static void ArrangeLayers(this HostLayer activeLayer, ArrangeLayersDocument arrangement) { var context = activeLayer.GetPropertyContext(); var parentLayer = activeLayer.ParentLayer ?? activeLayer; int numPresentLayers = parentLayer.Layers.Count; int numDestLayers = arrangement.NumberOfColumns * arrangement.NumberOfRows; int additionalLayers = Math.Max(0, numDestLayers - numPresentLayers); if (null == parentLayer.Grid) parentLayer.CreateDefaultGrid(); ArrangeGrid(arrangement, parentLayer.Grid); int nLayer = -1; for (int i = 0; i < arrangement.NumberOfRows; ++i) { for (int j = 0; j < arrangement.NumberOfColumns; ++j) { nLayer++; if (nLayer >= numPresentLayers) { var graph = Altaxo.Graph.Gdi.GraphTemplates.TemplateWithXYPlotLayerWithG2DCartesicCoordinateSystem.CreateGraph(context, Guid.NewGuid().ToString(), "", false); if (graph != null && graph.RootLayer.Layers.Count > 0) { var newLayer = (HostLayer)graph.RootLayer.Layers[0].Clone(); parentLayer.Layers.Add(newLayer); } else { var newLayer = new XYPlotLayer(parentLayer); newLayer.CreateDefaultAxes(context); parentLayer.Layers.Add(newLayer); } } var oldSize = parentLayer.Layers[nLayer].Size; parentLayer.Layers[nLayer].Location = new ItemLocationByGrid { GridColumn = 2 * j + 1, GridRow = 2 * i + 1, GridColumnSpan = 1, GridRowSpan = 1 }; var newSize = parentLayer.Layers[nLayer].Size; } } // act now on superfluous layers if (numPresentLayers > numDestLayers) { switch (arrangement.SuperfluousLayersAction) { case SuperfluousLayersAction.Remove: for (int i = numPresentLayers - 1; i >= numDestLayers; i--) parentLayer.Layers.RemoveAt(i); break; case SuperfluousLayersAction.OverlayFirstLayer: case SuperfluousLayersAction.OverlayLastLayer: int template = arrangement.SuperfluousLayersAction == SuperfluousLayersAction.OverlayFirstLayer ? 0 : numDestLayers - 1; var templateLayer = parentLayer.Layers[template]; for (int i = numDestLayers; i < numPresentLayers; i++) { var oldSize = parentLayer.Layers[i].Size; parentLayer.Layers[i].Location = (IItemLocation)templateLayer.Location.Clone(); var newSize = parentLayer.Layers[i].Size; } break; } } }