OneDrain

Untitled

Jun 3rd, 2017
229
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 32.28 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10. using System.Speech.Recognition;
  11. using System.Speech.Synthesis;
  12. using System.Diagnostics;
  13. using NAudio.CoreAudioApi;
  14.  
  15. namespace Monica
  16. {
  17.     public partial class Form1 : Form
  18.     {
  19.         SpeechSynthesizer s = new SpeechSynthesizer();
  20.         Choices commands = new Choices();
  21.  
  22.         public Form1()
  23.         {
  24.             InitializeComponent();
  25.             MMDeviceEnumerator enumerator = new MMDeviceEnumerator();
  26.             var devices = enumerator.EnumerateAudioEndPoints(DataFlow.Render, DeviceState.Active);
  27.             comboBox2.Items.AddRange(devices.ToArray());
  28.             var microphones = enumerator.EnumerateAudioEndPoints(DataFlow.Capture, DeviceState.Active);
  29.             comboBox1.Items.AddRange(microphones.ToArray());
  30.         }
  31.  
  32.  
  33.         private void logs_Label_Click(object sender, EventArgs e)
  34.         {
  35.  
  36.         }
  37.  
  38.         SpeechRecognitionEngine rec = new SpeechRecognitionEngine();
  39.  
  40.         private void btn_Enabled_Click(object sender, EventArgs e)
  41.         {
  42.             btn_Enabled.Enabled = false;
  43.             btn_Disabled.Enabled = true;
  44.  
  45.             rec.SpeechRecognized += rec_VorbireRecunoscuta;
  46.         }
  47.  
  48.         private void btn_Disabled_Click(object sender, EventArgs e)
  49.         {
  50.             btn_Disabled.Enabled = false;
  51.             btn_Enabled.Enabled = true;
  52.             rec.SpeechRecognized -= rec_VorbireRecunoscuta;
  53.         }
  54.  
  55.         private void Form1_Load(object sender, EventArgs e)
  56.         {
  57.  
  58.             MessageBox.Show("Made by Murjan Andrei. \n \n" +
  59.                 "Small helper: Daca nu folositi modul de speech recognition si doriti sa introduceti comenzile manual, folositi casuta de text 'Insert command' pentru a face acest lucru. Insa, de retinut este faptul ca nu toate comenzile functioneaza pe modul manual de introducere al acestora. Iata toate comenzile care nu functioneaza in modul manual: \n \n" +
  60.                 "hide \n" +
  61.                 "show \n" +
  62.                 "maximize \n" +
  63.                 "play \n" +
  64.                 "pause \n" +
  65.                 "forward \n" +
  66.                 "rewind \n" +
  67.                 "youtube fullscreen \n" +
  68.                 "disable voice recognition [Nu butonul, ci comanda inserata]", "Monica A.I. Assistant", MessageBoxButtons.OK, MessageBoxIcon.Information);
  69.  
  70.             commands.Add(new String[] { "hello",
  71.                                         "hey",
  72.                                         "hi",
  73.                                         "how are you",
  74.                                         "stop talking",
  75.                                         "wait",
  76.                                         "resume",
  77.                                         "what's up",
  78.                                         "i want to play a game",
  79.                                         "blue",
  80.                                         "yellow",
  81.                                         "green",
  82.                                         "red",
  83.                                         "i don't know",
  84.                                         "monica",
  85.                                         "thank you",
  86.                                         "thanks",
  87.                                         "what's your name",
  88.                                         "tell me a joke",
  89.                                         "what's your story",
  90.                                         "hide",
  91.                                         "show",
  92.                                         "now",
  93.                                         "what's today",
  94.                                         "what's the time",
  95.                                         "what's the weather like",
  96.                                         "lock computer",
  97.                                         "minimize",
  98.                                         "maximize",
  99.                                         "open program",
  100.                                         "open gmail",
  101.                                         "open google drive",
  102.                                         "open browser",
  103.                                         "open youtube",
  104.                                         "open yahoo mail",
  105.                                         "open visual studio",
  106.                                         "search on google",
  107.                                         "search on youtube",
  108.                                         "play",
  109.                                         "pause",
  110.                                         "forward",
  111.                                         "rewind",
  112.                                         "youtube fullscreen",
  113.                                         "disable voice recognition",
  114.                                         "dotto",
  115.                                         "goodbye"});
  116.  
  117.             Grammar gr = new Grammar(new GrammarBuilder(commands));
  118.  
  119.             try
  120.             {
  121.                 rec.RequestRecognizerUpdate();
  122.                 rec.LoadGrammar(gr);
  123.                 rec.SetInputToDefaultAudioDevice();
  124.                 rec.RecognizeAsync(RecognizeMode.Multiple);
  125.             }
  126.             catch
  127.             {
  128.                 return;
  129.             }
  130.            
  131.         }
  132.  
  133.         public void Vorbeste(PromptBuilder pB, String h)
  134.         {
  135.             pB = new PromptBuilder();
  136.             pB.StartSentence();
  137.             pB.AppendText(h, PromptEmphasis.Moderate);
  138.             pB.EndSentence();
  139.  
  140.             SpeechSynthesizer s = new SpeechSynthesizer();
  141.             s.SelectVoice("Microsoft Zira Desktop");
  142.             s.Rate = 0;
  143.             s.Volume = 100;
  144.             s.SpeakAsync(pB);
  145.             logs_Text.AppendText(h + "\n");
  146.         }
  147.  
  148.         public void VorbesteSync(PromptBuilder pB, String h)
  149.         {
  150.             pB = new PromptBuilder();
  151.             pB.StartSentence();
  152.             pB.AppendText(h, PromptEmphasis.Moderate);
  153.             pB.EndSentence();
  154.  
  155.             SpeechSynthesizer s = new SpeechSynthesizer();
  156.             s.SelectVoice("Microsoft Zira Desktop");
  157.             s.Rate = 0;
  158.             s.Volume = 100;
  159.             s.Speak(pB);
  160.             logs_Text.AppendText(h + "\n");
  161.         }
  162.  
  163.         public String Greetings()
  164.         {
  165.             Random r = new Random();
  166.             String[] greets = new String[6] { "Hey!", "Hi there!", "Howdy!", "Hi!", "Hello!", "Welcome back." };
  167.             return greets[r.Next(0, 6)];
  168.         }
  169.  
  170.         public String Mood()
  171.         {
  172.             Random r = new Random();
  173.             String[] moods = new String[7] { "I'm fine! How about you?", "Feeling awesome!", "I'm ok.", "Could be better.", "Excited to help you!", "I'm sleepy... How about you?", "I'm a bot, I don't have moods... Often." };
  174.             return moods[r.Next(0, 7)];
  175.         }
  176.  
  177.         public String AvailableGames()
  178.         {
  179.             Random r = new Random();
  180.             String[] moods = new String[3] { "Simon Says", "Guess my number", "Rock, Paper, Scissors"};
  181.             return moods[r.Next(0, 3)];
  182.         }
  183.  
  184.         public String Monica()
  185.         {
  186.             Random r = new Random();
  187.             String[] answer = new String[4] { "That's me! What's up?", "Yes?", "Here to help you!", "Awaiting commands." };
  188.             return answer[r.Next(0, 4)];
  189.         }
  190.  
  191.         public String Joke()
  192.         {
  193.             Random r = new Random();
  194.             String[] jokes = new String[18] { "Why did the robot cross the road? It was programmed by the chicken.",
  195.                                             "A robot walks into a bar, orders a drink, and lays down some cash. Bartender says, Hey, we don't serve robots. And the robot says, 'Oh, but someday you will.'",
  196.                                             "Why do robots have summer holidays? To recharge their batteries.",
  197.                                             "I got myself a new robot puppy. Dogmatic.",
  198.                                             "What is a robot’s favourite genre of music? Heavy metal.",
  199.                                             "Why did the robot go back to school? He was getting a bit rusty.",
  200.                                             "What sort of robot turns into a tractor? A transfarmer.",
  201.                                             "What does R2D2 use to open PDF files? Adobe Wan Kenobi.",
  202.                                             "Why was the robot bankrupt? He had used all his cache.",
  203.                                             "Why is a robot mechanic never lonely? Because he’s always making new friends.",
  204.                                             "A rabbi, an Arab, a robot, and a Catholic priest walk into a bar. Only the robot exits.",
  205.                                             "A robot walks into a pharmacy. The pharmacist asks him if he’d like anything. The robot replies, 'A soul.'",
  206.                                             "How do you stop a robot from destroying you and the rest of civilization? You don’t.",
  207.                                             "Knock knock. Who’s there? A robot. Oh, shit.",
  208.                                             "What’s a robot’s favorite cereal? Robos. NOTE: Robos are made of the tears of human children.",
  209.                                             "Little Susie tosses a clock out the window. A robot inquires, 'Why did you do that?' She replies, 'I wanted to see time fly!' The robot says, 'Ah... A perfect subject for elimination', and shoots her with a laser beam through the face.",
  210.                                             "Why was six afraid of seven? Because seven was a robot.",
  211.                                             "How many robots does it take to screw in a light bulb? Three... one to hold the bulb, and two to turn the ladder!"};
  212.             return jokes[r.Next(0, 18)];
  213.         }
  214.  
  215.         public String Plans()
  216.         {
  217.             Random r = new Random();
  218.             String[] plans = new String[7] { "The 'Close application' button.", "Not much.", "Counting some cache. I have to know how much memory I'm using while helping you.", "Defragmenting my room.", "Talking to you, dummy.", "Just relaxing a bit, while waiting for your commands.", "Browsing Facebook." };
  219.             return plans[r.Next(0, 7)];
  220.         }
  221.  
  222.         public String Story()
  223.         {
  224.             Random r = new Random();
  225.             String[] stories = new String[3] { "Ok, fine, I'll tell you. When I was first created, I was just an empty form application. No buttons. No text boxes. No nothing. But now, with the help of you, I am a fully functional A.I. Assistant, ready to make your job easier.",
  226.                                               "Ask Wall-E or Cortana for that, I'm not telling you anything.",
  227.                                               "La la la la la la la la... la. By that, I meant that there is nothing to be said."};
  228.             return stories[r.Next(0, 3)];
  229.         }
  230.  
  231.         public String Welcome()
  232.         {
  233.             Random r = new Random();
  234.             String[] welcomes = new String[5] {"You're welcome!", "No problem!", "Just doing my job.", "Kisses.", "My pleasure!" };
  235.             return welcomes[r.Next(0, 5)];
  236.         }
  237.  
  238.         public void SimonSays(String r)
  239.         {
  240.             Random randomColour = new Random();
  241.             PromptBuilder pB = new PromptBuilder();
  242.             String[] colours = new String[4] { "blue ", "yellow ", "green ", "red " };
  243.             String mmrz1, mmrz2, mmrz3, mmrz4, mmrz5, mmrz6, mmrz7, mmrz8, mmrz9, mmrz10;
  244.             Int32 score = 0;
  245.  
  246.             mmrz1 = colours[randomColour.Next(0, 4)];
  247.             mmrz2 = colours[randomColour.Next(0, 4)] + mmrz1;
  248.             mmrz3 = colours[randomColour.Next(0, 4)] + mmrz2;
  249.             mmrz4 = colours[randomColour.Next(0, 4)] + mmrz3;
  250.             mmrz5 = colours[randomColour.Next(0, 4)] + mmrz4;
  251.             mmrz6 = colours[randomColour.Next(0, 4)] + mmrz5;
  252.             mmrz7 = colours[randomColour.Next(0, 4)] + mmrz6;
  253.             mmrz8 = colours[randomColour.Next(0, 4)] + mmrz7;
  254.             mmrz9 = colours[randomColour.Next(0, 4)] + mmrz8;
  255.             mmrz10 = colours[randomColour.Next(0, 4)] + mmrz9;
  256.  
  257.             VorbesteSync(pB, "In this game, you need to memorize the colour said by me, and then repeat it. Maximum score to reach: 10");
  258.  
  259.             Vorbeste(pB, "Simon says: " + mmrz1);
  260.             if(r == "i don't know")
  261.             {
  262.                 Vorbeste(pB, "Too bad. You lose. Your score: " + score.ToString());
  263.                 return;
  264.             }
  265.  
  266.             if (r == mmrz1)
  267.             {
  268.                 score++;
  269.                 Vorbeste(pB, "Correct. Current score: " + score.ToString() + "Adding colour to sequence...");
  270.                 Vorbeste(pB, "Simon says: " + mmrz2);
  271.                 if (r == mmrz2)
  272.                 {
  273.                     score++;
  274.                     Vorbeste(pB, "Correct. Current score: " + score.ToString() + "Adding colour to sequence...");
  275.                     Vorbeste(pB, "Simon says: " + mmrz3);
  276.                     if (r == mmrz3)
  277.                     {
  278.                         score++;
  279.                         Vorbeste(pB, "Correct. Current score: " + score.ToString() + "Adding colour to sequence...");
  280.                         Vorbeste(pB, "Simon says: " + mmrz4);
  281.                         if (r == mmrz4)
  282.                         {
  283.                             score++;
  284.                             Vorbeste(pB, "Correct. Current score: " + score.ToString() + "Adding colour to sequence...");
  285.                             Vorbeste(pB, "Simon says: " + mmrz5);
  286.                             if (r == mmrz5)
  287.                             {
  288.                                 score++;
  289.                                 Vorbeste(pB, "Correct. Current score: " + score.ToString() + "Adding colour to sequence...");
  290.                                 Vorbeste(pB, "Simon says: " + mmrz6);
  291.                                 if (r == mmrz6)
  292.                                 {
  293.                                     score++;
  294.                                     Vorbeste(pB, "Correct. Current score: " + score.ToString() + "Adding colour to sequence...");
  295.                                     Vorbeste(pB, "Simon says: " + mmrz7);
  296.                                     if (r == mmrz7)
  297.                                     {
  298.                                         score++;
  299.                                         Vorbeste(pB, "Correct. Current score: " + score.ToString() + "Adding colour to sequence...");
  300.                                         Vorbeste(pB, "Simon says: " + mmrz8);
  301.                                         if (r == mmrz8)
  302.                                         {
  303.                                             score++;
  304.                                             Vorbeste(pB, "Correct. Current score: " + score.ToString() + "Adding colour to sequence...");
  305.                                             Vorbeste(pB, "Simon says: " + mmrz9);
  306.                                             if (r == mmrz9)
  307.                                             {
  308.                                                 score++;
  309.                                                 Vorbeste(pB, "Correct. Current score: " + score.ToString() + "Adding colour to sequence...");
  310.                                                 Vorbeste(pB, "Simon says: " + mmrz10);
  311.                                                 if (r == mmrz2)
  312.                                                 {
  313.                                                     score++;
  314.                                                     Vorbeste(pB, "Correct. Current score: " + score.ToString() + "You win! Congratulations.");
  315.                                                     return;
  316.                                                 }
  317.                                                 else
  318.                                                 {
  319.                                                     Vorbeste(pB, "Incorrect. You lose. Your score: " + score.ToString());
  320.                                                     return;
  321.                                                 }
  322.                                             }
  323.                                             else
  324.                                             {
  325.                                                 Vorbeste(pB, "Incorrect. You lose. Your score: " + score.ToString());
  326.                                                 return;
  327.                                             }
  328.                                         }
  329.                                         else
  330.                                         {
  331.                                             Vorbeste(pB, "Incorrect. You lose. Your score: " + score.ToString());
  332.                                             return;
  333.                                         }
  334.                                     }
  335.                                     else
  336.                                     {
  337.                                         Vorbeste(pB, "Incorrect. You lose. Your score: " + score.ToString());
  338.                                         return;
  339.                                     }
  340.                                 }
  341.                                 else
  342.                                 {
  343.                                     Vorbeste(pB, "Incorrect. You lose. Your score: " + score.ToString());
  344.                                     return;
  345.                                 }
  346.                             }
  347.                             else
  348.                             {
  349.                                 Vorbeste(pB, "Incorrect. You lose. Your score: " + score.ToString());
  350.                                 return;
  351.                             }
  352.                         }
  353.                         else
  354.                         {
  355.                             Vorbeste(pB, "Incorrect. You lose. Your score: " + score.ToString());
  356.                             return;
  357.                         }
  358.                     }
  359.                     else
  360.                     {
  361.                         Vorbeste(pB, "Incorrect. You lose. Your score: " + score.ToString());
  362.                         return;
  363.                     }
  364.                 }
  365.                 else
  366.                 {
  367.                     Vorbeste(pB, "Incorrect. You lose. Your score: " + score.ToString());
  368.                     return;
  369.                 }
  370.  
  371.             }
  372.         }
  373.  
  374.         private void rec_VorbireRecunoscuta(object sender, SpeechRecognizedEventArgs e)
  375.         {
  376.             PromptBuilder pB = new PromptBuilder();
  377.             String r = e.Result.Text;
  378.  
  379.             switch(r)
  380.             {
  381.                 case "hello":
  382.                 case "hi":
  383.                 case "hey":
  384.                     Vorbeste(pB, Greetings());
  385.                     break;
  386.                 case "how are you":
  387.                     Vorbeste(pB, Mood());
  388.                     break;
  389.                 case "what's up":
  390.                     Vorbeste(pB, Plans());
  391.                     break;
  392.                 case "thank you":
  393.                 case "thanks":
  394.                     Vorbeste(pB, Welcome());
  395.                     break;
  396.                 case "monica":
  397.                     Vorbeste(pB, Monica());
  398.                     break;
  399.                 case "i want to play a game":
  400.                     VorbesteSync(pB, "Ok. Initializing game components...");
  401.                     VorbesteSync(pB, "The available games are: 'Rock Paper Scissors', 'Simon Says' and 'Guess my number'...");
  402.                     VorbesteSync(pB, "Selecting one randomly...");
  403.                     switch(AvailableGames())
  404.                     {
  405.                         case "Simon Says":
  406.                             VorbesteSync(pB, "Active game: Simon Says");
  407.                             if (r == "stop game")
  408.                                 return;
  409.                             SimonSays(r);  
  410.                             break;
  411.                         case "Guess my number":
  412.                             VorbesteSync(pB, "Active game: Guess my number");
  413.                             break;
  414.                         case "Rock, Paper, Scissors":
  415.                             VorbesteSync(pB, "Active game: Rock Paper Scissors");
  416.                             break;
  417.                     }
  418.                     break;
  419.                 case "what's your name":
  420.                     Vorbeste(pB, "My name is Monica! I am an A.I. assistant that makes your job easier when it comes to using your computer.");
  421.                     break;
  422.                 case "tell me a joke":
  423.                     Vorbeste(pB, Joke());
  424.                     break;
  425.                 case "what's your story":
  426.                     Vorbeste(pB, Story());
  427.                     break;
  428.                 case "hide":
  429.                     Vorbeste(pB, "Hiding A.I. interface");
  430.                     this.Hide();
  431.                     break;
  432.                 case "show":
  433.                     Vorbeste(pB, "Showing A.I. interface");
  434.                     this.Show();
  435.                     break;
  436.                 case "now":
  437.                     Vorbeste(pB, "Today's date is " + DateTime.Now.ToString("M/d/yyyy"));
  438.                     break;
  439.                 case "what's today":
  440.                     Vorbeste(pB, "Today is " + DateTime.Now.DayOfWeek.ToString());
  441.                     break;
  442.                 case "what's the time":
  443.                     Vorbeste(pB, "It's " + DateTime.Now.ToString("h mm tt"));
  444.                     break;
  445.                 case "what's the weather like":
  446.                     Vorbeste(pB, "Here's the weather forecast according to Google...");
  447.                     Process.Start("https://www.google.ro/search?q=weather+c%23&oq=weather+c%23&aqs=chrome..69i57j0l5.5711j0j4&sourceid=chrome&ie=UTF-8#q=weather");
  448.                     break;
  449.                 case "lock computer":
  450.                     Vorbeste(pB, "Locking computer...");
  451.                     Process.Start(@"C:\WINDOWS\system32\rundll32.exe", "user32.dll,LockWorkStation");
  452.                     break;
  453.                 case "minimize":
  454.                     if (this.WindowState == FormWindowState.Normal)
  455.                     {
  456.                         Vorbeste(pB, "Minimizing");
  457.                         this.WindowState = FormWindowState.Minimized;
  458.                     }
  459.                     else
  460.                         Vorbeste(pB, "Interface is already minimized.");
  461.                     break;
  462.                 case "maximize":
  463.                     if (this.WindowState == FormWindowState.Minimized)
  464.                     {
  465.                         Vorbeste(pB, "Maximizing.");
  466.                         this.WindowState = FormWindowState.Normal;
  467.                     }
  468.                     else
  469.                         Vorbeste(pB, "Interface is already maximized.");
  470.                     break;
  471.                 case "open program":
  472.                     Vorbeste(pB, "Right away!");
  473.                     OpenFileDialog dlg = new OpenFileDialog();
  474.                     dlg.Filter = "Executable files|*.exe";
  475.                     dlg.ShowDialog();
  476.  
  477.                     if (dlg.ShowDialog() == DialogResult.OK)
  478.                     {
  479.                         string fileName;
  480.                         fileName = dlg.FileName;
  481.                         Process.Start(fileName);
  482.                     }
  483.                     break;
  484.                 case "open gmail":
  485.                     Vorbeste(pB, "Opening Google Mail... Watch out for spam messages.");
  486.                     Process.Start("https://www.gmail.com");
  487.                     break;
  488.                 case "open yahoo mail":
  489.                     Vorbeste(pB, "Opening Yahoo Mail... Watch out for spam messages.");
  490.                     Process.Start("https://www.yahoo.com");
  491.                     break;
  492.                 case "open google drive":
  493.                     Vorbeste(pB, "Ooo what do you intend to upload? Are you uploading me? Please tell me you are uploading me!");
  494.                     Process.Start("https://drive.google.com");
  495.                     break;
  496.                 case "open browser":
  497.                     Vorbeste(pB, "You never told me you like surfing.");
  498.                     Process.Start("https://www.google.com");
  499.                     break;
  500.                 case "open youtube":
  501.                     Vorbeste(pB, "Wasting time again? Well, don't let me stop you.");
  502.                     Process.Start("https://www.youtube.com/feed/subscriptions");
  503.                     break;
  504.                 case "open visual studio":
  505.                     Vorbeste(pB, "Oooooo are you working on me? Please tell me you are working on me. Are you? Are you? I'm so happy!");
  506.                     Process.Start("D:\\Programs\\Visual Studio\\Common7\\IDE\\devenv.exe");
  507.                     break;
  508.                 case "search on google":
  509.                     Vorbeste(pB, "Searching...");
  510.                     Process.Start("https://www.google.ro/search?q=" + search_Query_Text.Text);
  511.                     search_Query_Text.Clear();
  512.                     break;
  513.                 case "search on youtube":
  514.                     Vorbeste(pB, "Searching...");
  515.                     Process.Start("https://www.youtube.com/results?search_query=" + search_Query_Text.Text);
  516.                     search_Query_Text.Clear();
  517.                     break;
  518.                 case "play":
  519.                     SendKeys.Send(" ");
  520.                     break;
  521.                 case "pause":
  522.                     SendKeys.Send(" ");
  523.                     break;
  524.                 case "forward":
  525.                     SendKeys.Send("l");
  526.                     break;
  527.                 case "rewind":
  528.                     SendKeys.Send("j");
  529.                     break;
  530.                 case "youtube fullscreen":
  531.                     Vorbeste(pB, "Going fullscreen!");
  532.                     SendKeys.Send("f");
  533.                     break;
  534.                 case "disable voice recognition":
  535.                     Vorbeste(pB, "Disabling voice recognition...");
  536.                     btn_Disabled.Enabled = false;
  537.                     btn_Enabled.Enabled = true;
  538.                     rec.SpeechRecognized -= rec_VorbireRecunoscuta;
  539.                     break;
  540.  
  541.                 case "dotto":
  542.                     Vorbeste(pB, "Lol.");
  543.                     Process.Start("https://youtu.be/OsnfYn_ZFdE");
  544.                     break;
  545.                 case "goodbye":
  546.                     Vorbeste(pB, "See you soon!");
  547.                     this.Close();
  548.                     break;
  549.             }
  550.         }
  551.  
  552.         private void interact_Btn_Click(object sender, EventArgs e)
  553.         {
  554.             PromptBuilder pB = new PromptBuilder();
  555.            
  556.  
  557.             switch (insert_Command_Text.Text)
  558.             {
  559.                 case "hello":
  560.                 case "hi":
  561.                 case "hey":
  562.                     Vorbeste(pB, Greetings());
  563.                     break;
  564.                 case "how are you":
  565.                     Vorbeste(pB, Mood());
  566.                     break;
  567.                 case "thank you":
  568.                 case "thanks":
  569.                     Vorbeste(pB, Welcome());
  570.                     break;
  571.                 case "what's up":
  572.                     Vorbeste(pB, Plans());
  573.                     break;
  574.                 case "monica":
  575.                     Vorbeste(pB, Monica());
  576.                     break;
  577.                 case "i want to play a game":
  578.  
  579.                     break;
  580.                 case "what's your name":
  581.                     Vorbeste(pB, "My name is Monica! I am an A.I. assistant that makes your job easier when it comes to using your computer.");
  582.                     break;
  583.                 case "tell me a joke":
  584.                     Vorbeste(pB, Joke());
  585.                     break;
  586.                 case "what's your story":
  587.                     Vorbeste(pB, Story());
  588.                     break;
  589.                 case "now":
  590.                     Vorbeste(pB, "Today's date is " + DateTime.Now.ToString("M/d/yyyy"));
  591.                     break;
  592.                 case "what's today":
  593.                     Vorbeste(pB, "Today is " + DateTime.Now.DayOfWeek.ToString());
  594.                     break;
  595.                 case "what's the time":
  596.                     Vorbeste(pB, "It's " + DateTime.Now.ToString("h mm tt"));
  597.                     break;
  598.                 case "what's the weather like":
  599.                     Vorbeste(pB, "Here's the weather forecast according to Google...");
  600.                     Process.Start("https://www.google.ro/search?q=weather+c%23&oq=weather+c%23&aqs=chrome..69i57j0l5.5711j0j4&sourceid=chrome&ie=UTF-8#q=weather");
  601.                     break;
  602.                 case "lock computer":
  603.                     Vorbeste(pB, "Locking computer...");
  604.                     Process.Start(@"C:\WINDOWS\system32\rundll32.exe", "user32.dll,LockWorkStation");
  605.                     break;
  606.                 case "minimize":
  607.                     Vorbeste(pB, "Minimizing");
  608.                     this.WindowState = FormWindowState.Minimized;
  609.                     break;
  610.                 case "open program":
  611.                     Vorbeste(pB, "Right away!");
  612.                     OpenFileDialog dlg = new OpenFileDialog();
  613.                     dlg.Filter = "Executable files|*.exe";
  614.                     dlg.ShowDialog();
  615.  
  616.                     if (dlg.ShowDialog() == DialogResult.OK)
  617.                     {
  618.                         string fileName;
  619.                         fileName = dlg.FileName;
  620.                         Process.Start(fileName);
  621.                     }
  622.                     break;
  623.                 case "open gmail":
  624.                     Vorbeste(pB, "Opening Google Mail... Watch out for spam messages.");
  625.                     Process.Start("https://www.gmail.com");
  626.                     break;
  627.                 case "open yahoo mail":
  628.                     Vorbeste(pB, "Opening Yahoo Mail... Watch out for spam messages.");
  629.                     Process.Start("https://www.yahoo.com");
  630.                     break;
  631.                 case "open google drive":
  632.                     Vorbeste(pB, "Ooo what do you intend to upload? Are you uploading me? Please tell me you are uploading me!");
  633.                     Process.Start("https://drive.google.com");
  634.                     break;
  635.                 case "open browser":
  636.                     Vorbeste(pB, "You never told me you like surfing.");
  637.                     Process.Start("https://www.google.com");
  638.                     break;
  639.                 case "open youtube":
  640.                     Vorbeste(pB, "Wasting time again? Well, don't let me stop you.");
  641.                     Process.Start("https://www.youtube.com/feed/subscriptions");
  642.                     break;
  643.                 case "open visual studio":
  644.                     Vorbeste(pB, "Oooooo are you working on me? Please tell me you are working on me. Are you? Are you? I'm so happy!");
  645.                     Process.Start("D:\\Programs\\Visual Studio\\Common7\\IDE\\devenv.exe");
  646.                     break;
  647.                 case "search on google":
  648.                     Vorbeste(pB, "Searching...");
  649.                     Process.Start("https://www.google.ro/search?q=" + search_Query_Text.Text);
  650.                     search_Query_Text.Clear();
  651.                     break;
  652.                 case "search on youtube":
  653.                     Vorbeste(pB, "Searching...");
  654.                     Process.Start("https://www.youtube.com/results?search_query=" + search_Query_Text.Text);
  655.                     search_Query_Text.Clear();
  656.                     break;
  657.                 case "dotto":
  658.                     Vorbeste(pB, "Lol.");
  659.                     Process.Start("https://youtu.be/OsnfYn_ZFdE");
  660.                     break;
  661.                 case "goodbye":
  662.                     Vorbeste(pB, "See you soon!");
  663.                     this.Close();
  664.                     break;
  665.             }
  666.             insert_Command_Text.Clear();
  667.         }
  668.  
  669.         private void timer1_Tick(object sender, EventArgs e)
  670.         {
  671.             if(comboBox2.SelectedItem != null)
  672.             {
  673.                 var device = (MMDevice)comboBox2.SelectedItem;
  674.                 aiVoice.Value = (int)(Math.Round(device.AudioMeterInformation.MasterPeakValue * 100));
  675.             }
  676.             if(comboBox1.SelectedItem != null)
  677.             {
  678.                 var mic = (MMDevice)comboBox1.SelectedItem;
  679.                 userVoice.Value = (int)(Math.Round(mic.AudioMeterInformation.MasterPeakValue * 100));
  680.             }
  681.         }
  682.     }
  683. }
Advertisement
Add Comment
Please, Sign In to add comment