/// <summary>
 /// Generate sequence of controls for graph path
 /// </summary>
 /// <param name="path"></param>
 private void DrawGraphPath(IGraphPath path)
 {
     foreach (GraphItem item in path.DirectFlow)
     {
         DrawGraphItem(item);
     }
 }
        private void DrawPathConnections(IGraphPath path, bool isSelected, Microsoft.Msagl.Drawing.Graph graph)
        {
            if (path == null || path.DirectFlow.Count <= 1)
            {
                return;
            }

            graph.Attr.MinNodeHeight = 40;
            graph.Attr.MinNodeWidth  = 110;

            GraphItem prev = path.DirectFlow[0];
            GraphItem next = path.DirectFlow[1];

            if (prev.RelatedTo != null)
            {
                prev = (GraphItem)prev.RelatedTo;
            }

            if (next.RelatedTo != null)
            {
                next = (GraphItem)next.RelatedTo;
            }

            if (prev == null || next == null)
            {
                return;
            }

            DrawingHelper.DrawArrow(gLocalViewer, prev, next, isSelected, graph, path);
        }
 public static void Highlight(this IGraphPath self, IEndPoints endpoints)
 {
     self.Path
     .Except(endpoints.Source, endpoints.Target)
     .OfType <IMarkable>()
     .ForEach(vertex => vertex.MarkAsPath());
 }
Beispiel #4
0
 public static void Highlight(this IGraphPath self, IEndPoints endpoints)
 {
     self.Path
     .Where(vertex => !endpoints.IsEndPoint(vertex))
     .OfType <IMarkable>()
     .ForEach(vertex => vertex.MarkAsPath());
 }
 /// <summary>
 /// Execute graph drawing
 /// </summary>
 public void DrawGraph()
 {
     for (int j = 0; j < _graph.Paths.Count; j++)
     {
         IGraphPath path = _graph.Paths[j];
         DrawGraphPath(path);
     }
 }
Beispiel #6
0
 public void Update(IGraphPath path, int time)
 {
     if (path.IsChanged || (path as SvgElement).pretime == -1)
     {
         this.Update(path);
         path.IsChanged = false;
     }
 }
Beispiel #7
0
        public void AddNewPath(IGraphPath path)
        {
            if (_paths == null)
            {
                _paths = new List <GraphPath>();
            }

            _paths.Add((GraphPath)path);

            AddRelations();
        }
Beispiel #8
0
 public void Paint(Graphics g, IGraphPath path, GraphicsPath gpath, int time)
 {
     if (path.IsChanged || (path as SvgElement).pretime == -1)
     {
         this.Update(path);
         path.IsChanged = false;
     }
     if (this.brush != null)
     {
         this.brush.Stroke(gpath, g, time, this.Opacity);
     }
 }
Beispiel #9
0
        public static IEnumerable <V> GetPathVertexList(IGraphPath <V, E> path)
        {
            IGraph <V, E> graph       = path.Graph;
            var           pathVerices = new List <V>();
            var           vertex      = path.StartVertex;

            pathVerices.Add(vertex);

            foreach (var edge in path.Edges)
            {
                vertex = GetOppositeVertex(graph, edge, vertex);
                pathVerices.Add(vertex);
            }

            return(pathVerices);
        }
