コード例 #1
0
 private void selectUserClick(object sender, RoutedEventArgs e)
 {
     /*
      *  Non thread blocking Function to SelectUser window. would be made Synchronous
      */
     SelectUser.OpenUserSelectWindow();
 }
コード例 #2
0
        private static void UiGrammar_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
        {
            if (e.Result != null & e.Result.Confidence >= 0.86)
            {
                Task.Run(() =>
                {
                    writeToTextBox(e.Result.Text);
                });

                DataStore.AddRecentCommand(e.Result.Text);
                try
                {
                    if (e.Result.Text == "Add User")
                    {
                        AddUser.OpenAddUserDialog();                            //opens a new AddUser Dialog box on a new thread
                    }
                    else if (e.Result.Text == "Select User")
                    {
                        SelectUser.OpenUserSelectWindow();                      //opens a new SelectUser Dialog box on a new thread
                    }
                    else if (e.Result.Text == "Expand Expander")
                    {
                        ExpandIt();
                    }
                    else if (e.Result.Text == "Increase Synthesizer Volume")
                    {
                        UpdateSlider(1, "volume");                               //INCREASES the Synthesizer Volume slider by 1 point
                    }
                    else if (e.Result.Text == "Increase Synthesizer Rate")
                    {
                        UpdateSlider(1, "rate");                                 //INCREASES the Synthesizer Rate Slider by 1 point
                    }
                    else if (e.Result.Text == "Decrease Synthesizer Volume")
                    {
                        UpdateSlider(-1, "volume");                              //DECREASES the Synthesizer Volume slider by 1 point
                    }
                    else if (e.Result.Text == "Decrease Synthesizer Rate")
                    {
                        UpdateSlider(-1, "rate");                                //DECREASES the Synthesizer Volume slider by 1 point
                    }
                    else if (e.Result.Text == "Exit")
                    {
                        Task.Run(() => { CloseMainWindow(); });
                    }
                    else
                    {
                        throw new Exception("Unknown recognition");
                    }
                }
                catch (Exception exception)
                {
                    DataStore.AddToErrorLog(string.Format("Exception occured---\n Message : {0}\n StackTrace : {1}", exception.Message, exception.StackTrace));
                }
                //do UI refreshing here
                UIResponse(new Response(CommandType.UI, DateTime.Now.TimeOfDay.Hours, e.Result.Text));
            }
        }
コード例 #3
0
        public static void OpenUserSelectWindow()
        {
            /*
             *  Starts a new SelectUser window on separate thread of execution
             *  hence not blocking the Main UI
             */
            Thread thread = new Thread(() =>
            {
                SelectUser su = new SelectUser();
                su.Closed    += (sender, e) =>
                {
                    su.Dispatcher.InvokeShutdown();
                    DataStore.handle1.Set();                                        //sets the handle in DataStore
                };
                su.Show();
                System.Windows.Threading.Dispatcher.Run();                              //MAkes the system Dispatcher to Run the thread
            });

            thread.SetApartmentState(ApartmentState.STA);                               //STA apartment state is necessary for Wpf components to run on
            thread.Start();
        }
コード例 #4
0
        public static void StartDataStoreManager()
        {
            LoadUserSettings();
            if (NoStoredUser)
            {
                AddUser.OpenAddUserDialog();
                handle1.WaitOne();
            }

            else
            {
                SelectUser.OpenUserSelectWindow();
                handle1.WaitOne();
            }
            SetUserNow(CurrentUser);
            IsUserSet = true;

            Directory.CreateDirectory(voixDir);
            Directory.CreateDirectory(voixDir + @"\Dump");


            Init.waitHandle2.Set();
        }
コード例 #5
0
 public static void OpenUserSelectWindow()
 {
     /*
         Starts a new SelectUser window on separate thread of execution
         hence not blocking the Main UI
     */
     Thread thread = new Thread(() =>
       {
           SelectUser su = new SelectUser();
           su.Closed += (sender, e) =>
           {
               su.Dispatcher.InvokeShutdown();
               DataStore.handle1.Set();                                      //sets the handle in DataStore
           };
           su.Show();
           System.Windows.Threading.Dispatcher.Run();                            //MAkes the system Dispatcher to Run the thread
       });
     thread.SetApartmentState(ApartmentState.STA);                               //STA apartment state is necessary for Wpf components to run on
     thread.Start();
 }