Visit(ProgressNode node, ArrayList unused, int unusedToo)
            {
                Tally += node.LinesRequiredMethod(_rawUi, _maxWidth);

                // We don't need to walk all the nodes, once it's larger than the max height, we should stop
                if (Tally > _maxHeight)
                {
                    return(false);
                }

                return(true);
            }
예제 #2
0
            Visit(ProgressNode node, ArrayList listWhereFound, int indexWhereFound)
            {
                if (node.Age >= _oldestSoFar)
                {
                    _oldestSoFar         = node.Age;
                    FoundNode            = node;
                    this.ListWhereFound  = listWhereFound;
                    this.IndexWhereFound = indexWhereFound;
                }

                return(true);
            }
예제 #3
0
            Visit(ProgressNode node, ArrayList listWhereFound, int indexWhereFound)
            {
                if (node.ActivityId == _idToFind && node.SourceId == _sourceIdToFind)
                {
                    this.FoundNode       = node;
                    this.ListWhereFound  = listWhereFound;
                    this.IndexWhereFound = indexWhereFound;
                    return(false);
                }

                return(true);
            }
예제 #4
0
 internal override bool Visit(ProgressNode node, ArrayList unused, int unusedToo)
 {
     PendingProgress.HeightTallyer tally = this;
     tally.Tally = tally.Tally + node.LinesRequiredMethod(this.rawUi, this.maxWidth);
     if (this.Tally <= this.maxHeight)
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
예제 #5
0
 internal override bool Visit(ProgressNode node, ArrayList listWhereFound, int indexWhereFound)
 {
     if (node.ActivityId != this.idToFind || node.SourceId != this.sourceIdToFind)
     {
         return(true);
     }
     else
     {
         this.FoundNode       = node;
         this.ListWhereFound  = listWhereFound;
         this.IndexWhereFound = indexWhereFound;
         return(false);
     }
 }
예제 #6
0
        private void EvictNode()
        {
            ArrayList    arrayLists   = null;
            int          num          = -1;
            ProgressNode progressNode = this.FindOldestLeafmostNode(out arrayLists, out num);

            if (progressNode != null)
            {
                this.RemoveNode(arrayLists, num);
                return;
            }
            else
            {
                this.RemoveNode(this.topLevelNodes, 0);
                return;
            }
        }
예제 #7
0
        RemoveNode(ArrayList nodes, int indexToRemove)
        {
#if DEBUG || ASSERTIONS_TRACE
            ProgressNode nodeToRemove = (ProgressNode)nodes[indexToRemove];

            Dbg.Assert(nodes != null, "can't remove nodes from a null list");
            Dbg.Assert(indexToRemove < nodes.Count, "index is not in list");
            Dbg.Assert(nodes[indexToRemove] != null, "no node at specified index");
            Dbg.Assert(nodeToRemove.Children == null || nodeToRemove.Children.Count == 0, "can't remove a node with children");
#endif

            nodes.RemoveAt(indexToRemove);
            --_nodeCount;

#if DEBUG || ASSERTIONS_ON
            Dbg.Assert(_nodeCount == this.CountNodes(), "We've lost track of the number of nodes in the tree");
#endif
        }
예제 #8
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);
        }
예제 #9
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);
        }
예제 #10
0
        RemoveNodeAndPromoteChildren(ArrayList nodes, int indexToRemove)
        {
            ProgressNode nodeToRemove = (ProgressNode)nodes[indexToRemove];

            Dbg.Assert(nodes != null, "can't remove nodes from a null list");
            Dbg.Assert(indexToRemove < nodes.Count, "index is not in list");
            Dbg.Assert(nodeToRemove != null, "no node at specified index");

            if (nodeToRemove == null)
            {
                return;
            }

            if (nodeToRemove.Children != null)
            {
                // promote the children.

                for (int i = 0; i < nodeToRemove.Children.Count; ++i)
                {
                    // unparent the children. If the children are ever updated again, they will be reparented.

                    ((ProgressNode)nodeToRemove.Children[i]).ParentActivityId = -1;
                }

                // add the children as siblings

                nodes.RemoveAt(indexToRemove);
                --_nodeCount;
                nodes.InsertRange(indexToRemove, nodeToRemove.Children);

#if DEBUG || ASSERTIONS_TRACE
                Dbg.Assert(_nodeCount == this.CountNodes(), "We've lost track of the number of nodes in the tree");
#endif
            }
            else
            {
                // nothing to promote

                RemoveNode(nodes, indexToRemove);
                return;
            }
        }
