Exemple #1
0
 private static void HandleDisplayMode(NasdaqStock stock, SpeechRecognizedEventArgs e)
 {
     if (e.Result.Semantics["Modifier"].Value.ToString() == "close of")
     {
         string ticker         = stock.ticker;
         var    myQuoteService = new QuoteService();
         var    requestedQuote = myQuoteService.Quote(ticker).Return(QuoteReturnParameter.PreviousClose);
         using (SpeechSynthesizer synth = new SpeechSynthesizer())
         {
             // Configure the audio output.
             synth.SetOutputToDefaultAudioDevice();
             // Speak a string synchronously.
             synth.Speak("The last close of " + e.Result.Semantics["CompanyName"].Value.ToString() + "was" + requestedQuote.PreviousClose.ToString() + "dollars");
         }
     }
     else if (e.Result.Semantics["Modifier"].Value.ToString() == "ask of")
     {
         string ticker         = stock.ticker;
         var    myQuoteService = new QuoteService();
         var    requestedQuote = myQuoteService.Quote(ticker).Return(QuoteReturnParameter.Ask);
         using (SpeechSynthesizer synth = new SpeechSynthesizer())
         {
             // Configure the audio output.
             synth.SetOutputToDefaultAudioDevice();
             // Speak a string synchronously.
             synth.Speak("The last ask of " + e.Result.Semantics["CompanyName"].Value.ToString() + "was" + requestedQuote.Ask.ToString() + "dollars");
         }
     }
 }
Exemple #2
0
        private static void GraphHandler(NasdaqStock stock, SpeechRecognizedEventArgs e)
        {
            string   ticker = stock.ticker;
            var      historical_price_service = new HistoricalPriceService();
            DateTime startDate        = HandleDates(e.Result.Semantics["yearModifier"].Value.ToString(), e.Result.Semantics["monthModifier"].Value.ToString());
            DateTime endDate          = HandleDates(e.Result.Semantics["yearModifier2"].Value.ToString(), e.Result.Semantics["monthModifier2"].Value.ToString());
            var      historicalPrices = historical_price_service.Get(ticker, startDate, endDate, Period.Daily);

            if (e.Result.Semantics.ContainsKey("GraphModifier1"))
            {
                if (e.Result.Semantics["GraphModifier1"].Value.ToString() == "as a line graph the")
                {
                    decimal[]  priceArray;
                    DateTime[] dateArray;
                    Tuple <decimal[], DateTime[]> tuple = GraphBuilder.buildLineGraph(historicalPrices);
                    priceArray = tuple.Item1;
                    dateArray  = tuple.Item2;
                    ChartForm myChart = new ChartForm(priceArray, dateArray);
                    myChart.Show();
                }
                else if (e.Result.Semantics["GraphModifier1"].Value.ToString() == "Bar Graph")
                {
                }
            }
            else
            {
                decimal[]  priceArray;
                DateTime[] dateArray;
                Tuple <decimal[], DateTime[]> tuple = GraphBuilder.buildLineGraph(historicalPrices);
                priceArray = tuple.Item1;
                dateArray  = tuple.Item2;
                ChartForm myChart = new ChartForm(priceArray, dateArray);
                myChart.Show();
            }
        }
        public static List <NasdaqStock> readInStocks()
        {
            TextFieldParser    parser          = new TextFieldParser(new StringReader(StockVoice.Properties.Resources.companylist));
            List <NasdaqStock> nasdaqStockList = new List <NasdaqStock>();

            parser.HasFieldsEnclosedInQuotes = true;
            parser.SetDelimiters(",");
            string[] fields;
            while (!parser.EndOfData)
            {
                fields = parser.ReadFields();
                String nameWithoutInc = fields[0];
                nameWithoutInc = nameWithoutInc.Replace(", Inc.", "");
                nameWithoutInc = nameWithoutInc.Replace(", Inc", "");
                nameWithoutInc = nameWithoutInc.Replace(" Inc.", "");
                nameWithoutInc = nameWithoutInc.Replace(" Inc", "");
                NasdaqStock stock = new NasdaqStock(nameWithoutInc, fields[1], fields[6], fields[7]);
                nasdaqStockList.Add(stock);
            }
            return(nasdaqStockList);
        }