Esempio n. 1
0
        private void addstatementbtn_Click(object sender, EventArgs e)
        {
            string inputtext  = inputtxt.Text.ToLower();
            string outputtext = outputtxt.Text;


            if (commandtypecombo.SelectedIndex == 1)
            {
                var MyIni = new INI_Reader("Data/humor.ini");
                if (!MyIni.KeyExists(inputtext, "Humor"))
                {
                    MyIni.Write(inputtext + " ", " " + outputtext, "Humor");
                    MyIni.Write(outputtext + " ", " " + inputtext, "Humor2");

                    File.AppendAllText("Data/dictionary.txt", Environment.NewLine + inputtext);
                }
            }
            else if (commandtypecombo.SelectedIndex == 0)
            {
                var MyIni = new INI_Reader("Data/commands.ini");
                if (!MyIni.KeyExists(inputtext, "Commands"))
                {
                    MyIni.Write(inputtext + " ", " " + outputtext, "Commands");
                    MyIni.Write(outputtext + " ", " " + inputtext, "Commands2");

                    File.AppendAllText("Data/dictionary.txt", Environment.NewLine + inputtext);
                }
            }
        }
Esempio n. 2
0
        public static void Save()
        {
            INI_Reader Inisettings = new INI_Reader("Data/settings.ini");

            if (Initialized)
            {
                Inisettings.DeleteKey("Location", "Settings");
                Inisettings.Write("Location", Location, "Settings");

                Inisettings.DeleteKey("TempunitF", "Settings");
                Inisettings.Write("TempunitF", Temp_Unit_F.ToString(), "Settings");

                Inisettings.DeleteKey("RefreshInterval", "Settings");
                Inisettings.Write("RefreshInterval", RefreshInterval.ToString(), "Settings");

                if (NameSet)
                {
                    Inisettings.DeleteKey("Name", "Settings");
                    Inisettings.Write("Name", Name, "Settings");
                }
            }
            else
            {
                Console.WriteLine("Error");
            }
        }
Esempio n. 3
0
        public string GetCmdquestion(string output)
        {
            var MyIni = new INI_Reader("Data/commands.ini");

            var answer = MyIni.Read(output, "Commands2");

            return(answer);
        }
Esempio n. 4
0
        public bool GetCmdExists(string input)
        {
            var MyIni = new INI_Reader("Data/commands.ini");

            var answer = MyIni.KeyExists(input, "Commands");

            return(answer);
        }
Esempio n. 5
0
        public static void Initialise()
        {
            var Inisettings = new INI_Reader("Data/settings.ini");

            if (Inisettings.KeyExists("Name", "Settings"))
            {
                NameSet = true;
                Name    = Inisettings.Read("Name", "Settings");
            }

            Location = Inisettings.Read("Location", "Settings");

            Temp_Unit_F = Functions.ToBoolean(Inisettings.Read("TempunitF", "Settings"));

            RefreshInterval = Convert.ToInt32(Inisettings.Read("RefreshInterval", "Settings"));
            Initialized     = true;
        }