Beispiel #10
0
        public static ISvgBrush Parsing(string text, SvgDocument doc, IGraphPath path)
        {
            while (text.Trim().EndsWith(";"))
            {
                text = text.Substring(0, text.Length - 1);
            }
            if (text.Trim().StartsWith("url"))
            {
                int     num1  = text.Trim().IndexOf("#", 0, text.Trim().Length);
                int     num2  = text.Trim().IndexOf(")", 0, text.Trim().Length);
                string  text1 = text.Trim().Substring(num1 + 1, (num2 - num1) - 1);
                XmlNode node1 = NodeFunc.GetRefNode(text1, doc);
                if (node1 != null)
                {
                    if (node1.NodeType != XmlNodeType.Element)
                    {
                        return(null);
                    }
                    XmlElement element1 = (XmlElement)node1;
                    if (element1 != null)
                    {
                        return((ISvgBrush)element1);
                    }
                }
                return(null);
            }
            string text7 = "none";           // AttributeFunc.ParseAttribute("hatch-style",(SvgElement) path,false).ToString();

            if (((SvgElement)path).SvgAttributes.ContainsKey("hatch-style"))
            {
                text7 = ((SvgElement)path).SvgAttributes["hatch-style"].ToString();
            }
            if ((text7 != "") && (text7.ToLower() != "none") && (text != "none"))
            {
                Color color1 = ColorFunc.ParseColor(text);
                Color color2 = ColorFunc.ParseColor(AttributeFunc.ParseAttribute("hatch-color", (SvgElement)path, false).ToString());

                Struct.Pattern pattern = new ItopVector.Struct.Pattern(color1, (ItopVector.PatternType)Enum.Parse(typeof(ItopVector.PatternType), text7, false), color2);

                return(new RatHatchBrush(pattern));
            }

            return(new SolidColor(ColorFunc.ParseColor(text)));
        }
        void SelectNodeGraph()
        {
            // TODO: select nodes in selected Path
            Node selectedNode = gLocalViewer.SelectedObject as Node;

            if (selectedNode != null)
            {
                if (_prevSelectedNode != null)
                {
                    IGraphItem prevItem = _prevSelectedNode.UserData as GraphItem;
                    if (prevItem != null)
                    {
                        prevItem.IsSelected        = false;
                        _prevSelectedNode.UserData = prevItem;
                    }
                }

                GraphItem item = selectedNode.UserData as GraphItem;

                ColorButton.ColorButton nodeButton = new ColorButton.ColorButton();
                nodeButton.Text   = selectedNode.Id;
                nodeButton.Anchor = AnchorStyles.Top;
                nodeButton.Tag    = item;
                _selectedPath     = null;
                if (item.CurrentPathIndex > 0)
                {
                    DrawingHelper.SelectedPathItemUniqueID = item.QueryItem.Paths[item.CurrentPathIndex - 1].UniqueID;
                }
                DrawingHelper.SelectedNodeUniqueID = item.UniqueID;
                DrawingHelper.isEdgeSelected       = false;
                //ChangeSelectedFile(nodeButton, null);
                if (_pathItemClick != null)
                {
                    _pathItemClick(item.QueryItem.Paths[item.CurrentPathIndex - 1], null);
                }
                gLocalViewer.Refresh();
                gLocalViewer.ResumeLayout();
                gLocalViewer.Update();
                //_prevSelectedNode = selectedNode;
            }
        }
        public void SelectEdgeGraphByPath(GraphItem itemSource, GraphItem item, IGraphPath selectedPath)
        {
            if (itemSource.CurrentPathIndex > 0)
            {
                DrawingHelper.SelectedPathItem1UniqueID = itemSource.UniqueID;
            }

            if (item.CurrentPathIndex > 0)
            {
                DrawingHelper.SelectedPathItem2UniqueID = item.UniqueID;
            }
            DrawingHelper.SelectedNodeUniqueID = item.UniqueID;
            DrawingHelper.isEdgeSelected       = true;
            ColorButton.ColorButton nodeButton = new ColorButton.ColorButton();
            nodeButton.Text   = itemSource.ID;
            nodeButton.Anchor = AnchorStyles.Top;
            nodeButton.Tag    = item;
            _selectedPath     = selectedPath;
            gLocalViewer.Refresh();
            gLocalViewer.ResumeLayout();
            gLocalViewer.Update();
        }
Beispiel #13
0
 public void SelectEdgeGraphByPath(GraphItem itemSource, GraphItem item, IGraphPath selectedPath)
 {
     tblLayout.SelectEdgeGraphByPath(itemSource, item, selectedPath);
 }
