private void Psdata_DataAdding(object sender, DataAddingEventArgs e)
 {
     Dispatcher.Invoke(() =>
     {
         Output.AddColoredText(e.ItemAdded.ToString(), Brushes.White);
     });
 }
        private void Warning_DataAdded(object sender, DataAddedEventArgs e)
        {
            var data  = sender as PSDataCollection <WarningRecord>;
            var datum = data[e.Index];

            Dispatcher.Invoke(() =>
            {
                Output.AddColoredText(datum.Message, Brushes.Yellow);
            });
        }
        private void Error_DataAdded(object sender, DataAddedEventArgs e)
        {
            var data  = sender as PSDataCollection <ErrorRecord>;
            var datum = data[e.Index];

            Dispatcher.Invoke(() =>
            {
                Output.AddColoredText(datum.Exception.Message, Brushes.Red);
            });
        }
        private void Information_DataAdded(object sender, DataAddedEventArgs e)
        {
            var data  = sender as PSDataCollection <InformationRecord>;
            var datum = data[e.Index];

            Dispatcher.Invoke(() =>
            {
                var msg             = datum.MessageData as HostInformationMessage;
                var foregroundColor = msg.ForegroundColor;
                if (foregroundColor.HasValue)
                {
                    var brush = new SolidColorBrush(_ColorMapping[foregroundColor.Value]);
                    Output.AddColoredText(msg.Message, brush);
                }
                else
                {
                    Output.AddColoredText(msg.Message, Brushes.White);
                }
            });
        }