Ejemplo n.º 1
0
        private bool saveSettingsToFile()
        {
            TextWriter writter = new StreamWriter(configFile);
            bool result = false;

            try
            {
                XmlSerializer serializer = new XmlSerializer(this.settings.GetType());
                serializer.Serialize(writter, this.settings);
                result = true;
                this.addToLog("config saved");
                manager = new TaskManager(this, this.settings);
            }
            catch (Exception e)
            {
                this.addToLog("error: " + e.Message);
                MessageBox.Show(e.Message);
            }
            finally
            {
                writter.Flush();
                writter.Close();
            }

            return result;
        }
Ejemplo n.º 2
0
 private void mainForm_Shown(object sender, EventArgs e)
 {
     this.stop();
     if (this.readSettingsFromFile())
     {
         manager = new TaskManager(this, this.settings);
         this.addToLog("set params");
         this.setParams();
         if (!this.isFormValid())
         {
             this.addToLog("error: form is not valid");
         }
         if (this.settings.StartAfterRun)
         {
             this.start();
             this.WindowState = FormWindowState.Minimized;
             this.Hide();
             this.ShowInTaskbar = false;
             this.menuItemShow.Text = "Show";
         }
     }
     else
     {
         this.addToLog("error: cant load config file");
         this.stop();
     }
 }