private void btnSendMessage_Click(object sender, EventArgs e)
        {
            try
            {
                var message = txtMessage.Text.ToUpper();
                txtMessage.Text = message;

                var messageBytes = teletype.EncodeBytes(message);
                ShowBytes(messageBytes);
                teletype.Print(message);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
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();
            }
        }
Exemplo n.º 3
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.º 4
0
        public void PrintTweet(Tweet t)
        {
            teletype.SwitchOn();

            teletype.WaitForTT(2000);

            teletype.Bell();
            teletype.Bell();

            PrintTweetText(t.Text);
            teletype.CRLF();
            teletype.Print(string.Format("Tweeted by : {0} (@{1})", t.Author, t.ScreenName));
            teletype.CRLF();
            teletype.CRLF();

            teletype.WaitForTT(2000);

            teletype.SwitchOff();

            teletype.WaitForTT(2000);
        }