⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 configinfo.cs

📁 一个通用的数据库访问层
💻 CS
字号:
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
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -