private async Task DrawLayersGeneral(Graphics graph, Func <ILayerDrawing, ICanvas, Task> drawLayerAction) { var layersDrawingSize = this.ControlCanvas.GetLayersDrawingSize(); var graphCanvas = new GraphicsCanvas(graph, this.ControlCanvas.Size.Width, this.ControlCanvas.Size.Height); int x = 0; _selectionResolver.SetCurrentRootCanvas(graphCanvas); IDictionary <NodeBase, INodeDrawing> previousNodesDic = new Dictionary <NodeBase, INodeDrawing>(); var inputLayer = this.ControlCanvas.Control.InputLayer; var preferences = this.ControlCanvas.Control.Preferences; LayerSizesPreCalc layersCache = new LayerSizesPreCalc(layersDrawingSize, inputLayer.GetMaxNodeCountInLayer(), preferences); SimpleNodeSizesPreCalc simpleNodesCache = new SimpleNodeSizesPreCalc(); PerceptronSizesPreCalc perceptronCache = new PerceptronSizesPreCalc(preferences); EdgeSizesPreCalc edgesCache = new EdgeSizesPreCalc(); for (LayerBase layer = inputLayer; layer != null; layer = layer.Next) { ILayerDrawing layerDrawing = null; if (layer == inputLayer) { layerDrawing = new InputLayerDrawing(layer as InputLayer, preferences, layersCache, simpleNodesCache, _selectionChecker, _selectableElementRegister); } else { layerDrawing = new PerceptronLayerDrawing(layer as PerceptronLayer, previousNodesDic, graphCanvas, preferences, layersCache, perceptronCache, simpleNodesCache, edgesCache, _selectionChecker, _selectableElementRegister); } var canvasRect = new Rectangle(x, 0, layersDrawingSize.Width, layersDrawingSize.Height); var layerCanvas = new NestedCanvas(canvasRect, graphCanvas); await drawLayerAction(layerDrawing, layerCanvas); previousNodesDic = layerDrawing.NodesDrawing.ToDictionary(n => n.Node, n => n); x += layersDrawingSize.Width; } }
private void DrawNode(INodeDrawing nodeDrawing, ICanvas parentCanvas, int y) { var newCanvas = new NestedCanvas(new Rectangle(_preferences.NodeMargins, y, _cache.NodeWidth, _cache.NodeEllipseHeight), parentCanvas); nodeDrawing.Draw(newCanvas); }