当前位置: 首页>>代码示例>>C#>>正文


C# Drawing.Node类代码示例

本文整理汇总了C#中Microsoft.Msagl.Drawing.Node的典型用法代码示例。如果您正苦于以下问题:C# Node类的具体用法?C# Node怎么用?C# Node使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Node类属于Microsoft.Msagl.Drawing命名空间,在下文中一共展示了Node类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Bfs

        List<Edge> Bfs(Node root, Node target)
        {
            ((NodeData)(root.UserData)).TraverseParent = null;
            ((NodeData)(target.UserData)).TraverseParent = null;

            var queue = new Queue<Node>();
            var discovered = new HashSet<Node>();
            queue.Enqueue(root);

            while (queue.Count > 0)
            {
                Node current = queue.Dequeue();
                discovered.Add(current);

                if (current.Id == target.Id)
                    return GetPath(current);

                var nodeEdges = current.OutEdges;
                foreach (var edge in nodeEdges)
                {
                    var next = edge.TargetNode;
                    var c = ((EdgeData)(edge.UserData)).currFlow;
                    if (c > 0 && !discovered.Contains(next))
                    {
                        ((NodeData)(next.UserData)).TraverseParent = current;
                        queue.Enqueue(next);
                    }
                }
            }
            return null;
        }
开发者ID:danielskowronski,项目名称:network-max-flow-demo,代码行数:31,代码来源:Algorithm.cs

示例2: MakeNodePrivate

 protected void MakeNodePrivate(Node node)
 {
     node.Attr.Shape = Shape.Box;
     node.Attr.LabelMargin = 3;
     node.Attr.FillColor = GameMasterNode.kPurple;
     node.Label.FontSize = 6;
 }
开发者ID:stonehearth,项目名称:stonehearth-editor,代码行数:7,代码来源:NodeData.cs

示例3: CreateDrawingGraph

 public static Graph CreateDrawingGraph(GeometryGraph gg)
 {
     counter = 0;
     localMap = new Dictionary<GeometryNode,Node>();
     dg = new Graph(counter++.ToString()) { GeometryGraph = gg };
     foreach (GeometryNode n in gg.Nodes)
     {
         Node node = new Node(counter++.ToString());
         node.Attr.Shape = Shape.Ellipse;
         node.GeometryNode = n;
         dg.AddNode(node);
         localMap[n]=node;
     }
     Subgraph cluster = new Subgraph(counter++.ToString());
     cluster.GeometryNode = gg.RootCluster;
     dg.RootSubgraph = cluster;
     PopulateClusters(cluster, gg.RootCluster);
 
     foreach (GeometryEdge e in gg.Edges)
     {
         Edge edge = new Edge(localMap[e.Source], localMap[e.Target], ConnectionToGraph.Disconnected);
         edge.Attr.ArrowheadAtSource = e.ArrowheadAtSource ? ArrowStyle.Normal : ArrowStyle.None;
         edge.Attr.ArrowheadAtTarget = e.ArrowheadAtTarget ? ArrowStyle.Normal : ArrowStyle.None;
         edge.GeometryEdge = e;
         dg.AddPrecalculatedEdge(edge);
     }
     //PopulateClusterEdges(dg.RootSubgraph, gg.RootCluster);
     
     return dg;
 }
开发者ID:mrkcass,项目名称:SuffixTreeExplorer,代码行数:30,代码来源:FromGeometry.cs

示例4: UpdateGraphNode

 public virtual void UpdateGraphNode(Node graphNode)
 {
     graphNode.Attr.LabelWidthToHeightRatio = 1;
     graphNode.Attr.Shape = Shape.Box;
     graphNode.Attr.FillColor = GameMasterNode.kGreen;
     graphNode.Attr.LabelMargin = 6;
 }
开发者ID:stonehearth,项目名称:stonehearth-editor,代码行数:7,代码来源:NodeData.cs

