public void loginClose() { TopMost = false; WindowState = FormWindowState.Normal; Close(); of.refreshForm(); }
public void default_SpeechRecognized(object sender, SpeechRecognizedEventArgs e) { String speech1 = e.Result.Text; // of.mainLabel.Text = speech1; Login login = new Login(of); Admin admin = new Admin(of); if (speech1 == "Hello" && e.Result.Confidence > 0.92 || speech1 == "Open admin" && e.Result.Confidence > 0.92 || speech1 == "Close admin" && e.Result.Confidence > 0.92) { switch (speech1) { case "What time is it?": System.DateTime now = System.DateTime.Now; string time = now.GetDateTimeFormats('t')[0]; of.optio.SpeakAsync(time); of.productLabel.Text = ""; break; case "What day is it today?": string dayis; dayis = "Today is " + System.DateTime.Now.ToString("dddd", new System.Globalization.CultureInfo("en-US")); of.optio.SpeakAsync(dayis); of.productLabel.Text = ""; break; case "What is todays date?": string date; date = "the date is " + System.DateTime.Now.ToString("dd MMM yyyy", new System.Globalization.CultureInfo("en-US")); of.optio.SpeakAsync(date); of.productLabel.Text = ""; break; case "What can you do?": string action; action = "I can help you find anything you are looking for"; of.optio.SpeakAsync(action); of.productLabel.Text = ""; of.mainLabel.Text = action; break; case "What is your name?": string name; name = "My name is Optio"; of.optio.SpeakAsync(name); of.productLabel.Text = ""; of.mainLabel.Text = name; break; case "Hello": string greeting; greeting = "Hi, what would you like to find?"; of.optio.SpeakAsync(greeting); of.mainLabel.Text = greeting; of.productLabel.Text = ""; break; case "Open admin": of.optio.SpeakAsync("opening Admin"); of.productLabel.Text = ""; of.mainLabel.Text = ""; Task.Delay(5000); if (Application.OpenForms.OfType <Login>().Count() == 1) { Application.OpenForms.OfType <Login>().First().Close(); } login.Show(); login.TopMost = true; Cursor.Show(); volumeCheck(); break; case "Close admin": // of.optio.Volume = 100; of.optio.SpeakAsync("Closing admin"); of.refreshForm(); if (Application.OpenForms.OfType <Login>().Count() == 1) { Application.OpenForms.OfType <Login>().Last().Close(); } break; } } }