Beispiel #14
0
        private void Update(IGraphPath path)
        {
            Pen pen1 = null;
            string text1 = AttributeFunc.ParseAttribute("stroke", (SvgElement) path, false).ToString();
            ISvgBrush brush1 = new SolidColor(Color.Black);
            if ((text1 != null) && (text1 != string.Empty))
            {
                brush1 = BrushManager.Parsing(text1, ((SvgElement) path).OwnerDocument);
            }
            text1 = AttributeFunc.ParseAttribute("stroke-opacity", (SvgElement) path, false).ToString();
            float single1 = 1f;
            if ((text1 != string.Empty) && (text1 != null))
            {
                single1 = Math.Max((float) 0f, Math.Min((float) 255f, ItopVector.Core.Func.Number.ParseFloatStr(text1)));
            }
            if (single1 > 1f)
            {
                single1 /= 255f;
            }
            single1 = Math.Min(path.Opacity, path.StrokeOpacity);
            float single2 = 1f;
            object obj1 = AttributeFunc.ParseAttribute("stroke-width", (SvgElement) path, false);
            if (obj1 is float)
            {
                single2 = (float) obj1;
            }
            pen1 = new Pen(Color.Empty, single2);
            pen1.Alignment = PenAlignment.Outset;
            string text2 = AttributeFunc.FindAttribute("stroke-linecap", (SvgElement) path).ToString();
            if (text2 == "round")
            {
                LineCap cap1;
                pen1.EndCap = cap1 = LineCap.Round;
                pen1.StartCap = cap1;
            }
            else if (text2 == "square")
            {
                LineCap cap2;
                pen1.EndCap = cap2 = LineCap.Square;
                pen1.StartCap = cap2;
            }
            else
            {
                LineCap cap3;
                pen1.EndCap = cap3 = LineCap.Flat;
                pen1.StartCap = cap3;
            }
            string text3 = AttributeFunc.FindAttribute("stroke-linejoin", (SvgElement) path).ToString();
            if (text3 == "round")
            {
                pen1.LineJoin = LineJoin.Round;
            }
            else if (text3 == "bevel")
            {
                pen1.LineJoin = LineJoin.Bevel;
            }
            else
            {
                pen1.LineJoin = LineJoin.Miter;
            }
            string text4 = AttributeFunc.FindAttribute("stroke-miterlimit", (SvgElement) path).ToString();
            if (text4 == "")
            {
                text4 = "4";
            }
            float single3 = ItopVector.Core.Func.Number.parseToFloat(text4, (SvgElement) path, SvgLengthDirection.Horizontal);
            if (single3 < 1f)
            {
                throw new Exception("stroke-miterlimit " + ItopVector.Core.Config.Config.GetLabelForName("notlowerstr") + " 1:" + text4);
            }
            pen1.MiterLimit = single3;
            string text5 = AttributeFunc.FindAttribute("stroke-dasharray", (SvgElement) path).ToString();
            if ((text5 != "") && (text5 != "none"))
            {
                Regex regex1 = new Regex(@"[\s\,]+");
                text5 = regex1.Replace(text5, ",");
                char[] chArray1 = new char[1] { ',' } ;
                string[] textArray1 = text5.Split(chArray1);
                float[] singleArray1 = new float[textArray1.GetLength(0)];
                for (int num1 = 0; num1 < textArray1.GetLength(0); num1++)
                {
                    singleArray1[num1] = ItopVector.Core.Func.Number.parseToFloat(textArray1[num1], (SvgElement) path, SvgLengthDirection.Horizontal) / pen1.Width;
                }
                if ((singleArray1.GetLength(0) % 2) == 1)
                {
                    float[] singleArray2 = new float[singleArray1.GetLength(0) * 2];
                    singleArray1.CopyTo(singleArray2, 0);
                    singleArray1.CopyTo(singleArray2, singleArray1.GetLength(0));
                    singleArray1 = singleArray2;
                }
                pen1.DashPattern = singleArray1;
            }
            string text6 = AttributeFunc.FindAttribute("stroke-dashoffset", (SvgElement) path).ToString();
            float single4 = 0f;
            if (text6 != "")
            {
                single4 = ItopVector.Core.Func.Number.parseToFloat(text6, (SvgElement) path, SvgLengthDirection.Horizontal);
            }
            float single5 = Math.Abs((float) AnimFunc.GetAnimateValue((SvgElement) path, "stroke-dashoffset", DomType.SvgNumber, single4)) / pen1.Width;
            pen1.DashOffset = single5 / single2;

            this.pen=pen1;
            this.Width=pen1.Width;
            if (brush1 != null)
            {
                brush1.Pen = pen1;
            }
            this.Opacity = single1;
            this.brush = brush1;
        }
 public static bool HasPath(this IGraphPath self)
 {
     return(self.Path.Any());
 }
Beispiel #16
0
 public void OnMouseDown(MouseEventArgs e)
 {
     if (e.Button == MouseButtons.Left)
     {
         if (this.mouseAreaControl.Cursor == this.mouseAreaControl.DefaultCursor)
         {
             PointF tf1 = new PointF((float) e.X, (float) e.Y);
             SvgElementCollection collection1 = this.mouseAreaControl.SVGDocument.SelectCollection;
             if (collection1 != null)
             {
                 for (int num1 = collection1.Count - 1; num1 >= 0; num1--)
                 {
                     if (collection1[num1] is IGraphPath)
                     {
                         IGraph graph1 = (IGraphPath) collection1[num1];
                         GraphicsPath path1 = (GraphicsPath) graph1.GPath.Clone();
                         Matrix matrix1 = graph1.GraphTransform.Matrix.Clone();
                         path1.Transform(matrix1);
                         Pen pen1 = new Pen(Color.Blue, 4f);
                         pen1.Alignment = PenAlignment.Center;
                         bool flag1 = false;
                         flag1 = path1.IsVisible(tf1);
                         if (path1.IsOutlineVisible(tf1, pen1))
                         {
                             flag1 = true;
                         }
                         if (flag1)
                         {
                             this.ActiveGraph = (IGraphPath) graph1;
                             return;
                         }
                     }
                 }
                 collection1 = this.mouseAreaControl.PicturePanel.ElementList;
                 for (int num2 = collection1.Count - 1; num2 >= 0; num2--)
                 {
                     if (collection1[num2] is IGraphPath)
                     {
                         IGraph graph2 = (IGraphPath) collection1[num2];
                         GraphicsPath path2 = (GraphicsPath) graph2.GPath.Clone();
                         Matrix matrix2 = graph2.GraphTransform.Matrix.Clone();
                         path2.Transform(matrix2);
                         Pen pen2 = new Pen(Color.Blue, 4f);
                         pen2.Alignment = PenAlignment.Center;
                         bool flag2 = false;
                         flag2 = path2.IsVisible(tf1);
                         if (path2.IsOutlineVisible(tf1, pen2))
                         {
                             flag2 = true;
                         }
                         if (flag2)
                         {
                             this.ActiveGraph = (IGraphPath) graph2;
                             return;
                         }
                     }
                 }
                 this.activeGraph = null;
                 this.mouseAreaControl.Invalidate();
             }
         }
         else
         {
             this.startPoint = new PointF((float) e.X, (float) e.Y);
             this.reversePath.Reset();
         }
     }
 }
Beispiel #17
0
        public static void _DrawArrow(GViewer gLocalViewer, GraphItem nodeId1, GraphItem nodeId2, bool isSelected, Microsoft.Msagl.Drawing.Graph graph, IGraphPath path)
        {
            #region Set node 1 caption

            bool isNewEdge = false;
            //Microsoft.Msagl.Drawing.Graph graph = gLocalViewer.Graph;
            Node sourceNode = graph.FindNode(nodeId1.UniqueID);
            if (sourceNode == null)
            {
                isNewEdge  = true;
                sourceNode = new Node(nodeId1.UniqueID);
                if (nodeId1.Name.Length > 12)
                {
                    sourceNode.Label.Text = string.Format("{0}...", nodeId1.Name.Substring(0, 6));
                }
                else
                {
                    sourceNode.Label.Text = nodeId1.Name;
                }
            }

            #endregion

            #region Set node 2 caption

            Node targetNode = graph.FindNode(nodeId2.UniqueID);
            if (targetNode == null)
            {
                isNewEdge  = true;
                targetNode = new Node(nodeId2.UniqueID);
                if (nodeId2.Name.Length > 12)
                {
                    targetNode.Label.Text = string.Format("{0}...", nodeId2.Name.Substring(0, 6));
                }
                else
                {
                    targetNode.Label.Text = nodeId2.Name;
                }
            }

            #endregion

            #region Set Drawing type

            GraphItem nodeItem1 = sourceNode.UserData as GraphItem;
            GraphItem nodeItem2 = targetNode.UserData as GraphItem;

            sourceNode.UserData = nodeId1;
            targetNode.UserData = nodeId2;
            #endregion

            if (isNewEdge)
            {
                graph.AddNode(sourceNode);
                graph.AddNode(targetNode);
                if (nodeId1.UniqueID != nodeId2.UniqueID)
                {
                    Edge edge = graph.AddEdge(nodeId1.UniqueID, nodeId2.UniqueID);
                    edge.UserData = path;
                }
            }
            else
            {
                if (!IsNodesConnected(sourceNode, targetNode))
                {
                    if (nodeId1.UniqueID != nodeId2.UniqueID)
                    {
                        Edge edge = graph.AddEdge(nodeId1.UniqueID, nodeId2.UniqueID);
                        edge.UserData = path;
                    }
                }
            }

            SetNodeColor(graph, nodeId1, nodeId2, sourceNode, targetNode, isSelected);
        }
