Exemplo n.º 1
0
Arquivo: UI.cs Projeto: Xlator/TextTV
        /// <summary>
        /// Print the header bar
        /// <returns>Length of left header text (for printing multipage numbers)</returns>
        /// </summary>
        public static void PrintHeader(Browser texttv, bool multipage)
        {
            Page page = texttv.Page;
            UI.Color(0, 15);
            Console.SetCursorPosition(0, 0);

            // Get page category
            Category category = (Category)page.Number - (page.Number % 100);
            string left = String.Format(" {0} - {1}", page.Number, category);

            if (multipage)
                left += String.Format(" {0}/{1}", texttv.PageChunkIndex + 1, texttv.PageCount);

            string right = String.Format("{0} ", DateTime.Now.ToString());
            string center = "SVT Text".PadCenter(Console.WindowWidth - left.Length - right.Length);
            Console.Write("{0}{1}{2}\n", left, center, right);
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            // Basic console settings
            Console.SetWindowSize(82, 28);
            Console.CursorVisible = false;
            Console.CursorSize = 100;

            // Show welcome message until loading is complete
            new UI.MessageBox("SVT Text-TV i C#\n\nav Viktor Jackson, i samarbete med Genom AB\nMars-April 2012\n\nwww.svt.se/texttv",
                "Välkommen!", "info", ConsoleColor.Black, ConsoleColor.Yellow).ShowMessage();

            // Create the browser object and get the start page
            Browser TextTV = new Browser();
            System.Threading.Thread.Sleep(3000);
            //TextTV.PrintPage();

            while (true) // Begin program loop
            {
                // If an exception was caught by TryPage(), print an error message
                if (TextTV.Message != String.Empty)
                {
                    new UI.MessageBox(TextTV.Message.WordWrap(40), "Felmeddelande", "error",
                        ConsoleColor.White, ConsoleColor.DarkRed).ShowMessage();

                    while (true)
                        // Wait for user to press escape, then reprint the last page.
                        if (Console.ReadKey(true).Key == ConsoleKey.Escape)
                            break;
                }

                // Output the page, then wait for input
                TextTV.GetPageInfo();
                TextTV.PrintPage();
                TextTV.WatchKeys();
            }
        }