/// <summary> /// Constructs a new ConsoleWindow instance, binding it to a shell session. /// </summary> public ConsoleWindow(ShellSession shellSession) { InitializeComponent(); HyperlinkStyle = (Style)this.FindResource("HyperlinkStyle"); InfoTextStyle = (Style)this.FindResource("InfoTextStyle"); OutputBlockStyle = (Style)this.FindResource("OutputBlockStyle"); OutputTextStyle = (Style)this.FindResource("OutputTextStyle"); RunShellRequestCommand = new RunShellRequestCommand(shellSession); ShellSession = shellSession; }
/// <summary> /// Initializes the UI by creating and hooking up the initial shell session. /// </summary> /// <param name="commandProcessor">The command processor instance to associate with the shell session.</param> public void SetupInitialShellSession(CommandProcessor commandProcessor) { // Create a new shell session collection and add an initial session to it. DefaultShellSession = new ShellSession(this, commandProcessor); ShellSessions = new List <ShellSession> { DefaultShellSession }; // Replace the main window's "design-time" ConsoleWindow instance with a new one // that is properly hooked up to the shell session. DefaultShellSession.Window = new ConsoleWindow(DefaultShellSession); MainWindow.viewCommandOutput.Children.Clear(); MainWindow.viewCommandOutput.Children.Add(DefaultShellSession.Window); // Use our thread's current directory as the initial current directory for the initial shell session. DefaultShellSession.CurrentDirectory = Directory.GetCurrentDirectory(); }