private void SetGraph(GraphEmbedding graphEmbedding) { PauseButton_Click(null, null); this.RunAlgorithmButton.IsEnabled = true; this.StaticGraphCanvas.Children.Clear(); this.GraphVisual = GraphVisual.Create(StaticGraphCanvas, NodeBrush, NumBrush, LineBrush, PenLineCap); foreach (var node in graphEmbedding.Graph.Nodes) { GraphVisual.AddNode(node, graphEmbedding.Embedding[node]); } foreach (var edge in graphEmbedding.Graph.Edges) { GraphVisual.AddEdge(edge); } var scaleViewStackPanel = new StackPanel(); this.ScaleViewViewer.Content = scaleViewStackPanel; WeightsHandler.Create(scaleViewStackPanel, NodeBrush, LineBrush, GraphVisual.NodeWidth, GraphVisual.MinLineThickness, GraphVisual.MaxLineThickness, GraphVisual.MinWeight, GraphVisual.MaxWeight); var edges = EdgesHandler.Create(this.WeightsViewer); foreach (var edge in graphEmbedding.Graph.Edges) { edges.AddEdge(edge, active: false); } }
public GraphCreatorWindow(Action <string> graphPathChosen, Brush nodeBrush, Brush numBrush, Brush lineBrush, PenLineCap penLineCap) { InitializeComponent(); this.MinWidth = this.MaxWidth = this.Width; this.MinHeight = this.MaxHeight = this.Height; GraphPathChosen = graphPathChosen; this.GraphVisual = GraphVisual.Create(GraphCanvas, nodeBrush, numBrush, lineBrush, penLineCap); this.EdgeHandler = EdgesHandler.Create(EdgesScrollViewer, GraphVisual.UpdateWeight, _ => GraphUpdated()); GraphVisual.EdgeAddedEvent += (sender, args) => EdgeHandler.AddEdge(args.AddedEdge); GraphVisual.EdgeRemovedEvent += (sender, args) => EdgeHandler.RemoveEdge(args.RemovedEdge); GraphVisual.EdgeAddedEvent += (sender, args) => this.GraphUpdated(); GraphVisual.EdgeRemovedEvent += (sender, args) => this.GraphUpdated(); GraphVisual.NodeAmountChangedEvent += (sender, args) => this.GraphUpdated(); this.StateController = new IdleState(GraphVisual); this.WeightsHandler = WeightsHandler.Create(this.ThicknessDictionaryStackPanel, nodeBrush, lineBrush, GraphVisual.NodeWidth, GraphVisual.MinLineThickness, GraphVisual.MaxLineThickness, 0.0, 2.0); }