private void sBtnImportColors_Click(object sender, EventArgs e) { OpenFileDialog openFileDialog1 = new OpenFileDialog(); openFileDialog1.Filter = "Analogy Color Settings (*.json)|*.json"; openFileDialog1.Title = @"Import NLog settings"; openFileDialog1.Multiselect = true; if (openFileDialog1.ShowDialog() == DialogResult.OK) { try { var json = File.ReadAllText(openFileDialog1.FileName); ColorSettings color = ColorSettings.FromJson(json); Settings.ColorSettings = color; LoadColorsSettings(); XtraMessageBox.Show("File Imported. Save settings if desired", @"Import settings", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception ex) { AnalogyLogManager.Instance.LogError("Error during import data: " + e, nameof(sBtnImportColors_Click)); XtraMessageBox.Show("Error Import: " + ex.Message, @"Error Import file", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
private void SetupEventsHandlers() { tsEnableColors.IsOnChanged += (s, e) => Settings.ColorSettings.EnableMessagesColors = tsEnableColors.IsOn; ceOverrideLogLevelColor.CheckedChanged += (s, e) => Settings.ColorSettings.OverrideLogLevelColor = ceOverrideLogLevelColor.Checked; sBtnExportColors.Click += (s, e) => { UpdateColors(); SaveFileDialog saveFileDialog = new SaveFileDialog(); saveFileDialog.Filter = "Analogy Color Settings (*.json)|*.json"; saveFileDialog.Title = @"Export Analogy Color settings"; if (saveFileDialog.ShowDialog(this) == DialogResult.OK) { try { File.WriteAllText(saveFileDialog.FileName, Settings.ColorSettings.AsJson()); XtraMessageBox.Show("File Saved", @"Export settings", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception ex) { AnalogyLogManager.Instance.LogError("Error during save to file: " + e, ""); XtraMessageBox.Show("Error Export: " + ex.Message, @"Error Saving file", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }; sBtnImportColors.Click += (s, e) => { OpenFileDialog openFileDialog1 = new OpenFileDialog(); openFileDialog1.Filter = "Analogy Color Settings (*.json)|*.json"; openFileDialog1.Title = @"Import NLog settings"; openFileDialog1.Multiselect = true; if (openFileDialog1.ShowDialog() == DialogResult.OK) { try { var json = File.ReadAllText(openFileDialog1.FileName); ColorSettings color = ColorSettings.FromJson(json); Settings.ColorSettings = color; LoadColorsSettings(); XtraMessageBox.Show("File Imported. Save settings if desired", @"Import settings", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception ex) { AnalogyLogManager.Instance.LogError("Error during import data: " + e, ""); XtraMessageBox.Show("Error Import: " + ex.Message, @"Error Import file", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }; ceNewMessagesColor.CheckedChanged += (s, e) => { cpeNewMessagesColor.Enabled = ceNewMessagesColor.Checked; Settings.ColorSettings.EnableNewMessagesColor = ceNewMessagesColor.Checked; }; cpeLogLevelUnknown.ColorChanged += (s, e) => UpdateColors(); cpeLogLevelUnknownText.ColorChanged += (s, e) => UpdateColors(); cpeLogLevelDisabled.ColorChanged += (s, e) => UpdateColors(); cpeLogLevelDisabledText.ColorChanged += (s, e) => UpdateColors(); cpeLogLevelTrace.ColorChanged += (s, e) => UpdateColors(); cpeLogLevelTraceText.ColorChanged += (s, e) => UpdateColors(); cpeLogLevelVerbose.ColorChanged += (s, e) => UpdateColors(); cpeLogLevelVerboseText.ColorChanged += (s, e) => UpdateColors(); cpeLogLevelDebug.ColorChanged += (s, e) => UpdateColors(); cpeLogLevelDebugText.ColorChanged += (s, e) => UpdateColors(); cpeLogLevelInformation.ColorChanged += (s, e) => UpdateColors(); cpeLogLevelInformationText.ColorChanged += (s, e) => UpdateColors(); cpeLogLevelWarning.ColorChanged += (s, e) => UpdateColors(); cpeLogLevelWarningText.ColorChanged += (s, e) => UpdateColors(); cpeLogLevelError.ColorChanged += (s, e) => UpdateColors(); cpeLogLevelErrorText.ColorChanged += (s, e) => UpdateColors(); cpeLogLevelCritical.ColorChanged += (s, e) => UpdateColors(); cpeLogLevelCriticalText.ColorChanged += (s, e) => UpdateColors(); cpeLogLevelAnalogyInformation.ColorChanged += (s, e) => UpdateColors(); cpeLogLevelAnalogyInformationText.ColorChanged += (s, e) => UpdateColors(); cpeHighlightColor.ColorChanged += (s, e) => UpdateColors(); cpeHighlightColorText.ColorChanged += (s, e) => UpdateColors(); cpeNewMessagesColor.ColorChanged += (s, e) => UpdateColors(); cpeNewMessagesColorText.ColorChanged += (s, e) => UpdateColors(); }
private void SetupEventsHandlers() { #region filter tab tbFilteringLastEntries.ToggleStateChanged += (s, e) => { Settings.SaveSearchFilters = e.ToggleState == ToggleButtonState.Active; }; tbDataTimeAscendDescend.ToggleStateChanged += (s, e) => { Settings.DefaultDescendOrder = e.ToggleState == ToggleButtonState.Active; }; tbErrorLevelAsDefault.ToggleStateChanged += (s, e) => { Settings.StartupErrorLogLevel = tbErrorLevelAsDefault.ToggleState == ToggleButtonState.Active; }; tbAutoComplete.ToggleStateChanged += (s, e) => { Settings.RememberLastSearches = e.ToggleState == ToggleButtonState.Active; }; tbHistory.ToggleStateChanged += (s, e) => { Settings.ShowHistoryOfClearedMessages = e.ToggleState == ToggleButtonState.Active; }; cbPaging.CheckedChanged += (s, e) => { Settings.PagingEnabled = cbPaging.Checked; nudPageLength.Enabled = Settings.PagingEnabled; }; nudPageLength.ValueChanged += (s, e) => { Settings.PagingSize = (int)nudPageLength.Value; }; tbFileCaching.ToggleStateChanged += (s, e) => { Settings.EnableFileCaching = e.ToggleState == ToggleButtonState.Active; }; #endregion #region Pre-Defined Query sfBtnPreDefinedSelectColor.Click += (s, e) => { if (colorDialog1.ShowDialog(this) == DialogResult.OK) { tbHighlighColor.BackColor = colorDialog1.Color; } }; btnDeleteHighlight.Click += (s, e) => { if (lboxHighlightItems.SelectedItem is PreDefineHighlight highlight) { lboxHighlightItems.DataSource = null; lboxHighlightItems.Items.Clear(); Settings.PreDefinedQueries.RemoveHighlight(highlight); lboxHighlightItems.DataSource = Settings.PreDefinedQueries.Highlights; } }; btnAddFilter.Click += (s, e) => { lboxFilters.DataSource = null; Settings.PreDefinedQueries.AddFilter(tbIncludeTextFilter.Text, tbExcludeFilter.Text, tbSourcesFilter.Text, tbModulesFilter.Text); lboxFilters.DataSource = Settings.PreDefinedQueries.Filters; }; btnDeleteFilter.Click += (s, e) => { if (lboxFilters.SelectedItem is PreDefineFilter filter) { lboxFilters.DataSource = null; Settings.PreDefinedQueries.RemoveFilter(filter); lboxFilters.DataSource = Settings.PreDefinedQueries.Filters; } }; btnAddAlerts.Click += (s, e) => { lboxAlerts.DataSource = null; Settings.PreDefinedQueries.AddAlert(tbIncludeTextAlert.Text, tbExcludeAlert.Text, tbSourcesAlert.Text, tbModulesAlert.Text); lboxAlerts.DataSource = Settings.PreDefinedQueries.Alerts; lboxAlerts.Refresh(); }; btnDeleteAlerts.Click += (s, e) => { if (lboxAlerts.SelectedItem is PreDefineAlert alert) { lboxAlerts.DataSource = null; Settings.PreDefinedQueries.RemoveAlert(alert); lboxAlerts.DataSource = Settings.PreDefinedQueries.Alerts; lboxAlerts.Refresh(); } }; #endregion #region Look and feel tab btnExportColors.Click += (s, e) => { SaveSetting(); SaveFileDialog saveFileDialog = new SaveFileDialog(); saveFileDialog.Filter = "Analogy Color Settings (*.json)|*.json"; saveFileDialog.Title = @"Export Analogy Color settings"; if (saveFileDialog.ShowDialog(this) == DialogResult.OK) { try { File.WriteAllText(saveFileDialog.FileName, Settings.ColorSettings.AsJson()); MessageBox.Show("File Saved", @"Export settings", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception ex) { AnalogyLogManager.Instance.LogError("Error during save to file: " + e); MessageBox.Show("Error Export: " + ex.Message, @"Error Saving file", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }; btnImportColors.Click += (s, e) => { OpenFileDialog openFileDialog1 = new OpenFileDialog(); openFileDialog1.Filter = "Analogy Color Settings (*.json)|*.json"; openFileDialog1.Title = @"Import NLog settings"; openFileDialog1.Multiselect = true; if (openFileDialog1.ShowDialog() == DialogResult.OK) { try { var json = File.ReadAllText(openFileDialog1.FileName); ColorSettings color = ColorSettings.FromJson(json); Settings.ColorSettings = color; LoadColorSettings(); MessageBox.Show("File Imported. Save settings if desired", @"Import settings", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception ex) { AnalogyLogManager.Instance.LogError("Error during import data: " + e); MessageBox.Show("Error Import: " + ex.Message, @"Error Import file", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }; void SelectColor(TextBoxExt targetTextBox) { if (colorDialog1.ShowDialog(this) == DialogResult.OK) { targetTextBox.BackColor = colorDialog1.Color; } } sfBtnLogLevelUnknown.Click += (s, e) => SelectColor(tbLogLevelUnknown); sfBtnLogLevelDisabled.Click += (s, e) => SelectColor(tbLogLevelDisabled); sfBtnLogLevelTrace.Click += (s, e) => SelectColor(tbLogLevelTrace); sfBtnLogLevelVerbose.Click += (s, e) => SelectColor(tbLogLevelVerbose); sfBtnLogLevelDebug.Click += (s, e) => SelectColor(tbLogLevelDebug); sfBtnLogLevelEvent.Click += (s, e) => SelectColor(tbLogLevelEvent); sfBtnLogLevelWarning.Click += (s, e) => SelectColor(tbLogLevelWarning); sfBtnLogLevelError.Click += (s, e) => SelectColor(tbLogLevelError); sfBtnLogLevelCritical.Click += (s, e) => SelectColor(tbLogLevelCritical); sfBtnLogLevelAnalogyInformation.Click += (s, e) => SelectColor(tbLogLevelAnalogyInformation); sfBtnHighlightColor.Click += (s, e) => SelectColor(tbHighlightColor); #endregion #region User Statistics tab tbUserStatistics.ToggleStateChanged += (s, e) => { EnableDisableUserStatistics(e.ToggleState == ToggleButtonState.Active); Settings.EnableUserStatistics = e.ToggleState == ToggleButtonState.Active; }; btnClearStatistics.Click += (s, e) => { var result = MessageBox.Show(@"Clear statistics?", @"Confirmation Required", MessageBoxButtons.YesNo); if (result == DialogResult.Yes) { Settings.ClearStatistics(); } }; #endregion #region Extensions tab tbExtensionsStartup.ToggleStateChanged += (s, e) => { Settings.LoadExtensionsOnStartup = e.ToggleState == ToggleButtonState.Active; clExtensionslItems.Enabled = e.ToggleState == ToggleButtonState.Active; }; clExtensionslItems.SelectedIndexChanged += (s, e) => { Settings.StartupExtensions = clExtensionslItems.CheckedItems.Cast <IAnalogyExtension>() .Select(ex => ex.ExtensionID).ToList(); }; #endregion nudRecent.ValueChanged += (s, e) => Settings.RecentFilesCount = (int)nudRecent.Value; #region Resource Tab tbIdleMode.ToggleStateChanged += (s, e) => Settings.IdleMode = e.ToggleState == ToggleButtonState.Active; nudIdleTime.ValueChanged += (s, e) => Settings.IdleTimeMinutes = (int)nudIdleTime.Value; #endregion }