I want to be able in Form1 constructor for example to type: Options_DB.Save
Something like that or Options_DB.Save(true) or (false)
So if its false the class will not take effect onl all the settings i did in Form1 according to Options_DB and if its true it will take effect and do all the things in the class Options_DB.
This is the class Options_DB:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DannyGeneral;
using System.IO;
using System.Windows.Forms;
namespace GatherLinks
{
static class OptionsDB
{
static string changeWebsite;
static bool downloadImages;
static bool localOnly;
static decimal num1;
static string num1_numricupdown;
static string path_exe;
static string path_settings;
static string settings_file;
static string settings_dir;
static OptionsFile setting_file;
static OptionsDB()
{
path_exe = Path.GetDirectoryName(Application.LocalUserAppDataPath);
path_settings = Path.GetDirectoryName(Application.LocalUserAppDataPath);
settings_file = "\\settings.txt";
settings_dir = path_settings + @"\settings";
setting_file = new OptionsFile(settings_dir + settings_file);
// ---- L O A D I N G A L L K E Y S ---- \\
changeWebsite = setting_file.GetKey("changeWebSite");
}
// ---- FUNCTIONS GET AND SET ---- \\
public static string get_changedWebSite()
{
return changeWebsite;
}
public static void set_changeWebSite(string website)
{
changeWebsite = website;
setting_file.SetKey("changeWebSite", changeWebsite);
}
}
}
And im using in it in Form1 for example like this:
In the Form1 constructor:
mainUrl = OptionsDB.get_changedWebSite();
And in the button2 click event:
private void button2_Click(object sender, EventArgs e)
{
cl = new ChangeLink();
cl.StartPosition = FormStartPosition.CenterParent;
DialogResult dr = cl.ShowDialog(this);
if (dr == DialogResult.Cancel)
{
cl.Close();
}
else if (dr == DialogResult.OK)
{
label4.Text = cl.getText();
mainUrl = cl.getText();
OptionsDB.set_changeWebSite(cl.getText());
cl.Close();
}
}
Now in the Form1 constructor before im doing the Options_DB.get…
I want to add a property of the Options_DB or something that will tell me if to do the class the new class or not. This class im using a lot of time already to save on a text file all the options like checkBoxes and things so when i run the program it will remember the settings i changed.
Now i want a property that will tell the program of to save any changes i did or not to save them.
This is the best I can do based on your question. It is hard to read/understand your question
In
Form1just writeOptionsDB.IsActive = false;to turn off.OptionsDB.IsActive = true;to turn on. Possibly setting the initial value in the constuctur (static OptionsDB()).Finally, you can really just change your get and set method to use Accessors. Like the Get and Set I used. –Side advise; just because you can