Exemplo n.º 1
0
        private static void ShowClipboardDemo(IConsole console)
        {
            console.WriteLine("We'll replace line #2 and restore it after 2 seconds");
            console.WriteLine("Then will copy line #2 and paste at last,");
            console.WriteLine("but changing the foreground color of first letter");
            console.WriteLine("Line #1");
            console.WriteLine("Line #2");
            console.WriteLine("Line #3");

            var    clip    = new ConsoleClipboard();
            string replace = "Replacement text";

            clip.Copy(0, 6, (short)replace.Length, 1);  //y parameter: Take in account the 2 first lines from main and the 3 description lines
                                                        //width param: replacement text is longer that the original text.
            console.At(0, 6).Write(replace);
            console.At(0, 9);                           //Reposition the cursor for next normal write operation in main

            System.Threading.Thread.Sleep(2000);
            clip.Paste();
            clip.ColorAttributes[0, 0] = 0b1110;        //see https://docs.microsoft.com/en-us/windows/console/char-info-str for available values
            clip.Paste(0, 8);
        }
Exemplo n.º 2
0
 internal Attributes(ConsoleClipboard consoleClipboard)
 {
     instance = consoleClipboard;
 }