Esempio n. 1
0
        internal int LinesRequiredMethod(PSHostRawUserInterface rawUi, int maxWidth)
        {
            ProgressNode.RenderStyle style = this.Style;
            switch (style)
            {
            case ProgressNode.RenderStyle.Invisible:
            {
                return(0);
            }

            case ProgressNode.RenderStyle.Minimal:
            {
                return(1);
            }

            case ProgressNode.RenderStyle.Compact:
            {
                return(this.LinesRequiredInCompactStyle);
            }

            case ProgressNode.RenderStyle.Full:
            {
                return(this.LinesRequiredInFullStyleMethod(rawUi, maxWidth, false));
            }

            case ProgressNode.RenderStyle.FullPlus:
            {
                return(this.LinesRequiredInFullStyleMethod(rawUi, maxWidth, true));
            }
            }
            return(0);
        }
Esempio n. 2
0
        AllNodesHaveGivenStyle(ArrayList nodes, ProgressNode.RenderStyle style)
        {
            if (nodes == null)
            {
                return(false);
            }

            for (int i = 0; i < nodes.Count; ++i)
            {
                ProgressNode node = (ProgressNode)nodes[i];
                Dbg.Assert(node != null, "nodes should not contain null elements");

                if (node.Style != style)
                {
                    return(false);
                }
                if (node.Children != null)
                {
                    if (!AllNodesHaveGivenStyle(node.Children, style))
                    {
                        return(false);
                    }
                }
            }

            return(true);
        }
Esempio n. 3
0
        CompressToFitHelper(
            PSHostRawUserInterface rawUi,
            int maxHeight,
            int maxWidth,
            out int nodesCompressed,
            ProgressNode.RenderStyle priorStyle,
            ProgressNode.RenderStyle newStyle)
        {
            nodesCompressed = 0;

            while (true)
            {
                ProgressNode node = FindOldestNodeOfGivenStyle(_topLevelNodes, oldestSoFar: 0, priorStyle);
                if (node == null)
                {
                    // We've compressed every node of the prior style already.

                    break;
                }

                node.Style = newStyle;
                ++nodesCompressed;
                if (TallyHeight(rawUi, maxHeight, maxWidth) <= maxHeight)
                {
                    return(true);
                }
            }

            // If we get all the way to here, then we've compressed all the nodes and we still don't fit.
            return(false);
        }
Esempio n. 4
0
 internal ProgressNode(long sourceId, ProgressRecord record) : base(record.ActivityId, record.Activity, record.StatusDescription)
 {
     this.Style            = ProgressNode.RenderStyle.FullPlus;
     base.ParentActivityId = record.ParentActivityId;
     base.CurrentOperation = record.CurrentOperation;
     base.PercentComplete  = Math.Min(record.PercentComplete, 100);
     base.SecondsRemaining = record.SecondsRemaining;
     base.RecordType       = record.RecordType;
     this.Style            = ProgressNode.RenderStyle.FullPlus;
     this.SourceId         = sourceId;
 }
Esempio n. 5
0
		internal ProgressNode(long sourceId, ProgressRecord record) : base(record.ActivityId, record.Activity, record.StatusDescription)
		{
			this.Style = ProgressNode.RenderStyle.FullPlus;
			base.ParentActivityId = record.ParentActivityId;
			base.CurrentOperation = record.CurrentOperation;
			base.PercentComplete = Math.Min(record.PercentComplete, 100);
			base.SecondsRemaining = record.SecondsRemaining;
			base.RecordType = record.RecordType;
			this.Style = ProgressNode.RenderStyle.FullPlus;
			this.SourceId = sourceId;
		}
Esempio n. 6
0
        CompressToFitHelper(
            PSHostRawUserInterface rawUi,
            int maxHeight,
            int maxWidth,
            out int nodesCompressed,
            ProgressNode.RenderStyle priorStyle,
            ProgressNode.RenderStyle newStyle)
        {
            nodesCompressed = 0;

            int age = 0;

            do
            {
                ProgressNode node = FindOldestNodeOfGivenStyle(_topLevelNodes, age, priorStyle);
                if (node == null)
                {
                    // We've compressed every node of the prior style already.

                    break;
                }

                node.Style = newStyle;
                ++nodesCompressed;
                if (TallyHeight(rawUi, maxHeight, maxWidth) <= maxHeight)
                {
                    return(true);
                }
            } while (true);

            // If we get all the way to here, then we've compressed all the nodes and we still don't fit.

#if DEBUG || ASSERTIONS_TRACE
            Dbg.Assert(
                nodesCompressed == CountNodes(),
                "We should have compressed every node in the tree.");
            Dbg.Assert(
                AllNodesHaveGivenStyle(_topLevelNodes, newStyle),
                "We should have compressed every node in the tree.");
#endif

            return(false);
        }
