Exemple #1
0
        public void HeightAndWidthPropertiesShouldBeSetAfterNewInstanceCreated()
        {
            var size = new Size(10, 20);

            Assert.AreEqual(20, size.Height);
            Assert.AreEqual(10, size.Width);
        }
Exemple #2
0
		protected BrowserTestCmdlet()
		{
			AutoClose = false;
			BrowserSize = new Size(0, 0);
			BrowserType = BrowserType.All;
			SlowMotion = false;
		}
        public PowershellAdapterPSHostRawUserInterface()
        {
            this.ForegroundColor = ConsoleColor.White;
            this.BackgroundColor = ConsoleColor.Black;

            this.bufferSize = new Size(DefaultConsoleWidth, DefaultConsoleHeight);
            this.windowSize = new Size(DefaultConsoleWidth, DefaultConsoleHeight);
        }
Exemple #4
0
        public void GetHashCodeIsImplemented()
        {
            var size = new Size(10, 20);

            int hash = size.GetHashCode();

            Assert.AreEqual(30, hash);
        }
Exemple #5
0
        public void ToStringShouldReturnWidthAndHeightSeparatedByCommad()
        {
            var size = new Size(10, 20);

            string result = size.ToString();

            Assert.AreEqual(result, "10,20");
        }
Exemple #6
0
        public void EqualityOperatorShouldReturnTrueForSizesWithSameHeightAndWidth()
        {
            var size1 = new Size(10, 20);
            var size2 = new Size(10, 20);

            bool result = size1 == size2;

            Assert.IsTrue(result);
        }
Exemple #7
0
        public void InequalityOperatorShouldReturnFalseForSizesWithSameHeightAndWidth()
        {
            var size1 = new Size(10, 20);
            var size2 = new Size(10, 20);

            bool result = size1 != size2;

            Assert.IsFalse(result);
        }
Exemple #8
0
        public void InequalityOperatorShouldReturnTrueForSizesWithDifferentHeightAndWidth(int width1, int height1, int width2, int height2)
        {
            var size1 = new Size(width1, height1);
            var size2 = new Size(width2, height2);

            bool result = size1 != size2;

            Assert.IsTrue(result);
        }
 public ScriptingHostRawUserInterface(ApplicationSettings settings)
 {
     Output = new OutputBuffer();
     backgroundColor = settings.BackgroundColor;
     foregroundColor = settings.ForegroundColor;
     cursorPosition = new Coordinates(0, 0);
     windowPosition = new Coordinates(0, 0);
     cursorSize = 1;
     bufferSize = new Size(settings.HostWidth, Int32.MaxValue);
     windowSize = bufferSize;
 }
Exemple #10
0
		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;
			}
		}
        public void RawUIBufferSize_ScriptingConsoleHas90MaximumVisibleColumns_ReturnsSizeWithWidthOf90()
        {
            CreateHostUserInterface();
            scriptingConsole.MaximumVisibleColumns = 90;

            Size actualSize = hostUI.RawUI.BufferSize;

            Size expectedSize = new Size() {
                Width = 90,
                Height = 0
            };

            Assert.AreEqual(expectedSize, actualSize);
        }
        private Size currentBufferSize;// = new Size(DefaultConsoleWidth, DefaultConsoleHeight);

        public CustomHostRawUserInterface(ConsoleView consoleView)
        {
            _consoleView = consoleView;
            currentBufferSize = new Size((int)_consoleView.Width, (int)_consoleView.Height);
        }
Exemple #13
0
		private bool CombineWriteMessage(WriteMessage writeMessage, Size bufferSize)
		{
			WriteMessage item;
			if (this.messageQueue.Count > 0)
			{
				item = this.messageQueue[this.messageQueue.Count - 1] as WriteMessage;
			}
			else
			{
				item = null;
			}
			WriteMessage writeMessage1 = item;
			if (writeMessage1 != null)
			{
				if (writeMessage1.BackgroundColor != writeMessage.BackgroundColor || writeMessage1.ForegroundColor != writeMessage.ForegroundColor || writeMessage1.Value.Length + writeMessage.Value.Length > bufferSize.Width)
				{
					return false;
				}
				else
				{
					writeMessage1.Append(writeMessage.Value);
					return true;
				}
			}
			else
			{
				return false;
			}
		}
Exemple #14
0
		private void FlushMessageQueue(Size bufferSize)
		{
			int num = -1;
			int num1 = 0;
			while (num1 < this.messageQueue.Count)
			{
				if (this.messageQueue[num1].MessageType != ClientMessageType.WriteLine)
				{
					num1++;
				}
				else
				{
					num = num1;
					break;
				}
			}
			if (num >= 0)
			{
				int num2 = num + 1;
				while (num2 < this.messageQueue.Count && num2 - num < 0x400 && this.messageQueue[num2].MessageType == ClientMessageType.WriteLine)
				{
					num2++;
				}
				if (num2 - num >= 128)
				{
					List<ClientMessage> clientMessages = new List<ClientMessage>();
					for (int i = 0; i < num; i++)
					{
						clientMessages.Add(this.messageQueue[i]);
					}
					WriteLineMessage item = (WriteLineMessage)this.messageQueue[num];
					object[] objArray = new object[1];
					objArray[0] = num2 - num;
					clientMessages.Add(new WriteLineMessage(item.ForegroundColor, item.BackgroundColor, string.Format(CultureInfo.CurrentCulture, Resources.ClientMessagesFlushed_Format, objArray)));
					for (int j = num2; j < this.messageQueue.Count; j++)
					{
						clientMessages.Add(this.messageQueue[j]);
					}
					this.messageQueue = clientMessages;
					return;
				}
				else
				{
					throw new InvalidOperationException(Resources.ErrorTooManyClientMessages);
				}
			}
			else
			{
				throw new InvalidOperationException(Resources.ErrorTooManyClientMessages);
			}
		}
Exemple #15
0
		public void Post(ClientMessage message, bool isInputMessage, bool isInternalMessage, Size bufferSize)
		{
			if (message.JsonSerializationLength <= PowwaSessionManager.Instance.JsonSerializer.MaxJsonLength)
			{
				bool flag = false;
				if (message.MessageType != ClientMessageType.Write)
				{
					if (message.MessageType == ClientMessageType.WriteLine)
					{
						flag = this.CombineWriteLineMessage((WriteLineMessage)message);
					}
				}
				else
				{
					flag = this.CombineWriteMessage((WriteMessage)message, bufferSize);
				}
				if (!flag)
				{
					if (this.messageQueue.Count >= 0x2800 && !isInputMessage && message.MessageType != ClientMessageType.CommandCompleted && !isInternalMessage)
					{
						this.messagesAvailable.Set();
						this.FlushMessageQueue(bufferSize);
					}
					this.messageQueue.Add(message);
				}
				if (message.MessageType != ClientMessageType.CommandCompleted)
				{
					if (this.messageQueue.Count != 1)
					{
						if (!this.messagesAvailableTimer.Enabled)
						{
							this.messagesAvailable.Set();
						}
					}
					else
					{
						this.messagesAvailableTimer.Stop();
						this.messagesAvailableTimer.Start();
					}
				}
				else
				{
					this.messagesAvailable.Set();
				}
				if (isInputMessage)
				{
					this.pendingInputMessage = message;
				}
				return;
			}
			else
			{
				this.messagesAvailable.Set();
				throw new InvalidOperationException(Resources.ErrorClientMessageTooLarge);
			}
		}
Exemple #16
0
        public void EqualsShouldReturnFalseForNonSizeObjectBeingCompared()
        {
            var size = new Size(10, 20);

            bool result = size.Equals(new Object());

            Assert.IsFalse(result);
        }
Exemple #17
0
		internal SetWindowSizeMessage(Size size) : base((ClientMessageType)113)
		{
			this.Size = size;
		}
 NewBufferCellArray(Size size, BufferCell contents)
 {
     return NewBufferCellArray(size.Width, size.Height, contents);
 }
Exemple #19
0
        public void EqualsShouldReturnFalseForSizesWithDifferentHeightAndWidth(int width1, int height1, int width2, int height2)
        {
            var size1 = new Size(width1, height1);
            var size2 = new Size(width2, height2);

            bool result = size1.Equals(size2);

            Assert.IsFalse(result);
        }
		static PowwaHostRawUserInterface()
		{
			PowwaHostRawUserInterface.DefaultBufferSizeDesktop = new Size(120, 0x12c);
			PowwaHostRawUserInterface.MaxBufferSizeDesktop = new Size(250, 0x3e7);
			PowwaHostRawUserInterface.MinBufferSizeDesktop = new Size(20, 14);
			PowwaHostRawUserInterface.DefaultWindowSizeDesktop = new Size(120, 35);
			PowwaHostRawUserInterface.MaxWindowSizeDesktop = new Size(250, 0x3e7);
			PowwaHostRawUserInterface.MinWindowSizeDesktop = new Size(20, 14);
			PowwaHostRawUserInterface.DefaultBufferSizeMobile = new Size(80, 100);
			PowwaHostRawUserInterface.MaxBufferSizeMobile = new Size(250, 0x3e7);
			PowwaHostRawUserInterface.MinBufferSizeMobile = new Size(20, 14);
			PowwaHostRawUserInterface.DefaultWindowSizeMobile = new Size(80, 25);
			PowwaHostRawUserInterface.MaxWindowSizeMobile = new Size(250, 0x3e7);
			PowwaHostRawUserInterface.MinWindowSizeMobile = new Size(20, 14);
		}
