protected override void EndProcessing() { object SendObj = null; if (FullList.Count == 0) { return; //nothing to do. } SendObj = new ArrayList(); ((ArrayList)SendObj).AddRange(FullList); // XxX Verify - Might be FUllList.BaseObject //////////////////////////////////////////////////////////////// // Display List SynchronizedInvoke.InvokeIfRequired(PSHostCallBack.ParentControl, () => PSHostCallBack.ParentControl.FinishedGridEdit(SendObj, FullList.Count, this.HeaderWidths)); List <PSObject> result = null; if (PSHostCallBack.ParentControl.WaitForResultEdit(out result)) { Trace.TraceInformation("Out-GridEdit() Complete Count: {0}", result.Count); foreach (var Item in result) { base.WriteObject(Item); } } // Cleanup base.StopProcessing(); SynchronizedInvoke.InvokeIfRequired(PSHostCallBack.ParentControl, () => PSHostCallBack.ParentControl.EndGridEdit()); base.EndProcessing(); }
protected override void EndProcessing() { base.EndProcessing(); //////////////////////////////////////////////////////////////// // Display List SynchronizedInvoke.InvokeIfRequired(PSHostCallBack.ParentControl, () => PSHostCallBack.ParentControl.DisplayMDTView( RootNode, base.InvokeCommand, this.OutputMode != OutputModeOption.None, this.OutputMode == OutputModeOption.Multiple, FileType)); if (this.OutputMode == OutputModeOption.None) { return; // Done do not wait for output... } List <PSObject> selectedItems = null; if (PSHostCallBack.ParentControl.WaitForResultMDT(out selectedItems)) { if (selectedItems != null && selectedItems.Count > 0 && this.OutputMode != OutputModeOption.None) { Trace.TraceInformation("Out-GridView() Complete Count: {0}", selectedItems.Count); foreach (PSObject Item in selectedItems) { base.WriteObject(Item); } } } // Cleanup base.StopProcessing(); SynchronizedInvoke.InvokeIfRequired(PSHostCallBack.ParentControl, () => PSHostCallBack.ParentControl.EndMDTView()); }
/// <summary> /// Necessary only for "Clear-Host" /// </summary> public override void SetBufferContents(Rectangle rectangle, BufferCell fill) { if (fill.BufferCellType == BufferCellType.Complete && fill.Character == ' ' && rectangle == (new Rectangle(-1, -1, -1, -1))) { Trace.WriteLine("SetBufferContents-->ClearScreen", "PSHostRawUserInterface"); SynchronizedInvoke.InvokeIfRequired(this.Parent, () => this.Parent.ClearScreen()); } else { throw new NotImplementedException("The method or operation is not implemented."); } }
public void WriteExCommon(System.Drawing.Color foregroundColor, System.Drawing.Color backgroundColor, string category, string value) { if (foregroundColor == System.Drawing.Color.Black && backgroundColor == System.Drawing.Color.Black) { // Special override for "CLS" scenario. this.WriteExCommon(Parent.ForeColor, Parent.BackColor, category, value); } else if (value.Length > 0) { SynchronizedInvoke.InvokeIfRequired(this.Parent, () => Parent.Write(foregroundColor, backgroundColor, value)); } }
/// <summary> /// This API 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. /// </summary> /// <param name="options">Options, such as IncludeKeyDown, used when reading the keyboard.</param> public override KeyInfo ReadKey(ReadKeyOptions options) { Trace.WriteLine(string.Format("ReadKey({0})", options.ToString()), "PSHostRawUserInterface"); SynchronizedInvoke.InvokeIfRequired(this.Parent, () => this.Parent.ReadKey(options)); PSObject result = null; if (this.Parent.WaitForResult(out result)) { return((KeyInfo)result.BaseObject); } return(new KeyInfo()); }
public override System.Security.SecureString ReadLineAsSecureString() { DebugWriteLine("ReadLineAsSecureString() Start"); SynchronizedInvoke.InvokeIfRequired(this.Parent, () => this.Parent.ReadLine('*')); PSObject result = null; if (this.Parent.WaitForResult(out result)) { DebugWriteLine("ReadLineAsSecureString() Complete"); return((System.Security.SecureString)result.BaseObject); } DebugWriteLine("ReadLineAsSecureString() Empty"); return(new System.Security.SecureString()); }
public override string ReadLine() { DebugWriteLine("ReadLine()"); SynchronizedInvoke.InvokeIfRequired(this.Parent, () => this.Parent.ReadLine('\0')); PSObject result = null; if (this.Parent.WaitForResult(out result)) { DebugWriteLine("ReadLine() Complete"); return((string)result.BaseObject); } DebugWriteLine("ReadLine() Empty"); return(""); }
/// <summary> /// Provides a set of choices that enable the user to choose a single option from a set of options. /// </summary> /// <param name="caption">Text that proceeds (a title) the choices.</param> /// <param name="message">A message that describes the choice.</param> /// <param name="choices">A collection of ChoiceDescription objects that describes each choice.</param> /// <param name="defaultChoice">The index of the label in the Choices parameter collection. To indicate no default choice, set to -1.</param> public override int PromptForChoice(string caption, string message, System.Collections.ObjectModel.Collection <ChoiceDescription> choices, int defaultChoice) { DebugWriteLine("PromptForChoice(caption:{0},message:{1})", caption, message); SynchronizedInvoke.InvokeIfRequired(this.Parent, () => this.Parent.PromptForChoice(caption, message, choices, defaultChoice)); PSObject result = null; if (this.Parent.WaitForResult(out result)) { DebugWriteLine("PromptForChoice() Complete"); return((int)result.BaseObject); } DebugWriteLine("PromptForChoice() Empty"); return(-1); }
/// <summary> /// Prompts the user for input. /// </summary> /// <param name="caption">The caption or title of the prompt.</param> /// <param name="message">The text of the prompt.</param> /// <param name="descriptions">A collection of FieldDescription objects that /// describe each field of the prompt.</param> public override Dictionary <string, PSObject> Prompt(string caption, string message, System.Collections.ObjectModel.Collection <FieldDescription> descriptions) { DebugWriteLine("Prompt(caption:{0},message:{1},Description count:{2})", caption, message, descriptions.Count); SynchronizedInvoke.InvokeIfRequired(this.Parent, () => this.Parent.Prompt(caption, message, descriptions)); Dictionary <string, PSObject> result = null; if (this.Parent.WaitForResult(out result)) { DebugWriteLine("Prompt() Complete Count: {0}", result.Count); return(result); } DebugWriteLine("Prompt() Empty"); return(null); }
protected override void EndProcessing() { object SendObj = null; bool isScalar = false; List <System.Management.Automation.TableControlColumn> TableColl = null; base.EndProcessing(); if (FullList.Count == 0) { return; //nothing to do. } //////////////////////////////////////////////////////////////// // Generate objects for call if (ScalarTypes.Contains(FullList[0].TypeNames[0])) { isScalar = true; SendObj = new DataTable(); ((DataTable)SendObj).Columns.Add(FullList[0].TypeNames[0], FullList[0].BaseObject.GetType()); foreach (PSObject Item in FullList) { ((DataTable)SendObj).Rows.Add(Item); } } else if (HasObjectSpecialForammting(FullList[0], out SendObj, out TableColl)) { foreach (PSObject Item in FullList) { SessionState.PSVariable.Set("MyOutGridViewDataItem", Item); object[] values = new object[((DataTable)SendObj).Columns.Count]; for (int i = 0; i < TableColl.Count; i++) { if (TableColl[i].DisplayEntry.ValueType == DisplayEntryValueType.Property) { if (Item.Properties[TableColl[i].DisplayEntry.Value] != null) { values[i] = Item.Properties[TableColl[i].DisplayEntry.Value].Value; } } else { Collection <PSObject> results = base.InvokeCommand.InvokeScript("$MyOutGridViewDataItem | foreach-object -process { " + TableColl[i].DisplayEntry.Value + " }"); if (results.Count > 0) { values[i] = results.First(); } } } ((DataTable)SendObj).Rows.Add(values); } } else { SendObj = new ArrayList(); ((ArrayList)SendObj).AddRange(FullList); // XxX Verify - Might be FUllList.BaseObject } //////////////////////////////////////////////////////////////// // Display List SynchronizedInvoke.InvokeIfRequired(PSHostCallBack.ParentControl, () => PSHostCallBack.ParentControl.FinishedGridView(SendObj, FullList.Count, this.Wait || this.OutputMode != OutputModeOption.None, this.OutputMode == OutputModeOption.Multiple, !isScalar)); if (!this.Wait && this.OutputMode == OutputModeOption.None) { return; // Done do not wait for output... } List <int> selectedItems = null; if (PSHostCallBack.ParentControl.WaitForResult(out selectedItems)) { if (selectedItems != null && selectedItems.Count > 0 && this.OutputMode != OutputModeOption.None) { Trace.TraceInformation("Out-GridView() Complete Count: {0}", selectedItems.Count); foreach (int Row in selectedItems) { if (Row >= 0 && Row < FullList.Count) { base.WriteObject(FullList[Row]); } } } } // Cleanup base.StopProcessing(); SynchronizedInvoke.InvokeIfRequired(PSHostCallBack.ParentControl, () => PSHostCallBack.ParentControl.EndGridView()); FullList = null; }
public override void WriteProgress(long sourceId, ProgressRecord record) { // WAY to verbose // DebugWriteLine("WriteProgress(Source:{0},Activity:{1},ParentActivity:{2})",sourceId,record.ActivityId,record.ParentActivityId); SynchronizedInvoke.InvokeIfRequired(this.Parent, () => Parent.WriteProgress(sourceId, record)); }