/// <summary>
 /// Set the attributes of the nodes in the graph
 /// </summary>
 /// <param name="attribute">Attribute to be set on all nodes in the graph</param>
 public static void SetNodeAttribute(this Graph graph, NodeAttr attribute)
 {
     foreach (var node in graph.Nodes)
     {
         node.Attr = attribute.Clone();
     }
 }
Exemplo n.º 2
0
        void graphViewer_MouseDown(object sender, MsaglMouseEventArgs evt)
        {
            if (_currentCmd == "add node")
            {
                var    gv = _graphViewer;
                string id = null;
                do
                {
                    id = (++_nodeIdCounter).ToString();
                } while (gv.Graph.FindNode(id) != null);
                var n = gv.Graph.AddNode(id);
                n.Attr    = _defaultNodeAttr.Clone();
                n.Attr.Id = id;
                GVH.addVnodeByDnode(gv, n, gv.ScreenToSource(evt));

                _mouseEventHandled = true;
            }
            else if (_currentCmd == "node editing")
            {
                exitNodeEditor();
                _currentCmd = "select";
            }
            else if (_currentCmd == "apply attr")
            {
                var obj = _graphViewer.ObjectUnderMouseCursor;
                if (obj == null)
                {
                    return;
                }
                var vedge = obj as VEdge;
                if (vedge != null)
                {
                    var att = vedge.Edge.Attr;
                    if (edge_defApplyAttrPanel != null)
                    {
                        EdgeAttrApplyEditor e = edge_defApplyAttrPanel.Content as EdgeAttrApplyEditor;
                        if (e.TarArrowStyleCmb.IsEnabled)
                        {
                            att.ArrowheadAtTarget = (ArrowStyle)e.TarArrowStyleCmb.SelectedValue;
                        }
                        if (e.SrcArrowStyleCmb.IsEnabled)
                        {
                            att.ArrowheadAtSource = (ArrowStyle)e.SrcArrowStyleCmb.SelectedValue;
                        }
                        if (e.LineStyleCmb.IsEnabled)
                        {
                            att.FirstStyle = (DStyle)e.LineStyleCmb.SelectedValue;
                        }
                        if (e.DecorateSymbolCmb.IsEnabled)
                        {
                            att.DefinedDrawDelegateName = (string)e.DecorateSymbolCmb.SelectedValue;
                        }
                    }
                }
            }
        }