예제 #11
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);
        }
예제 #12
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;
		}
예제 #13
0
        private int LinesRequiredInFullStyleMethod(PSHostRawUserInterface rawUi, int maxWidth, bool isFullPlus)
        {
            int       count      = 1;
            string    str        = new string(' ', 5);
            ArrayList arrayLists = new ArrayList();

            if (!isFullPlus)
            {
                count++;
            }
            else
            {
                arrayLists.Clear();
                ProgressNode.RenderFullDescription(base.StatusDescription, str, maxWidth, rawUi, arrayLists, true);
                count = count + arrayLists.Count;
            }
            if (base.PercentComplete >= 0)
            {
                count++;
            }
            if (base.SecondsRemaining >= 0)
            {
                count++;
            }
            if (!string.IsNullOrEmpty(base.CurrentOperation))
            {
                if (!isFullPlus)
                {
                    count = count + 2;
                }
                else
                {
                    count++;
                    arrayLists.Clear();
                    ProgressNode.RenderFullDescription(base.CurrentOperation, str, maxWidth, rawUi, arrayLists, true);
                    count = count + arrayLists.Count;
                }
            }
            return(count);
        }
예제 #14
0
        Hide()
        {
            if (IsShowing)
            {
                if (ProgressNode.IsMinimalProgressRenderingEnabled())
                {
                    _rawui.CursorPosition = _location;
                    int maxWidth = PSStyle.Instance.Progress.MaxWidth;
                    if (maxWidth > _bufSize.Width)
                    {
                        maxWidth = _bufSize.Width;
                    }

                    for (int i = 0; i < _savedRegion.GetLength(1); i++)
                    {
                        if (i < _savedRegion.GetLength(1) - 1)
                        {
                            Console.Out.WriteLine(string.Empty.PadRight(maxWidth));
                        }
                        else
                        {
                            Console.Out.Write(string.Empty.PadRight(maxWidth));
                        }
                    }
                }
                else
                {
                    // It would be nice if we knew that the saved region could be kept for the next time Show is called, but alas,
                    // we have no way of knowing if the screen buffer has changed since we were hidden.  By "no good way" I mean that
                    // detecting a change would be at least as expensive as chucking the savedRegion and rebuilding it.  And it would
                    // be very complicated.

                    _rawui.SetBufferContents(_location, _savedRegion);
                }

                _savedRegion          = null;
                _rawui.CursorPosition = _savedCursor;
            }
        }
예제 #15
0
        EvictNode()
        {
            ArrayList listWhereFound  = null;
            int       indexWhereFound = -1;

            ProgressNode oldestNode = FindOldestLeafmostNode(out listWhereFound, out indexWhereFound);

            if (oldestNode == null)
            {
                // Well that's a surprise.  There's got to be at least one node there that's older than 0.

                Dbg.Assert(false, "Must be an old node in the tree somewhere");

                // We'll just pick the root node, then.

                RemoveNode(_topLevelNodes, 0);
            }
            else
            {
                RemoveNode(listWhereFound, indexWhereFound);
            }
        }
예제 #16
0
        FindOldestLeafmostNode(out ArrayList listWhereFound, out int indexWhereFound)
        {
            listWhereFound  = null;
            indexWhereFound = -1;

            ProgressNode result       = null;
            ArrayList    treeToSearch = _topLevelNodes;

            do
            {
                result = FindOldestLeafmostNodeHelper(treeToSearch, out listWhereFound, out indexWhereFound);
                if (result == null || result.Children == null || result.Children.Count == 0)
                {
                    break;
                }

                // search the subtree for the oldest child

                treeToSearch = result.Children;
            } while (true);

            return(result);
        }
예제 #17
0
            VisitNodes(ArrayList nodes, NodeVisitor v)
            {
                if (nodes == null)
                {
                    return;
                }

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

                    if (!v.Visit(node, nodes, i))
                    {
                        return;
                    }

                    if (node.Children != null)
                    {
                        VisitNodes(node.Children, v);
                    }
                }
            }
