示例#1
0
        private void LoadSettings()
        {
            tsRememberLastPositionAndState.IsOn = Settings.AnalogyPosition.RememberLastPosition;
            logGrid.Columns["Date"].DisplayFormat.FormatType   = FormatType.DateTime;
            logGrid.Columns["Date"].DisplayFormat.FormatString = Settings.DateTimePattern;
            tsHistory.IsOn          = Settings.ShowHistoryOfClearedMessages;
            teDateTimeFormat.Text   = Settings.DateTimePattern;
            tsFilteringExclude.IsOn = Settings.SaveSearchFilters;
            listBoxFoldersProbing.Items.AddRange(Settings.AdditionalProbingLocations.ToArray());
            tsAutoComplete.IsOn    = Settings.RememberLastSearches;
            nudRecentFiles.Value   = Settings.RecentFilesCount;
            nudRecentFolders.Value = Settings.RecentFoldersCount;
            tsUserStatistics.IsOn  = Settings.EnableUserStatistics;
            //tsSimpleMode.IsOn = Settings.SimpleMode;
            tsFileCaching.IsOn            = Settings.EnableFileCaching;
            tswitchExtensionsStartup.IsOn = Settings.LoadExtensionsOnStartup;
            tsStartupRibbonMinimized.IsOn = Settings.StartupRibbonMinimized;
            tsErrorLevelAsDefault.IsOn    = Settings.StartupErrorLogLevel;
            chkEditPaging.Checked         = Settings.PagingEnabled;
            if (Settings.PagingEnabled)
            {
                nudPageLength.Value = Settings.PagingSize;
            }
            else
            {
                nudPageLength.Enabled = false;
            }

            checkEditSearchAlsoInSourceAndModule.Checked = Settings.SearchAlsoInSourceAndModule;
            toggleSwitchIdleMode.IsOn    = Settings.IdleMode;
            nudIdleTime.Value            = Settings.IdleTimeMinutes;
            tsDataTimeAscendDescend.IsOn = Settings.DefaultDescendOrder;
            var manager    = ExtensionsManager.Instance;
            var extensions = manager.GetExtensions().ToList();

            foreach (var extension in extensions)
            {
                chklItems.Items.Add(extension, Settings.StartupExtensions.Contains(extension.ID));
                chklItems.DisplayMember = "DisplayName";
            }

            var startup = Settings.AutoStartDataProviders;
            var loaded  = FactoriesManager.Instance.GetRealTimeDataSourcesNamesAndIds();

            foreach (var realTime in loaded)
            {
                FactoryCheckItem itm = new FactoryCheckItem(realTime.Name, realTime.ID);
                chkLstItemRealTimeDataSources.Items.Add(itm, startup.Contains(itm.ID));
            }



            foreach (var setting in Settings.FactoriesOrder)
            {
                FactorySettings factory = Settings.GetFactorySetting(setting);
                if (factory == null)
                {
                    continue;
                }
                FactoryCheckItem itm = new FactoryCheckItem(factory.FactoryName, factory.FactoryId);
                chkLstDataProviderStatus.Items.Add(itm, factory.Status == DataProviderFactoryStatus.Enabled);
            }
            //add missing:
            foreach (var factory in Settings.FactoriesSettings.Where(itm => !Settings.FactoriesOrder.Contains(itm.FactoryId)))
            {
                FactoryCheckItem itm = new FactoryCheckItem(factory.FactoryName, factory.FactoryId);
                chkLstDataProviderStatus.Items.Add(itm, factory.Status != DataProviderFactoryStatus.Disabled);
            }

            //file associations:
            cbDataProviderAssociation.DataSource    = Settings.FactoriesSettings;
            cbDataProviderAssociation.DisplayMember = "FactoryName";
            tsRememberLastOpenedDataProvider.IsOn   = Settings.RememberLastOpenedDataProvider;
            lboxHighlightItems.DataSource           = Settings.PreDefinedQueries.Highlights;
            lboxAlerts.DataSource      = Settings.PreDefinedQueries.Alerts;
            lboxFilters.DataSource     = Settings.PreDefinedQueries.Filters;
            nudAutoCompleteCount.Value = Settings.NumberOfLastSearches;
            tsSingleInstance.IsOn      = Settings.SingleInstance;
            if (Settings.AnalogyIcon == "Light")
            {
                rbtnLightIconColor.Checked = true;
            }
            else
            {
                rbtnDarkIconColor.Checked = true;
            }
            LoadColorSettings();
            cbUpdates.Properties.Items.AddRange(typeof(UpdateMode).GetDisplayValues().Values);
            cbUpdates.SelectedItem            = UpdateManager.Instance.UpdateMode.GetDisplay();
            tsTraybar.IsOn                    = Settings.MinimizedToTrayBar;
            tsCheckAdditionalInformation.IsOn = Settings.CheckAdditionalInformation;
        }
        private void LoadSettings()
        {
            tsHistory.IsOn          = Settings.ShowHistoryOfClearedMessages;
            tsFilteringExclude.IsOn = Settings.SaveSearchFilters;
            nudRecent.Value         = Settings.RecentFilesCount;
            tsUserStatistics.IsOn   = Settings.EnableUserStatistics;
            //tsSimpleMode.IsOn = Settings.SimpleMode;
            tsFileCaching.IsOn            = Settings.EnableFileCaching;
            tswitchExtensionsStartup.IsOn = Settings.LoadExtensionsOnStartup;
            tsStartupRibbonMinimized.IsOn = Settings.StartupRibbonMinimized;
            tsErrorLevelAsDefault.IsOn    = Settings.StartupErrorLogLevel;
            chkEditPaging.Checked         = Settings.PagingEnabled;
            if (Settings.PagingEnabled)
            {
                nudPageLength.Value = Settings.PagingSize;
            }
            else
            {
                nudPageLength.Enabled = false;
            }

            checkEditSearchAlsoInSourceAndModule.Checked = Settings.SearchAlsoInSourceAndModule;
            toggleSwitchIdleMode.IsOn    = Settings.IdleMode;
            nudIdleTime.Value            = Settings.IdleTimeMinutes;
            tsDataTimeAscendDescend.IsOn = Settings.DefaultDescendOrder;
            var manager    = ExtensionsManager.Instance;
            var extensions = manager.GetExtensions().ToList();

            foreach (var extension in extensions)
            {
                chklItems.Items.Add(extension, Settings.StartupExtensions.Contains(extension.ExtensionID));
                chklItems.DisplayMember = "DisplayName";
            }

            var startup = Settings.AutoStartDataProviders;
            var loaded  = FactoriesManager.Instance.GetRealTimeDataSourcesNamesAndIds();

            foreach (var realTime in loaded)
            {
                FactoryCheckItem itm = new FactoryCheckItem(realTime.Name, realTime.ID);
                chkLstItemRealTimeDataSources.Items.Add(itm, startup.Contains(itm.ID));
            }



            foreach (var setting in Settings.FactoriesOrder)
            {
                FactorySettings factory = Settings.GetFactorySetting(setting);
                if (factory == null)
                {
                    continue;
                }
                FactoryCheckItem itm = new FactoryCheckItem(factory.FactoryName, factory.FactoryGuid);
                chkLstDataProviderStatus.Items.Add(itm, factory.Status == DataProviderFactoryStatus.Enabled);
            }
            //add missing:
            foreach (var factory in Settings.FactoriesSettings.Where(itm => !Settings.FactoriesOrder.Contains(itm.FactoryGuid)))
            {
                FactoryCheckItem itm = new FactoryCheckItem(factory.FactoryName, factory.FactoryGuid);
                chkLstDataProviderStatus.Items.Add(itm, factory.Status != DataProviderFactoryStatus.Disabled);
            }

            //file associations:
            cbDataProviderAssociation.DataSource    = Settings.FactoriesSettings;
            cbDataProviderAssociation.DisplayMember = "FactoryName";
            tsRememberLastOpenedDataProvider.IsOn   = Settings.RememberLastOpenedDataProvider;
            lboxHighlightItems.DataSource           = Settings.PreDefinedQueries.Highlights;
            lboxAlerts.DataSource  = Settings.PreDefinedQueries.Alerts;
            lboxFilters.DataSource = Settings.PreDefinedQueries.Filters;
            LoadColorSettings();
        }
        private void SaveSetting()
        {
            SaveColorsSettings();
            Settings.SimpleMode         = tsSimpleMode.IsOn;
            Settings.LogLevelSelection  = tsLogLevels.IsOn ? LogLevelSelectionType.Multiple : LogLevelSelectionType.Single;
            Settings.RecentFilesCount   = (int)nudRecentFiles.Value;
            Settings.RecentFoldersCount = (int)nudRecentFolders.Value;
            List <Guid> order = new List <Guid>(chkLstDataProviderStatus.Items.Count);

            foreach (CheckedListBoxItem item in chkLstDataProviderStatus.Items)
            {
                FactoryCheckItem fci = (FactoryCheckItem)item.Value;
                order.Add(fci.ID);
                var guid    = fci.ID;
                var factory = Settings.FactoriesSettings.SingleOrDefault(f => f.FactoryId == guid);
                if (factory != null)
                {
                    factory.Status = item.CheckState == CheckState.Checked
                        ? DataProviderFactoryStatus.Enabled
                        : DataProviderFactoryStatus.Disabled;
                }
            }

            Settings.RememberLastOpenedDataProvider = tsRememberLastOpenedDataProvider.IsOn;
            Settings.RememberLastSearches           = tsAutoComplete.IsOn;
            Settings.UpdateOrder(order);
            Settings.AdditionalProbingLocations = listBoxFoldersProbing.Items.Cast <string>().ToList();
            Settings.SingleInstance             = tsSingleInstance.IsOn;
            Settings.AnalogyIcon = rbtnLightIconColor.Checked ? "Light" : "Dark";
            var options = typeof(UpdateMode).GetDisplayValues();

            UpdateManager.Instance.UpdateMode = (UpdateMode)Enum.Parse(typeof(UpdateMode),
                                                                       options.Single(k => k.Value == cbUpdates.SelectedItem.ToString()).Key, true);
            Settings.MinimizedToTrayBar                   = tsTraybar.IsOn;
            Settings.CheckAdditionalInformation           = tsCheckAdditionalInformation.IsOn;
            Settings.AnalogyPosition.RememberLastPosition = tsRememberLastPositionAndState.IsOn;
            Settings.EnableCompressedArchives             = tsEnableCompressedArchive.IsOn;

            if (rbFontSizeNormal.Checked)
            {
                Settings.FontSettings.SetFontSelectionType(FontSelectionType.Normal);
            }
            if (rbFontSizeLarge.Checked)
            {
                Settings.FontSettings.SetFontSelectionType(FontSelectionType.Large);
            }
            if (rbFontSizeVeryLarge.Checked)
            {
                Settings.FontSettings.SetFontSelectionType(FontSelectionType.VeryLarge);
            }

            if (rbMenuFontSizeNormal.Checked)
            {
                Settings.FontSettings.SetMenuFontSelectionType(FontSelectionType.Normal);
            }
            if (rbMenuFontSizeLarge.Checked)
            {
                Settings.FontSettings.SetMenuFontSelectionType(FontSelectionType.Large);
            }
            if (rbMenuFontSizeVeryLarge.Checked)
            {
                Settings.FontSettings.SetMenuFontSelectionType(FontSelectionType.VeryLarge);
            }

            Settings.EnableFirstChanceException = tsEnableFirstChanceException.IsOn;

            Settings.Save();
        }
        private void LoadSettings()
        {
            //Filter tab
            tbFilteringLastEntries.ToggleState =
                Settings.SaveSearchFilters ? ToggleButtonState.Active : ToggleButtonState.Inactive;
            tbDataTimeAscendDescend.ToggleState =
                Settings.DefaultDescendOrder ? ToggleButtonState.Active : ToggleButtonState.Inactive;
            tbErrorLevelAsDefault.ToggleState =
                Settings.StartupErrorLogLevel ? ToggleButtonState.Active : ToggleButtonState.Inactive;

            tbAutoComplete.ToggleState =
                Settings.RememberLastSearches ? ToggleButtonState.Active : ToggleButtonState.Inactive;

            tbHistory.ToggleState =
                Settings.ShowHistoryOfClearedMessages ? ToggleButtonState.Active : ToggleButtonState.Inactive;


            cbPaging.Checked      = Settings.PagingEnabled;
            nudPageLength.Enabled = Settings.PagingEnabled;

            tbFileCaching.ToggleState =
                Settings.EnableFileCaching ? ToggleButtonState.Active : ToggleButtonState.Inactive;

            nudRecent.Value = Settings.RecentFilesCount;
            tbUserStatistics.ToggleState =
                Settings.EnableUserStatistics ? ToggleButtonState.Active : ToggleButtonState.Inactive;
            //tsSimpleMode.IsOn = Settings.SimpleMode;
            tbExtensionsStartup.ToggleState = Settings.LoadExtensionsOnStartup ? ToggleButtonState.Active : ToggleButtonState.Inactive;
            if (Settings.PagingEnabled)
            {
                nudPageLength.Value = Settings.PagingSize;
            }
            else
            {
                nudPageLength.Enabled = false;
            }

            tbIdleMode.ToggleState = Settings.IdleMode? ToggleButtonState.Active:ToggleButtonState.Inactive;
            nudIdleTime.Value      = Settings.IdleTimeMinutes;
            var manager    = ExtensionsManager.Instance;
            var extensions = manager.GetExtensions().ToList();

            foreach (var extension in extensions)
            {
                clExtensionslItems.Items.Add(extension, Settings.StartupExtensions.Contains(extension.ExtensionID));
                clExtensionslItems.DisplayMember = "DisplayName";
            }

            var startup = Settings.AutoStartDataProviders;
            var loaded  = FactoriesManager.Instance.GetRealTimeDataSourcesNamesAndIds();

            foreach (var realTime in loaded)
            {
                FactoryCheckItem itm = new FactoryCheckItem(realTime.Name, realTime.ID);
                chkLstItemRealTimeDataSources.Items.Add(itm, startup.Contains(itm.ID));
            }



            foreach (var setting in Settings.FactoriesOrder)
            {
                FactorySettings factory = Settings.GetFactorySetting(setting);
                if (factory == null)
                {
                    continue;
                }
                FactoryCheckItem itm = new FactoryCheckItem(factory.FactoryName, factory.FactoryGuid);
                chkLstDataProviderStatus.Items.Add(itm, factory.Status == DataProviderFactoryStatus.Enabled);
            }
            //add missing:
            foreach (var factory in Settings.FactoriesSettings.Where(itm => !Settings.FactoriesOrder.Contains(itm.FactoryGuid)))
            {
                FactoryCheckItem itm = new FactoryCheckItem(factory.FactoryName, factory.FactoryGuid);
                chkLstDataProviderStatus.Items.Add(itm, factory.Status != DataProviderFactoryStatus.Disabled);
            }

            //file associations:
            cbDataProviderAssociation.DataSource         = Settings.FactoriesSettings;
            cbDataProviderAssociation.DisplayMember      = "FactoryName";
            tbRememberLastOpenedDataProvider.ToggleState = Settings.RememberLastOpenedDataProvider
                ? ToggleButtonState.Active
                : ToggleButtonState.Inactive;
            lboxHighlightItems.DataSource = Settings.PreDefinedQueries.Highlights;
            lboxAlerts.DataSource         = Settings.PreDefinedQueries.Alerts;
            lboxFilters.DataSource        = Settings.PreDefinedQueries.Filters;
            LoadColorSettings();
        }
        private void LoadSettings()
        {
            tsSimpleMode.IsOn = Settings.SimpleMode;
            tsEnableCompressedArchive.IsOn      = Settings.EnableCompressedArchives;
            tsRememberLastPositionAndState.IsOn = Settings.AnalogyPosition.RememberLastPosition;
            logGrid.Columns["Date"].DisplayFormat.FormatType   = FormatType.DateTime;
            logGrid.Columns["Date"].DisplayFormat.FormatString = Settings.DateTimePattern;
            tsHistory.IsOn          = Settings.ShowHistoryOfClearedMessages;
            teDateTimeFormat.Text   = Settings.DateTimePattern;
            tsFilteringExclude.IsOn = Settings.SaveSearchFilters;
            listBoxFoldersProbing.Items.AddRange(Settings.AdditionalProbingLocations.ToArray());
            tsAutoComplete.IsOn    = Settings.RememberLastSearches;
            nudRecentFiles.Value   = Settings.RecentFilesCount;
            nudRecentFolders.Value = Settings.RecentFoldersCount;
            tsUserStatistics.IsOn  = Settings.EnableUserStatistics;
            //tsSimpleMode.IsOn = Settings.SimpleMode;
            tsFileCaching.IsOn            = Settings.EnableFileCaching;
            tsStartupRibbonMinimized.IsOn = Settings.StartupRibbonMinimized;
            tsErrorLevelAsDefault.IsOn    = Settings.StartupErrorLogLevel;
            chkEditPaging.Checked         = Settings.PagingEnabled;
            if (Settings.PagingEnabled)
            {
                nudPageLength.Value = Settings.PagingSize;
            }
            else
            {
                nudPageLength.Enabled = false;
            }

            checkEditSearchAlsoInSourceAndModule.Checked = Settings.SearchAlsoInSourceAndModule;
            toggleSwitchIdleMode.IsOn    = Settings.IdleMode;
            nudIdleTime.Value            = Settings.IdleTimeMinutes;
            tsDataTimeAscendDescend.IsOn = Settings.DefaultDescendOrder;

            var startup = Settings.AutoStartDataProviders;
            var loaded  = FactoriesManager.Instance.GetRealTimeDataSourcesNamesAndIds();

            foreach (var realTime in loaded)
            {
                FactoryCheckItem itm = new FactoryCheckItem(realTime.Name, realTime.ID, realTime.Description, realTime.Image);
                chkLstItemRealTimeDataSources.Items.Add(itm, startup.Contains(itm.ID));
            }

            foreach (var setting in Settings.FactoriesOrder)
            {
                FactorySettings factory = Settings.GetFactorySetting(setting);
                if (factory == null)
                {
                    continue;
                }
                var              factoryContainer = FactoriesManager.Instance.FactoryContainer(factory.FactoryId);
                string           about            = (factoryContainer?.Factory != null) ? factoryContainer.Factory.About : "Disabled";
                var              image            = FactoriesManager.Instance.GetLargeImage(factory.FactoryId);
                FactoryCheckItem itm = new FactoryCheckItem(factory.FactoryName, factory.FactoryId, about, image);
                chkLstDataProviderStatus.Items.Add(itm, factory.Status == DataProviderFactoryStatus.Enabled);
            }
            //add missing:
            foreach (var factory in Settings.FactoriesSettings.Where(itm => !Settings.FactoriesOrder.Contains(itm.FactoryId)))
            {
                var              factoryContainer = FactoriesManager.Instance.FactoryContainer(factory.FactoryId);
                string           about            = (factoryContainer?.Factory != null) ? factoryContainer.Factory.About : "Disabled";
                var              image            = FactoriesManager.Instance.GetLargeImage(factory.FactoryId);
                FactoryCheckItem itm = new FactoryCheckItem(factory.FactoryName, factory.FactoryId, about, image);
                chkLstDataProviderStatus.Items.Add(itm, factory.Status != DataProviderFactoryStatus.Disabled);
            }

            //file associations:

            cbDataProviderAssociation.Properties.DataSource    = Settings.FactoriesSettings;
            cbDataProviderAssociation.Properties.DisplayMember = "FactoryName";
            cbDataProviderAssociation.EditValue = Settings.FactoriesSettings.First();
            //cbDataProviderAssociation.Properties.ValueMember = "ID";
            tsRememberLastOpenedDataProvider.IsOn = Settings.RememberLastOpenedDataProvider;
            lboxHighlightItems.DataSource         = Settings.PreDefinedQueries.Highlights;
            lboxAlerts.DataSource      = Settings.PreDefinedQueries.Alerts;
            lboxFilters.DataSource     = Settings.PreDefinedQueries.Filters;
            nudAutoCompleteCount.Value = Settings.NumberOfLastSearches;
            tsSingleInstance.IsOn      = Settings.SingleInstance;
            if (Settings.AnalogyIcon == "Light")
            {
                rbtnLightIconColor.Checked = true;
            }
            else
            {
                rbtnDarkIconColor.Checked = true;
            }
            LoadColorsSettings();
            cbUpdates.Properties.Items.AddRange(typeof(UpdateMode).GetDisplayValues().Values);
            cbUpdates.SelectedItem            = UpdateManager.Instance.UpdateMode.GetDisplay();
            tsTraybar.IsOn                    = Settings.MinimizedToTrayBar;
            tsCheckAdditionalInformation.IsOn = Settings.CheckAdditionalInformation;
            tsLogLevels.IsOn                  = Settings.LogLevelSelection == LogLevelSelectionType.Multiple;
            Utils.SetLogLevel(chkLstLogLevel);

            switch (Settings.FontSettings.FontSelectionType)
            {
            case FontSelectionType.Normal:
                rbFontSizeNormal.Checked = true;
                break;

            case FontSelectionType.Large:
                rbFontSizeLarge.Checked = true;
                break;

            case FontSelectionType.VeryLarge:
                rbFontSizeVeryLarge.Checked = true;
                break;

            case FontSelectionType.Manual:
            default:
                rbFontSizeNormal.Checked = true;
                break;
            }
            switch (Settings.FontSettings.MenuFontSelectionType)
            {
            case FontSelectionType.Normal:
                rbMenuFontSizeNormal.Checked = true;
                break;

            case FontSelectionType.Large:
                rbMenuFontSizeLarge.Checked = true;
                break;

            case FontSelectionType.VeryLarge:
                rbMenuFontSizeVeryLarge.Checked = true;
                break;

            case FontSelectionType.Manual:
            default:
                rbMenuFontSizeNormal.Checked = true;
                break;
            }

            tsRibbonCompactStyle.IsOn         = Settings.RibbonStyle == CommandLayout.Simplified;
            tsEnableFirstChanceException.IsOn = Settings.EnableFirstChanceException;
        }