Esempio n. 1
0
 public override void PositionWindow()
 {
     position = new Rect(Nexus.Self.position.x + (Nexus.Self.position.width - Nexus.Self.minSize.x) / 2, 120, Nexus.Self.minSize.x, TestMonitorHelpers.DetermineRectHeightBasedOnLinesInNodeDetails(Message) + 140);
     minSize  = maxSize = new Vector2(Nexus.Self.position.width, System.Convert.ToInt32(System.Math.Round(Nexus.Self.position.height / 1.25)));
 }
Esempio n. 2
0
 public override void PositionWindow()
 {
     position = new Rect(Nexus.Self.position.x + (Nexus.Self.position.width - Nexus.Self.minSize.x) / 2, Nexus.Self.position.height / 3, Nexus.Self.minSize.x, TestMonitorHelpers.DetermineRectHeightBasedOnLinesInNodeDetails(Message) + 140);
 }
Esempio n. 3
0
        private void OnGUI()
        {
            if (lastPassDetectedNoWebTestsSoDisplayDebugAsExample && testsAndTheirDependenciesList.Count == 0)
            {
                MapDependencies();
            }

            GUIStyle refButton = new GUIStyle(GUI.skin.button);

            refButton.normal.textColor = EditorGUIUtility.isProSkin ? Color.white : Color.black;
            Color defaultBgColor = GUI.backgroundColor;

            GUI.backgroundColor = Color.gray;
            if (GUI.Button(new Rect(0, 0, 75, 25), "Refresh", refButton))
            {
                inspectedNodeWindow           = -1;
                RenderedNodes                 = new List <DependencyNode>();
                testsAndTheirDependenciesList = new List <KeyValuePair <string, string[]> >();
                DependencyWebs                = new List <DependencyNode>();
                MapDependencies();
            }
            GUI.backgroundColor = defaultBgColor;

            Rect allSize = new Rect(0, 0, lastRenderX + infoBoxMinWidth, maxWindowY + infoBoxMinWidth);

            scroll = GUI.BeginScrollView(new Rect(0, 0, lastRenderX, lastRenderY), scroll, new Rect(0, 0, lastRenderX + infoBoxMinWidth, lastRenderY + infoBoxMinWidth), GUIStyle.none, GUIStyle.none);
            GUI.Box(allSize, string.Empty);

            for (int all = 0; all < DependencyWebs.Count; all++)
            {
                int            index      = 0;
                DependencyNode parentNode = DependencyWebs[all];
                if (!RenderedNodes.Where(x => x.TestName == parentNode.TestName).Any())
                {
                    RenderedNodes.Add(parentNode);
                    index = RenderedNodes.Count - 1;
                    float width   = DetermineRectWidthBasedOnLengthOfString(RenderedNodes[index].TestName);
                    Rect  newRect = originRect;
                    newRect.width             = width;
                    RenderedNodes[index].rect = GenerateNewNonOverlappingRectPositionForNewNode(newRect);
                }
                else
                {
                    index = RenderedNodes.FindIndex(a => a.TestName == parentNode.TestName);
                }

                //Create new node, or find existing one, and draw lines between this node and the dependency.
                List <KeyValuePair <DependencyNodeConnectionType, string> > LinkedNodeTestNames = RenderedNodes[index].Dependencies.ToList();
                for (int s = 0; s < LinkedNodeTestNames.Count; s++)
                {
                    if (LinkedNodeTestNames[s].Key == DependencyNodeConnectionType.Incoming)
                    {
                        string         testName = LinkedNodeTestNames[s].Value;
                        DependencyNode thisNode = new DependencyNode();

                        int indexChild = 0;

                        List <DependencyNode> match = RenderedNodes.Where(x => x.TestName == testName).ToList();
                        if (!match.Any())
                        {
                            thisNode.TestName     = testName;
                            thisNode.Dependencies = DependencyWebs.Where(x => x.TestName == thisNode.TestName).Select(x => x.Dependencies).Single();
                            RenderedNodes.Add(thisNode);
                            indexChild = RenderedNodes.Count - 1;
                            float width   = DetermineRectWidthBasedOnLengthOfString(RenderedNodes[indexChild].TestName);
                            Rect  newRect = RenderedNodes[all].rect;
                            newRect.width = width;
                            RenderedNodes[indexChild].rect = GenerateNewNonOverlappingRectPositionForNewNode(newRect);
                        }
                        else
                        {
                            indexChild = RenderedNodes.FindIndex(a => a.TestName == testName);
                        }

                        Handles.BeginGUI();
                        Handles.DrawBezier(RenderedNodes[index].rect.center, RenderedNodes[indexChild].rect.center, new Vector2(RenderedNodes[index].rect.xMax + 50f, RenderedNodes[index].rect.center.y), new Vector2(RenderedNodes[indexChild].rect.xMin - 50f, RenderedNodes[indexChild].rect.center.y), Color.cyan, null, 5f);
                        Handles.EndGUI();
                    }
                }
            }

            GUIStyle f = new GUIStyle(EditorStyles.foldout);

            f.richText = true;

            //Render each node window object.
            BeginWindows();
            for (int i = 0; i < RenderedNodes.Count; i++)
            {
                RenderedNodes[i].rect = GUI.Window(i, RenderedNodes[i].rect, WindowEvents, RenderedNodes[i].TestName);
            }
            EndWindows();

            string nodeDetails = inspectedNodeWindow >= 0 ? GetNodeDetails(RenderedNodes[inspectedNodeWindow]) : GetNodeDetails(new DependencyNode());
            float  boxHeight   = TestMonitorHelpers.DetermineRectHeightBasedOnLinesInNodeDetails(nodeDetails) + 50;
            float  boxWidth    = longestTestNameInInfoBox > infoBoxMinWidth ? longestTestNameInInfoBox : infoBoxMinWidth;

            bool overflowX = boxWidth > infoBoxMinWidth;

            //Account for size of scroll bar in scrollable space
            if (overflowX)
            {
                boxHeight += 40;
            }
            float scrollViewHeight = boxHeight < position.height ? boxHeight : position.height;
            bool  overflowY        = scrollViewHeight == position.height;

            if (overflowY)
            {
                boxWidth += 40;
            }

            GUI.EndScrollView();

            GUIStyle verticalScrollBar   = new GUIStyle(GUI.skin.verticalScrollbar);
            GUIStyle horizontalScrollBar = overflowX ? new GUIStyle(GUI.skin.horizontalScrollbar) : GUIStyle.none;

            infoBoxScroll = GUI.BeginScrollView(new Rect(position.width - infoBoxMinWidth, 0, infoBoxMinWidth, scrollViewHeight), infoBoxScroll, new Rect(new Vector2(position.width - (infoBoxMinWidth - 5), 4), new Vector2(boxWidth, boxHeight)), horizontalScrollBar, verticalScrollBar);

            //Display selected node's details in details panel.
            GUIStyle infoBox = new GUIStyle(GUI.skin.box);

            infoBox.richText          = true;
            infoBox.normal.background = MakeTextureFromColor(new Color(0.175f, 0.175f, 0.175f, 1f));
            infoBox.alignment         = TextAnchor.UpperLeft;
            GUI.Box(new Rect(new Vector2(position.width - (infoBoxMinWidth - 5), 4), new Vector2(boxWidth, boxHeight)), nodeDetails, infoBox);

            lastRenderX = position.width + infoBoxMinWidth;
            lastRenderY = position.height;

            GUI.EndScrollView();
        }