示例5: XNode

        public XNode(Node node, string category = null)
        {
            Node = node;
            _category = category;

            Border b = new Border();
            double size = node.Label.Text.Length * 9;
            b.Width = size + 12;
            b.Height = size * 2 / 3 + 4;
            _visualObject = b;

            Brush strokeBrush = CommonX.BrushFromMsaglColor(Node.Attr.Color);
            if (category != null)
            {
                Brush brush = Categories.GetBrush(_category);
                if (brush != null) strokeBrush = brush;
            }

            BoundaryPath = new Path {
                //Data = CreatePathFromNodeBoundary(),
                Stroke = strokeBrush,
                Fill = CommonX.BrushFromMsaglColor(Node.Attr.FillColor),
                StrokeThickness = Node.Attr.LineWidth
            };

            Node.Attr.LineWidthHasChanged += AttrLineWidthHasChanged;
            //Node.Attr.GeometryNode.LayoutChangeEvent += GeometryNodeBeforeLayoutChangeEvent;
        }
开发者ID:mrkcass,项目名称:SuffixTreeExplorer,代码行数:28,代码来源:VNodeX.cs

示例6: FordFulkersonAlgo

        void FordFulkersonAlgo(Node nodeSource, Node nodeTerminal)
        {
            label_flow.Text = "Przepływ = 0";
            invalidateFlow();

            var flow = 0f;
            var path = Bfs(nodeSource, nodeTerminal);
            List<AlgoState> steps = new List<AlgoState>(); AlgoState cas = new AlgoState();

            while (path != null && path.Count > 0)
            {
                label_flow.Text = "Przepływ = " + flow;
                var minCapacity = float.MaxValue;
                foreach (var edge in path)
                {
                    if (((EdgeData)(edge.UserData)).currFlow < minCapacity)
                        minCapacity = ((EdgeData)(edge.UserData)).currFlow;
                }

                AugmentPath(path, minCapacity);
                flow += minCapacity;

                clearColors();
                reloadLabels();
                foreach (Edge e in path)
                {
                    foreach (Edge e2 in graph.Edges)
                    {
                        if (e2.Source == e.Source && e2.Target == e.Target) e2.Attr.Color = Color.Red;
                        //dirty code written without understanding Graph class - fixme!
                    }
                }
                label_flow.Text = "Przepływ = " + flow;
                redraw();
                DialogResult dr = MessageBox.Show("Tak=kontynuuj, Nie=wstecz o jeden krok", "pauza", MessageBoxButtons.YesNo);
                if (dr == DialogResult.Yes) {
                    cas.g = graph; cas.p = path; steps.Add(cas); 
                    path = Bfs(nodeSource, nodeTerminal);
                }
                else if (dr == DialogResult.No)
                {
                    if (steps.Count < 1)
                    {
                        MessageBox.Show("Nie można sie cofnąć!");
                    }
                    else { 
                        cas = steps[steps.Count - 1];
                        steps.RemoveAt(steps.Count - 1);
                        graph = cas.g; path = cas.p;
                        label_flow.Text = "Przepływ = " + flow;
                        continue;
                    }
                }
            }

            clearColors();
            reloadLabels();
            MessageBox.Show("Maksymalny przepływ wynosi: "+flow.ToString());
        }
开发者ID:danielskowronski,项目名称:network-max-flow-demo,代码行数:59,代码来源:Algorithm.cs

示例7: GetNodeBoundary

 /// <summary>
 /// Compute the size of the block
 /// </summary>
 /// <param name="node"></param>
 /// <returns></returns>
 public ICurve GetNodeBoundary(Node node)
 {
     const double radiusRatio = 0.3;
     var extent = Layout.CalculateExtent();
     double height = extent.Height;
     double width = extent.Width;
     return CurveFactory.CreateRectangleWithRoundedCorners(width, height, width * radiusRatio, height * radiusRatio, new P2());
 }
开发者ID:relaxar,项目名称:reko,代码行数:13,代码来源:CfgBlockNode.cs

