Ejemplo n.º 1
0
        public void Test1()
        {
            var xx = new WpfTerminalControl();
            var w  = CreateWindow();

            xx.FontSize   = 32.0;
            xx.NumRows    = 10;
            xx.NumColumns = 40;
            w.Content     = xx;

            xx.SetCellCharacter(0, 0,
                                'H', ConsoleColor.Black,
                                ConsoleColor.White);
            var chi = xx.GetCellCharacter(0, 0);

            Assert.Equal('H', chi.Character);

            xx.SetCellCharacter(0, 1,
                                'X', ConsoleColor.Black,
                                ConsoleColor.White);
            var chi2 = xx.GetCellCharacter(0, 1);

            Assert.Equal('X', chi2.Character);

            DoShowWindow(w);
        }
Ejemplo n.º 2
0
        public void Test5()
        {
            var term = CreateWpfTerminalControl(out var w);

            w.ShowActivated = true;

            _terminal = term;
            var wClosed = false;

            w.Closed += (sender, args) => { wClosed = true; };
            w.Loaded += (sender, args) =>
            {
                var xx   = new TerminalWriter(term);
                var file = new StreamReader(@"C:\temp\Program2.cs");
                try
                {
                    while (file.EndOfStream == false)
                    {
                        var s = file.ReadLine();
                        xx.WriteLine(s);
                        DoEvents();
                    }
                }
                catch (Exception ex)
                {
                    Debug.WriteLine(xx._written);
                    throw;
                }
            };
            w.ShowDialog();
        }
Ejemplo n.º 3
0
        public void Test7()
        {
            var term = CreateWpfTerminalControl(out var w);

            term.NumRows    = 20;
            term.NumColumns = 20;

            ITerminalInterface xxi = new TerminalInterface(term);

            w.ShowActivated = true;
            // w.ShowDialog();
            _terminal = term;
            var wClosed = false;

            w.Closed += (sender, args) => { wClosed = true; };
            // for (var i = 0; i < 25; i++)
            // {
            // var s = i.ToString("D3");
            // for (int j = 0; j < s.Length; j++)
            // {
            // xxi.SetCellCharacter(i, j, s[j]);
            // }

            // }

            w.Show();
        }
Ejemplo n.º 4
0
        public void Test4()
        {
            var term = CreateWpfTerminalControl(out var w);

            w.ShowActivated = true;

            _terminal = term;
            var wClosed = false;

            w.Closed  += (sender, args) => { wClosed = true; };
            w.KeyDown += (sender, args) =>
            {
                var xx   = new TerminalWriter(term);
                var file = new StreamReader(@"C:\data\logs\client2\12308.json");
                try
                {
                    while (file.EndOfStream == false)
                    {
                        var s = file.ReadLine();
                        xx.WriteLine(s);
                        DoEvents();
                    }
                }
                catch (Exception ex)
                {
                    Debug.WriteLine(xx._written);
                    throw;
                }
            };
            DoShowWindow(w);
        }
Ejemplo n.º 5
0
        private void PowershellExecuted(object sender, RoutedEventArgs e)
        {
#if POWERSHELL
            var shell = new WpfTerminalControl();
            shell.BeginInit();
            shell.ForegroundColor = ConsoleColor.Black;
            shell.BackgroundColor = ConsoleColor.White;
            shell.Background      = Brushes.White;
            ;
            shell.Foreground = Brushes.Black;
            ;
            shell.AutoResize  = true;
            shell.CursorBrush = Brushes.Orange;
            shell.EndInit();
            var wrapped = new WrappedPowerShell();
            wrapped.BeginInit();
            wrapped.Terminal = shell;
            wrapped.EndInit();
            wrapped.CoerceValue(WrappedPowerShell.InitialSessionStateProperty);
            wrapped.CoerceValue(WrappedPowerShell.RunspaceProperty);

            shell.TextEntryComplete += (o, args) => JTF.RunAsync(async() =>
            {
                await wrapped.ExecuteAsync(args.Text);
            });

            Tabs.Items.Add(new TabItem()
            {
                Header = "PowerShell", Content = shell
            });
            Tabs.SelectedIndex = Tabs.Items.Count - 1;
#endif
        }
