Exemplo n.º 1
0
        /// <summary>
        /// Creates a new MainWindow object
        /// </summary>
        public MainWindow()
        {
            InitializeComponent();

            //Set Dimensions of the Window
            Height = 600;
            Width  = 350;
            Left   = SystemParameters.FullPrimaryScreenWidth - Width;
            Top    = SystemParameters.FullPrimaryScreenHeight;

            //Animate from Bottom
            var da = new DoubleAnimation(SystemParameters.FullPrimaryScreenHeight, SystemParameters.WorkArea.Height - Height, TimeSpan.FromSeconds(1));

            da.EasingFunction = new QuinticEase();
            da.BeginTime      = TimeSpan.FromSeconds(2);
            BeginAnimation(TopProperty, da);

            //Set the greeting text
            HelloUser.Content = Greetings.Greet();

            //Attach the exiting code to the viewControllerConnector
            ViewControllerConnector.Exit += ExitAISA;

            //Initialize the OpenSpeak Engine
            OpenSpeak.Init();
        }
Exemplo n.º 2
0
        /// <summary>
        /// Exits AISA after greeting the user
        /// </summary>
        private void ExitAISA()
        {
            //Stop the AISA Recognition


            //Say the end greeting
            OpenSpeak.Speak(Greetings.End());

            AISAHandler.Pause();

            //Disappear the program
            var da = new DoubleAnimation(SystemParameters.PrimaryScreenHeight, TimeSpan.FromSeconds(1));

            da.EasingFunction = new QuinticEase();
            BeginAnimation(TopProperty, da);

            //Close the program in 2 seconds
            var dt = new DispatcherTimer();

            dt.Interval = TimeSpan.FromSeconds(2);
            dt.Tick    += (a, b) =>
            {
                Application.Current.Shutdown();
            };
            dt.Start();
        }
Exemplo n.º 3
0
        private void PronounceQA()
        {
            var q = Context.currentPaper.questions[currentIndex];

            //Speak the result
            OpenSpeak.Speak("Question " + (currentIndex + 1).ToString() + ", " + q.question.ToString() + ", " +
                            "A: " + q.answer1.ToString() + ", " +
                            "B: " + q.answer2.ToString() + ", " +
                            "C: " + q.answer3.ToString() + ", " +
                            "D: " + q.answer4.ToString()
                            );
        }
Exemplo n.º 4
0
        /// <summary>
        /// This occurs on asynchronous basis
        /// </summary>
        /// <param name="Q"></param>
        /// <param name="A"></param>
        private void AsyncResultChanged(string Q, string A)
        {
            this.Dispatcher.Invoke(() =>
            {
                if (A.StartsWith("SUDO:") == false)
                {
                    //Play results audio
                    AudioHandler.Results();

                    //Hide the spinner
                    Spinner.Hide();

                    //Hide the hypothesis
                    var da = new DoubleAnimation(0, TimeSpan.FromMilliseconds(500));
                    Hypothesis.BeginAnimation(OpacityProperty, da);

                    ResultSheet.Visibility = Visibility.Visible;
                    var sa = FindResource("ResultsAnimation") as Storyboard;
                    sa.Begin();

                    //Speak the answer
                    OpenSpeak.Speak(A);

                    q_label.Content = "\"" + Q + "\"";
                    a_label.Text    = A;
                }
                else
                {
                    //Play results audio
                    AudioHandler.Results();

                    //Hide the spinner
                    Spinner.Hide();

                    //Hide the hypothesis
                    var da = new DoubleAnimation(0, TimeSpan.FromMilliseconds(500));
                    Hypothesis.BeginAnimation(OpacityProperty, da);

                    ResultSheet.Visibility = Visibility.Visible;
                    var sa = FindResource("ResultsAnimation") as Storyboard;
                    sa.Begin();

                    //Speak the answer
                    OpenSpeak.Speak(A.Replace("SUDO:", ""));

                    q_label.Content = "\"" + Q + "\"";
                    a_label.Text    = "Here's what I've got";
                }
            });
        }
