本文整理汇总了C#中System.Management.Automation.Host.Coordinates类的典型用法代码示例。如果您正苦于以下问题:C# Coordinates类的具体用法?C# Coordinates怎么用?C# Coordinates使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Coordinates类属于System.Management.Automation.Host命名空间,在下文中一共展示了Coordinates类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PowerShellRawUI
public PowerShellRawUI(PowerShellConsoleModel model)
{
_model = model;
ForegroundColor = ConsoleColor.White;
BackgroundColor = ConsoleColor.Black;
CursorPosition = new Coordinates(0, 0);
}
示例2: ScriptingHostRawUserInterface
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;
}
示例3: ProgressPane
internal ProgressPane(ConsoleHostUserInterface ui)
{
this.location = new Coordinates(0, 0);
if (ui != null)
{
this.ui = ui;
this.rawui = ui.RawUI;
return;
}
else
{
throw new ArgumentNullException("ui");
}
}
示例4: BlankAtCursor
/// <summary>
/// Blank out at and move rawui.CursorPosition to <paramref name="cursorPosition"/>
/// </summary>
/// <param name="cursorPosition">Position to blank out</param>
private void BlankAtCursor(Coordinates cursorPosition)
{
_rawui.CursorPosition = cursorPosition;
WriteToConsole(" ", true);
_rawui.CursorPosition = cursorPosition;
}
示例5: WritePrintToken
/// <summary>
///
/// Handle writing print token with proper cursor adjustment for ReadLineSafe
///
/// </summary>
/// <param name="printToken">
///
/// token output for each char input. It must be a one-char string
///
/// </param>
/// <param name="originalCursorPosition">
///
/// it is the cursor position where ReadLineSafe begins
///
/// </param>
/// <exception cref="HostException">
///
/// If obtaining information about the buffer failed
/// OR
/// Win32's SetConsoleCursorPosition failed
///
/// </exception>
private void WritePrintToken(
string printToken,
ref Coordinates originalCursorPosition)
{
Dbg.Assert(!string.IsNullOrEmpty(printToken),
"Calling WritePrintToken with printToken being null or empty");
Dbg.Assert(printToken.Length == 1,
"Calling WritePrintToken with printToken's Length being " + printToken.Length);
Size consoleBufferSize = _rawui.BufferSize;
Coordinates currentCursorPosition = _rawui.CursorPosition;
// if the cursor is currently at the lower right corner, this write will cause the screen buffer to
// scroll up. So, it is necessary to adjust the original cursor position one row up.
if (currentCursorPosition.Y >= consoleBufferSize.Height - 1 && // last row
currentCursorPosition.X >= consoleBufferSize.Width - 1) // last column
{
if (originalCursorPosition.Y > 0)
{
originalCursorPosition.Y--;
}
}
WriteToConsole(printToken, false);
}
示例6: WriteBackSpace
/// <summary>
///
/// Handle backspace with proper cursor adjustment for ReadLineSafe
///
/// </summary>
/// <param name="originalCursorPosition">
///
/// it is the cursor position where ReadLineSafe begins
///
/// </param>
/// <exception cref="HostException">
///
/// If obtaining information about the buffer failed
/// OR
/// Win32's SetConsoleCursorPosition failed
///
/// </exception>
private void WriteBackSpace(Coordinates originalCursorPosition)
{
Coordinates cursorPosition = _rawui.CursorPosition;
if (cursorPosition == originalCursorPosition)
{
// at originalCursorPosition, don't move
return;
}
if (cursorPosition.X == 0)
{
if (cursorPosition.Y <= originalCursorPosition.Y)
{
return;
}
// BufferSize.Width is 1 larger than cursor position
cursorPosition.X = _rawui.BufferSize.Width - 1;
cursorPosition.Y--;
BlankAtCursor(cursorPosition);
}
else if (cursorPosition.X > 0)
{
cursorPosition.X--;
BlankAtCursor(cursorPosition);
}
// do nothing if cursorPosition.X is left of screen
}
示例7: SetBufferContents
public override void SetBufferContents(Coordinates origin, BufferCell[,] contents)
{
throw new NotSupportedException(Resources.PSHostRawUserInterfaceSetBufferContentsNotSupported);
}
示例8: SetBufferContents
/// <summary>
/// Copies a given character to a region of the screen buffer based
/// on the coordinates of the region. This method is not implemented.
/// The call fails with an exception.
/// </summary>
/// <param name="origin">The coordnates of the region.</param>
/// <param name="contents">A BufferCell structure that defines the fill character.</param>
public override void SetBufferContents(Coordinates origin, BufferCell[,] contents)
{
throw new NotImplementedException("The SetBufferContents() method is not implemented by MyRawUserInterface.");
}
示例9: ScrollBufferContents
public override void ScrollBufferContents(Rectangle source, Coordinates destination, Rectangle clip, BufferCell fill)
{
// TODO: REIMPLEMENT PSHostRawUserInterface.ScrollBufferContents(Rectangle source, Coordinates destination, Rectangle clip, BufferCell fill)
throw new NotImplementedException("The ScrollBufferContents method is not (yet) implemented!");
//if (_control.Dispatcher.CheckAccess())
//{
// _control.ScrollBufferContents(source, destination, clip, fill);
//}
//else
//{
// _control.Dispatcher.BeginInvoke(DispatcherPriority.Normal, (Action)delegate
// {
// _control.ScrollBufferContents(source, destination, clip, fill);
// });
//}
}
示例10: Complete
/// <summary>
/// Executes the native command once all of the input has been gathered.
/// </summary>
/// <exception cref="PipelineStoppedException">
/// The pipeline is stopping
/// </exception>
/// <exception cref="ApplicationFailedException">
/// The native command could not be run
/// </exception>
internal override void Complete()
{
// Indicate whether we need to consider redirecting the output/error of the current native command.
// Usually a windows program which is the last command in a pipeline can be executed as 'background' -- we don't need to capture its output/error streams.
bool background;
// Figure out if we're going to run this process "standalone" i.e. without
// redirecting anything. This is a bit tricky as we always run redirected so
// we have to see if the redirection is actually being done at the topmost level or not.
//Calculate if input and output are redirected.
bool redirectOutput;
bool redirectError;
bool redirectInput;
CalculateIORedirection(out redirectOutput, out redirectError, out redirectInput);
// Find out if it's the only command in the pipeline.
bool soloCommand = this.Command.MyInvocation.PipelineLength == 1;
// Get the start info for the process.
ProcessStartInfo startInfo = GetProcessStartInfo(redirectOutput, redirectError, redirectInput, soloCommand);
if (this.Command.Context.CurrentPipelineStopping)
{
throw new PipelineStoppedException();
}
// If a problem occurred in running the program, this exception will
// be set and should be rethrown at the end of the try/catch block...
Exception exceptionToRethrow = null;
Host.Coordinates startPosition = new Host.Coordinates();
bool scrapeHostOutput = false;
try
{
// If this process is being run standalone, tell the host, which might want
// to save off the window title or other such state as might be tweaked by
// the native process
if (!redirectOutput)
{
this.Command.Context.EngineHostInterface.NotifyBeginApplication();
// Also, store the Raw UI coordinates so that we can scrape the screen after
// if we are transcribing.
try
{
if (this.Command.Context.EngineHostInterface.UI.IsTranscribing)
{
scrapeHostOutput = true;
startPosition = this.Command.Context.EngineHostInterface.UI.RawUI.CursorPosition;
startPosition.X = 0;
}
}
catch (Host.HostException)
{
// The host doesn't support scraping via its RawUI interface
scrapeHostOutput = false;
}
}
//Start the process. If stop has been called, throw exception.
//Note: if StopProcessing is called which this method has the lock,
//Stop thread will wait for nativeProcess to start.
//If StopProcessing gets the lock first, then it will set the stopped
//flag and this method will throw PipelineStoppedException when it gets
//the lock.
lock (_sync)
{
if (_stopped)
{
throw new PipelineStoppedException();
}
try
{
_nativeProcess = new Process();
_nativeProcess.StartInfo = startInfo;
_nativeProcess.Start();
}
catch (Win32Exception)
{
#if CORECLR // Shell doesn't exist on OneCore, so a file cannot be associated with an executable,
// and we cannot run an executable as 'ShellExecute' either.
throw;
#else
// See if there is a file association for this command. If so
// then we'll use that. If there's no file association, then
// try shell execute...
string executable = FindExecutable(startInfo.FileName);
bool notDone = true;
//.........这里部分代码省略.........
示例11: SetBufferContents
public abstract void SetBufferContents(Coordinates origin, BufferCell[,] contents);
示例12: ScrollBufferContents
/// <summary>
/// This functionality is not currently implemented. The call fails with an exception.
/// </summary>
/// <param name="source">Unused</param>
/// <param name="destination">Unused</param>
/// <param name="clip">Unused</param>
/// <param name="fill">Unused</param>
public override void ScrollBufferContents(Rectangle source, Coordinates destination, Rectangle clip, BufferCell fill)
{
throw new NotImplementedException("The method or operation is not implemented.");
}
示例13: SetBufferContents
/// <summary>
/// Set buffer contents.
/// </summary>
public override void SetBufferContents(Coordinates origin, BufferCell[,] contents)
{
_serverMethodExecutor.ExecuteVoidMethod(RemoteHostMethodId.SetBufferContents2, new object[] { origin, contents });
}
示例14: ScrollBufferContents
public abstract void ScrollBufferContents(Rectangle source, Coordinates destination, Rectangle clip, BufferCell fill);
示例15: ScrollBufferContents
/// <summary>
/// Scroll buffer contents.
/// </summary>
public override void ScrollBufferContents(Rectangle source, Coordinates destination, Rectangle clip, BufferCell fill)
{
_serverMethodExecutor.ExecuteVoidMethod(RemoteHostMethodId.ScrollBufferContents, new object[] { source, destination, clip, fill });
}