コード例 #1
0
        private void backgroundWorkerWeather_DoWork(object sender, DoWorkEventArgs e)
        {
            try
            {
                bool showw = bool.Parse(HelpClass.GETHtml("http://myspy.diodegames.eu/ShowWeather.txt"));

                if (showw)
                {
                    SaveWriter Loc = new SaveWriter(PathMS + "/Temp/location.dat");
                    Loc.Load();
                    string Latitude = "", Longtitude = "", CityName = "";

                    Latitude   = Loc.GetItem("Latitude");
                    Longtitude = Loc.GetItem("Longtitude");
                    CityName   = Loc.GetItem("City");


                    if (File.Exists(PathMS + "/Temp/weather.dat"))
                    {
                        SaveWriter save = new SaveWriter(PathMS + "/Temp/weather.dat");
                        save.Load();

                        if (save.GetItemInt("Day") != DateTime.Now.Day || DateTime.Now.Hour >= save.GetItemInt("Hour") + 3)
                        {
                            Debug.WriteLine("New Weather: Day: " + save.GetItemInt("Day") + "   Hour: " + save.GetItemInt("Hour"));
                            NewWeather(Latitude, Longtitude, CityName);
                        }
                        else
                        {
                            Debug.WriteLine("Weather from file");
                            weather.weatherinfo.Temperature = save.GetItem("Temperature");
                            weather.weatherinfo.Cloudiness  = save.GetItem("Clouds");
                            weather.weatherinfo.CityName    = save.GetItem("City");
                            weathericon = (Bitmap)Bitmap.FromFile(PathMS + "/Temp/weathericon.dat");

                            SaveWriter wsave = new SaveWriter(PathMS + "/Temp/weathersettings.dat");
                            wsave.Load();
                            bool wunit = wsave.GetItemBool("Unit");

                            if (wunit)
                            {
                                weather.weatherinfo.TemperatureUnit = "F";
                            }
                            else
                            {
                                weather.weatherinfo.TemperatureUnit = "C";
                            }

                            backgroundWorkerWeather.ReportProgress(0, "");
                        }
                    }
                    else
                    {
                        Debug.WriteLine("New Weather because file not found");
                        NewWeather(Latitude, Longtitude, CityName);
                    }
                }
            }catch (Exception ex)
            {
                Debug.WriteLine("" + ex);
            }
        }
コード例 #2
0
        private void button2_Click(object sender, EventArgs e)
        {
            Directory.CreateDirectory(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + "/My Spy/MonitoringReports/Notes/");
            string key   = HelpClass.RandomString(5);
            bool   close = true;
            bool   write = true;

            if (checkBox2.Checked)
            {
                RegistryKey registry = Registry.LocalMachine.OpenSubKey("Software\\My_Spy", false);
                if (!textBox1.Text.Equals(encryption.DecryptString((string)registry.GetValue("Properties"), "2pqB7l4eRM6nHaZPtetkkHePguacGTvrMhvnE4fy")))
                {
                    MessageBox.Show(ResourcesFiles.ProgramStrings.badpassword);
                    close = false;
                    write = false;
                }
            }

            if (write)
            {
                SaveWriter save = new SaveWriter(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) +
                                                 "/My Spy/MonitoringReports/Notes/note_" + DateTime.Now.Year + "_" + DateTime.Now.Month + "_" + DateTime.Now.Day + "_" + DateTime.Now.Hour + "_" + DateTime.Now.Minute + "_" + key + ".notesp");
                if (Edit)
                {
                    save.PathToFile = SPath;
                    File.Delete(SPath);
                    File.Delete(Path);
                }

                DateTime date = new DateTime(dateTimePicker1.Value.Year, dateTimePicker1.Value.Month, dateTimePicker1.Value.Day,
                                             dateTimePicker2.Value.Hour, dateTimePicker2.Value.Minute, 0);
                save.AddItem("Warn", checkBox1.Checked);
                save.AddItem("WarnTimeDate", date.ToString());
                save.AddItem("Password", checkBox2.Checked);
                if (Edit)
                {
                    save.AddItem("DateofCreate", "" + Createdate);
                }
                else
                {
                    save.AddItem("DateofCreate", "" + DateTime.Now.ToString());
                }

                save.AddItem("DateofEdit", "" + DateTime.Now.ToString());
                //save.AddItem("Text",richTextBox1.Text);
                save.Save();
                save.Clear();


                if (!Edit)
                {
                    using (StreamWriter writer = new StreamWriter(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) +
                                                                  "/My Spy/MonitoringReports/Notes/note_" + DateTime.Now.Year + "_" + DateTime.Now.Month + "_" + DateTime.Now.Day + "_" + DateTime.Now.Hour + "_" + DateTime.Now.Minute + "_" + key + ".note"))
                    {
                        writer.WriteLine(richTextBox1.Text);
                    }
                }
                else
                {
                    using (StreamWriter writer = new StreamWriter(Path))
                    {
                        writer.WriteLine(richTextBox1.Text);
                    }
                }
            }

            if (close)
            {
                this.Close();
                HelpClass.NotesChange = true;
            }
        }