Beispiel #18
0
        public static void DrawArrow(GViewer gLocalViewer, GraphItem nodeId1, GraphItem nodeId2, bool isSelected, Microsoft.Msagl.Drawing.Graph graph, IGraphPath path)
        {
            ReportQueryItemPathResult prevItem = null;
            int  index = 1;
            bool isSelectedEdgeDrawn = false;

            foreach (ReportQueryItemPathResult item in nodeId1.QueryItem.Paths)
            {
                Node sourceNode = graph.FindNode(item.UniqueID);
                if (sourceNode == null)
                {
                    sourceNode = new Node(item.UniqueID);
                    if (item.Name.Length > 12)
                    {
                        sourceNode.Label.Text = string.Format("{0}...", item.Name.Substring(0, 6));
                    }
                    else
                    {
                        sourceNode.Label.Text = item.Name;
                    }

                    graph.AddNode(sourceNode);
                }
                GraphItem newItem = new GraphItem();
                newItem.Column           = nodeId1.Column;
                newItem.CurrentPathIndex = item.NodeId;
                newItem.FileName         = nodeId1.FileName;
                newItem.GraphX           = nodeId1.GraphX;
                newItem.GraphY           = nodeId1.GraphY;
                newItem.IsMultiReletions = nodeId1.IsMultiReletions;
                newItem.IsPrimary        = nodeId1.IsPrimary;
                newItem.IsSelected       = nodeId1.IsSelected;
                newItem.Length           = nodeId1.Length;
                newItem.Line             = nodeId1.Line;
                newItem.Name             = nodeId1.Name;
                newItem.Parent           = nodeId1.Parent;
                newItem.QueryItem        = nodeId1.QueryItem;
                newItem.RelatedTo        = nodeId1.RelatedTo;
                newItem.RelationsFrom    = nodeId1.RelationsFrom;
                sourceNode.UserData      = newItem;


                if (isSelected && item.UniqueID == DrawingHelper.SelectedPathItemUniqueID && !isEdgeSelected)
                {
                    newItem.IsSelected = true;
                    SetDrawDelegateByNode(sourceNode, NodeTypes.NormalSelected);
                }
                else
                {
                    newItem.IsSelected = false;
                    SetDrawDelegateByNode(sourceNode, NodeTypes.Normal);
                }

                if (prevItem != null)
                {
                    Edge edge = IsEdgeExisted(sourceNode, prevItem.UniqueID);
                    if (edge == null)
                    {
                        edge = graph.AddEdge(prevItem.UniqueID, item.UniqueID);
                        edge.Attr.ArrowheadAtTarget = ArrowStyle.Normal;
                        edge.Attr.ArrowheadLength   = 10;
                        edge.Attr.LineWidth         = 2;
                        edge.Attr.Weight            = 2;
                        path.QueryItemResult        = nodeId1.QueryItem;
                        edge.UserData = path;
                    }
                    SetMaxReletions(edge);

                    if (isSelected &&
                        ((SelectedNodeUniqueID == nodeId1.UniqueID && !isEdgeSelected) ||
                         (IsContainPath(nodeId1.QueryItem.Paths) && isEdgeSelected) ||
                         (DrawingHelper.SelectedNodeUniqueID == null)
                        ))
                    {
                        edge.Attr.Color     = Microsoft.Msagl.Drawing.Color.Black;
                        edge.Attr.Weight    = 2;
                        edge.Attr.LineWidth = 2;
                        isSelectedEdgeDrawn = true;
                    }
                    else
                    {
                        edge.Attr.Color     = Microsoft.Msagl.Drawing.Color.DarkGray;
                        edge.Attr.Weight    = 2;
                        edge.Attr.LineWidth = 2;
                    }
                }
                prevItem = item;
                index++;
            }

            prevItem = null;
            index    = 1;
            foreach (ReportQueryItemPathResult item in nodeId2.QueryItem.Paths)
            {
                Node sourceNode = graph.FindNode(item.UniqueID);
                if (sourceNode == null)
                {
                    sourceNode = new Node(item.UniqueID);
                    if (item.Name.Length > 12)
                    {
                        sourceNode.Label.Text = string.Format("{0}...", item.Name.Substring(0, 6));
                    }
                    else
                    {
                        sourceNode.Label.Text = item.Name;
                    }
                    graph.AddNode(sourceNode);
                }

                GraphItem newItem = new GraphItem();
                newItem.Column           = nodeId2.Column;
                newItem.CurrentPathIndex = item.NodeId;
                newItem.FileName         = nodeId2.FileName;
                newItem.GraphX           = nodeId2.GraphX;
                newItem.GraphY           = nodeId2.GraphY;
                newItem.IsMultiReletions = nodeId2.IsMultiReletions;
                newItem.IsPrimary        = nodeId2.IsPrimary;
                newItem.IsSelected       = nodeId2.IsSelected;
                newItem.Length           = nodeId2.Length;
                newItem.Line             = nodeId2.Line;
                newItem.Name             = nodeId2.Name;
                newItem.Parent           = nodeId2.Parent;
                newItem.QueryItem        = nodeId2.QueryItem;
                newItem.RelatedTo        = nodeId2.RelatedTo;
                newItem.RelationsFrom    = nodeId2.RelationsFrom;
                sourceNode.UserData      = newItem;

                if (isSelected && item.UniqueID == DrawingHelper.SelectedPathItemUniqueID && !isEdgeSelected)
                {
                    newItem.IsSelected = true;
                    SetDrawDelegateByNode(sourceNode, NodeTypes.NormalSelected);
                }
                else
                {
                    newItem.IsSelected = false;
                    SetDrawDelegateByNode(sourceNode, NodeTypes.Normal);
                }

                if (prevItem != null)
                {
                    Edge edge = IsEdgeExisted(sourceNode, prevItem.UniqueID);
                    if (edge == null)
                    {
                        edge = graph.AddEdge(prevItem.UniqueID, item.UniqueID);
                        edge.Attr.ArrowheadAtTarget = ArrowStyle.Normal;
                        edge.Attr.ArrowheadLength   = 10;
                        path.QueryItemResult        = nodeId2.QueryItem;
                        edge.UserData = path;
                    }
                    SetMaxReletions(edge);

                    if (isSelected &&
                        ((SelectedNodeUniqueID == nodeId2.UniqueID && !isEdgeSelected) ||
                         (IsContainPath(nodeId2.QueryItem.Paths) && isEdgeSelected) ||
                         (DrawingHelper.SelectedNodeUniqueID == null)
                        ))
                    {
                        if (!isSelectedEdgeDrawn || isEdgeSelected)
                        {
                            edge.Attr.Color     = Microsoft.Msagl.Drawing.Color.Black;
                            edge.Attr.Weight    = 2;
                            edge.Attr.LineWidth = 2;
                        }
                    }
                    else
                    {
                        //if (!isSelectedEdgeDrawn || !isEdgeSelected)
                        if (!isSelectedEdgeDrawn)
                        {
                            edge.Attr.Color     = Microsoft.Msagl.Drawing.Color.DarkGray;
                            edge.Attr.Weight    = 2;
                            edge.Attr.LineWidth = 2;
                        }
                    }
                }
                prevItem = item;
                index++;
            }


            bool isTopNodeFound = false;

            if (isSelected &&
                ((IsContainPath(nodeId1.QueryItem.Paths) && isEdgeSelected) ||
                 (DrawingHelper.SelectedNodeUniqueID == null))
                )
            {
                Node       firstNode = graph.FindNode(nodeId1.QueryItem.Paths[0].UniqueID);
                IGraphItem item      = firstNode.UserData as IGraphItem;
                item.IsSelected = true;
                SetDrawDelegateByNode(firstNode, NodeTypes.NormalSelected);

                isTopNodeFound = true;

                SelectedNodeUniqueID = nodeId1.UniqueID;
            }

            if (!isTopNodeFound && isSelected &&
                ((IsContainPath(nodeId2.QueryItem.Paths) && isEdgeSelected) ||
                 (DrawingHelper.SelectedNodeUniqueID == null))
                )
            {
                Node       firstNode = graph.FindNode(nodeId2.QueryItem.Paths[0].UniqueID);
                IGraphItem item      = firstNode.UserData as IGraphItem;
                item.IsSelected = true;
                SetDrawDelegateByNode(firstNode, NodeTypes.NormalSelected);

                SelectedNodeUniqueID = nodeId2.UniqueID;
            }
        }
        void SelectEdgeGraph()
        {
            try
            {
                // Fix problem with redrawing selected edge.(msagl bug)
                gLocalViewer.PanButtonPressed = true;
                Point pt = Cursor.Position;
                pt.X           += 120;
                pt.Y           += 100;
                Cursor.Position = pt;

                // TODO: select nodes in selected Path
                Edge selectedEdge = gLocalViewer.SelectedObject as Edge;
                if (selectedEdge != null)
                {
                    selectedEdge.Attr.Color     = Microsoft.Msagl.Drawing.Color.Black;
                    selectedEdge.Attr.LineWidth = 2;
                    selectedEdge.Attr.Weight    = 2;

                    Node sourceNode   = selectedEdge.SourceNode as Node;
                    Node selectedNode = sourceNode;
                    Node targetNode   = selectedEdge.TargetNode as Node;
                    selectedNode = targetNode;

                    GraphItem item = targetNode.UserData as GraphItem;
                    if (item == null)
                    {
                        return;
                    }

                    GraphItem itemSource = sourceNode.UserData as GraphItem;

                    if (itemSource.CurrentPathIndex > 0)
                    {
                        DrawingHelper.SelectedPathItem1UniqueID = itemSource.QueryItem.Paths[itemSource.CurrentPathIndex - 1].UniqueID;
                    }

                    if (item.CurrentPathIndex > 0)
                    {
                        DrawingHelper.SelectedPathItem2UniqueID = item.QueryItem.Paths[item.CurrentPathIndex - 1].UniqueID;
                    }
                    DrawingHelper.SelectedNodeUniqueID = item.UniqueID;
                    DrawingHelper.isEdgeSelected       = true;
                    ColorButton.ColorButton nodeButton = new ColorButton.ColorButton();
                    nodeButton.Text   = selectedNode.Id;
                    nodeButton.Anchor = AnchorStyles.Top;
                    nodeButton.Tag    = item;
                    _selectedPath     = selectedEdge.UserData as IGraphPath;
                    //ChangeSelectedFile(nodeButton, null);
                    if (_pathItemClick != null)
                    {
                        _pathItemClick(item.QueryItem.Paths[item.CurrentPathIndex - 1], null);
                    }
                    gLocalViewer.Refresh();
                    gLocalViewer.ResumeLayout();
                    gLocalViewer.Update();
                    _prevSelectedNode = selectedNode;
                }
            }
            finally
            {
                gLocalViewer.PanButtonPressed = false;
            }
        }
 public IDictionary <int, IRoute> Optimize(IGraphPath rGraph)
 {
     throw new NotImplementedException();
 }
