コード例 #1
0
ファイル: ProgressPane.cs プロジェクト: nickchal/pash
		internal void Hide()
		{
			if (this.IsShowing)
			{
				this.rawui.SetBufferContents(this.location, this.savedRegion);
				this.savedRegion = null;
			}
		}
コード例 #2
0
ファイル: ProgressPane.cs プロジェクト: nickchal/pash
		internal void Show()
		{
			BufferCell[,] bufferCellArray = this.progressRegion;
			if (bufferCellArray != null)
			{
				int length = bufferCellArray.GetLength(0);
				int num = bufferCellArray.GetLength(1);
				this.location = this.rawui.WindowPosition;
				this.location.X = 0;
				this.location.Y = Math.Min(this.location.Y + 2, this.bufSize.Height);
				this.savedRegion = this.rawui.GetBufferContents(new Rectangle(this.location.X, this.location.Y, this.location.X + num - 1, this.location.Y + length - 1));
				this.rawui.SetBufferContents(this.location, bufferCellArray);
				return;
			}
			else
			{
				return;
			}
		}
コード例 #3
0
ファイル: ProgressPane.cs プロジェクト: nickchal/pash
		internal void Show(PendingProgress pendingProgress)
		{
			bool flag;
			this.bufSize = this.rawui.BufferSize;
			int width = this.bufSize.Width;
			Size windowSize = this.rawui.WindowSize;
			int num = Math.Max(5, windowSize.Height / 3);
			string[] strArrays = pendingProgress.Render(width, num, this.rawui);
			if (strArrays != null)
			{
				BufferCell[,] bufferCellArray = this.rawui.NewBufferCellArray(strArrays, this.ui.ProgressForegroundColor, this.ui.ProgressBackgroundColor);
				if (this.progressRegion != null)
				{
					if (bufferCellArray.GetLength(0) != this.progressRegion.GetLength(0) || bufferCellArray.GetLength(1) != this.progressRegion.GetLength(1))
					{
						flag = true;
					}
					else
					{
						flag = false;
					}
					bool flag1 = flag;
					this.progressRegion = bufferCellArray;
					if (!flag1)
					{
						this.rawui.SetBufferContents(this.location, this.progressRegion);
						return;
					}
					else
					{
						if (this.IsShowing)
						{
							this.Hide();
						}
						this.Show();
						return;
					}
				}
				else
				{
					this.progressRegion = bufferCellArray;
					this.Show();
					return;
				}
			}
			else
			{
				this.Hide();
				this.progressRegion = null;
				return;
			}
		}
コード例 #4
0
 public override void SetBufferContents(Coordinates origin, BufferCell[,] contents)
 {
 }
コード例 #5
0
 public override void SetBufferContents(Coordinates origin, BufferCell[,] contents)
 {
     throw new NotImplementedException();
 }
コード例 #6
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);

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

#if UNIX
                _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);
                for (int i = 0; i < rows; i++)
                {
                    Console.Out.Write('\n');
                }
                if (scrollRows > 0)
                {
                    _location.Y    -= scrollRows;
                    _savedCursor.Y -= scrollRows;
                }

                //create cleared region to clear progress bar later
                _savedRegion = tempProgressRegion;
                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));
#endif

                // replace the saved region in the screen buffer with our progress display
                _rawui.SetBufferContents(_location, tempProgressRegion);
            }
        }
コード例 #7
0
        Show(PendingProgress pendingProgress)
        {
            Util.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);

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

                Hide();
                _progressRegion = null;
                return;
            }

            // NTRAID#Windows OS Bugs-1061752-2004/12/15-sburns should read a skin setting here...

            BufferCell[,] newRegion = _rawui.NewBufferCellArray(contents, _ui.ProgressForegroundColor, _ui.ProgressBackgroundColor);
            Util.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))
                    ? true : false;

                _progressRegion = newRegion;

                if (sizeChanged)
                {
                    if (IsShowing)
                    {
                        Hide();
                    }
                    Show();
                }
                else
                {
                    _rawui.SetBufferContents(_location, _progressRegion);
                }
            }
        }
