Ejemplo n.º 1
0
        public async Task Can_set_and_get_text()
        {
            var sut      = new WindowsClipboardService(TimeSpan.FromMinutes(1));
            var expected = "Hello world";
            await sut.SetTextAsync(expected);

            var actual = await sut.GetTextAsync();

            Assert.That(actual, Is.EqualTo(expected));
        }
Ejemplo n.º 2
0
 public void SetText(string p_text)
 {
     _clipboardService.SetTextAsync(p_text);
 }
Ejemplo n.º 3
0
        /*TODO List:
         * Language filter
         * Keyword Filter
         * Interface Cleanup & Debug
         * "Menu Bar"
         * Favorites Category
         * Refresh file list
         * Create New Entry
         */
        public static void Run()
        {
            //Create and Populate Categories, Color Profile, DrawScreens, NoteDatat
            string[]            categories = ReadFile.ReadCategories();
            List <ColorProfile> colors     = new List <ColorProfile>();
            List <DrawScreen>   draws      = new List <DrawScreen>();
            List <List <KeyValuePair <string, string> > > fileNamesAndTitles = new List <List <KeyValuePair <string, string> > >();
            List <List <NoteObject> > allSnippets = new List <List <NoteObject> >();

            int[] consoleSize = { Console.WindowWidth, Console.WindowHeight };
            InitializeConsoleDisplay.SetConsoleParameters();

            //Add Colors, data, into DrawScreen objects
            for (int i = 0; i < categories.Length; i++)
            {
                fileNamesAndTitles.Add(ReadFile.ReadFileTitles(categories[i]));
                colors.Add(ReadFile.ReadColorProfile(categories[i]));
                allSnippets.Add(new List <NoteObject>());
                foreach (KeyValuePair <string, string> f in fileNamesAndTitles[i])
                {
                    string fileName = f.Key;
                    allSnippets[i].Add(ReadFile.ParseAndReturnSnippet(f.Key));
                }
                draws.Add(new DrawScreen(consoleSize, colors[i], categories[i], fileNamesAndTitles[i], allSnippets[i]));
            }

            int category    = 0;
            int maxCategory = categories.Length - 1;

            //Display
            DisplayScreen(draws[category]);

            do
            {
                while (!Console.KeyAvailable)
                {
                    // Wait...
                }
                switch (Console.ReadKey(true).Key)
                {
                case ConsoleKey.Tab:
                    if (category < maxCategory)
                    {
                        category++;
                    }
                    else
                    {
                        category = 1;     // index 0 is reserved for "help" articles
                    }
                    draws[category].DrawBorders();
                    draws[category].PrintList();
                    draws[category].HighlightCurrentListSelectionAfterTransition();
                    draws[category].PrintContentsHeader();
                    draws[category].DrawMenuBar();
                    break;

                case ConsoleKey.Enter:
                    draws[category].PrintContentsHeader();
                    break;

                case ConsoleKey.PageUp:
                    if (draws[category].Focus == 0)     //scroll pages in list
                    {
                        if (draws[category].ListScrollUpAllow)
                        {
                            draws[category].Selection = 0;
                            draws[category].ListPage--;
                            draws[category].PrintList();
                            break;
                        }
                        else
                        {
                            break;
                        }
                    }
                    else if (draws[category].Focus == 1)     //scroll pages in content
                    {
                        if (draws[category].ContentScrollUpAllow)
                        {
                            draws[category].ContentPage--;
                            draws[category].PrintContentsBody();
                            draws[category].DrawNavText();
                            break;
                        }
                        else
                        {
                            break;
                        }
                    }
                    break;

                case ConsoleKey.PageDown:
                    if (draws[category].Focus == 0)    // scroll pages in list
                    {
                        if (draws[category].ListScrollDownAllow)
                        {
                            draws[category].Selection = 0;
                            draws[category].ListPage++;
                            draws[category].PrintList();
                            break;
                        }
                        else
                        {
                            break;
                        }
                    }
                    else if (draws[category].Focus == 1)     //scroll pages in content
                    {
                        if (draws[category].ContentScrollDownAllow)
                        {
                            draws[category].ContentPage++;
                            draws[category].PrintContentsBody();
                            draws[category].DrawNavText();
                            break;
                        }
                        else
                        {
                            break;
                        }
                    }
                    break;

                case ConsoleKey.LeftArrow:
                    if (draws[category].Focus == 1)
                    {
                        draws[category].Focus = 0;
                        draws[category].DrawNavText();
                        draws[category].HighlightCurrentListSelectionAfterTransition();
                    }
                    break;

                case ConsoleKey.RightArrow:
                    if (draws[category].Focus == 0)
                    {
                        if (!draws[category].ContentEndOfContent)
                        {
                            draws[category].Focus = 1;
                            draws[category].DrawNavText();
                            draws[category].RemoveHighlightCurrentListSelectionAfterTransition();
                        }
                    }
                    break;

                case ConsoleKey.UpArrow:
                    if (draws[category].Selection == 0)
                    {
                        break;
                    }
                    else
                    {
                        draws[category].Selection--;
                        draws[category].MoveListSelection(true);
                        draws[category].PrintContentsHeader();
                        break;
                    }

                case ConsoleKey.DownArrow:
                    if (draws[category].Selection == DrawScreen.MaxListLength - 1 || draws[category].Selection + (DrawScreen.MaxListLength * draws[category].ListPage) >= draws[category].FilesAndTitles.Count - 1)
                    {
                        break;
                    }
                    else
                    {
                        draws[category].Selection++;
                        draws[category].MoveListSelection(false);
                        draws[category].PrintContentsHeader();
                        break;
                    }

                case ConsoleKey.F1:
                    //Displays "help" category (index 0);
                    category = 0;     // index 0 is reserved for "help" articles
                    draws[category].DrawBorders();
                    draws[category].PrintList();
                    break;

                case ConsoleKey.F2:
                    var clipboardService = new WindowsClipboardService(timeout: TimeSpan.FromMilliseconds(200));
                    clipboardService.SetTextAsync(draws[category].ContentForClipboard);
                    break;

                case ConsoleKey.F10:
                    bool exit = draws[category].PromptYesOrNo("Exit Program?");
                    if (exit)
                    {
                        EndProgram();
                    }
                    else
                    {
                        draws[category].PrintContentsBody();
                    }
                    break;

                case ConsoleKey.F12:
                    consoleSize[0] = Console.WindowWidth;
                    consoleSize[1] = Console.WindowHeight;
                    foreach (DrawScreen d in draws)
                    {
                        d.XMax = consoleSize[0];
                        d.YMax = consoleSize[1];
                    }
                    DisplayScreen(draws[category]);
                    break;

                //case ConsoleKey.F3:
                //    break;
                //case ConsoleKey.Backspace:
                //    break;
                //case ConsoleKey.Clear:
                //    break;
                //case ConsoleKey.Pause:
                //    break;
                //case ConsoleKey.Escape:
                //    break;
                //case ConsoleKey.Spacebar:
                //    break;
                //case ConsoleKey.End:
                //    break;
                //case ConsoleKey.Home:
                //    break;
                //case ConsoleKey.Select:
                //    break;
                //case ConsoleKey.Print:
                //    break;
                //case ConsoleKey.Execute:
                //    break;
                //case ConsoleKey.PrintScreen:
                //    break;
                //case ConsoleKey.Insert:
                //    break;
                //case ConsoleKey.Delete:
                //    break;
                //case ConsoleKey.Help:
                //    break;
                //case ConsoleKey.D0:
                //    break;
                //case ConsoleKey.D1:
                //    break;
                //case ConsoleKey.D2:
                //    break;
                //case ConsoleKey.D3:
                //    break;
                //case ConsoleKey.D4:
                //    break;
                //case ConsoleKey.D5:
                //    break;
                //case ConsoleKey.D6:
                //    break;
                //case ConsoleKey.D7:
                //    break;
                //case ConsoleKey.D8:
                //    break;
                //case ConsoleKey.D9:
                //    break;
                //case ConsoleKey.A:
                //    break;
                //case ConsoleKey.B:
                //    break;
                //case ConsoleKey.C:
                //    break;
                //case ConsoleKey.D:
                //    break;
                //case ConsoleKey.E:
                //    break;
                //case ConsoleKey.F:
                //    break;
                //case ConsoleKey.G:
                //    break;
                //case ConsoleKey.H:
                //    break;
                //case ConsoleKey.I:
                //    break;
                //case ConsoleKey.J:
                //    break;
                //case ConsoleKey.K:
                //    break;
                //case ConsoleKey.L:
                //    break;
                //case ConsoleKey.M:
                //    break;
                //case ConsoleKey.N:
                //    break;
                //case ConsoleKey.O:
                //    break;
                //case ConsoleKey.P:
                //    break;
                //case ConsoleKey.Q:
                //    break;
                //case ConsoleKey.R:
                //    break;
                //case ConsoleKey.S:
                //    break;
                //case ConsoleKey.T:
                //    break;
                //case ConsoleKey.U:
                //    break;
                //case ConsoleKey.V:
                //    break;
                //case ConsoleKey.W:
                //    break;
                //case ConsoleKey.X:
                //    break;
                //case ConsoleKey.Y:
                //    break;
                //case ConsoleKey.Z:
                //    break;
                //case ConsoleKey.LeftWindows:
                //    break;
                //case ConsoleKey.RightWindows:
                //    break;
                //case ConsoleKey.Applications:
                //    break;
                //case ConsoleKey.Sleep:
                //    break;
                //case ConsoleKey.NumPad0:
                //    break;
                //case ConsoleKey.NumPad1:
                //    break;
                //case ConsoleKey.NumPad2:
                //    break;
                //case ConsoleKey.NumPad3:
                //    break;
                //case ConsoleKey.NumPad4:
                //    break;
                //case ConsoleKey.NumPad5:
                //    break;
                //case ConsoleKey.NumPad6:
                //    break;
                //case ConsoleKey.NumPad7:
                //    break;
                //case ConsoleKey.NumPad8:
                //    break;
                //case ConsoleKey.NumPad9:
                //    break;
                //case ConsoleKey.Multiply:
                //    break;
                //case ConsoleKey.Add:
                //    break;
                //case ConsoleKey.Separator:
                //    break;
                //case ConsoleKey.Subtract:
                //    break;
                //case ConsoleKey.Decimal:
                //    break;
                //case ConsoleKey.Divide:
                //    break;
                //case ConsoleKey.F4:
                //    break;
                //case ConsoleKey.F5:
                //    break;
                //case ConsoleKey.F6:
                //    break;
                //case ConsoleKey.F7:
                //    break;
                //case ConsoleKey.F8:
                //    break;
                //case ConsoleKey.F9:
                //    break;
                //case ConsoleKey.F11:
                //    break;
                //case ConsoleKey.F13:
                //    break;
                //case ConsoleKey.F14:
                //    break;
                //case ConsoleKey.F15:
                //    break;
                //case ConsoleKey.F16:
                //    break;
                //case ConsoleKey.F17:
                //    break;
                //case ConsoleKey.F18:
                //    break;
                //case ConsoleKey.F19:
                //    break;
                //case ConsoleKey.F20:
                //    break;
                //case ConsoleKey.F21:
                //    break;
                //case ConsoleKey.F22:
                //    break;
                //case ConsoleKey.F23:
                //    break;
                //case ConsoleKey.F24:
                //    break;
                //case ConsoleKey.BrowserBack:
                //    break;
                //case ConsoleKey.BrowserForward:
                //    break;
                //case ConsoleKey.BrowserRefresh:
                //    break;
                //case ConsoleKey.BrowserStop:
                //    break;
                //case ConsoleKey.BrowserSearch:
                //    break;
                //case ConsoleKey.BrowserFavorites:
                //    break;
                //case ConsoleKey.BrowserHome:
                //    break;
                //case ConsoleKey.VolumeMute:
                //    break;
                //case ConsoleKey.VolumeDown:
                //    break;
                //case ConsoleKey.VolumeUp:
                //    break;
                //case ConsoleKey.MediaNext:
                //    break;
                //case ConsoleKey.MediaPrevious:
                //    break;
                //case ConsoleKey.MediaStop:
                //    break;
                //case ConsoleKey.MediaPlay:
                //    break;
                //case ConsoleKey.LaunchMail:
                //    break;
                //case ConsoleKey.LaunchMediaSelect:
                //    break;
                //case ConsoleKey.LaunchApp1:
                //    break;
                //case ConsoleKey.LaunchApp2:
                //    break;
                //case ConsoleKey.Oem1:
                //    break;
                //case ConsoleKey.OemPlus:
                //    break;
                //case ConsoleKey.OemComma:
                //    break;
                //case ConsoleKey.OemMinus:
                //    break;
                //case ConsoleKey.OemPeriod:
                //    break;
                //case ConsoleKey.Oem2:
                //    break;
                //case ConsoleKey.Oem3:
                //    break;
                //case ConsoleKey.Oem4:
                //    break;
                //case ConsoleKey.Oem5:
                //    break;
                //case ConsoleKey.Oem6:
                //    break;
                //case ConsoleKey.Oem7:
                //    break;
                //case ConsoleKey.Oem8:
                //    break;
                //case ConsoleKey.Oem102:
                //    break;
                //case ConsoleKey.Process:
                //    break;
                //case ConsoleKey.Packet:
                //    break;
                //case ConsoleKey.Attention:
                //    break;
                //case ConsoleKey.CrSel:
                //    break;
                //case ConsoleKey.ExSel:
                //    break;
                //case ConsoleKey.EraseEndOfFile:
                //    break;
                //case ConsoleKey.Play:
                //    break;
                //case ConsoleKey.Zoom:
                //    break;
                //case ConsoleKey.NoName:
                //    break;
                //case ConsoleKey.Pa1:
                //    break;
                //case ConsoleKey.OemClear:
                //    break;
                default:
                    break;
                }
            } while (true);
        }