コード例 #1
0
 /// <summary>
 /// Writes a newline character (carriage return)
 /// to the output display of the host.
 /// </summary>
 public override void WriteLine()
 {
     PowerShellConsolePrinter.RemoveLines(new List <string>()
     {
         ConsolePromptDefinator
     });
     PowerShellConsolePrinter.WriteDelayedMessage("\n");
 }
コード例 #2
0
 /// <summary>
 /// Writes a line of characters to the output display of the host
 /// and appends a newline character(carriage return).
 /// </summary>
 /// <param name="value">The line to be written.</param>
 public override void WriteLine(string value)
 {
     if (!m_SkipRemoveLines)
     {
         PowerShellConsolePrinter.RemoveLines(new List <string>()
         {
             ConsolePromptDefinator
         });
     }
     PowerShellConsolePrinter.WriteDelayedMessage(value + "\n");
 }
コード例 #3
0
 /// <summary>
 /// Basic script execution routine. Any runtime exceptions are
 /// caught and passed back to the Windows PowerShell engine to
 /// display.
 /// </summary>
 /// <param name="cmd">Script to run.</param>
 private void Execute(string cmd)
 {
     try
     {
         // Execute the command with no input.
         this.executeHelper(cmd, null);
     }
     catch (RuntimeException rte)
     {
         this.ReportException(rte);
     }
     PowerShellConsolePrinter.WriteDelayedMessage(((MyHostUserInterface)this.myHost.UI).ConsolePromptDefinator);
 }
コード例 #4
0
 /// <summary>
 /// Writes a progress report to the output display of the host.
 /// Wrinting a progress report is not required for the cmdlet to
 /// work so it is better to do nothing instead of throwing an
 /// exception.
 /// </summary>
 /// <param name="sourceId">Unique identifier of the source of the record. </param>
 /// <param name="record">A ProgressReport object.</param>
 public override void WriteProgress(long sourceId, ProgressRecord record)
 {
     if (PowerShellConsolePrinter.ActivityProgressbar != null)
     {
         PowerShellConsolePrinter.SetPanelStatus(record.Activity, PS_Console_Test.Helpers.Status.InProgress);
         PowerShellConsolePrinter.ActivityProgressbar.StepProgress(record.PercentComplete);
         PowerShellConsolePrinter.WriteDelayedMessage(record.CurrentOperation);
     }
     if (record.PercentComplete >= 99)
     {
         PowerShellConsolePrinter.SetPanelStatus(record.Activity + " complete!", PS_Console_Test.Helpers.Status.Success);
     }
 }
コード例 #5
0
        /// <summary>
        /// Writes a line of characters to the output display of the host
        /// with foreground and background colors and appends a newline (carriage return).
        /// </summary>
        /// <param name="foregroundColor">The forground color of the display. </param>
        /// <param name="backgroundColor">The background color of the display. </param>
        /// <param name="value">The line to be written.</param>
        public override void WriteLine(
            ConsoleColor foregroundColor,
            ConsoleColor backgroundColor,
            string value)
        {
            ConsoleColor oldFg = ColorExtension.GetConsoleColor(PowerShellConsolePrinter.TextColor);
            ConsoleColor oldBg = ColorExtension.GetConsoleColor(PowerShellConsolePrinter.BackgroundColor);

            PowerShellConsolePrinter.RemoveLines(new List <string>()
            {
                ConsolePromptDefinator
            });
            PowerShellConsolePrinter.TextColor       = ColorExtension.GetColor(foregroundColor);
            PowerShellConsolePrinter.BackgroundColor = ColorExtension.GetColor(backgroundColor);
            PowerShellConsolePrinter.WriteDelayedMessage(value + "\n");
            PowerShellConsolePrinter.TextColor       = ColorExtension.GetColor(oldFg);
            PowerShellConsolePrinter.BackgroundColor = ColorExtension.GetColor(oldBg);
        }
コード例 #6
0
        /// <summary>
        /// Reads a pressed, released, or pressed and released keystroke
        /// from the keyboard device, blocking processing until a keystroke
        /// is typed that matches the specified keystroke options. This
        /// functionality is not implemented. The call fails with an
        /// exception.
        /// </summary>
        /// <param name="options">A bit mask of the options to be used when
        /// reading from the keyboard. </param>
        /// <returns>KeyInfo</returns>
        public override KeyInfo ReadKey(ReadKeyOptions options)
        {
            PowerShellConsolePrinter.WaitForKey = true;
            KeyInfo keyInfo = new KeyInfo();

            PowerShellConsolePrinter.KeyPressedHandler += (object sender, System.Windows.Forms.KeyPressEventArgs e) => {
                if (!options.HasFlag(ReadKeyOptions.NoEcho))
                {
                    PowerShellConsolePrinter.WriteDelayedMessage((e.KeyChar).ToString());
                }
                keyInfo.KeyDown   = true;
                keyInfo.Character = e.KeyChar;
            };
            while (!keyInfo.KeyDown)
            {
                //Wait for the key
            }
            return(keyInfo);
            //throw new NotImplementedException("The ReadKey() method is not implemented by MyRawUserInterface.");
        }