Exemplo n.º 5
0
        /// <summary>
        /// Creates a new MainWindow object
        /// </summary>
        public MainWindow()
        {
            InitializeComponent();

            //Set Dimensions of the Window
            Height = 600;
            Width  = 350;
            Left   = SystemParameters.FullPrimaryScreenWidth - Width;
            Top    = SystemParameters.FullPrimaryScreenHeight;

            //Animate from Bottom
            var da = new DoubleAnimation(SystemParameters.FullPrimaryScreenHeight, SystemParameters.WorkArea.Height - Height, TimeSpan.FromSeconds(1));

            da.EasingFunction = new QuinticEase();
            da.BeginTime      = TimeSpan.FromSeconds(2);
            BeginAnimation(TopProperty, da);

            //Set the greeting text
            HelloUser.Content = Greetings.Greet();

            //Attach the exiting code to the viewControllerConnector
            ViewControllerConnector.Exit += ExitAISA;

            //Initialize the OpenSpeak Engine
            OpenSpeak.Init();

            //Change the color of the Animating Lines according to Windows Accent Color.
            grid1.Background = SystemParameters.WindowGlassBrush;
            grid2.Background = SystemParameters.WindowGlassBrush;
            grid3.Background = SystemParameters.WindowGlassBrush;
            grid4.Background = SystemParameters.WindowGlassBrush;

            //Color the extraContent Topics
            Topic1.Foreground = SystemParameters.WindowGlassBrush;
            Topic2.Foreground = SystemParameters.WindowGlassBrush;
            Topic3.Foreground = SystemParameters.WindowGlassBrush;

            //Get the tips from the server
            var threadstart = new ThreadStart(() =>
            {
                try
                {
                    var healthtip  = AISA_API.Tips.Get(new AISA_API.HealthTip()).tip;
                    var weathertip = AISA_API.Tips.Get(new AISA_API.WeatherTip()).tip;
                    var studytip   = AISA_API.Tips.Get(new AISA_API.StudyTip()).tip;

                    Application.Current.Dispatcher.Invoke(() =>
                    {
                        health_tip.Text  = healthtip;
                        weather_tip.Text = weathertip;
                        study_tip.Text   = studytip;
                    });
                }
                catch (Exception)
                {
                }
            });
            var thread = new Thread(threadstart);

            thread.Start();

            //Add the news items to the list in another thread
            var newsthreadstart = new ThreadStart(
                () =>
            {
                try
                {
                    var newsItems = AISA_API.News.GetAllNews();

                    Application.Current.Dispatcher.Invoke(() =>
                    {
                        foreach (var newsItem in newsItems.news)
                        {
                            //Add them to the newsContainer
                            var maingrid      = new Grid();
                            maingrid.Cursor   = Cursors.Hand;
                            maingrid.MouseUp += (a, b) =>
                            {
                                Process.Start(newsItem.url);
                            };

                            maingrid.ColumnDefinitions.Add(new ColumnDefinition()
                            {
                                Width = new GridLength(50, GridUnitType.Pixel)
                            });
                            maingrid.ColumnDefinitions.Add(new ColumnDefinition()
                            {
                                Width = new GridLength(200, GridUnitType.Star)
                            });

                            var newsImage    = new Image();
                            newsImage.Source = new BitmapImage(new Uri(newsItem.thumbnail));
                            newsImage.Margin = new Thickness(0, 0, 10, 0);


                            var stackPanel = new StackPanel();

                            var newstitle          = new TextBlock();
                            newstitle.Text         = newsItem.title;
                            newstitle.TextTrimming = TextTrimming.CharacterEllipsis;
                            newstitle.Foreground   = new SolidColorBrush(Colors.White);

                            var newsdescription          = new TextBlock();
                            newsdescription.Text         = newsItem.description;
                            newsdescription.TextTrimming = TextTrimming.CharacterEllipsis;
                            newsdescription.Foreground   = new SolidColorBrush(Color.FromRgb(170, 170, 170));

                            stackPanel.Children.Add(newstitle);
                            stackPanel.Children.Add(newsdescription);

                            stackPanel.VerticalAlignment = VerticalAlignment.Center;

                            maingrid.Children.Add(newsImage);
                            maingrid.Children.Add(stackPanel);

                            Grid.SetColumn(newsImage, 0);
                            Grid.SetColumn(stackPanel, 1);

                            maingrid.Margin = new Thickness(0, 0, 0, 15);
                            NewsContainer.Children.Add(maingrid);
                        }
                    });
                }
                catch (Exception)
                {
                    // Error occurred while getting news information
                    Application.Current.Dispatcher.Invoke(() =>
                    {
                        var errorContainer = new Grid();
                        //Add the column definitions to this grid
                        errorContainer.ColumnDefinitions.Add(new ColumnDefinition()
                        {
                            Width = new GridLength(2, GridUnitType.Pixel)
                        });
                        errorContainer.ColumnDefinitions.Add(new ColumnDefinition()
                        {
                            Width = new GridLength(248, GridUnitType.Star)
                        });

                        //Create the before of the label
                        var LabelBefore        = new Grid();
                        LabelBefore.Background = SystemParameters.WindowGlassBrush;

                        var errorlbl        = new Label();
                        errorlbl.Content    = "I'm having a trouble connecting to our servers.";
                        errorlbl.Foreground = new SolidColorBrush(Colors.White);
                        errorlbl.Margin     = new Thickness(5, 0, 0, 0);

                        errorContainer.Children.Add(errorlbl);
                        errorContainer.Children.Add(LabelBefore);

                        Grid.SetColumn(errorlbl, 1);
                        Grid.SetColumn(LabelBefore, 0);

                        NewsContainer.Children.Add(errorContainer);
                    }
                                                          );
                }
            });

            var newsThread = new Thread(newsthreadstart);

            newsThread.Start();
        }