Ejemplo n.º 6
0
        public HostUI(WpfTerminalControl wpfTerminalControl)
        {
            if (wpfTerminalControl == null)
            {
                throw new ArgumentNullException(nameof(wpfTerminalControl));
            }
            _wpfTerminalControl = wpfTerminalControl;
            _terminalInterface  = MakeView(wpfTerminalControl);

            // WriteDebugLine("this is debug");
            myRawUi = new RawUI(_terminalInterface);
        }
Ejemplo n.º 7
0
        public RawUI(WpfTerminalControl c, TerminalInterface terminalInterface)
        {
            Control = c ?? throw new ArgumentNullException(nameof(c));


            TerminalCharacteristics.AddNumColumnsChangedEventHandler(terminalInterface, TerminalInterfaceOnNumColumnsChanged);
            TerminalCharacteristics.AddNumRowsChangedEventHandler(terminalInterface, TerminalInterfaceOnNumRowsChanged);

            TermInterface = terminalInterface;

            buf = new ConsoleBuffer {
                Buf = NewBufferCellArray(new Size(80, 25), new BufferCell())
            };
        }
Ejemplo n.º 8
0
 public Host(WpfTerminalControl uicontrol)
 {
     if (uicontrol == null)
     {
         throw new ArgumentNullException(nameof(uicontrol));
     }
     this.InstanceId = Guid.NewGuid();
     this.HostUI     = new HostUI(uicontrol);
     _uI             = this.HostUI;
     this.Name       = "Host1";
     this.Version    = Version.Parse("0.1");
     _CurrentCulture = System.Threading.Thread.CurrentThread.CurrentCulture ??
                       System.Threading.Thread.CurrentThread.CurrentUICulture ?? CultureInfo.InstalledUICulture;
     _CurrentUICulture = _CurrentCulture;
 }
Ejemplo n.º 9
0
        public TerminalInterface(WpfTerminalControl wpfTerminalControl)
        {
            this.wpfTerminalControl = wpfTerminalControl;
            if (wpfTerminalControl.NumColumns != -1)
            {
                NumColumns = wpfTerminalControl.NumColumns - columnOffset;
            }
            if (wpfTerminalControl.NumRows != -1)
            {
                NumRows = wpfTerminalControl.NumRows - rowOffset;
            }

            TerminalCharacteristics.AddNumColumnsChangedEventHandler(wpfTerminalControl, Target2);
            TerminalCharacteristics.AddNumRowsChangedEventHandler(wpfTerminalControl, Target);
        }
Ejemplo n.º 10
0
        public void Test2()
        {
            _terminal = CreateWpfTerminalControl(out var w);
            _terminal.SetCellCharacter(0, 0,
                                       'H', ConsoleColor.Black,
                                       ConsoleColor.White);

            _rowIndex = 0;
            _colIndex = 0;
            var fExit = false;

            w.Show();
            w.Activate();
            //var task1 = Task.Run(Writechar);
            for (;;)
            {
                DoEvents();
                var ch  = '-';
                var cur = DateTime.Now;
                _terminal.SetCellCharacter(_rowIndex, _colIndex, ch, ConsoleColor.White, ConsoleColor.Black);
                Debug.WriteLine($"{_rowIndex},{_colIndex}");
                _colIndex++;
                if (_colIndex == _terminal.NumColumns)
                {
                    _colIndex = 0;
                    _rowIndex++;
                    if (_rowIndex == _terminal.NumRows)
                    {
                        return;
                    }
                }


                // if (task1.Status == TaskStatus.Faulted)
                // {
                // throw task1.Exception.Flatten();
                // }
                // if (task1.Wait(300))
                // {
                // break;
                // }
                if (fExit)
                {
                    return;
                }
            }
        }