예제 #18
0
            Visit(ProgressNode node, ArrayList unused, int unusedToo)
            {
                Tally += node.LinesRequiredMethod(_rawUi, _maxWidth);

                // We don't need to walk all the nodes, once it's larger than the max height, we should stop
                if (Tally > _maxHeight)
                {
                    return false;
                }

                return true;
            }
예제 #19
0
 Visit(ProgressNode node, ArrayList unused, int unusedToo)
 {
     node.Age = Math.Min(node.Age + 1, Int32.MaxValue - 1);
     node.Style = ProgressNode.RenderStyle.FullPlus;
     return true;
 }
예제 #20
0
        Update(Int64 sourceId, ProgressRecord record)
        {
            Dbg.Assert(record != null, "record should not be null");

            do
            {
                if (record.ParentActivityId == record.ActivityId)
                {
                    // ignore malformed records.
                    break;
                }

                ArrayList listWhereFound = null;
                int indexWhereFound = -1;
                ProgressNode foundNode =
                    FindNodeById(sourceId, record.ActivityId, out listWhereFound, out indexWhereFound);

                if (foundNode != null)
                {
                    Dbg.Assert(listWhereFound != null, "node found, but list not identified");
                    Dbg.Assert(indexWhereFound >= 0, "node found, but index not returned");

                    if (record.RecordType == ProgressRecordType.Completed)
                    {
                        RemoveNodeAndPromoteChildren(listWhereFound, indexWhereFound);
                        break;
                    }
                    if (record.ParentActivityId == foundNode.ParentActivityId)
                    {
                        // record is an update to an existing activity. Copy the record data into the found node, and 
                        // reset the age of the node.

                        foundNode.Activity = record.Activity;
                        foundNode.StatusDescription = record.StatusDescription;
                        foundNode.CurrentOperation = record.CurrentOperation;
                        foundNode.PercentComplete = Math.Min(record.PercentComplete, 100);
                        foundNode.SecondsRemaining = record.SecondsRemaining;
                        foundNode.Age = 0;
                        break;
                    }
                    else
                    {
                        // The record's parent Id mismatches with that of the found node's.  We interpret 
                        // this to mean that the activity represented by the record (and the found node) is
                        // being "re-parented" elsewhere. So we remove the found node and treat the record
                        // as a new activity.

                        RemoveNodeAndPromoteChildren(listWhereFound, indexWhereFound);
                    }
                }

                // At this point, the record's activity is not in the tree. So we need to add it.

                if (record.RecordType == ProgressRecordType.Completed)
                {
                    // We don't track completion records that don't correspond to activities we're not
                    // already tracking.

                    break;
                }

                ProgressNode newNode = new ProgressNode(sourceId, record);

                // If we're adding a node, and we have no more space, then we need to pick a node to evict.

                while (_nodeCount >= maxNodeCount)
                {
                    EvictNode();
                }

                if (newNode.ParentActivityId >= 0)
                {
                    ProgressNode parentNode = FindNodeById(newNode.SourceId, newNode.ParentActivityId);
                    if (parentNode != null)
                    {
                        if (parentNode.Children == null)
                        {
                            parentNode.Children = new ArrayList();
                        }

                        AddNode(parentNode.Children, newNode);
                        break;
                    }

                    // The parent node is not in the tree. Make the new node's parent the root,
                    // and add it to the tree.  If the parent ever shows up, then the next time
                    // we receive a record for this activity, the parent id's won't match, and the 
                    // activity will be properly re-parented.

                    newNode.ParentActivityId = -1;
                }

                AddNode(_topLevelNodes, newNode);
            } while (false);

            // At this point the tree is up-to-date.  Make a pass to age all of the nodes

            AgeNodesAndResetStyle();
        }
예제 #21
0
			internal override bool Visit(ProgressNode node, ArrayList unused, int unusedToo)
			{
				node.Age = Math.Min(node.Age + 1, 0x7ffffffe);
				node.Style = ProgressNode.RenderStyle.FullPlus;
				return true;
			}
