Exemple #1
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();
        }
Exemple #2
0
        public RawUI(TerminalInterface terminalInterface)
        {
            TerminalCharacteristics.AddNumColumnsChangedEventHandler(terminalInterface,
                                                                     TerminalInterfaceOnNumColumnsChanged);
            TerminalCharacteristics.AddNumRowsChangedEventHandler(terminalInterface, TerminalInterfaceOnNumRowsChanged);
            TermInterface = terminalInterface;
            var rows = TerminalCharacteristics.GetNumRows(terminalInterface);

            if (rows != -1)
            {
                numRows = rows;
            }
            var cols = TerminalCharacteristics.GetNumColumns(terminalInterface);

            if (cols != -1)
            {
                numCols = cols;
            }


            if (numCols.HasValue && numRows.HasValue)
            {
                buf = new ConsoleBuffer {
                    Buf = NewBufferCellArray(new Size(numCols.Value, numRows.Value), new BufferCell())
                }
            }
            ;
        }
        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);
        }
Exemple #4
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())
            };
        }
Exemple #5
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);
        }
Exemple #6
0
        static void Main(string[] args)
        {
            display = new TerminalInterface();

            ModeSelection();
            display.AddTable(table);



            while (true)
            {
                Player.Player nextPlayer = table.NextToPlay();

                display.GameState();
                while (true)
                {
                    int[] move = nextPlayer.MakeMove(table.tableState);
                    if (table.AddMove(move[0], move[1]) == -1)
                    {
                        display.InvalidMoveError();
                    }
                    else
                    {
                        break;
                    }
                }
                if (table.Winner())
                {
                    display.Winner();
                    break;
                }
                else if (table.Draw())
                {
                    display.Draw();
                    break;
                }
            }
        }
Exemple #7
0
 public User(TerminalInterface d)
 {
     display = d;
     display.InsertName();
     name = Console.ReadLine();
 }