Beispiel #21
0
 public void Update(IGraphPath path, int time)
 {
     if (path.IsChanged || (path as SvgElement).pretime == -1) {
         this.Update(path);
         path.IsChanged = false;
     }
 }
Beispiel #22
0
 public static bool IsExtracted(this IGraphPath self)
 {
     return(self.Path.Any());
 }
Beispiel #23
0
 public static int GetPathLength(this IGraphPath self)
 {
     return(self.Path.Count());
 }
Beispiel #24
0
        public static Stroke GetStroke(IGraphPath path)
        {
            Pen       pen1   = null;
            string    text1  = AttributeFunc.ParseAttribute("stroke", (SvgElement)path, false).ToString();
            Color     color1 = Color.Empty;
            ISvgBrush brush1 = new SolidColor(Color.Empty);

            if ((text1 != null) || (text1 != string.Empty))
            {
                brush1 = BrushManager.Parsing(text1, ((SvgElement)path).OwnerDocument);
            }
            text1 = AttributeFunc.ParseAttribute("stroke-opacity", (SvgElement)path, false).ToString();
            float single1 = 1f;

            if ((text1 != string.Empty) && (text1 != null))
            {
                single1 = Math.Max((float)0f, Math.Min((float)255f, ItopVector.Core.Func.Number.ParseFloatStr(text1)));
            }
            if (single1 > 1f)
            {
                single1 /= 255f;
            }
            single1 = Math.Min(path.Opacity, path.StrokeOpacity);
            float  single2 = 1f;
            object obj1    = AttributeFunc.ParseAttribute("stroke-width", (SvgElement)path, false);

            if (obj1 is float)
            {
                single2 = (float)obj1;
            }
            pen1           = new Pen(Color.Empty, single2);
            pen1.Alignment = PenAlignment.Outset;
            string text2 = AttributeFunc.FindAttribute("stroke-linecap", (SvgElement)path).ToString();

            if (text2 == "round")
            {
                LineCap cap1;
                pen1.EndCap   = cap1 = LineCap.Round;
                pen1.StartCap = cap1;
            }
            else if (text2 == "square")
            {
                LineCap cap2;
                pen1.EndCap   = cap2 = LineCap.Square;
                pen1.StartCap = cap2;
            }
            else
            {
                LineCap cap3;
                pen1.EndCap   = cap3 = LineCap.Flat;
                pen1.StartCap = cap3;
            }
            string text3 = AttributeFunc.FindAttribute("stroke-linejoin", (SvgElement)path).ToString();

            if (text3 == "round")
            {
                pen1.LineJoin = LineJoin.Round;
            }
            else if (text3 == "bevel")
            {
                pen1.LineJoin = LineJoin.Bevel;
            }
            else
            {
                pen1.LineJoin = LineJoin.Miter;
            }
            string text4 = AttributeFunc.FindAttribute("stroke-miterlimit", (SvgElement)path).ToString();

            if (text4 == "")
            {
                text4 = "4";
            }
            float single3 = ItopVector.Core.Func.Number.parseToFloat(text4, (SvgElement)path, SvgLengthDirection.Horizontal);

            if (single3 < 1f)
            {
                throw new Exception("stroke-miterlimit " + ItopVector.Core.Config.Config.GetLabelForName("notlowerstr") + " 1:" + text4);
            }
            pen1.MiterLimit = single3;
            string text5 = AttributeFunc.FindAttribute("stroke-dasharray", (SvgElement)path).ToString();

            if ((text5 != "") && (text5 != "none"))
            {
                Regex regex1 = new Regex(@"[\s\,]+");
                text5 = regex1.Replace(text5, ",");
                char[] chArray1 = new char[1] {
                    ','
                };
                string[] textArray1   = text5.Split(chArray1);
                float[]  singleArray1 = new float[textArray1.GetLength(0)];
                for (int num1 = 0; num1 < textArray1.GetLength(0); num1++)
                {
                    singleArray1[num1] = ItopVector.Core.Func.Number.ParseFloatStr(textArray1[num1]) / pen1.Width;
                }
                if ((singleArray1.GetLength(0) % 2) == 1)
                {
                    float[] singleArray2 = new float[singleArray1.GetLength(0) * 2];
                    singleArray1.CopyTo(singleArray2, 0);
                    singleArray1.CopyTo(singleArray2, singleArray1.GetLength(0));
                    singleArray1 = singleArray2;
                }
                pen1.DashPattern = singleArray1;
            }
            string text6   = AttributeFunc.FindAttribute("stroke-dashoffset", (SvgElement)path).ToString();
            float  single4 = 0f;

            if (text6 != "")
            {
                single4 = ItopVector.Core.Func.Number.parseToFloat(text6, (SvgElement)path, SvgLengthDirection.Horizontal);
            }
            float single5 = Math.Abs((float)AnimFunc.GetAnimateValue((SvgElement)path, "stroke-dashoffset", DomType.SvgNumber, single4)) / pen1.Width;

            pen1.DashOffset = single5 / single2;
            if (brush1 != null)
            {
                brush1.Pen = pen1;
            }
            Stroke stroke1 = new Stroke(brush1);

            stroke1.Opacity = single1;
            return(stroke1);
        }
Beispiel #25
0
 public void Paint(Graphics g, IGraphPath path,GraphicsPath gpath, int time)
 {
     if(path.IsChanged ||(path as SvgElement).pretime==-1)
     {
         this.Update(path);
         path.IsChanged=false;
     }
     if (this.brush != null)
     {
         this.brush.Stroke(gpath, g, time, this.Opacity);
     }
 }