示例#1
0
 internal OutWindowProxy(string title, OutputModeOption outPutMode, OutGridViewCommand parentCmdlet)
 {
     this.title = title;
     this.outputMode = outPutMode;
     this.parentCmdlet = parentCmdlet;
     this.graphicalHostReflectionWrapper = GraphicalHostReflectionWrapper.GetGraphicalHostReflectionWrapper(parentCmdlet, "Microsoft.Management.UI.Internal.OutGridViewWindow");
 }
示例#2
0
 internal OutWindowProxy(string title, OutputModeOption outPutMode, OutGridViewCommand parentCmdlet)
 {
     this.title        = title;
     this.outputMode   = outPutMode;
     this.parentCmdlet = parentCmdlet;
     this.graphicalHostReflectionWrapper = GraphicalHostReflectionWrapper.GetGraphicalHostReflectionWrapper(parentCmdlet, "Microsoft.Management.UI.Internal.OutGridViewWindow");
 }
示例#3
0
        public MainWindowViewModel(ApplicationData applicationData)
        {
            IsPassThruEnabled = applicationData.PassThru;
            Title             = applicationData.Title;
            outputMode        = applicationData.OutputMode;
            dataTable         = applicationData.DataTable;

            PassThruOkCommand     = ReactiveCommand.Create <Window>(OnPassThruOk);
            PassThruCancelCommand = ReactiveCommand.Create <Window>(OnPassThruCancel);


            var observableColumns = new SourceList <DataTableColumn>();

            observableColumns.AddRange(dataTable.DataColumns);

            var observableData = new SourceList <DataTableRow>();

            observableData.AddRange(dataTable.Data);
            this.WhenActivated((CompositeDisposable disposables) =>
            {
                FilterQueryBuilder = new FilterQueryBuilderViewModel(observableColumns);

                var filterData = Observable.Merge(this.WhenAnyValue(x => x.SearchText).Select(_ => Unit.Default),
                                                  FilterQueryBuilder.FiltersByDataColumn.Connect().AutoRefresh().Select(_ => Unit.Default));

                var filterPredicate = filterData.Select(x => FilterBuilder.BuildFilter(SearchText, FilterQueryBuilder.FiltersByDataColumn));

                var filteredObjects = observableData.Connect()
                                      .Filter(filterPredicate)
                                      .AsObservableList();

                DataGridView = new DataGridViewModel(dataTable.DataColumns, filteredObjects, outputMode);
            });
        }
示例#4
0
        /// <summary>
        /// Initializes a new instance of the OutWindowProxy class.
        /// </summary>
        internal OutWindowProxy(string title, OutputModeOption outPutMode, OutGridViewCommand parentCmdlet)
        {
            _title        = title;
            _outputMode   = outPutMode;
            _parentCmdlet = parentCmdlet;

            _graphicalHostReflectionWrapper = GraphicalHostReflectionWrapper.GetGraphicalHostReflectionWrapper(parentCmdlet, OutWindowProxy.OutGridViewWindowClassName);
        }
示例#5
0
        /// <summary>
        /// Initializes a new instance of the OutWindowProxy class.
        /// </summary>
        internal OutWindowProxy(string title, OutputModeOption outPutMode, OutGridViewCommand parentCmdlet)
        {
            _title = title;
            _outputMode = outPutMode;
            _parentCmdlet = parentCmdlet;

            _graphicalHostReflectionWrapper = GraphicalHostReflectionWrapper.GetGraphicalHostReflectionWrapper(parentCmdlet, OutWindowProxy.OutGridViewWindowClassName);
        }
示例#6
0
        public DataGridSelectionMode OutputModeToSelectionMode(OutputModeOption outputModeOption)
        {
            switch (outputModeOption)
            {
            case OutputModeOption.None:
                return(DataGridSelectionMode.Extended);

            case OutputModeOption.Single:
                return(DataGridSelectionMode.Single);

            case OutputModeOption.Multiple:
                return(DataGridSelectionMode.Extended);

            default:
                return(DataGridSelectionMode.Extended);
            }
        }
示例#7
0
        public static void Start(string title, OutputModeOption outputMode, PSCmdlet cmdlet)
        {
            _gridViewerProcess = new Process();

            _gridViewerProcess.StartInfo.FileName  = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Contents", "MacOS", "GridViewer");
            _gridViewerProcess.StartInfo.Arguments = string.Format("\"{0}\"", title.Replace("\"", "\\\""));

            _gridViewerProcess.StartInfo.CreateNoWindow  = true;
            _gridViewerProcess.StartInfo.UseShellExecute = false;

            _gridViewerProcess.StartInfo.RedirectStandardInput  = true;
            _gridViewerProcess.StartInfo.RedirectStandardOutput = true;
            _gridViewerProcess.StartInfo.RedirectStandardError  = true;

            // Just Console.WriteLine it.
            _gridViewerProcess.OutputDataReceived += (sender, data) =>
            {
                if (!string.IsNullOrWhiteSpace(data.Data))
                {
                    selectedIndexes.Add(Convert.ToInt32(data.Data));
                }
            };
            _gridViewerProcess.ErrorDataReceived += (sender, data) =>
            {
                Console.WriteLine(data.Data);
            };

            try
            {
                _gridViewerProcess.Start();
                _gridViewerProcess.BeginOutputReadLine();
                _gridViewerProcess.BeginErrorReadLine();
            }
            catch (Exception ex)
            {
                cmdlet.ThrowTerminatingError(new ErrorRecord(ex, "GridViewException", ErrorCategory.OperationStopped, null));
            }
        }
示例#8
0
        public DataGridViewModel(List <DataTableColumn> dataColumns, IObservableList <DataTableRow> data, OutputModeOption outputMode)
        {
            var columns = dataColumns.Select(x => new Column(x));

            Columns.AddRange(columns);

            SelectionMode = OutputModeToSelectionMode(outputMode);

            this.WhenActivated((CompositeDisposable disposables) =>
            {
                Columns.Connect()
                .AutoRefresh()
                .ObserveOn(RxApp.MainThreadScheduler)
                .Bind(out _columnSelect)
                .Subscribe();

                data.Connect()
                .Bind(out _viewObjects)
                .Subscribe();
            });
        }