Ejemplo n.º 11
0
        public void Test9()
        {
            var term = CreateWpfTerminalControl(out var w);

            term.FontFamily = new FontFamily("Lucida console");
            term.NumRows    = 10;
            term.NumColumns = 30;

            ITerminalInterface xxi = new TerminalInterface(term);

            w.ShowActivated = true;
            w.Show();
            _terminal = term;
            var wClosed = false;

            w.Closed += (sender, args) => { wClosed = true; };
            var xxiNumRows    = xxi.NumRows;
            var xxiNumColumns = xxi.NumColumns;

            _testOutputHelper.WriteLine($"Numrows is {xxiNumRows}");
            _testOutputHelper.WriteLine($"cols is {xxiNumColumns}");
            for (var i = 0; i < xxiNumRows; i++)
            {
                var s = i.ToString("D3");

                for (int j = 0; j < xxiNumColumns; j++)
                {
                    try
                    {
                        xxi.SetCellCharacter(i, j, 'a');
                    }
                    catch (Exception ex)
                    {
                        throw;
                    }
                    DoEvents();
                }
            }

            Thread.Sleep(10000);
        }
Ejemplo n.º 12
0
        private WpfTerminalControl CreateWpfTerminalControl(out Window w)
        {
            var xx = new WpfTerminalControl();

            xx.HorizontalAlignment = HorizontalAlignment.Left;
            xx.VerticalAlignment   = VerticalAlignment.Top;

            xx.DebugCb         = _testOutputHelper.WriteLine;
            xx.BorderBrush     = Brushes.Red;
            xx.BorderThickness = new Thickness(10);
            var ow = xx.CellHeight;
            var oh = xx.CellWidth;

            xx.FontSize = 20;
            Debug.WriteLine(xx.CellWidth);
            Debug.WriteLine(xx.CellHeight);
            w = CreateWindow();
            var grid = new Grid();

            w.Content = xx;

            return(xx);
        }
Ejemplo n.º 13
0
 public MyConsoleWriter(WpfTerminalControl consoleTerm)
 {
     ConsoleTerm = consoleTerm;
     MemoryStream s = new MemoryStream();
 }
Ejemplo n.º 14
0
 public TerminalWriter(WpfTerminalControl term)
 {
     _term = term;
 }
Ejemplo n.º 15
0
        private static void ThreadStartingPoint()
        {
            WpfTerminalControl consoleTerm = new WpfTerminalControl()
            {
                AutoResize = true, CursorBrush = Brushes.BlueViolet
            };

            TerminalCharacteristics.AddNumRowsChangedEventHandler(consoleTerm, (sender, e) =>
            {
                Debug.WriteLine("Rows: " + e.NewValue);
            });
            consoleTerm.FontSize = 18.0;
            // consoleTerm.BackgroundColor = ConsoleColor.Black;
            // consoleTerm.ForegroundColor = ConsoleColor.Green;
            // consoleTerm.Background = Brushes.Black;

            Window consoleWindow = new Window();
            var    grid          = new Grid();

            grid.RowDefinitions.Add(new RowDefinition()
            {
                Height = new GridLength(1, GridUnitType.Star)
            });
            grid.RowDefinitions.Add(new RowDefinition()
            {
                Height = GridLength.Auto
            });
            grid.ColumnDefinitions.Add(new ColumnDefinition()
            {
                Width = new GridLength(1, GridUnitType.Star)
            });

            grid.Children.Add(consoleTerm);
            StackPanel sp = new StackPanel()
            {
                Orientation = Orientation.Horizontal, Margin = new Thickness(5)
            };
            TextBlock t1 = new TextBlock();

            t1.SetBinding(TextBlock.TextProperty,
                          new Binding("CursorColumn")
            {
                Source = consoleTerm, StringFormat = "Col: {N2}"
            });
            TextBlock t3 = new TextBlock();

            t3.SetBinding(TextBlock.TextProperty, new Binding("CursorRow")
            {
                Source = consoleTerm, StringFormat = "Row: {N2}"
            });

            sp.Children.Add(t3);
            sp.Children.Add(new TextBlock {
                Text = " , "
            });
            sp.Children.Add(t1);
            Grid.SetRow(sp, 1);
            grid.Children.Add(sp);
            consoleWindow.Content = grid;
            consoleWindow.Show();

            Console.SetOut(new MyConsoleWriter(consoleTerm));

            consoleWindow.Show();
            System.Windows.Threading.Dispatcher.Run();
        }
Ejemplo n.º 16
0
 private TerminalInterface MakeView(WpfTerminalControl o)
 {
     return(new TerminalInterface(o));
 }
Ejemplo n.º 17
0
 public MyConsoleWriter(WpfTerminalControl consoleTerm)
 {
     ConsoleTerm = consoleTerm;
 }