예제 #22
0
        Show(PendingProgress pendingProgress)
        {
            Dbg.Assert(pendingProgress != null, "pendingProgress may not be null");

            _bufSize = _rawui.BufferSize;

            // In order to keep from slicing any CJK double-cell characters that might be present in the screen buffer,
            // we use the full width of the buffer.

            int maxWidth  = _bufSize.Width;
            int maxHeight = Math.Max(5, _rawui.WindowSize.Height / 3);

            _content = pendingProgress.Render(maxWidth, maxHeight, _rawui);
            if (_content == null)
            {
                // There's nothing to show.

                Hide();
                _progressRegion = null;
                return;
            }

            BufferCell[,] newRegion;
            if (ProgressNode.IsMinimalProgressRenderingEnabled())
            {
                // Legacy progress rendering relies on a BufferCell which defines a character, foreground color, and background color
                // per cell.  This model doesn't work with ANSI escape sequences.  However, there is existing logic on rendering that
                // relies on the existence of the BufferCell to know if something has been rendered previously.  Here we are creating
                // an empty BufferCell, but using the second dimension to capture the number of rows so that we can clear that many
                // elsewhere in Hide().
                newRegion = new BufferCell[0, _content.Length];
            }
            else
            {
                newRegion = _rawui.NewBufferCellArray(_content, _ui.ProgressForegroundColor, _ui.ProgressBackgroundColor);
            }

            Dbg.Assert(newRegion != null, "NewBufferCellArray has failed!");

            if (_progressRegion == null)
            {
                // we've never shown this pane before.

                _progressRegion = newRegion;
                Show();
            }
            else
            {
                // We have shown the pane before. We have to be smart about when we restore the saved region to minimize
                // flicker. We need to decide if the new contents will change the dimensions of the progress pane
                // currently being shown.  If it will, then restore the saved region, and show the new one.  Otherwise,
                // just blast the new one on top of the last one shown.

                // We're only checking size, not content, as we assume that the content will always change upon receipt
                // of a new ProgressRecord.  That's not guaranteed, of course, but it's a good bet.  So checking content
                // would usually result in detection of a change, so why bother?

                bool sizeChanged =
                    (newRegion.GetLength(0) != _progressRegion.GetLength(0)) ||
                    (newRegion.GetLength(1) != _progressRegion.GetLength(1));

                _progressRegion = newRegion;

                if (sizeChanged)
                {
                    if (IsShowing)
                    {
                        Hide();
                    }

                    Show();
                }
                else
                {
                    if (ProgressNode.IsMinimalProgressRenderingEnabled())
                    {
                        WriteContent();
                    }
                    else
                    {
                        _rawui.SetBufferContents(_location, _progressRegion);
                    }
                }
            }
        }
예제 #23
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;
        }
예제 #24
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;
        }
예제 #25
0
 internal void Update(long sourceId, ProgressRecord record)
 {
     if (record.ParentActivityId != record.ActivityId)
     {
         ArrayList    arrayLists = null;
         int          num        = -1;
         ProgressNode activity   = this.FindNodeById(sourceId, record.ActivityId, out arrayLists, out num);
         if (activity != null)
         {
             if (record.RecordType != ProgressRecordType.Completed)
             {
                 if (record.ParentActivityId == activity.ParentActivityId)
                 {
                     activity.Activity          = record.Activity;
                     activity.StatusDescription = record.StatusDescription;
                     activity.CurrentOperation  = record.CurrentOperation;
                     activity.PercentComplete   = Math.Min(record.PercentComplete, 100);
                     activity.SecondsRemaining  = record.SecondsRemaining;
                     activity.Age = 0;
                     this.AgeNodesAndResetStyle();
                     return;
                 }
                 this.RemoveNodeAndPromoteChildren(arrayLists, num);
             }
             else
             {
                 this.RemoveNodeAndPromoteChildren(arrayLists, num);
                 this.AgeNodesAndResetStyle();
                 return;
             }
         }
         if (record.RecordType != ProgressRecordType.Completed)
         {
             ProgressNode progressNode = new ProgressNode(sourceId, record);
             while (this.nodeCount >= 128)
             {
                 this.EvictNode();
             }
             if (progressNode.ParentActivityId >= 0)
             {
                 ProgressNode arrayLists1 = this.FindNodeById(progressNode.SourceId, progressNode.ParentActivityId);
                 if (arrayLists1 != null)
                 {
                     if (arrayLists1.Children == null)
                     {
                         arrayLists1.Children = new ArrayList();
                     }
                     this.AddNode(arrayLists1.Children, progressNode);
                     this.AgeNodesAndResetStyle();
                     return;
                 }
                 progressNode.ParentActivityId = -1;
             }
             this.AddNode(this.topLevelNodes, progressNode);
         }
     }
     else
     {
         PendingProgress.tracer.WriteLine("Ignoring malformed record:", new object[0]);
         PendingProgress.tracer.WriteLine(record);
     }
     this.AgeNodesAndResetStyle();
 }