Esempio n. 6
0
        public void getjawab(string r)
        {
            switch (r)
            {
            case "wake up":
                status                  = true;
                statuslbl.Text          = "Awake";
                stoplistenbtn.Enabled   = true;
                startlistenbtn.Enabled  = true;
                resumelistenbtn.Enabled = false;
                pauselistenbtn.Enabled  = true;
                inputtxt.Text           = "";
                outputtxt.Text          = "";
                say3("Okay, I'm Here", "Okay, I'm up!", "Yo! I'm Here");
                break;

            case "get up":
                status                  = true;
                statuslbl.Text          = "Awake";
                stoplistenbtn.Enabled   = true;
                startlistenbtn.Enabled  = true;
                resumelistenbtn.Enabled = false;
                pauselistenbtn.Enabled  = true;
                inputtxt.Text           = "";
                outputtxt.Text          = "";
                say3("Okay, I'm Here", "Okay, I'm up!", "Yo! I'm Here");
                break;

            case "sleep":
                status                  = false;
                statuslbl.Text          = "Sleep";
                stoplistenbtn.Enabled   = false;
                resumelistenbtn.Enabled = true;
                pauselistenbtn.Enabled  = false;
                startlistenbtn.Enabled  = false;
                inputtxt.Text           = "";
                outputtxt.Text          = "";
                say("Fine, Bye bye!");
                break;
            }
            if (status == true && sayon == true)
            {
                //Commands

                /*
                 * var commands = new INI_Reader("Data/commands.ini");
                 * var statement = commands.Read(r, "Commands");//nothing
                 * var statement2 = commands.Read(statement, "Commands2");//what
                 *
                 * if (statement.Contains("%time%"))
                 * {
                 *  statement = DateTime.Now.ToString("h:mm tt");
                 * }
                 * if (statement.Contains("%date%"))
                 * {
                 *  statement = DateTime.Now.ToString("dd/MM/yyyy");
                 * }
                 * if (statement.Contains("%weather%"))
                 * {
                 *  if (weather.Weatherdatastatus == false)
                 *  {
                 *      statement = "Error Reciving data";
                 *  }
                 *  else
                 *  {
                 *      statement = ("It's " + weather.WeatherData["Condition"] + " outside");
                 *  }
                 * }
                 * if (statement.Contains("%temperature%"))
                 * {
                 *  if (Properties.Settings.Default.Temp_Unit_F) statement = ("It's " + weather.WeatherData["TemperatureF"] + " degrees in " + Properties.Settings.Default.Location);
                 *  else
                 *  {
                 *      try
                 *      {
                 *          statement = ("It's " + weather.WeatherData["TemperatureC"] + " degrees in " + Properties.Settings.Default.Location);
                 *      }
                 *      catch (Exception)
                 *      {
                 *          statement = "Connection Problem";
                 *      }
                 *  }
                 * }*/
                //Commands Workaround...

                //humor
                var humor       = new INI_Reader("Data/humor.ini");
                var statement1  = humor.Read(r, "Humor");           //nothing
                var statement12 = humor.Read(statement1, "Humor2"); //what

                //if r-what = what...
                if (GetCmdExists(r))
                {
                    say(GetCmdanswer(r));//say nothing
                }
                else
                {
                    if (r == statement12)
                    {
                        say(statement1);//say nothing
                    }
                    else
                    {
                        switch (r)
                        {
                        case "hello":
                            say("Hey, i'm Spark");
                            break;

                        case "what time is it":
                            say(DateTime.Now.ToString("h:mm tt"));
                            break;

                        case "how are you":
                            say("Fine, what about you?");
                            break;

                        case "open internet":
                            Process.Start("https://www.google.com");
                            say2("Fine", "Okay");
                            break;

                        case "open calculator":
                            Process.Start("calc.exe");
                            say2("Fine", "Okay");
                            break;
                        }
                    }
                }
            }
        }
Esempio n. 7
0
        public string GetCmdanswer(string input)
        {
            var MyIni = new INI_Reader("Data/commands.ini");

            var answer = MyIni.Read(input, "Commands");

            if (answer.Contains("%time%"))
            {
                answer = answer.Replace("%time%", DateTime.Now.ToString("h:mm tt"));
            }
            if (answer.Contains("%date%"))
            {
                answer = answer.Replace("%date%", DateTime.Now.ToString("dd/MM/yyyy"));
            }
            if (answer.Contains("%weather%"))
            {
                try
                {
                    answer = answer.Replace("%weather%", weather.WeatherData["Condition"]);
                }
                catch (Exception)
                {
                    answer = "Connection Problem";
                }
            }
            if (answer.Contains("%temperature%"))
            {
                if (Settings.Temp_Unit_F)
                {
                    try
                    {
                        answer = answer.Replace("%temperature%", weather.WeatherData["TemperatureF"]);
                    }
                    catch (Exception)
                    {
                        answer = "Connection Problem";
                    }
                }
                else
                {
                    try
                    {
                        answer = answer.Replace("%temperature%", weather.WeatherData["TemperatureC"]);
                    }
                    catch (Exception)
                    {
                        answer = "Connection Problem";
                    }
                }
            }
            if (answer.Contains("%temperatureF%"))
            {
                try
                {
                    answer = answer.Replace("%temperatureF%", weather.WeatherData["TemperatureF"]);
                }
                catch (Exception)
                {
                    answer = "Connection Problem";
                }
            }
            if (answer.Contains("%temperatureC%"))
            {
                try
                {
                    answer = answer.Replace("%temperatureC%", weather.WeatherData["TemperatureC"]);
                }
                catch (Exception)
                {
                    answer = "Connection Problem";
                }
            }
            if (answer.Contains("%location%"))
            {
                answer = answer.Replace("%location%", Settings.Location);
            }
            if (answer.Contains("%name%") && Settings.NameSet)
            {
                answer = answer.Replace("%name%", Settings.Name);
            }
            else
            {
                answer = "Error: Name not Set";
            }
            return(answer);
        }