示例8: AutomatonViewModel

 public AutomatonViewModel()
 {
     graph = new Graph();
     graph.Attr.LayerDirection = LayerDirection.LR;
     dummy = new Node(" ");
     dummy.IsVisible = false;
     graph.AddNode(dummy);
     ResetAll();
 }
开发者ID:phamhathanh,项目名称:Automata,代码行数:9,代码来源:AutomatonViewModel.cs

示例9: ImageOfNode

 private Image ImageOfNode(DrawingNode node) {
     Image image;
     if (node.Id == leavesId)
         image = leaves;
     else if (node.Id == creekId)
         image = creek;
     else if (node.Id == wId)
         image = waterfall;
     else
         image = tree;
     return image;
 }
开发者ID:WenzCao,项目名称:automatic-graph-layout,代码行数:12,代码来源:Form1.cs

示例10: DNode

        internal DNode(DGraph graph, DrawingNode drawingNode)
            : base(graph)
        {
            this.DrawingNode = drawingNode;
            _OutEdges = new List<DEdge>();
            _InEdges = new List<DEdge>();
            _SelfEdges = new List<DEdge>();
            PortsToDraw = new Set<Port>();

            if (drawingNode.Label != null)
                Label = new DTextLabel(this, drawingNode.Label);
        }
开发者ID:mrkcass,项目名称:SuffixTreeExplorer,代码行数:12,代码来源:DNode.cs

示例11: CreateLabelAndBoundary

 static ICurve CreateLabelAndBoundary(Node node)
 {
     node.Attr.Shape = Shape.DrawFromGeometry;
     node.Attr.LabelMargin *= 2;
     double width;
     double height;
     StringMeasure.MeasureWithFont(node.Label.Text,
                                   new Font(node.Label.FontName, (float)node.Label.FontSize), out width, out height);
     node.Label.Width = width;
     node.Label.Height = height;
     int r = node.Attr.LabelMargin;
     return CurveFactory.CreateRectangleWithRoundedCorners(width + r * 2, height + r * 2, r, r, new Point());
 }
开发者ID:mrkcass,项目名称:SuffixTreeExplorer,代码行数:13,代码来源:Form1.cs

示例12: DNode

        internal DNode(DObject graph, DrawingNode drawingNode)
            : base(graph)
        {
            this.DrawingNode = drawingNode;
            _OutEdges = new List<DEdge>();
            _InEdges = new List<DEdge>();
            _SelfEdges = new List<DEdge>();
            PortsToDraw = new Set<Port>();

            if (drawingNode.Label != null && drawingNode.Label.GeometryLabel != null)
                Label = new DTextLabel(this, drawingNode.Label);

            if (!(this is DCluster))
                Canvas.SetZIndex(this, 10000);
        }
开发者ID:mrkcass,项目名称:SuffixTreeExplorer,代码行数:15,代码来源:DNode.cs

示例13: GetNodeBoundaryCurve

      /// <summary>
      /// a helper function to creat a node boundary curve 
      /// </summary>
      /// <param name="node">the node</param>
      /// <param name="width">the node width</param>
      /// <param name="height">the node height</param>
      /// <returns></returns>
    public  static ICurve GetNodeBoundaryCurve(Node node, double width, double height)
    {
      if (node == null)
        throw new InvalidOperationException();
      NodeAttr nodeAttr = node.Attr;

      switch (nodeAttr.Shape)
      {
        case Shape.Ellipse:
        case Shape.DoubleCircle:
          return CurveFactory.CreateEllipse(width, height, new P2(0, 0));
        case Shape.Circle:
          {
            double r = Math.Max(width / 2, height / 2);
            return CurveFactory.CreateEllipse(r, r, new P2(0, 0));
          }

        case Shape.Box:
              if (nodeAttr.XRadius != 0 || nodeAttr.YRadius != 0)
                  return CurveFactory.CreateRectangleWithRoundedCorners(width, height, nodeAttr.XRadius,
                                                                       nodeAttr.YRadius, new P2(0, 0));
              return CurveFactory.CreateRectangle(width, height, new P2(0, 0));


          case Shape.Diamond:
          return CurveFactory.CreateDiamond(
            width, height, new P2(0, 0));
              
          case Shape.House:
              return CurveFactory.CreateHouse(width, height, new P2());

          case Shape.InvHouse:
              return CurveFactory.CreateInvertedHouse(width, height, new P2());
          case Shape.Octagon:
              return CurveFactory.CreateOctagon(width, height, new P2());
#if DEBUG
          case Shape.TestShape:
              return CurveFactory.CreateTestShape(width, height);
#endif
      
        default:
          {
            //  Console.WriteLine("creating ellipse for shape {0}",nodeAttr.Shape);
            return new Ellipse(
              new P2(width / 2, 0), new P2(0, height / 2), new P2());
          }
      }
    }
