Example #1
0
        //Save Settings textbox in settings variables
        private void SettingsSaveButton_Click(object sender, EventArgs e)
        {
            Properties.Settings.Default.Files                = textBoxFiles.Text;
            Properties.Settings.Default.Arguments            = textBoxArguments.Text;
            Properties.Settings.Default.EnvironmentVariables = textBoxEnvironmentVariables.Text;
            Properties.Settings.Default.Notify               = checkBoxNotify.Checked;
            Properties.Settings.Default.Restart              = checkBoxRestart.Checked;
            Properties.Settings.Default.FilesTerminate       = textBoxFilesTerminate.Text;
            Properties.Settings.Default.ArgumentsTerminate   = textBoxArgumentsTerminate.Text;
            Properties.Settings.Default.Save();

            AutoRun autoRun = new AutoRun();

            autoRun.appShortcutToAutoRunFolder(checkBoxAutoRun.Checked);

            // Save Settings in the NginxTrayRu.settings.xml file
            XMLSettingsManager xml = new XMLSettingsManager();

            xml.Files                = Properties.Settings.Default.Files;
            xml.Arguments            = Properties.Settings.Default.Arguments;
            xml.EnvironmentVariables = Properties.Settings.Default.EnvironmentVariables;
            xml.Notify               = Properties.Settings.Default.Notify;
            xml.Restart              = Properties.Settings.Default.Restart;
            xml.FilesTerminate       = Properties.Settings.Default.FilesTerminate;
            xml.ArgumentsTerminate   = Properties.Settings.Default.ArgumentsTerminate;
            XMLSettingsManager.Serialize(autoRun.appName + ".settings.xml", xml);

            this.Close();
        }
        public static void Serialize(string file, XMLSettingsManager c)
        {
            System.Xml.Serialization.XmlSerializer xs
                = new System.Xml.Serialization.XmlSerializer(c.GetType());
            StreamWriter writer = File.CreateText(file);

            xs.Serialize(writer, c);
            writer.Flush();
            writer.Close();
        }
        public static XMLSettingsManager Deserialize(string file)
        {
            System.Xml.Serialization.XmlSerializer xs
                = new System.Xml.Serialization.XmlSerializer(
                      typeof(XMLSettingsManager));
            StreamReader       reader = File.OpenText(file);
            XMLSettingsManager c      = (XMLSettingsManager)xs.Deserialize(reader);

            reader.Close();
            return(c);
        }
Example #4
0
        // check is the program in auto run
        private void frmStartup_Load(object sender, EventArgs e)
        {
            AutoRun autoRun = new AutoRun();

            if (System.IO.File.Exists(autoRun.appName + ".settings.xml"))
            {
                // Read the configuration object from a file and write it to the Properties.Settings.Default (if it exists!)
                XMLSettingsManager xml = XMLSettingsManager.Deserialize(autoRun.appName + ".settings.xml");
                Properties.Settings.Default.Files                = xml.Files.Replace("\n", "\r\n");
                Properties.Settings.Default.Arguments            = xml.Arguments.Replace("\n", "\r\n");
                Properties.Settings.Default.FilesTerminate       = xml.FilesTerminate.Replace("\n", "\r\n");
                Properties.Settings.Default.ArgumentsTerminate   = xml.ArgumentsTerminate.Replace("\n", "\r\n");
                Properties.Settings.Default.EnvironmentVariables = xml.EnvironmentVariables.Replace("\n", "\r\n");
                Properties.Settings.Default.Notify               = xml.Notify;
                Properties.Settings.Default.Restart              = xml.Restart;
            }

            this.MenuItemStart_Click1();
        }