示例#1
0
        public void Display(TreeNode treeNode)
        {
            if (treeNode == null)
            {
                throw new ArgumentNullException(nameof(treeNode));
            }

            _treeNode        = treeNode;
            _testNode        = (TestNode)treeNode.Tag;
            _resultNode      = _model.GetResultForTest(_testNode.Id);
            _packageSettings = _model.GetPackageSettingsForTest(_testNode.Id);

            testResult.Text = _resultNode?.Outcome.ToString() ?? _testNode.RunState.ToString();
            testResult.Font = new Font(this.Font, FontStyle.Bold);
            if (_testNode.Type == "Project" || _testNode.Type == "Assembly")
            {
                TestName = Path.GetFileName(_testNode.Name);
            }
            else
            {
                TestName = _testNode.Name;
            }

            // Display each groupBox, for which there is data.
            // Boxes are displayed top-down at the vertical
            // offset
            int verticalOffset = packageGroupBox.Top;

            if (_packageSettings != null)
            {
                verticalOffset = DisplayPackageGroupBox(verticalOffset) + 4;
            }
            else
            {
                packageGroupBox.Hide();
            }

            // Test details are always shown
            verticalOffset = DisplayTestGroupBox(verticalOffset) + 4;

            if (_resultNode != null)
            {
                verticalOffset = DisplayResultGroupBox(verticalOffset) + 4;
            }
            else
            {
                resultGroupBox.Hide();
            }

            ClientSize = new Size(
                ClientSize.Width, verticalOffset);

            Rectangle screenArea = Screen.GetWorkingArea(this);

            Location = new Point(
                Location.X,
                Math.Max(0, Math.Min(Location.Y, screenArea.Bottom - Height)));

            Show();
        }