예제 #26
0
        Show()
        {
            if (!IsShowing)
            {
                // Get temporary reference to the progress region since it can be
                // changed at any time by a call to WriteProgress.
                BufferCell[,] tempProgressRegion = _progressRegion;
                if (tempProgressRegion == null)
                {
                    return;
                }

                // The location where we show ourselves is always relative to the screen buffer's current window position.

                int rows = tempProgressRegion.GetLength(0);
                int cols = tempProgressRegion.GetLength(1);

                if (ProgressNode.IsMinimalProgressRenderingEnabled())
                {
                    rows = _content.Length;
                    cols = PSStyle.Instance.Progress.MaxWidth;
                    if (cols > _bufSize.Width)
                    {
                        cols = _bufSize.Width;
                    }
                }

                _savedCursor = _rawui.CursorPosition;
                _location.X  = 0;

                if (!Platform.IsWindows || ProgressNode.IsMinimalProgressRenderingEnabled())
                {
                    _location.Y = _rawui.CursorPosition.Y;

                    // if cursor is not on left edge already move down one line
                    if (_rawui.CursorPosition.X != 0)
                    {
                        _location.Y++;
                        _rawui.CursorPosition = _location;
                    }

                    // if the cursor is at the bottom, create screen buffer space by scrolling
                    int scrollRows = rows - ((_rawui.BufferSize.Height - 1) - _location.Y);
                    if (scrollRows > 0)
                    {
                        // Scroll the console screen up by 'scrollRows'
                        var bottomLocation = _location;
                        bottomLocation.Y = _rawui.BufferSize.Height - 1;

                        _rawui.CursorPosition = bottomLocation;
                        for (int i = 0; i < scrollRows; i++)
                        {
                            Console.Out.Write('\n');
                        }

                        _location.Y    -= scrollRows;
                        _savedCursor.Y -= scrollRows;
                    }

                    // create cleared region to clear progress bar later
                    _savedRegion = tempProgressRegion;
                    if (ExperimentalFeature.IsEnabled(ExperimentalFeature.PSAnsiProgressFeatureName) && PSStyle.Instance.Progress.View != ProgressView.Minimal)
                    {
                        for (int row = 0; row < rows; row++)
                        {
                            for (int col = 0; col < cols; col++)
                            {
                                _savedRegion[row, col].Character = ' ';
                            }
                        }
                    }

                    // put cursor back to where output should be
                    _rawui.CursorPosition = _location;
                }
                else
                {
                    _location = _rawui.WindowPosition;

                    // We have to show the progress pane in the first column, as the screen buffer at any point might contain
                    // a CJK double-cell characters, which makes it impractical to try to find a position where the pane would
                    // not slice a character.  Column 0 is the only place where we know for sure we can place the pane.

                    _location.Y = Math.Min(_location.Y + 2, _bufSize.Height);

                    // Save off the current contents of the screen buffer in the region that we will occupy
                    _savedRegion =
                        _rawui.GetBufferContents(
                            new Rectangle(_location.X, _location.Y, _location.X + cols - 1, _location.Y + rows - 1));
                }

                if (ProgressNode.IsMinimalProgressRenderingEnabled())
                {
                    WriteContent();
                }
                else
                {
                    // replace the saved region in the screen buffer with our progress display
                    _rawui.SetBufferContents(_location, tempProgressRegion);
                }
            }
        }
예제 #27
0
		private void AddNode(ArrayList nodes, ProgressNode nodeToAdd)
		{
			nodes.Add(nodeToAdd);
			PendingProgress pendingProgress = this;
			pendingProgress.nodeCount = pendingProgress.nodeCount + 1;
		}
예제 #28
0
			internal abstract bool Visit(ProgressNode node, ArrayList listWhereFound, int indexWhereFound);
예제 #29
0
			internal override bool Visit(ProgressNode node, ArrayList unused, int unusedToo)
			{
				PendingProgress.HeightTallyer tally = this;
				tally.Tally = tally.Tally + node.LinesRequiredMethod(this.rawUi, this.maxWidth);
				if (this.Tally <= this.maxHeight)
				{
					return true;
				}
				else
				{
					return false;
				}
			}
