コード例 #1
0
ファイル: Settings.cs プロジェクト: rajabilal555/SPARK
        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;
        }
コード例 #2
0
ファイル: MainForm.cs プロジェクト: rajabilal555/SPARK
        public string GetCmdquestion(string output)
        {
            var MyIni = new INI_Reader("Data/commands.ini");

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

            return(answer);
        }
コード例 #3
0
ファイル: MainForm.cs プロジェクト: rajabilal555/SPARK
        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;
                        }
                    }
                }
            }
        }
コード例 #4
0
ファイル: MainForm.cs プロジェクト: rajabilal555/SPARK
        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);
        }