Exemple #21
0
        /// <summary>
        /// set the output buffer's size
        /// </summary>
        /// <param name="consoleHandle"></param>
        /// <param name="newSize"></param>
        /// <exception cref="HostException">
        /// If Win32's SetConsoleScreenBufferSize fails
        /// </exception>

        internal static void SetConsoleScreenBufferSize(ConsoleHandle consoleHandle, Size newSize)
        {
            Dbg.Assert(!consoleHandle.IsInvalid, "ConsoleHandle is not valid");
            Dbg.Assert(!consoleHandle.IsClosed, "ConsoleHandle is closed");

            COORD s;

            s.X = (short)newSize.Width;
            s.Y = (short)newSize.Height;

            bool result = NativeMethods.SetConsoleScreenBufferSize(consoleHandle.DangerousGetHandle(), s);

            if (result == false)
            {
                int err = Marshal.GetLastWin32Error();

                HostException e = CreateHostException(err, "SetConsoleScreenBufferSize",
                    ErrorCategory.ResourceUnavailable, ConsoleControlStrings.SetConsoleScreenBufferSizeExceptionTemplate);
                throw e;
            }
        }
Exemple #22
0
		internal SetBufferSizeMessage(Size size) : base((ClientMessageType)111)
		{
			this.Size = size;
		}
Exemple #23
0
		internal static void SetConsoleScreenBufferSize(SafeFileHandle consoleHandle, Size newSize)
		{
			ConsoleControl.COORD width;
            width.X = (short)newSize.Width;
			width.Y = (short)newSize.Height;
			bool flag = ConsoleControl.NativeMethods.SetConsoleScreenBufferSize(consoleHandle.DangerousGetHandle(), width);
			if (flag)
			{
				return;
			}
			else
			{
				int lastWin32Error = Marshal.GetLastWin32Error();
				HostException hostException = ConsoleControl.CreateHostException(lastWin32Error, "SetConsoleScreenBufferSize", ErrorCategory.ResourceUnavailable, ConsoleControlStrings.SetConsoleScreenBufferSizeExceptionTemplate);
				throw hostException;
			}
		}
		public PowwaHostRawUserInterface(ClientInfo clientInfo)
		{
			this.backgroundColor = ConsoleColor.DarkBlue;
			this.foregroundColor = ConsoleColor.White;
			this.windowTitle = string.Empty;
			if (!HtmlHelper.IsMobileBrowser(clientInfo.Agent))
			{
				this.bufferSize = PowwaHostRawUserInterface.DefaultBufferSizeDesktop;
				this.maxBufferSize = PowwaHostRawUserInterface.MaxBufferSizeDesktop;
				this.minBufferSize = PowwaHostRawUserInterface.MinBufferSizeDesktop;
				this.windowSize = PowwaHostRawUserInterface.DefaultWindowSizeDesktop;
				this.maxWindowSize = PowwaHostRawUserInterface.MaxWindowSizeDesktop;
				this.minWindowSize = PowwaHostRawUserInterface.MinWindowSizeDesktop;
				return;
			}
			else
			{
				this.bufferSize = PowwaHostRawUserInterface.DefaultBufferSizeMobile;
				this.maxBufferSize = PowwaHostRawUserInterface.MaxBufferSizeMobile;
				this.minBufferSize = PowwaHostRawUserInterface.MinBufferSizeMobile;
				this.windowSize = PowwaHostRawUserInterface.DefaultWindowSizeMobile;
				this.maxWindowSize = PowwaHostRawUserInterface.MaxWindowSizeMobile;
				this.minWindowSize = PowwaHostRawUserInterface.MinWindowSizeMobile;
				return;
			}
		}
 public BufferCell[,] NewBufferCellArray(Size size, BufferCell contents)
 {
     return this.NewBufferCellArray(size.Width, size.Height, contents);
 }
Exemple #26
0
 public BufferCell[,] NewBufferCellArray(Size size, BufferCell contents) { throw new NotImplementedException(); }
 public PSRemoteRawUserInterface()
 {
     BufferSize = new Size(80,25);
 }