예제 #30
0
			internal override bool Visit(ProgressNode node, ArrayList listWhereFound, int indexWhereFound)
			{
				if (node.Age >= this.oldestSoFar)
				{
					this.oldestSoFar = node.Age;
					this.FoundNode = node;
					this.ListWhereFound = listWhereFound;
					this.IndexWhereFound = indexWhereFound;
				}
				return true;
			}
예제 #31
0
			internal override bool Visit(ProgressNode node, ArrayList listWhereFound, int indexWhereFound)
			{
				if (node.ActivityId != this.idToFind || node.SourceId != this.sourceIdToFind)
				{
					return true;
				}
				else
				{
					this.FoundNode = node;
					this.ListWhereFound = listWhereFound;
					this.IndexWhereFound = indexWhereFound;
					return false;
				}
			}
예제 #32
0
 Visit(ProgressNode unused, ArrayList unusedToo, int unusedThree)
 {
     ++Count;
     return true;
 }
예제 #33
0
 Visit(ProgressNode node, ArrayList listWhereFound, int indexWhereFound);
예제 #34
0
 Visit(ProgressNode node, ArrayList listWhereFound, int indexWhereFound);
예제 #35
0
 Visit(ProgressNode node, ArrayList unused, int unusedToo)
 {
     node.Age   = Math.Min(node.Age + 1, Int32.MaxValue - 1);
     node.Style = ProgressNode.RenderStyle.FullPlus;
     return(true);
 }
예제 #36
0
 Visit(ProgressNode unused, ArrayList unusedToo, int unusedThree)
 {
     ++Count;
     return(true);
 }
예제 #37
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;
			}
		}
예제 #38
0
 internal override bool Visit(ProgressNode node, ArrayList unused, int unusedToo)
 {
     node.Age   = Math.Min(node.Age + 1, 0x7ffffffe);
     node.Style = ProgressNode.RenderStyle.FullPlus;
     return(true);
 }
예제 #39
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;
        }
예제 #40
0
        AddNode(ArrayList nodes, ProgressNode nodeToAdd)
        {
            nodes.Add(nodeToAdd);
            ++_nodeCount;

#if DEBUG || ASSERTIONS_TRACE
            Dbg.Assert(_nodeCount == this.CountNodes(), "We've lost track of the number of nodes in the tree");
            Dbg.Assert(_nodeCount <= maxNodeCount, "Too many nodes in tree!");
#endif
        }
예제 #41
0
		internal void Update(long sourceId, ProgressRecord record)
		{
			if (record.ParentActivityId != record.ActivityId)
			{
				ArrayList arrayLists = null;
				int num = -1;
				ProgressNode activity = this.FindNodeById(sourceId, record.ActivityId, out arrayLists, out num);
				if (activity != null)
				{
					if (record.RecordType != ProgressRecordType.Completed)
					{
						if (record.ParentActivityId == activity.ParentActivityId)
						{
							activity.Activity = record.Activity;
							activity.StatusDescription = record.StatusDescription;
							activity.CurrentOperation = record.CurrentOperation;
							activity.PercentComplete = Math.Min(record.PercentComplete, 100);
							activity.SecondsRemaining = record.SecondsRemaining;
							activity.Age = 0;
							this.AgeNodesAndResetStyle();
							return;
						}
						this.RemoveNodeAndPromoteChildren(arrayLists, num);
					}
					else
					{
						this.RemoveNodeAndPromoteChildren(arrayLists, num);
						this.AgeNodesAndResetStyle();
						return;
					}
				}
				if (record.RecordType != ProgressRecordType.Completed)
				{
					ProgressNode progressNode = new ProgressNode(sourceId, record);
					while (this.nodeCount >= 128)
					{
						this.EvictNode();
					}
					if (progressNode.ParentActivityId >= 0)
					{
						ProgressNode arrayLists1 = this.FindNodeById(progressNode.SourceId, progressNode.ParentActivityId);
						if (arrayLists1 != null)
						{
							if (arrayLists1.Children == null)
							{
								arrayLists1.Children = new ArrayList();
							}
							this.AddNode(arrayLists1.Children, progressNode);
							this.AgeNodesAndResetStyle();
							return;
						}
						progressNode.ParentActivityId = -1;
					}
					this.AddNode(this.topLevelNodes, progressNode);
				}
			}
			else
			{
				PendingProgress.tracer.WriteLine("Ignoring malformed record:", new object[0]);
				PendingProgress.tracer.WriteLine(record);
			}
			this.AgeNodesAndResetStyle();
		}
