Ejemplo n.º 1
0
        // save file
        public void SaveFile(string filename)
        {
            try
            {
                if (
                    Directory.Exists(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) +
                                     @"\ColourClock\") == false && filename == string.Empty)
                {
                    Directory.CreateDirectory(
                        Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\ColourClock\");
                }
                if (filename == string.Empty)
                {
                    filename = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) +
                               @"\ColourClock\settings.ini";
                }

                var saveSettings = new StreamWriter(filename);
                saveSettings.WriteLine(
                    "Colour Clock Configuration File.\r\nThis program comes with no warrantee and is entirely your own risk.\r\nAs there is little to NO error checking changing this file could be\r\na very stupid thing to do.");
                saveSettings.Write(X1 + "\r\n" + Y1 + "\r\n" + R1 + "\r\n" + C1.ToArgb() + "\r\n" + X2 + "\r\n" + Y2 +
                                   "\r\n" + R2 + "\r\n" + C2.ToArgb() + "\r\n" + X3 + "\r\n" + Y3 + "\r\n" + R3 + "\r\n" +
                                   C3.ToArgb() + "\r\n" + X4 + "\r\n" + Y4 + "\r\n" + R4 + "\r\n" + C4.ToArgb() + "\r\n" +
                                   Background.ToArgb() + "\r\n" + Shape + "\r\n" + Wx + "\r\n" + WY + "\r\n" +
                                   TaskbarTime + "\r\n" + FirstRun + "\r\n" + Location.X + "," + Location.Y);
                saveSettings.Close();
                MinimizeMemory();
            }
            catch (Exception ex)
            {
                MessageBox.Show(
                    "Settings could not be saved to file due to an error. Error is as follows:\n" + ex.Message,
                    "Colour Clock", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }