public Settings GetSettings(ref string strError)
        {
            Settings settings = new Settings();

            try
            {
                if (File.Exists(FileManager.DataPath + "settings.dat"))
                    settings = DeSerializeSettings();
            }
            catch (Exception ex)
            {
                strError = ex.Message;
            }

            return settings;
        }
        private void Setup()
        {
            InitializeComponent();
            string strError = string.Empty;

            settingsCall = new SettingCall();
            settings = settingsCall.GetSettings(ref strError);

            flpStatus = new FlowLayoutPanel() { Dock = DockStyle.Top, Height = 20, BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle };
            lblPipe = new Label() { Text = "|", AutoSize = true, Margin = new Padding(0, 2, 0, 0) };
            lblAvgHashrate = new Label() { Text = "Avg. Hashrate: 0 kh/s", Margin = new Padding(0, 2, 0, 0), AutoSize = true };
            lblRuntime = new Label() { Text = "Run Time: 00:00:00", Margin = new Padding(0, 2, 0, 0), AutoSize = true };
            txtConsole = new RichTextBox() { Dock = DockStyle.Fill, ReadOnly = true, BackColor = SystemColors.Control, ForeColor = SystemColors.WindowText, Multiline = true, Height = this.Height, BorderStyle = BorderStyle.FixedSingle };
            lblAccepts = new Label() { Text = "Accepts: 0/min", Margin = new Padding(0, 2, 0, 0), AutoSize = true };
            lblKernel = new Label() { Text = "Kernel: N/A", Margin = new Padding(0, 2, 0, 0), AutoSize = true };
            lblGUID = new Label() { Text = "GUID: ", Margin = new Padding(0, 2, 0, 0), AutoSize = true, ForeColor = Color.Gray };

            flpStatus.Controls.Add(lblAvgHashrate);
            flpStatus.Controls.Add(lblPipe); //Separator
            flpStatus.Controls.Add(lblRuntime);
            flpStatus.Controls.Add(lblPipe); //Separator
            flpStatus.Controls.Add(lblAccepts);
            flpStatus.Controls.Add(lblPipe); //Separator
            flpStatus.Controls.Add(lblKernel);
            flpStatus.Controls.Add(lblPipe); //Separator
            flpStatus.Controls.Add(lblGUID);

            this.Controls.Add(flpStatus);
            this.Controls.Add(txtConsole);

            watch = new Stopwatch();
            watch.Start();
        }
 public void SeriliazeSettings(Settings data)
 {
     using (var stream = File.Create(FileManager.DataPath + "settings.dat"))
     {
         var serializer = new XmlSerializer(typeof(Settings));
         serializer.Serialize(stream, data);
     }
 }