开发者ID:danielskowronski,项目名称:network-max-flow-demo,代码行数:55,代码来源:NodeBoundaryCurves.cs

示例14: GraphmapsNode

        internal GraphmapsNode(Node node, LgNodeInfo lgNodeInfo, FrameworkElement frameworkElementOfNodeForLabelOfLabel,
            Func<Edge, GraphmapsEdge> funcFromDrawingEdgeToVEdge, Func<double> pathStrokeThicknessFunc)
        {
            PathStrokeThicknessFunc = pathStrokeThicknessFunc;
            LgNodeInfo = lgNodeInfo;
            Node = node;
            FrameworkElementOfNodeForLabel = frameworkElementOfNodeForLabelOfLabel;

            this.funcFromDrawingEdgeToVEdge = funcFromDrawingEdgeToVEdge;

            CreateNodeBoundaryPath();
            if (FrameworkElementOfNodeForLabel != null) {
                FrameworkElementOfNodeForLabel.Tag = this; //get a backpointer to the VNode 
                Common.PositionFrameworkElement(FrameworkElementOfNodeForLabel, node.GeometryNode.Center, 1);
                Panel.SetZIndex(FrameworkElementOfNodeForLabel, Panel.GetZIndex(BoundaryPath) + 1);
            }
            SetupSubgraphDrawing();
            Node.GeometryNode.BeforeLayoutChangeEvent += GeometryNodeBeforeLayoutChangeEvent;
            Node.Attr.VisualsChanged += (a, b) => Invalidate();         
           
        }
开发者ID:WenzCao,项目名称:automatic-graph-layout,代码行数:21,代码来源:GraphmapsNode.cs

示例15: VNode

        internal VNode(Node node, FrameworkElement frameworkElementOfNodeForLabelOfLabel,
            Func<Edge, VEdge> funcFromDrawingEdgeToVEdge, Func<double> pathStrokeThicknessFunc) {
            PathStrokeThicknessFunc = pathStrokeThicknessFunc;
            Node = node;
            FrameworkElementOfNodeForLabel = frameworkElementOfNodeForLabelOfLabel;

            _funcFromDrawingEdgeToVEdge = funcFromDrawingEdgeToVEdge;

            CreateNodeBoundaryPath();
            if (FrameworkElementOfNodeForLabel != null) {
                FrameworkElementOfNodeForLabel.Tag = this; //get a backpointer to the VNode 
                Common.PositionFrameworkElement(FrameworkElementOfNodeForLabel, node.GeometryNode.Center, 1);
                Panel.SetZIndex(FrameworkElementOfNodeForLabel, Panel.GetZIndex(BoundaryPath) + 1);
            }
            SetupSubgraphDrawing();
            Node.Attr.VisualsChanged += (a, b) => Invalidate();
            Node.IsVisibleChanged += obj => {
                foreach (var frameworkElement in FrameworkElements) {
                    frameworkElement.Visibility = Node.IsVisible ? Visibility.Visible : Visibility.Hidden;
                }
            };
        }
开发者ID:UIKit0,项目名称:automatic-graph-layout,代码行数:22,代码来源:VNode.cs


注:本文中的Microsoft.Msagl.Drawing.Node类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。