Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
MmUserOptionsForm
Message
From
06/11/2008 17:45:16
Timothy Bryan
Sharpline Consultants
Conroe, Texas, United States
 
General information
Forum:
ASP.NET
Category:
The Mere Mortals .NET Framework
Environment versions
Environment:
C# 2.0
OS:
Windows XP SP2
Network:
Windows 2008 Server
Database:
MS SQL Server
Miscellaneous
Thread ID:
01359539
Message ID:
01360354
Views:
14
>>I have wished for a application settings form that would tie in better with the application settings. If you figure some of this out, I would be grateful if you shared.
>
>Tim,
>
>I am looking into it now and will definately share anything I develop.
>
>In the MM .NET Developer's Guide, there is a topic for the mmAppConfiguration class under the Contents Section "MM .NET Classes". This lists a method called ReadKeysFromConfig which:
>
>"Reads all the configuration settings from the .Config file into the public fields of this object"
>
>Do you know how to access the public fields of this object? When I execute the above method, I only see Non-Public members.
>
>Kind Regards,
>
>Mat

I subclassed the mmAppConfiguration class for my specific application. Then added public properties for everything I wanted. I put a property in the App.cs to access it.
public class TipTraxSettings : mmAppConfiguration
{
    public TipTraxSettings() : base(false)
    {
        // Specify the settings to be encrypted, and the encryption key
        this.SetEncryption("WSUserId,WSPassword", "PacificaSys");
			
        // Use a custom Config file
        this.ReadKeysFromConfig("TipTrax.Config");
    }

    #region Public Settings Properties

    /// <summary>
    /// MyTruckCode Property
    /// </summary>
    public string MyTruckCode
    {
        get { return _myTruckCode; }
        set { _myTruckCode = value; }
    }
    private string _myTruckCode = "120";

    /// <summary>
    /// EnableGps Property
    /// </summary>
    public bool EnableGps
    {
        get { return _enableGps; }
        set { _enableGps = value; }
    }
    private bool _enableGps = true;
}

Then in App.cs Add a static public property to get to access them.

/// <summary>
/// ApplicationSettings Property
/// </summary>
public static TipTraxSettings ApplicationSettings
{
    get
    {
				
        if (_applicationSettings == null)
            _applicationSettings = new TipTraxSettings();

        return _applicationSettings;
    }
}
private static TipTraxSettings _applicationSettings;

Now anywhere in the application I can reference it like this:
if (AppDesktop.ApplicationSettings.EnableGps)
{
    // Do something
}
or
string truckCode = AppDesktop.ApplicationSettings.MyTruckCode;
Hope that helps.
Regards;
Tim
Timothy Bryan
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform