protected void CopyNotReloadTreeParameters(SettingsInfo info)
 {
     info.ShowStatusPanel = this.ShowStatusPanel;
     info.SqlTimeout      = this.SqlTimeout;
     info.MaximumDBRequestsThreadCount = this.MaximumDBRequestsThreadCount;
     info.ShowCloseTabConfirmation     = this.ShowCloseTabConfirmation;
 }
		private frmSettings()
		{
			this._settingsInfo = null;
			this._model        = null;

			InitializeComponent();
		}
        public bool IsNeedReloadTree(SettingsInfo info)
        {
            var oldSettingCopy = info.GetCopy();

            this.CopyNotReloadTreeParameters(oldSettingCopy);

            if (!this.EqualSetting(info) && !this.EqualSetting(oldSettingCopy))
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
		/// <summary>
		/// Constructor with mainform
		/// </summary>
		/// <param name="mainForm">Mainform </param>
		public MsSqlAuditorModel()
		{
			this._vaultProcessors  = new Dictionary<ConnectionGroupInfo, IStorageManager>();
			this._settings         = null;
			this._layoutSettings   = null;
			this._localeManager    = null;
			this._templateSettings = null;
			this._filesProvider    = new FilesProvider(this);

			LoadSettings();

			this._visualizeProcessor = new VisualizeProcessor(this);
			this._cryptoService      = new CachingCryptoService(Settings.EncryptionKey);

			DeleteTempCurrentDbFile();
		}
        //protected bool Equals(SettingsInfo other)
        //{
        //    return string.Equals(_interfaceLanguage, other._interfaceLanguage)
        //        && string.Equals(_reportLanguage, other._reportLanguage)
        //        && _showCloseTabConfirmation.Equals(other._showCloseTabConfirmation)
        //        && _warnAboutUnsignedQuery.Equals(other._warnAboutUnsignedQuery)
        //        && SqlTimeout == other.SqlTimeout
        //        && MaximumDBRequestsThreadCount == other.MaximumDBRequestsThreadCount
        //        && ShowStatusPanel.Equals(other.ShowStatusPanel)
        //        && ShowMainMenu.Equals(other.ShowMainMenu)
        //        && ShowAddressLine.Equals(other.ShowAddressLine)
        //        && ShowConnectionTabIfSingle.Equals(other.ShowConnectionTabIfSingle)
        //        && HideSingleNodeInReportsTree.Equals(other.HideSingleNodeInReportsTree)
        //        && ConnectionsInTabs.Equals(other.ConnectionsInTabs)
        //        && Equals(LastDirectConnectionStrings, other.LastDirectConnectionStrings)
        //        && Equals(LastDirectConnectionStringsItems, other.LastDirectConnectionStringsItems)
        //        && Equals(LastExternalTemplatesItems, other.LastExternalTemplatesItems)
        //        && Equals(LastDirectConnectionStringsGroups, other.LastDirectConnectionStringsGroups)
        //        && string.Equals(LastSelectedTemplateId, other.LastSelectedTemplateId)
        //        && LastSelectedDataBaseType == other.LastSelectedDataBaseType
        //        && Equals(ScheduleNodeSettingList, other.ScheduleNodeSettingList)
        //        && ShowXML.Equals(other.ShowXML)
        //        && string.Equals(TemplateDirectory, other.TemplateDirectory)
        //        && MainWindowState.Equals(other.MainWindowState)
        //        && Equals(SystemSettings, other.SystemSettings);
        //}

        public bool EqualSetting(SettingsInfo secondInfo)
        {
            if (
                this.ConnectionsInTabs != secondInfo.ConnectionsInTabs ||
                this.HideSingleNodeInReportsTree != secondInfo.HideSingleNodeInReportsTree ||
                this.ShowAddressLine != secondInfo.ShowAddressLine ||
                this.ShowCloseTabConfirmation != secondInfo.ShowCloseTabConfirmation ||
                this.ShowConnectionTabIfSingle != secondInfo.ShowConnectionTabIfSingle ||
                this.ShowMainMenu != secondInfo.ShowMainMenu ||
                this.ShowStatusPanel != secondInfo.ShowStatusPanel ||
                this.ShowXML != secondInfo.ShowXML ||
                this.InterfaceLanguage != secondInfo.InterfaceLanguage ||
                this.MaximumDBRequestsThreadCount != secondInfo.MaximumDBRequestsThreadCount ||
                this.ReportLanguage != secondInfo.ReportLanguage ||
                this.SqlTimeout != secondInfo.SqlTimeout
                )
            {
                return(false);
            }
            else
            {
                return(true);
            }
        }
		public void SetSettings(SettingsInfo settings)
		{
			this._settingsInfo = settings;
		}
		//protected bool Equals(SettingsInfo other)
		//{
		//    return string.Equals(_interfaceLanguage, other._interfaceLanguage)
		//        && string.Equals(_reportLanguage, other._reportLanguage)
		//        && _showCloseTabConfirmation.Equals(other._showCloseTabConfirmation)
		//        && _warnAboutUnsignedQuery.Equals(other._warnAboutUnsignedQuery)
		//        && SqlTimeout == other.SqlTimeout
		//        && MaximumDBRequestsThreadCount == other.MaximumDBRequestsThreadCount
		//        && ShowStatusPanel.Equals(other.ShowStatusPanel)
		//        && ShowMainMenu.Equals(other.ShowMainMenu)
		//        && ShowAddressLine.Equals(other.ShowAddressLine)
		//        && ShowConnectionTabIfSingle.Equals(other.ShowConnectionTabIfSingle)
		//        && HideSingleNodeInReportsTree.Equals(other.HideSingleNodeInReportsTree)
		//        && ConnectionsInTabs.Equals(other.ConnectionsInTabs)
		//        && Equals(LastDirectConnectionStrings, other.LastDirectConnectionStrings)
		//        && Equals(LastDirectConnectionStringsItems, other.LastDirectConnectionStringsItems)
		//        && Equals(LastExternalTemplatesItems, other.LastExternalTemplatesItems)
		//        && Equals(LastDirectConnectionStringsGroups, other.LastDirectConnectionStringsGroups)
		//        && string.Equals(LastSelectedTemplateId, other.LastSelectedTemplateId)
		//        && LastSelectedDataBaseType == other.LastSelectedDataBaseType
		//        && Equals(ScheduleNodeSettingList, other.ScheduleNodeSettingList)
		//        && ShowXML.Equals(other.ShowXML)
		//        && string.Equals(TemplateDirectory, other.TemplateDirectory)
		//        && MainWindowState.Equals(other.MainWindowState)
		//        && Equals(SystemSettings, other.SystemSettings);
		//}

		public bool EqualSetting(SettingsInfo secondInfo)
		{
			if (
				this.ConnectionsInTabs            != secondInfo.ConnectionsInTabs            ||
				this.HideSingleNodeInReportsTree  != secondInfo.HideSingleNodeInReportsTree  ||
				this.ShowAddressLine              != secondInfo.ShowAddressLine              ||
				this.ShowCloseTabConfirmation     != secondInfo.ShowCloseTabConfirmation     ||
				this.ShowConnectionTabIfSingle    != secondInfo.ShowConnectionTabIfSingle    ||
				this.ShowMainMenu                 != secondInfo.ShowMainMenu                 ||
				this.ShowStatusPanel              != secondInfo.ShowStatusPanel              ||
				this.ShowXML                      != secondInfo.ShowXML                      ||
				this.InterfaceLanguage            != secondInfo.InterfaceLanguage            ||
				this.MaximumDBRequestsThreadCount != secondInfo.MaximumDBRequestsThreadCount ||
				this.ReportLanguage               != secondInfo.ReportLanguage               ||
				this.SqlTimeout                   != secondInfo.SqlTimeout
			)
			{
				return false;
			}
			else
			{
				return true;
			}
		}
		public bool IsNeedReloadTree(SettingsInfo info)
		{
			var oldSettingCopy = info.GetCopy();

			this.CopyNotReloadTreeParameters(oldSettingCopy);

			if (!this.EqualSetting(info) && !this.EqualSetting(oldSettingCopy))
			{
				return true;
			}
			else
			{
				return false;
			}
		}
		protected void CopyNotReloadTreeParameters(SettingsInfo info)
		{
			info.ShowStatusPanel              = this.ShowStatusPanel;
			info.SqlTimeout                   = this.SqlTimeout;
			info.MaximumDBRequestsThreadCount = this.MaximumDBRequestsThreadCount;
			info.ShowCloseTabConfirmation     = this.ShowCloseTabConfirmation;
		}
		/// <summary>
		/// Set new settings
		/// </summary>
		/// <param name="settingsInfo">New settings</param>
		public void SetSettings(SettingsInfo settingsInfo)
		{
			var oldSetting = this._settings.GetCopy();

			this._settings = settingsInfo;

			SaveSettings();

			OnSettingsChanged(new SettingsChangedEventArgs(oldSetting, settingsInfo));
		}
		private void LoadSettings()
		{
			if (!File.Exists(FilesProvider.SystemSettingsFileName))
			{
				MessageBox.Show("System settings file doesn't exists at path " + FilesProvider.SystemSettingsFileName);
				throw new FileLoadException("System settings file doesn't exists at path " + FilesProvider.SystemSettingsFileName);
			}

			if (File.Exists(FilesProvider.UserSettingsFileName))
			{
				this._settings = SettingsLoader.LoadFromXml(
					FilesProvider.UserSettingsFileName,
					FilesProvider.SystemSettingsFileName
				);
			}
			else
			{
				this._settings = SettingsLoader.LoadFromXml(
					FilesProvider.UserSettingDefaultFileName,
					FilesProvider.SystemSettingsFileName
				);

				SettingsLoader.SaveToXml(
					FilesProvider.UserSettingsFileName,
					this._settings
				);
			}

			if (File.Exists(FilesProvider.UserLayoutSettingsFileName))
			{
				this._layoutSettings = SettingsLoader.LoadAsBaseFromXml<LayoutSettings>(
					FilesProvider.UserLayoutSettingsFileName
				);
			}
			else
			{
				this._layoutSettings = new LayoutSettings();

				SettingsLoader.SaveToXml(
					FilesProvider.UserLayoutSettingsFileName,
					this._layoutSettings
				);
			}

			if (File.Exists(FilesProvider.UserTemplateSettingsFileName))
			{
				// this._templateSettings = SettingsLoader.LoadAsTemplateFromXml<ActivityLayoutSetting>(FilesProvider.UserTemplateSettingsFileName);
				// ActivityLayoutSetting loader = new ActivityLayoutSetting();
				this._templateSettings = new ActivityLayoutSetting();

				this._templateSettings.UserSettings = SettingsLoader.LoadAsTemplateFromXml<List<InstanceTemplate>>(
					FilesProvider.UserTemplateSettingsFileName
				);
			}
			else
			{
				this._templateSettings = new ActivityLayoutSetting();

				SettingsLoader.SaveTemplateToXml(
					FilesProvider.UserTemplateSettingsFileName,
					this._templateSettings
				);
			}
		}
		public SettingsChangedEventArgs(SettingsInfo oldInfo, SettingsInfo newInfo) : this()
		{
			this.OldSetting = oldInfo;
			this.NewSetting = newInfo;
		}
		public SettingsChangedEventArgs()
		{
			this.OldSetting = null;
			this.NewSetting = null;
		}
Example #14
0
		private void RestoreSizeAndLocation(SettingsInfo settings)
		{
			int      intShowOnMonitor = 0;
			Screen[] arrScreens       = Screen.AllScreens;

			this._windowInitialized = false;

			try
			{
				// this is the default
				this.WindowState = FormWindowState.Normal;
				this.StartPosition = FormStartPosition.WindowsDefaultBounds;

				if (settings.MainWindowState.Size.Width != 0 || settings.MainWindowState.Size.Height != 0)
				{
					// check if the saved bounds are nonzero and visible on any screen
					if (!settings.MainWindowState.IsEmpty() && IsVisibleOnAnyScreen(settings.MainWindowState.GetBounds()))
					{
						// first set the bounds
						this.StartPosition = FormStartPosition.Manual;
						this.DesktopBounds = settings.MainWindowState.GetBounds();

						// afterwards set the window state to the saved value (which could be Maximized)
						this.WindowState = settings.MainWindowState.WindowState;
					}
					else
					{
						// this resets the upper left corner of the window to windows standards
						this.StartPosition = FormStartPosition.WindowsDefaultLocation;

						// we can still apply the saved size
						// msorens: added gatekeeper, otherwise first time appears as just a title bar!
						if (!settings.MainWindowState.IsEmpty())
						{
							this.Size = settings.MainWindowState.Size;
						}
					}
				}

				//
				// Start to process commanl line parameters if any exists.
				// Command line parameters (if any given) are overwrite the default setting from the
				// configuratins.
				//
				if (intMonitor >= 0 && intMonitor < arrScreens.Length)
				{
					intShowOnMonitor = intMonitor;
				}
				else
				{
					intShowOnMonitor = 0;
				}

				if (intPosX >= 0)
				{
					this.Left = arrScreens[intShowOnMonitor].Bounds.Left + intPosX;
				}
				if (intPosY >= 0)
				{
					this.Top = arrScreens[intShowOnMonitor].Bounds.Top + intPosY;
				}
				if (intWidth > 0)
				{
					this.Width = intWidth;
				}
				if (intHeight > 0)
				{
					this.Height = intHeight;
				}
			}
			finally
			{
				this._windowInitialized = true;
			}
		}
Example #15
0
		private void UpdateMainMenuVisibility(SettingsInfo settings, bool? isDisableMainMenu)
		{
			if (isDisableMainMenu != null && isDisableMainMenu == true)
			{
				mainMenu.Visible = false;
			}
			else
			{
				mainMenu.Visible = settings.ShowMainMenu;
			}
		}