Component File /DBCommander/Misc/ConfigInfo.cs (C#)
using System;  
using System.Windows.Forms;  
  
namespace YariSoft.DBCommander.Misc  
{  
    [Serializable]  
    public class ConfigInfo  
    {  
        #region Local Variables  
        private const string defaultFileName = "Untitled.cfg";  
  
        private string _leftConnection    = "";  
        private string _rightConnection = "";  
        private GridStyleInfo  
                       _leftGridStyles  = null;  
        private GridStyleInfo  
                       _rightGridStyles = null;  
  
        [NonSerialized()]  
        private string _fileName        = defaultFileName;  
        [NonSerialized()]  
        private bool   _hasChanges        = false;  
        #endregion  
  
        #region Properties  
        public string LeftConnection  
        {  
            get{ return this._leftConnection; }  
            set{  
                this._leftConnection = value;  
                this._hasChanges = true;  
            }  
        }  
  
        public string RightConnection  
        {  
            get{ return this._rightConnection; }  
            set{  
                this._rightConnection = value;  
                this._hasChanges = true;  
            }  
        }  
  
        public string FileName  
        {  
            get{ return this._fileName;  }  
            set{ this._fileName = value; }  
        }  
  
        public bool HasChanges  
        {  
            get{ return this._hasChanges;  }  
            set{ this._hasChanges = value; }  
        }  
  
        public GridStyleInfo RightGridStyles  
        {  
            get{ return this._rightGridStyles;}  
        }  
  
        public GridStyleInfo LeftGridStyles  
        {  
            get{ return this._leftGridStyles;}  
        }  
        #endregion  
  
        #region Constructor  
        public ConfigInfo()  
        {  
            this._leftGridStyles  = new GridStyleInfo();  
            this._rightGridStyles = new GridStyleInfo();  
        }  
        #endregion  
  
        #region Public functions  
        public bool SaveToFile()  
        {  
            bool showDiaolg = false;  
            if( this._fileName == defaultFileName ){  
                showDiaolg = true;  
            }  
  
            if( YariSoft.Utils.ConfigFile.SaveToFile( ref this._fileName, this, showDiaolg ) ){  
                this._hasChanges = false;  
            }  
            return ! this._hasChanges;  
        }  
  
        public bool SaveAsToFile()  
        {  
            if( YariSoft.Utils.ConfigFile.SaveToFile( ref this._fileName, this, true ) ){  
                this._hasChanges = false;  
            }  
            return ! this._hasChanges;  
        }  
  
  
        public static ConfigInfo LoadFromFile( string FileName )  
        {  
            ConfigInfo result = null;  
            if( FileName != "" ){  
                result = ( ConfigInfo )YariSoft.Utils.ConfigFile.LoadFromFile( ref FileName, false );  
            }  
              
            if( result == null ){  
                result = new ConfigInfo();  
            } else {  
                result.FileName = FileName;  
            }  
  
            return result;  
        }      
        #endregion  
    }  
}