Exemple #1
0
        internal static List <ReportQueryItemPathResult> ParseQueryItemPathResult(XmlNode xmlNode, ReportQueryItemResult parent)
        {
            List <ReportQueryItemPathResult> outputItems = new List <ReportQueryItemPathResult>();


            foreach (XmlNode pathNode in xmlNode.ChildNodes)
            {
                ReportQueryItemPathResult reportQueryItemPathResult = new ReportQueryItemPathResult();
                reportQueryItemPathResult.QueryItem = parent;
                foreach (XmlNode pathSubNode in pathNode.ChildNodes)
                {
                    switch (pathSubNode.Name.ToLower())
                    {
                    case "filename": reportQueryItemPathResult.FileName = pathSubNode.InnerText; break;

                    case "line": reportQueryItemPathResult.Line = int.Parse(pathSubNode.InnerText); break;

                    case "column": reportQueryItemPathResult.Column = int.Parse(pathSubNode.InnerText); break;

                    case "name": reportQueryItemPathResult.Name = pathSubNode.InnerText; break;

                    case "length": reportQueryItemPathResult.Length = int.Parse(pathSubNode.InnerText); break;

                    case "nodeid": reportQueryItemPathResult.NodeId = int.Parse(pathSubNode.InnerText); break;
                    }
                }
                outputItems.Add(reportQueryItemPathResult);
            }


            return(outputItems);
        }
Exemple #2
0
        private void PathButtonClick(object sender, EventArgs e)
        {
            ReportQueryItemPathResult reportQueryItemPathResult = ((ColorButton.ColorButton)sender).Tag as ReportQueryItemPathResult;
            PerspectiveGraphCtrl      viewGraph = null;

            if (_graphWin != null)
            {
                viewGraph = _graphWin.Window as PerspectiveGraphCtrl;
                if (viewGraph != null)
                {
                    {
                        viewGraph.SelectedPath = viewGraph.FindPath(reportQueryItemPathResult.QueryItem);
                        DrawingHelper.SelectedPathItemUniqueID = reportQueryItemPathResult.UniqueID;
                        DrawingHelper.isEdgeSelected           = false;
                    }

                    viewGraph.BindData();

                    if (viewGraph.MsGalViewer != null)
                    {
                        viewGraph.MsGalViewer.Refresh();
                        viewGraph.MsGalViewer.ResumeLayout();
                        viewGraph.MsGalViewer.Update();
                    }
                }
            }

            ShowFile(reportQueryItemPathResult.FileName, reportQueryItemPathResult.Line, reportQueryItemPathResult.Column, reportQueryItemPathResult.Length);
        }
        public static IGraphPath Convert(ReportQueryItemResult queryItem, int columnNumber)
        {
            IGraphPath outputPath = new GraphPath();

            outputPath.DirectFlow = new List <GraphItem>();

            for (int i = 0; i < queryItem.Paths.Count; i++)
            {
                if (i == 0 || i == queryItem.Paths.Count - 1)
                {
                    ReportQueryItemPathResult item = queryItem.Paths[i];

                    GraphItem graphItem = (GraphItem)Convert(item, columnNumber, i == 0 ? 0 : 1);
                    graphItem.Parent = outputPath;

                    outputPath.DirectFlow.Add(graphItem);
                }
            }

            // To show two nodes in graph view if only one available
            if (outputPath.DirectFlow.Count == 1)
            {
                GraphItem graphItem = (GraphItem)Convert(queryItem.Paths[0], columnNumber, 1);
                graphItem.Parent = outputPath;

                outputPath.DirectFlow.Add(graphItem);
            }

            return(outputPath);
        }
Exemple #4
0
        public int CompareTo(object obj)
        {
            if (obj is IGraphItem)
            {
                IGraphItem compareItem = (IGraphItem)obj;

                if (compareItem.Name == Name &&
                    compareItem.Line == Line &&
                    compareItem.FileName == FileName &&
                    compareItem.Column == Column && string.Compare(((GraphItem)compareItem).ID, ID) == 0)
                {
                    return(0);
                }
                else
                {
                    return(1);
                }
            }
            else if (obj is ReportQueryItemPathResult)
            {
                ReportQueryItemPathResult compareItem = (ReportQueryItemPathResult)obj;

                if (compareItem.Name == Name &&
                    compareItem.FileName == FileName &&
                    compareItem.Line == Line &&
                    compareItem.Column == Column)
                {
                    return(0);
                }
                else
                {
                    return(1);
                }
            }
            else if (obj is CxViewerAction.CxVSWebService.CxWSPathNode)
            {
                CxViewerAction.CxVSWebService.CxWSPathNode compareItem = (CxViewerAction.CxVSWebService.CxWSPathNode)obj;

                if (compareItem.Name == Name &&
                    compareItem.FileName == FileName &&
                    compareItem.Line == Line &&
                    compareItem.Column == Column)
                {
                    return(0);
                }
                else
                {
                    return(1);
                }
            }

            return(1);
        }
        private static IGraphItem Convert(ReportQueryItemPathResult item, int columnNumber, int rowNumber)
        {
            IGraphItem outputItem = new GraphItem();

            outputItem.Name     = item.Name;
            outputItem.FileName = item.FileName;
            outputItem.Line     = item.Line;
            outputItem.Column   = item.Column;
            outputItem.Length   = item.Length;
            outputItem.GraphX   = columnNumber;
            outputItem.GraphY   = rowNumber;

            outputItem.QueryItem = item.QueryItem;

            return(outputItem);
        }
        private void btnPath_Click(object sender, EventArgs e)
        {
            ReportQueryItemPathResult reportQueryItemPathResult = ((ColorButton.ColorButton)sender).Tag as ReportQueryItemPathResult;

            ColorButton.ColorButton selected = ((ColorButton.ColorButton)sender);

            if (selectedBtnPath != null)
            {
                selectedBtnPath.IsSelected = false;
                selectedBtnPath.SetNormalState();
                selectedBtnPath.Invalidate();
            }

            selected.IsSelected = true;
            pnlPath.ScrollControlIntoView(selected);
            this.ScrollControlIntoView(selected);
            selectedBtnPath = selected;
        }
Exemple #7
0
        private void GraphClick(object sender, EventArgs e)
        {
            ReportQueryItemPathResult graphItem = ((ReportQueryItemPathResult)sender);
            PerspectiveGraphCtrl      viewGraph = null;

            if (_graphWin != null)
            {
                viewGraph = _graphWin.Window as PerspectiveGraphCtrl;
                if (viewGraph != null)
                {
                    viewGraph.SelectedPath = viewGraph.FindPath(graphItem.QueryItem);
                    DrawingHelper.SelectedPathItemUniqueID = graphItem.UniqueID;
                    DrawingHelper.isEdgeSelected           = false;
                    if (viewGraph.MsGalViewer != null)
                    {
                        viewGraph.MsGalViewer.Refresh();
                        viewGraph.MsGalViewer.ResumeLayout();
                        viewGraph.MsGalViewer.Update();
                    }
                    viewGraph.BindData();
                }
            }

            #region [Bind path view]
            if (_pathWin != null)
            {
                IPerspectivePathView viewPath = _pathWin.Window as IPerspectivePathView;
                viewPath.PathButtonClickHandler = PathButtonClick;

                viewPath.QueryItemResult = graphItem.QueryItem;

                viewPath.BindData(graphItem.NodeId);

                showView(_pathWin);
            }
            #endregion

            PerspectiveResultCtrl viewResult = _resultWin.Window as PerspectiveResultCtrl;
            viewResult.MarkRowAsSelected(graphItem.QueryItem.PathId);

            ShowFile(graphItem.FileName, graphItem.Line, graphItem.Column, graphItem.Length);
        }
Exemple #8
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;
            }
        }
        /// <summary>
        /// Bind object data to form controls. Generate path sequance
        /// </summary>
        public void BindData(int index)
        {
            pnlPath.Controls.Clear();
            pnlPath.Width = 200;

            if (_queryItemResult.Paths == null)
            {
                return;
            }

            pnlPath.RowCount = _queryItemResult.Paths.Count;

            System.IO.Stream file      = Assembly.GetExecutingAssembly().GetManifestResourceStream("CxViewerAction.Resources.down.gif");
            System.IO.Stream fileEmpty = Assembly.GetExecutingAssembly().GetManifestResourceStream("CxViewerAction.Resources.empty.gif");


            for (int i = 0; i < _queryItemResult.Paths.Count; i++)
            {
                int row = 2 * i;
                ReportQueryItemPathResult path = _queryItemResult.Paths[i];

                ColorButton.ColorButton btnPath = new ColorButton.ColorButton();
                btnPath.ButtonStyle      = ColorButton.ColorButton.ButtonStyles.Rectangle;
                btnPath.SmoothingQuality = ColorButton.ColorButton.SmoothingQualities.HighQuality;
                btnPath.HoverColorA      = Color.WhiteSmoke;
                btnPath.HoverColorB      = Color.WhiteSmoke;
                btnPath.Text             = path.Name;
                //btnPath.Width = 100;
                //btnPath.Height = 40;
                btnPath.Anchor = AnchorStyles.Top;
                btnPath.Tag    = path;
                btnPath.Click += btnPath_Click;
                btnPath.Click += _pathButtonClickHandler;
                if (index == path.NodeId)
                {
                    btnPath.IsSelected = true;
                    selectedBtnPath    = btnPath;
                }

                pnlPath.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 40F));
                pnlPath.Controls.Add(btnPath, 0, row);
                pnlPath.RowStyles[row].Height = 40F;

                PictureBox imgDown = new PictureBox();
                imgDown.Width    = 16;
                imgDown.Height   = 16;
                imgDown.SizeMode = PictureBoxSizeMode.StretchImage;
                // Add arrow to all buttons instead of last
                if (i != _queryItemResult.Paths.Count - 1)
                {
                    imgDown.Image = Image.FromStream(file);
                }
                else
                {
                    //imgDown.Image = Image.FromStream(fileEmpty);
                }
                imgDown.Anchor = AnchorStyles.Top;

                pnlPath.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 23F));
                pnlPath.Controls.Add(imgDown, 0, row + 1);
                pnlPath.RowStyles[row + 1].Height = 20F;
            }

            this.AutoScrollMinSize = new System.Drawing.Size(200, _queryItemResult.Paths.Count * 61);
            pnlPath.Refresh();
            if (selectedBtnPath != null)
            {
                selectedBtnPath.Select();
                pnlPath.ScrollControlIntoView(selectedBtnPath);
                this.ScrollControlIntoView(selectedBtnPath);
            }
        }