예제 #42
0
        Update(Int64 sourceId, ProgressRecord record)
        {
            Dbg.Assert(record != null, "record should not be null");

            do
            {
                if (record.ParentActivityId == record.ActivityId)
                {
                    // ignore malformed records.
                    break;
                }

                ArrayList    listWhereFound  = null;
                int          indexWhereFound = -1;
                ProgressNode foundNode       =
                    FindNodeById(sourceId, record.ActivityId, out listWhereFound, out indexWhereFound);

                if (foundNode != null)
                {
                    Dbg.Assert(listWhereFound != null, "node found, but list not identified");
                    Dbg.Assert(indexWhereFound >= 0, "node found, but index not returned");

                    if (record.RecordType == ProgressRecordType.Completed)
                    {
                        RemoveNodeAndPromoteChildren(listWhereFound, indexWhereFound);
                        break;
                    }
                    if (record.ParentActivityId == foundNode.ParentActivityId)
                    {
                        // record is an update to an existing activity. Copy the record data into the found node, and
                        // reset the age of the node.

                        foundNode.Activity          = record.Activity;
                        foundNode.StatusDescription = record.StatusDescription;
                        foundNode.CurrentOperation  = record.CurrentOperation;
                        foundNode.PercentComplete   = Math.Min(record.PercentComplete, 100);
                        foundNode.SecondsRemaining  = record.SecondsRemaining;
                        foundNode.Age = 0;
                        break;
                    }
                    else
                    {
                        // The record's parent Id mismatches with that of the found node's.  We interpret
                        // this to mean that the activity represented by the record (and the found node) is
                        // being "re-parented" elsewhere. So we remove the found node and treat the record
                        // as a new activity.

                        RemoveNodeAndPromoteChildren(listWhereFound, indexWhereFound);
                    }
                }

                // At this point, the record's activity is not in the tree. So we need to add it.

                if (record.RecordType == ProgressRecordType.Completed)
                {
                    // We don't track completion records that don't correspond to activities we're not
                    // already tracking.

                    break;
                }

                ProgressNode newNode = new ProgressNode(sourceId, record);

                // If we're adding a node, and we have no more space, then we need to pick a node to evict.

                while (_nodeCount >= maxNodeCount)
                {
                    EvictNode();
                }

                if (newNode.ParentActivityId >= 0)
                {
                    ProgressNode parentNode = FindNodeById(newNode.SourceId, newNode.ParentActivityId);
                    if (parentNode != null)
                    {
                        if (parentNode.Children == null)
                        {
                            parentNode.Children = new ArrayList();
                        }

                        AddNode(parentNode.Children, newNode);
                        break;
                    }

                    // The parent node is not in the tree. Make the new node's parent the root,
                    // and add it to the tree.  If the parent ever shows up, then the next time
                    // we receive a record for this activity, the parent id's won't match, and the
                    // activity will be properly re-parented.

                    newNode.ParentActivityId = -1;
                }

                AddNode(_topLevelNodes, newNode);
            } while (false);

            // At this point the tree is up-to-date.  Make a pass to age all of the nodes

            AgeNodesAndResetStyle();
        }
예제 #43
0
            Visit(ProgressNode node, ArrayList listWhereFound, int indexWhereFound)
            {
                if (node.Age >= _oldestSoFar)
                {
                    _oldestSoFar = node.Age;
                    FoundNode = node;
                    this.ListWhereFound = listWhereFound;
                    this.IndexWhereFound = indexWhereFound;
                }

                return true;
            }
예제 #44
0
 Visit(ProgressNode node, ArrayList listWhereFound, int indexWhereFound)
 {
     if (node.ActivityId == _idToFind && node.SourceId == _sourceIdToFind)
     {
         this.FoundNode = node;
         this.ListWhereFound = listWhereFound;
         this.IndexWhereFound = indexWhereFound;
         return false;
     }
     return true;
 }
예제 #45
0
 internal abstract bool Visit(ProgressNode node, ArrayList listWhereFound, int indexWhereFound);