Esempio n. 7
0
        FindOldestNodeOfGivenStyle(ArrayList nodes, int oldestSoFar, ProgressNode.RenderStyle style)
        {
            if (nodes == null)
            {
                return(null);
            }

            ProgressNode found = null;

            for (int i = 0; i < nodes.Count; ++i)
            {
                ProgressNode node = (ProgressNode)nodes[i];
                Dbg.Assert(node != null, "nodes should not contain null elements");

                if (node.Age >= oldestSoFar && node.Style == style)
                {
                    found       = node;
                    oldestSoFar = found.Age;
                }

                if (node.Children != null)
                {
                    ProgressNode child = FindOldestNodeOfGivenStyle(node.Children, oldestSoFar, style);

                    if (child != null)
                    {
                        // In this universe, parents can be younger than their children. We found a child older than us.

                        found       = child;
                        oldestSoFar = found.Age;
                    }
                }
            }

#if DEBUG || ASSERTIONS_TRACE
            if (found != null)
            {
                Dbg.Assert(found.Style == style, "unexpected style");
                Dbg.Assert(found.Age >= oldestSoFar, "unexpected age");
            }
#endif
            return(found);
        }
Esempio n. 8
0
        internal void Render(ArrayList strCollection, int indentation, int maxWidth, PSHostRawUserInterface rawUI)
        {
            ProgressNode.RenderStyle style = this.Style;
            switch (style)
            {
            case ProgressNode.RenderStyle.Invisible:
            {
                return;
            }

            case ProgressNode.RenderStyle.Minimal:
            {
                this.RenderMinimal(strCollection, indentation, maxWidth, rawUI);
                return;
            }

            case ProgressNode.RenderStyle.Compact:
            {
                this.RenderCompact(strCollection, indentation, maxWidth, rawUI);
                return;
            }

            case ProgressNode.RenderStyle.Full:
            {
                this.RenderFull(strCollection, indentation, maxWidth, rawUI, false);
                return;
            }

            case ProgressNode.RenderStyle.FullPlus:
            {
                this.RenderFull(strCollection, indentation, maxWidth, rawUI, true);
                return;
            }

            default:
            {
                return;
            }
            }
        }
Esempio n. 9
0
        private bool CompressToFitHelper(PSHostRawUserInterface rawUi, int maxHeight, int maxWidth, out int nodesCompressed, ProgressNode.RenderStyle priorStyle, ProgressNode.RenderStyle newStyle)
        {
            nodesCompressed = 0;
            int num = 0;

            do
            {
                ProgressNode progressNode = this.FindOldestNodeOfGivenStyle(this.topLevelNodes, num, priorStyle);
                if (progressNode == null)
                {
                    return(false);
                }
                else
                {
                    progressNode.Style = newStyle;
                    nodesCompressed    = nodesCompressed + 1;
                }
            }while (this.TallyHeight(rawUi, maxHeight, maxWidth) > maxHeight);
            return(true);
        }
Esempio n. 10
0
 private ProgressNode FindOldestNodeOfGivenStyle(ArrayList nodes, int oldestSoFar, ProgressNode.RenderStyle style)
 {
     if (nodes != null)
     {
         ProgressNode progressNode = null;
         for (int i = 0; i < nodes.Count; i++)
         {
             ProgressNode item = (ProgressNode)nodes[i];
             if (item.Age >= oldestSoFar && item.Style == style)
             {
                 progressNode = item;
                 oldestSoFar  = progressNode.Age;
             }
             if (item.Children != null)
             {
                 ProgressNode progressNode1 = this.FindOldestNodeOfGivenStyle(item.Children, oldestSoFar, style);
                 if (progressNode1 != null)
                 {
                     progressNode = progressNode1;
                     oldestSoFar  = progressNode.Age;
                 }
             }
         }
         return(progressNode);
     }
     else
     {
         return(null);
     }
 }