コード例 #8
0
 public abstract void SetBufferContents(Coordinates origin, BufferCell[,] contents);
コード例 #9
0
 /// <summary>
 /// This functionality is not currently implemented. The call fails with an exception.
 /// </summary>
 /// <param name="origin">Unused</param>
 /// <param name="contents">Unused</param>
 public override void SetBufferContents(Coordinates origin, BufferCell[,] contents)
 {
     throw new NotImplementedException("The method or operation is not implemented.");
 }
コード例 #10
0
 /// <summary>
 /// This functionality is not currently implemented. The call fails with an exception.
 /// </summary>
 /// <param name="origin">Unused</param>
 /// <param name="contents">Unused</param>
 public override void SetBufferContents(Coordinates origin, BufferCell[,] contents)
 {
     throw new NotImplementedException("The SetBufferContents() method is not implemented by MyRawUserInterface.");
 }
コード例 #11
0
        private static IEnumerable <object> StreamCaptureImpl(TrailingSpaceBehavior behavior,
                                                              BufferCell[,] cells,
                                                              ConsoleColor fg, ConsoleColor bg,
                                                              int width, int y,
                                                              bool populate)
        {
            List <Line>        lines     = populate ? new List <Line>(y) : null;
            Capturer           automaton = new Capturer(behavior, width, fg, bg);
            List <PendingSpan> pending   = automaton.pending;

            yield return(new ConsoleLog(fg, bg, width,
                                        populate ? lines.AsReadOnly() : EmptyLineList));

            for (int line = 0; line != y; ++line)
            {
                for (int column = 0; column != width; ++column)
                {
                    BufferCell target = cells[line, column];
                    char       ch     = target.Character;
                    if (target.BufferCellType == BufferCellType.Complete || ch != '\0')
                    {
                        automaton.AddCharacter(ch,
                                               target.ForegroundColor, target.BackgroundColor);
                    }
                    else
                    {
                        automaton.AddCJK();
                    }
                }
                automaton.CompleteCurrentSpan();
                Line ln;
                /* This should not happen, but just being safe. */
                if (pending.Count == 0)
                {
                    ln = new Line(fg, bg, EmptySpanList);
                    if (populate)
                    {
                        lines.Add(ln);
                    }
                    yield return(ln);

                    yield return(null);

                    continue;
                }
                ConsoleColor fgLine, bgLine;
                automaton.ResolveLineColors(out fgLine, out bgLine);
                automaton.RemoveTrailingSpace(bgLine);
                List <Span> spans = populate ? new List <Span>(pending.Count) : null;
                ln = new Line(fgLine, bgLine, populate ? spans.AsReadOnly() : EmptySpanList);
                if (populate)
                {
                    lines.Add(ln);
                }
                yield return(ln);

                foreach (PendingSpan sp in pending)
                {
                    if (sp.Trimmed.Length == 0)
                    {
                        sp.Foreground = fgLine;
                    }
                    Span span = sp.ToSpan();
                    if (populate)
                    {
                        spans.Add(span);
                    }
                    yield return(span);
                }
                yield return(null);

                pending.Clear();
            }
        }
コード例 #12
0
 /// <summary>
 /// Set buffer contents.
 /// </summary>
 public override void SetBufferContents(Coordinates origin, BufferCell[,] contents)
 {
     _serverMethodExecutor.ExecuteVoidMethod(RemoteHostMethodId.SetBufferContents2, new object[] { origin, contents });
 }
コード例 #13
0
 public static void SetBufferContents(Coordinates origin, BufferCell[,] contents)
 {
 }
コード例 #14
0
 public override void SetBufferContents(Coordinates origin, BufferCell[,] contents)
 {
     ConsoleHandler.SetBufferContents(origin, contents);
 }
コード例 #15
0
 public abstract void SetBufferContents(Point origin, BufferCell[,] contents);
コード例 #16
0
 public override void SetBufferContents(Coordinates origin, BufferCell[,] contents)
 {
     throw new NotImplementedException("Not implemented because not needed");
 }