Exemplo n.º 1
0
        static void Main(string[] args)
        {
            try
            {
                Logger.Instance.Write("Starting...");

                teletype = new TeletypeViaAtmega();
                teletype.Connect(new SerialTeletypeConnectPort());

                Logger.Instance.Write("Printing welcome message");
                teletype.SwitchOn();
                teletype.CRLF();
                teletype.Print(Settings.Default.WelcomeMessage);
                teletype.CRLF();
                teletype.SwitchOff();

                printer = new TweetPrinter(teletype);

                Logger.Instance.Write(Environment.NewLine + "Starting Twitter polling");
                tweeter = new Tweeter();
                tweeter.NewTweet += new EventHandler<NewTweetEventArgs>(tweeter_NewTweet);
                tweeter.StartSearch(Settings.Default.TwitterSearchTerm);

                Logger.Instance.Write(Environment.NewLine + "Startup complete.  Waiting for tweets");

                bool quit = false;
                do
                {
                    Logger.Instance.Write(Environment.NewLine + ">> Press 'e' to turn on, 'd' to turn off, 'q' to exit");

                    var key = System.Console.ReadKey(true);

                    switch (key.KeyChar)
                    {
                        case 'q':
                            quit = true;
                            break;

                        case 'e':
                            teletype.SwitchOn();
                            break;

                        case 'd':
                            teletype.SwitchOff();
                            break;
                    }
                }
                while (!quit);

                Logger.Instance.Write(Environment.NewLine + "Exiting...");

                teletype.SwitchOff();
                teletype.Disconnect();
            }
            catch (Exception ex)
            {
                Logger.Instance.Error("General Failure", ex);
                System.Console.ReadLine();
            }
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            try
            {
                Logger.Instance.Write("Starting...");

                teletype = new TeletypeViaAtmega();
                teletype.Connect(new SerialTeletypeConnectPort());

                Logger.Instance.Write("Printing welcome message");
                teletype.SwitchOn();
                teletype.CRLF();
                teletype.Print(Settings.Default.WelcomeMessage);
                teletype.CRLF();
                teletype.SwitchOff();

                printer = new TweetPrinter(teletype);

                Logger.Instance.Write(Environment.NewLine + "Starting Twitter polling");
                tweeter           = new Tweeter();
                tweeter.NewTweet += new EventHandler <NewTweetEventArgs>(tweeter_NewTweet);
                tweeter.StartSearch(Settings.Default.TwitterSearchTerm);

                Logger.Instance.Write(Environment.NewLine + "Startup complete.  Waiting for tweets");

                bool quit = false;
                do
                {
                    Logger.Instance.Write(Environment.NewLine + ">> Press 'e' to turn on, 'd' to turn off, 'q' to exit");

                    var key = System.Console.ReadKey(true);

                    switch (key.KeyChar)
                    {
                    case 'q':
                        quit = true;
                        break;

                    case 'e':
                        teletype.SwitchOn();
                        break;

                    case 'd':
                        teletype.SwitchOff();
                        break;
                    }
                }while (!quit);

                Logger.Instance.Write(Environment.NewLine + "Exiting...");

                teletype.SwitchOff();
                teletype.Disconnect();
            }
            catch (Exception ex)
            {
                Logger.Instance.Error("General Failure", ex);
                System.Console.ReadLine();
            }
        }
        private void btnConnectToTeletype_Click(object sender, EventArgs e)
        {
            try
            {
                //teletype = new Teletype();
                teletype = new TeletypeViaAtmega();
                teletype.Connect(new SerialTeletypeConnectPort());
                printer = new TweetPrinter(teletype);

                grpManualTransmission.Enabled = true;
                btnConnectToTeletype.Enabled  = false;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
        private void btnConnectToTeletype_Click(object sender, EventArgs e)
        {
            try
            {
                //teletype = new Teletype();
                teletype = new TeletypeViaAtmega();
                teletype.Connect(new SerialTeletypeConnectPort());
                printer = new TweetPrinter(teletype);

                grpManualTransmission.Enabled = true;
                btnConnectToTeletype.Enabled = false;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }