diff --git a/Analogy.Common/DataTypes/Enums.cs b/Analogy.Common/DataTypes/Enums.cs index df31be4a..b4cd0f7c 100644 --- a/Analogy.Common/DataTypes/Enums.cs +++ b/Analogy.Common/DataTypes/Enums.cs @@ -60,6 +60,7 @@ public enum FontSelectionType public enum SettingsMode { + None = -1, PerUser, ApplicationFolder, ProgramData, diff --git a/Analogy.Common/Interfaces/IUserSettingsManager.cs b/Analogy.Common/Interfaces/IUserSettingsManager.cs index c33585cd..0f1c9c5d 100644 --- a/Analogy.Common/Interfaces/IUserSettingsManager.cs +++ b/Analogy.Common/Interfaces/IUserSettingsManager.cs @@ -45,7 +45,7 @@ public interface IUserSettingsManager bool TrackActiveMessage { get; set; } float RealTimeRefreshInterval { get; set; } FilteringExclusion FilteringExclusion { get; set; } - string LogsLayoutFileName { get; set; } + string LogsLayoutFileName { get; } bool UseCustomLogsLayout { get; set; } bool ViewDetailedMessageWithHTML { get; set; } TimeSpan TimeOffset { get; set; } @@ -65,5 +65,6 @@ public interface IUserSettingsManager void ResetSettings(); bool TryGetWindowPosition(Guid id, out AnalogyPositionState? position); void SetWindowPosition(Guid id, AnalogyPositionState position); + void SetLogsLayoutFileName(string filename); } } \ No newline at end of file diff --git a/Analogy.Common/Managers/DefaultUserSettingsManager.cs b/Analogy.Common/Managers/DefaultUserSettingsManager.cs index f8a707b6..d9013490 100644 --- a/Analogy.Common/Managers/DefaultUserSettingsManager.cs +++ b/Analogy.Common/Managers/DefaultUserSettingsManager.cs @@ -43,7 +43,7 @@ public class DefaultUserSettingsManager : IUserSettingsManager public bool TrackActiveMessage { get; set; } public float RealTimeRefreshInterval { get; set; } = 1; public FilteringExclusion FilteringExclusion { get; set; } = new FilteringExclusion(); - public string LogsLayoutFileName { get; set; } + public string LogsLayoutFileName { get; } public bool UseCustomLogsLayout { get; set; } public bool ViewDetailedMessageWithHTML { get; set; } public TimeSpan TimeOffset { get; set; } = TimeSpan.Zero; @@ -102,5 +102,10 @@ public bool TryGetWindowPosition(Guid id, out AnalogyPositionState? position) public void SetWindowPosition(Guid id, AnalogyPositionState position) { } + + public void SetLogsLayoutFileName(string filename) + { + + } } } diff --git a/Analogy.CommonControls/UserControls/LogMessagesUC.cs b/Analogy.CommonControls/UserControls/LogMessagesUC.cs index 06d9d739..3e840f29 100644 --- a/Analogy.CommonControls/UserControls/LogMessagesUC.cs +++ b/Analogy.CommonControls/UserControls/LogMessagesUC.cs @@ -1001,7 +1001,7 @@ private void SetupEventsHandlers() wsLogs.WorkspaceSaved += (s, e) => { - Settings.LogsLayoutFileName = e.Workspace.Path; + Settings.SetLogsLayoutFileName(e.Workspace.Path); // Settings.UseCustomLogsLayout = true; }; wsLogs.AfterApplyWorkspace += (s, e) => @@ -1015,7 +1015,7 @@ private void SetupEventsHandlers() else if (File.Exists(ws.Workspace.Path)) { // Settings.UseCustomLogsLayout = true; - Settings.LogsLayoutFileName = ws.Workspace.Path; + Settings.SetLogsLayoutFileName(ws.Workspace.Path); } } diff --git a/Analogy.CommonControls/UserControls/ServerSideLogMessagesUC.cs b/Analogy.CommonControls/UserControls/ServerSideLogMessagesUC.cs index f5bbcd17..0cd6d850 100644 --- a/Analogy.CommonControls/UserControls/ServerSideLogMessagesUC.cs +++ b/Analogy.CommonControls/UserControls/ServerSideLogMessagesUC.cs @@ -761,7 +761,7 @@ private void SetupEventsHandlers() wsLogs.WorkspaceSaved += (s, e) => { - Settings.LogsLayoutFileName = e.Workspace.Path; + Settings.SetLogsLayoutFileName(e.Workspace.Path); // Settings.UseCustomLogsLayout = true; }; wsLogs.AfterApplyWorkspace += (s, e) => @@ -775,7 +775,7 @@ private void SetupEventsHandlers() else if (File.Exists(ws.Workspace.Path)) { // Settings.UseCustomLogsLayout = true; - Settings.LogsLayoutFileName = ws.Workspace.Path; + Settings.SetLogsLayoutFileName(ws.Workspace.Path); } } diff --git a/Analogy/ApplicationSettings/ApplicationGeneralSettingsUC.Designer.cs b/Analogy/ApplicationSettings/ApplicationGeneralSettingsUC.Designer.cs index 84b4a130..9a67af77 100644 --- a/Analogy/ApplicationSettings/ApplicationGeneralSettingsUC.Designer.cs +++ b/Analogy/ApplicationSettings/ApplicationGeneralSettingsUC.Designer.cs @@ -29,12 +29,12 @@ protected override void Dispose(bool disposing) /// private void InitializeComponent() { - DevExpress.Utils.SuperToolTip superToolTip3 = new DevExpress.Utils.SuperToolTip(); - DevExpress.Utils.ToolTipTitleItem toolTipTitleItem3 = new DevExpress.Utils.ToolTipTitleItem(); - DevExpress.Utils.ToolTipItem toolTipItem3 = new DevExpress.Utils.ToolTipItem(); DevExpress.Utils.SuperToolTip superToolTip1 = new DevExpress.Utils.SuperToolTip(); DevExpress.Utils.ToolTipTitleItem toolTipTitleItem1 = new DevExpress.Utils.ToolTipTitleItem(); DevExpress.Utils.ToolTipItem toolTipItem1 = new DevExpress.Utils.ToolTipItem(); + DevExpress.Utils.SuperToolTip superToolTip2 = new DevExpress.Utils.SuperToolTip(); + DevExpress.Utils.ToolTipTitleItem toolTipTitleItem2 = new DevExpress.Utils.ToolTipTitleItem(); + DevExpress.Utils.ToolTipItem toolTipItem2 = new DevExpress.Utils.ToolTipItem(); this.gcCompressedArchives = new DevExpress.XtraEditors.GroupControl(); this.tsEnableCompressedArchive = new DevExpress.XtraEditors.ToggleSwitch(); this.gcGeneral = new DevExpress.XtraEditors.GroupControl(); @@ -277,13 +277,13 @@ private void InitializeComponent() this.tsFileCaching.Properties.OffText = "Don\'t use caching of loaded logs"; this.tsFileCaching.Properties.OnText = "Use caching of loaded logs"; this.tsFileCaching.Size = new System.Drawing.Size(763, 24); - toolTipTitleItem3.Text = "Caching"; - toolTipItem3.LeftIndent = 6; - toolTipItem3.Text = "When enable files that were loaded won\'t be loaded again and the messages will be" + + toolTipTitleItem1.Text = "Caching"; + toolTipItem1.LeftIndent = 6; + toolTipItem1.Text = "When enable files that were loaded won\'t be loaded again and the messages will be" + " loaded from in-memory cache."; - superToolTip3.Items.Add(toolTipTitleItem3); - superToolTip3.Items.Add(toolTipItem3); - this.tsFileCaching.SuperTip = superToolTip3; + superToolTip1.Items.Add(toolTipTitleItem1); + superToolTip1.Items.Add(toolTipItem1); + this.tsFileCaching.SuperTip = superToolTip1; this.tsFileCaching.TabIndex = 1; // // tsSingleInstance @@ -297,13 +297,13 @@ private void InitializeComponent() this.tsSingleInstance.Properties.OffText = "Multi Instance Mode"; this.tsSingleInstance.Properties.OnText = "Single Instance Mode"; this.tsSingleInstance.Size = new System.Drawing.Size(763, 24); - toolTipTitleItem1.Text = "Single Instance mode"; - toolTipItem1.LeftIndent = 6; - toolTipItem1.Text = "When enabled only one instance will run and other instances will exit immediately" + + toolTipTitleItem2.Text = "Single Instance mode"; + toolTipItem2.LeftIndent = 6; + toolTipItem2.Text = "When enabled only one instance will run and other instances will exit immediately" + ""; - superToolTip1.Items.Add(toolTipTitleItem1); - superToolTip1.Items.Add(toolTipItem1); - this.tsSingleInstance.SuperTip = superToolTip1; + superToolTip2.Items.Add(toolTipTitleItem2); + superToolTip2.Items.Add(toolTipItem2); + this.tsSingleInstance.SuperTip = superToolTip2; this.tsSingleInstance.TabIndex = 2; // // gcSettingsLocation @@ -323,7 +323,7 @@ private void InitializeComponent() this.ceSettingsLocationApplicationFolder.Dock = System.Windows.Forms.DockStyle.Top; this.ceSettingsLocationApplicationFolder.Location = new System.Drawing.Point(2, 54); this.ceSettingsLocationApplicationFolder.Name = "ceSettingsLocationApplicationFolder"; - this.ceSettingsLocationApplicationFolder.Properties.Caption = "Portable: Store settings in the Application Folder (May need folder permissions)"; + this.ceSettingsLocationApplicationFolder.Properties.Caption = "Portable: Store settings in the Application Folder"; this.ceSettingsLocationApplicationFolder.Properties.CheckBoxOptions.Style = DevExpress.XtraEditors.Controls.CheckBoxStyle.SvgRadio2; this.ceSettingsLocationApplicationFolder.Properties.RadioGroupIndex = 0; this.ceSettingsLocationApplicationFolder.Size = new System.Drawing.Size(782, 26); diff --git a/Analogy/ApplicationSettings/ApplicationGeneralSettingsUC.cs b/Analogy/ApplicationSettings/ApplicationGeneralSettingsUC.cs index f814f301..e6d8d526 100644 --- a/Analogy/ApplicationSettings/ApplicationGeneralSettingsUC.cs +++ b/Analogy/ApplicationSettings/ApplicationGeneralSettingsUC.cs @@ -17,9 +17,12 @@ namespace Analogy.ApplicationSettings public partial class ApplicationGeneralSettingsUC : DevExpress.XtraEditors.XtraUserControl { private IAnalogyUserSettings Settings { get; } - public ApplicationGeneralSettingsUC(IAnalogyUserSettings settings) + private IAnalogyFoldersAccess FoldersAccess { get; } + + public ApplicationGeneralSettingsUC(IAnalogyUserSettings settings,IAnalogyFoldersAccess foldersAccess) { Settings = settings; + FoldersAccess = foldersAccess; InitializeComponent(); } @@ -71,6 +74,7 @@ private void SetupEventsHandlers() private void LoadSettings() { + ceSettingsLocationApplicationFolder.Text = $"Portable: Store settings in the Application Folder ({FoldersAccess.ConfigurationsFolder})"; toggleSwitchIdleMode.IsOn = Settings.IdleMode; nudIdleTime.Value = Settings.IdleTimeMinutes; nudRecentFiles.Value = Settings.RecentFilesCount; diff --git a/Analogy/CommonChangeLog.cs b/Analogy/CommonChangeLog.cs index dde6bfe3..6d596b31 100644 --- a/Analogy/CommonChangeLog.cs +++ b/Analogy/CommonChangeLog.cs @@ -9,6 +9,7 @@ public static IEnumerable GetChangeLog() { return new List { + new ("V5.0.0 - Support running from MSI Installer #1838", AnalogChangeLogType.Improvement,"Lior Banai",new DateTime(2023,09,03),"5.0.0.0"), new ("V5.0.0 - Add Export to Simple File #1815", AnalogChangeLogType.Improvement,"Lior Banai",new DateTime(2023,08,25),"5.0.0.0"), new ("V5.0.0 - Change Time Offset is very slow #1769", AnalogChangeLogType.Bug,"Lior Banai",new DateTime(2023,08,25),"5.0.0.0"), new ("V5.0.0 - Message viewer doesn't understand Linux-style new lines #1770", AnalogChangeLogType.Improvement,"Lior Banai",new DateTime(2023,08,25),"5.0.0.0"), diff --git a/Analogy/Forms/ApplicationSettingsForm.cs b/Analogy/Forms/ApplicationSettingsForm.cs index cdcc89c5..47276bb3 100644 --- a/Analogy/Forms/ApplicationSettingsForm.cs +++ b/Analogy/Forms/ApplicationSettingsForm.cs @@ -14,19 +14,21 @@ public partial class ApplicationSettingsForm : DevExpress.XtraBars.FluentDesignS { private IAnalogyUserSettings Settings { get; } private IFactoriesManager FactoriesManager { get; } + private IAnalogyFoldersAccess FoldersAccess { get; } private UpdateManager UpdateManager { get; } private ApplicationSettingsSelectionType SelectedSettingType { get; } - public ApplicationSettingsForm(IAnalogyUserSettings settings, IFactoriesManager factoriesManager, UpdateManager updateManager) + public ApplicationSettingsForm(IAnalogyUserSettings settings, IFactoriesManager factoriesManager, IAnalogyFoldersAccess foldersAccess, UpdateManager updateManager) { InitializeComponent(); Settings = settings; FactoriesManager = factoriesManager; + FoldersAccess = foldersAccess; UpdateManager = updateManager; EnableAcrylicAccent = false; SelectedSettingType = ApplicationSettingsSelectionType.ApplicationGeneralSettings; } - public ApplicationSettingsForm(ApplicationSettingsSelectionType selectedSettingType, IAnalogyUserSettings settings, IFactoriesManager factoriesManager, UpdateManager updateManager) : this(settings, factoriesManager, updateManager) + public ApplicationSettingsForm(ApplicationSettingsSelectionType selectedSettingType, IAnalogyUserSettings settings, IFactoriesManager factoriesManager, IAnalogyFoldersAccess foldersAccess, UpdateManager updateManager) : this(settings, factoriesManager, foldersAccess, updateManager) { SelectedSettingType = selectedSettingType; } @@ -48,7 +50,7 @@ private UserControl GetUserControlByType(ApplicationSettingsSelectionType settin switch (settingType) { case ApplicationSettingsSelectionType.ApplicationGeneralSettings: - return new ApplicationGeneralSettingsUC(Settings); + return new ApplicationGeneralSettingsUC(Settings, FoldersAccess); case ApplicationSettingsSelectionType.ApplicationUISettings: return new ApplicationUISettingsUC(Settings); case ApplicationSettingsSelectionType.MessagesFilteringSettings: @@ -199,7 +201,7 @@ private void bbtnReset_ItemClick(object sender, ItemClickEventArgs e) Hide(); Close(); Settings.ResetSettings(); - ApplicationSettingsForm us = new ApplicationSettingsForm(Settings, FactoriesManager, UpdateManager); + ApplicationSettingsForm us = new ApplicationSettingsForm(Settings, FactoriesManager, FoldersAccess, UpdateManager); us.ShowDialog(owner); } } diff --git a/Analogy/Forms/FluentDesignMainForm.cs b/Analogy/Forms/FluentDesignMainForm.cs index 4fdd588d..de86e2f0 100644 --- a/Analogy/Forms/FluentDesignMainForm.cs +++ b/Analogy/Forms/FluentDesignMainForm.cs @@ -65,11 +65,12 @@ public partial class FluentDesignMainForm : DevExpress.XtraBars.FluentDesignSyst private FileProcessingManager FileProcessingManager { get; } private List> OnlineSources { get; } = new List>(); private NotificationManager NotificationManager { get; } + private IAnalogyFoldersAccess FoldersAccess { get; } private AnalogyOnDemandPlottingManager PlottingManager { get; } public FluentDesignMainForm(IFactoriesManager factoriesManager, IExtensionsManager extensionsManager, BookmarkPersistManager bookmarkPersistManager, UpdateManager updateManager, FileProcessingManager fileProcessingManager, - NotificationManager notificationManager, AnalogyOnDemandPlottingManager plottingManager) + NotificationManager notificationManager, IAnalogyFoldersAccess foldersAccess, AnalogyOnDemandPlottingManager plottingManager) { FactoriesManager = factoriesManager; ExtensionsManager = extensionsManager; @@ -77,6 +78,7 @@ public FluentDesignMainForm(IFactoriesManager factoriesManager, IExtensionsManag UpdateManager = updateManager; FileProcessingManager = fileProcessingManager; NotificationManager = notificationManager; + FoldersAccess = foldersAccess; InitializeComponent(); EnableAcrylicAccent = false; PlottingManager = plottingManager; @@ -375,7 +377,7 @@ private void SetupEventHandlers() }; bbiWelcomeForm.ItemClick += (s, e) => { - WelcomeForm wf = new WelcomeForm(Settings, FactoriesManager, UpdateManager); + WelcomeForm wf = new WelcomeForm(Settings, FactoriesManager, FoldersAccess, UpdateManager); wf.ShowDialog(this); }; bbtnItemGithubHistory.ItemClick += (s, e) => @@ -405,92 +407,92 @@ private void SetupEventHandlers() btnSettingsUpdate.ItemClick += (s, e) => { - ApplicationSettingsForm user = new ApplicationSettingsForm(ApplicationSettingsSelectionType.UpdatesSettings, Settings, FactoriesManager, UpdateManager); + ApplicationSettingsForm user = new ApplicationSettingsForm(ApplicationSettingsSelectionType.UpdatesSettings, Settings, FactoriesManager, FoldersAccess, UpdateManager); user.ShowDialog(this); }; bbiSettingsExtensions.ItemClick += (s, e) => { - ApplicationSettingsForm user = new ApplicationSettingsForm(ApplicationSettingsSelectionType.ExtensionsSettings, Settings, FactoriesManager, UpdateManager); + ApplicationSettingsForm user = new ApplicationSettingsForm(ApplicationSettingsSelectionType.ExtensionsSettings, Settings, FactoriesManager, FoldersAccess, UpdateManager); user.ShowDialog(this); }; btnSettingsDebugging.ItemClick += (s, e) => { - ApplicationSettingsForm user = new ApplicationSettingsForm(ApplicationSettingsSelectionType.DebuggingSettings, Settings, FactoriesManager, UpdateManager); + ApplicationSettingsForm user = new ApplicationSettingsForm(ApplicationSettingsSelectionType.DebuggingSettings, Settings, FactoriesManager, FoldersAccess, UpdateManager); user.ShowDialog(this); }; btnShortcuts.ItemClick += (s, e) => { - ApplicationSettingsForm user = new ApplicationSettingsForm(ApplicationSettingsSelectionType.ShortcutsSettings, Settings, FactoriesManager, UpdateManager); + ApplicationSettingsForm user = new ApplicationSettingsForm(ApplicationSettingsSelectionType.ShortcutsSettings, Settings, FactoriesManager, FoldersAccess, UpdateManager); user.ShowDialog(this); }; bbiDonation.ItemClick += (s, e) => { - ApplicationSettingsForm user = new ApplicationSettingsForm(ApplicationSettingsSelectionType.DonationsSettings, Settings, FactoriesManager, UpdateManager); + ApplicationSettingsForm user = new ApplicationSettingsForm(ApplicationSettingsSelectionType.DonationsSettings, Settings, FactoriesManager, FoldersAccess, UpdateManager); user.ShowDialog(this); }; bbiAdvancedMode.ItemClick += (s, e) => { - ApplicationSettingsForm user = new ApplicationSettingsForm(ApplicationSettingsSelectionType.AdvancedModeSettings, Settings, FactoriesManager, UpdateManager); + ApplicationSettingsForm user = new ApplicationSettingsForm(ApplicationSettingsSelectionType.AdvancedModeSettings, Settings, FactoriesManager, FoldersAccess, UpdateManager); user.ShowDialog(this); }; btnApplicationSettings.ItemClick += (s, e) => { - ApplicationSettingsForm user = new ApplicationSettingsForm(ApplicationSettingsSelectionType.ApplicationGeneralSettings, Settings, FactoriesManager, UpdateManager); + ApplicationSettingsForm user = new ApplicationSettingsForm(ApplicationSettingsSelectionType.ApplicationGeneralSettings, Settings, FactoriesManager, FoldersAccess, UpdateManager); user.ShowDialog(this); }; btnApplicationUISettings.ItemClick += (s, e) => { - ApplicationSettingsForm user = new ApplicationSettingsForm(ApplicationSettingsSelectionType.ApplicationUISettings, Settings, FactoriesManager, UpdateManager); + ApplicationSettingsForm user = new ApplicationSettingsForm(ApplicationSettingsSelectionType.ApplicationUISettings, Settings, FactoriesManager, FoldersAccess, UpdateManager); user.ShowDialog(this); }; btnFiltering.ItemClick += (s, e) => { - ApplicationSettingsForm user = new ApplicationSettingsForm(ApplicationSettingsSelectionType.MessagesFilteringSettings, Settings, FactoriesManager, UpdateManager); + ApplicationSettingsForm user = new ApplicationSettingsForm(ApplicationSettingsSelectionType.MessagesFilteringSettings, Settings, FactoriesManager, FoldersAccess, UpdateManager); user.ShowDialog(this); }; btnMessageColumnsLayoutSettings.ItemClick += (s, e) => { - ApplicationSettingsForm user = new ApplicationSettingsForm(ApplicationSettingsSelectionType.MessagesLayoutSettings, Settings, FactoriesManager, UpdateManager); + ApplicationSettingsForm user = new ApplicationSettingsForm(ApplicationSettingsSelectionType.MessagesLayoutSettings, Settings, FactoriesManager, FoldersAccess, UpdateManager); user.ShowDialog(this); }; btnColorsSettings.ItemClick += (s, e) => { - ApplicationSettingsForm user = new ApplicationSettingsForm(ApplicationSettingsSelectionType.ColorSettings, Settings, FactoriesManager, UpdateManager); + ApplicationSettingsForm user = new ApplicationSettingsForm(ApplicationSettingsSelectionType.ColorSettings, Settings, FactoriesManager, FoldersAccess, UpdateManager); user.ShowDialog(this); }; btnColorHighlightSettings.ItemClick += (s, e) => { - ApplicationSettingsForm user = new ApplicationSettingsForm(ApplicationSettingsSelectionType.ColorHighlighting, Settings, FactoriesManager, UpdateManager); + ApplicationSettingsForm user = new ApplicationSettingsForm(ApplicationSettingsSelectionType.ColorHighlighting, Settings, FactoriesManager, FoldersAccess, UpdateManager); user.ShowDialog(this); }; btnPreDefinedQueries.ItemClick += (s, e) => { - ApplicationSettingsForm user = new ApplicationSettingsForm(ApplicationSettingsSelectionType.PredefinedQueriesSettings, Settings, FactoriesManager, UpdateManager); + ApplicationSettingsForm user = new ApplicationSettingsForm(ApplicationSettingsSelectionType.PredefinedQueriesSettings, Settings, FactoriesManager, FoldersAccess, UpdateManager); user.ShowDialog(this); }; btnDataProvidersSettings.ItemClick += (s, e) => { - ApplicationSettingsForm user = new ApplicationSettingsForm(ApplicationSettingsSelectionType.DataProvidersSettings, Settings, FactoriesManager, UpdateManager); + ApplicationSettingsForm user = new ApplicationSettingsForm(ApplicationSettingsSelectionType.DataProvidersSettings, Settings, FactoriesManager, FoldersAccess, UpdateManager); user.ShowDialog(this); }; bbiRealTimeProviders.ItemClick += (s, e) => { - ApplicationSettingsForm user = new ApplicationSettingsForm(ApplicationSettingsSelectionType.RealTimeDataProvidersSettings, Settings, FactoriesManager, UpdateManager); + ApplicationSettingsForm user = new ApplicationSettingsForm(ApplicationSettingsSelectionType.RealTimeDataProvidersSettings, Settings, FactoriesManager, FoldersAccess, UpdateManager); user.ShowDialog(this); }; bbiFileAssociations.ItemClick += (s, e) => { - ApplicationSettingsForm user = new ApplicationSettingsForm(ApplicationSettingsSelectionType.FilesAssociationSettings, Settings, FactoriesManager, UpdateManager); + ApplicationSettingsForm user = new ApplicationSettingsForm(ApplicationSettingsSelectionType.FilesAssociationSettings, Settings, FactoriesManager, FoldersAccess, UpdateManager); user.ShowDialog(this); }; bbiAdditionalLocations.ItemClick += (s, e) => { - ApplicationSettingsForm user = new ApplicationSettingsForm(ApplicationSettingsSelectionType.ExternalLocationsSettings, Settings, FactoriesManager, UpdateManager); + ApplicationSettingsForm user = new ApplicationSettingsForm(ApplicationSettingsSelectionType.ExternalLocationsSettings, Settings, FactoriesManager, FoldersAccess, UpdateManager); user.ShowDialog(this); }; #endregion diff --git a/Analogy/Forms/MainForm.cs b/Analogy/Forms/MainForm.cs index a2178f47..a7dc15dc 100644 --- a/Analogy/Forms/MainForm.cs +++ b/Analogy/Forms/MainForm.cs @@ -62,12 +62,13 @@ public partial class MainForm : RibbonForm private UpdateManager UpdateManager { get; } private FileProcessingManager FileProcessingManager { get; } private NotificationManager NotificationManager { get; } + private IAnalogyFoldersAccess FoldersAccess { get; } private AnalogyOnDemandPlottingManager PlottingManager { get; } public MainForm(IFactoriesManager factoriesManager, IExtensionsManager extensionsManager, BookmarkPersistManager bookmarkPersistManager, UpdateManager updateManager, FileProcessingManager fileProcessingManager, NotificationManager notificationManager, - AnalogyOnDemandPlottingManager plottingManager) + IAnalogyFoldersAccess foldersAccess, AnalogyOnDemandPlottingManager plottingManager) { FactoriesManager = factoriesManager; ExtensionsManager = extensionsManager; @@ -75,6 +76,7 @@ public MainForm(IFactoriesManager factoriesManager, IExtensionsManager extension UpdateManager = updateManager; FileProcessingManager = fileProcessingManager; NotificationManager = notificationManager; + FoldersAccess = foldersAccess; PlottingManager = plottingManager; InitializeComponent(); @@ -383,7 +385,7 @@ private void SetupEventHandlers() { bbiWelcomeForm.ItemClick += (s, e) => { - WelcomeForm wf = new WelcomeForm(Settings, FactoriesManager, UpdateManager); + WelcomeForm wf = new WelcomeForm(Settings, FactoriesManager, FoldersAccess, UpdateManager); wf.ShowDialog(this); }; @@ -458,92 +460,92 @@ private void SetupEventHandlers() btnSettingsUpdate.ItemClick += (s, e) => { - ApplicationSettingsForm user = new ApplicationSettingsForm(ApplicationSettingsSelectionType.UpdatesSettings, Settings, FactoriesManager, UpdateManager); + ApplicationSettingsForm user = new ApplicationSettingsForm(ApplicationSettingsSelectionType.UpdatesSettings, Settings, FactoriesManager, FoldersAccess, UpdateManager); user.ShowDialog(this); }; bbiSettingsExtensions.ItemClick += (s, e) => { - ApplicationSettingsForm user = new ApplicationSettingsForm(ApplicationSettingsSelectionType.ExtensionsSettings, Settings, FactoriesManager, UpdateManager); + ApplicationSettingsForm user = new ApplicationSettingsForm(ApplicationSettingsSelectionType.ExtensionsSettings, Settings, FactoriesManager, FoldersAccess, UpdateManager); user.ShowDialog(this); }; btnSettingsDebugging.ItemClick += (s, e) => { - ApplicationSettingsForm user = new ApplicationSettingsForm(ApplicationSettingsSelectionType.DebuggingSettings, Settings, FactoriesManager, UpdateManager); + ApplicationSettingsForm user = new ApplicationSettingsForm(ApplicationSettingsSelectionType.DebuggingSettings, Settings, FactoriesManager, FoldersAccess, UpdateManager); user.ShowDialog(this); }; btnShortcuts.ItemClick += (s, e) => { - ApplicationSettingsForm user = new ApplicationSettingsForm(ApplicationSettingsSelectionType.ShortcutsSettings, Settings, FactoriesManager, UpdateManager); + ApplicationSettingsForm user = new ApplicationSettingsForm(ApplicationSettingsSelectionType.ShortcutsSettings, Settings, FactoriesManager, FoldersAccess, UpdateManager); user.ShowDialog(this); }; bbiDonation.ItemClick += (s, e) => { - ApplicationSettingsForm user = new ApplicationSettingsForm(ApplicationSettingsSelectionType.DonationsSettings, Settings, FactoriesManager, UpdateManager); + ApplicationSettingsForm user = new ApplicationSettingsForm(ApplicationSettingsSelectionType.DonationsSettings, Settings, FactoriesManager, FoldersAccess, UpdateManager); user.ShowDialog(this); }; bbiAdvancedMode.ItemClick += (s, e) => { - ApplicationSettingsForm user = new ApplicationSettingsForm(ApplicationSettingsSelectionType.AdvancedModeSettings, Settings, FactoriesManager, UpdateManager); + ApplicationSettingsForm user = new ApplicationSettingsForm(ApplicationSettingsSelectionType.AdvancedModeSettings, Settings, FactoriesManager, FoldersAccess, UpdateManager); user.ShowDialog(this); }; btnApplicationSettings.ItemClick += (s, e) => { - ApplicationSettingsForm user = new ApplicationSettingsForm(ApplicationSettingsSelectionType.ApplicationGeneralSettings, Settings, FactoriesManager, UpdateManager); + ApplicationSettingsForm user = new ApplicationSettingsForm(ApplicationSettingsSelectionType.ApplicationGeneralSettings, Settings, FactoriesManager, FoldersAccess, UpdateManager); user.ShowDialog(this); }; btnApplicationUISettings.ItemClick += (s, e) => { - ApplicationSettingsForm user = new ApplicationSettingsForm(ApplicationSettingsSelectionType.ApplicationUISettings, Settings, FactoriesManager, UpdateManager); + ApplicationSettingsForm user = new ApplicationSettingsForm(ApplicationSettingsSelectionType.ApplicationUISettings, Settings, FactoriesManager, FoldersAccess, UpdateManager); user.ShowDialog(this); }; btnFiltering.ItemClick += (s, e) => { - ApplicationSettingsForm user = new ApplicationSettingsForm(ApplicationSettingsSelectionType.MessagesFilteringSettings, Settings, FactoriesManager, UpdateManager); + ApplicationSettingsForm user = new ApplicationSettingsForm(ApplicationSettingsSelectionType.MessagesFilteringSettings, Settings, FactoriesManager, FoldersAccess, UpdateManager); user.ShowDialog(this); }; btnMessageColumnsLayoutSettings.ItemClick += (s, e) => { - ApplicationSettingsForm user = new ApplicationSettingsForm(ApplicationSettingsSelectionType.MessagesLayoutSettings, Settings, FactoriesManager, UpdateManager); + ApplicationSettingsForm user = new ApplicationSettingsForm(ApplicationSettingsSelectionType.MessagesLayoutSettings, Settings, FactoriesManager, FoldersAccess, UpdateManager); user.ShowDialog(this); }; btnColorsSettings.ItemClick += (s, e) => { - ApplicationSettingsForm user = new ApplicationSettingsForm(ApplicationSettingsSelectionType.ColorSettings, Settings, FactoriesManager, UpdateManager); + ApplicationSettingsForm user = new ApplicationSettingsForm(ApplicationSettingsSelectionType.ColorSettings, Settings, FactoriesManager, FoldersAccess, UpdateManager); user.ShowDialog(this); }; btnColorHighlightSettings.ItemClick += (s, e) => { - ApplicationSettingsForm user = new ApplicationSettingsForm(ApplicationSettingsSelectionType.ColorHighlighting, Settings, FactoriesManager, UpdateManager); + ApplicationSettingsForm user = new ApplicationSettingsForm(ApplicationSettingsSelectionType.ColorHighlighting, Settings, FactoriesManager, FoldersAccess, UpdateManager); user.ShowDialog(this); }; btnPreDefinedQueries.ItemClick += (s, e) => { - ApplicationSettingsForm user = new ApplicationSettingsForm(ApplicationSettingsSelectionType.PredefinedQueriesSettings, Settings, FactoriesManager, UpdateManager); + ApplicationSettingsForm user = new ApplicationSettingsForm(ApplicationSettingsSelectionType.PredefinedQueriesSettings, Settings, FactoriesManager, FoldersAccess, UpdateManager); user.ShowDialog(this); }; btnDataProvidersSettings.ItemClick += (s, e) => { - ApplicationSettingsForm user = new ApplicationSettingsForm(ApplicationSettingsSelectionType.DataProvidersSettings, Settings, FactoriesManager, UpdateManager); + ApplicationSettingsForm user = new ApplicationSettingsForm(ApplicationSettingsSelectionType.DataProvidersSettings, Settings, FactoriesManager, FoldersAccess, UpdateManager); user.ShowDialog(this); }; bbiRealTimeProviders.ItemClick += (s, e) => { - ApplicationSettingsForm user = new ApplicationSettingsForm(ApplicationSettingsSelectionType.RealTimeDataProvidersSettings, Settings, FactoriesManager, UpdateManager); + ApplicationSettingsForm user = new ApplicationSettingsForm(ApplicationSettingsSelectionType.RealTimeDataProvidersSettings, Settings, FactoriesManager, FoldersAccess, UpdateManager); user.ShowDialog(this); }; bbiFileAssociations.ItemClick += (s, e) => { - ApplicationSettingsForm user = new ApplicationSettingsForm(ApplicationSettingsSelectionType.FilesAssociationSettings, Settings, FactoriesManager, UpdateManager); + ApplicationSettingsForm user = new ApplicationSettingsForm(ApplicationSettingsSelectionType.FilesAssociationSettings, Settings, FactoriesManager, FoldersAccess, UpdateManager); user.ShowDialog(this); }; bbiAdditionalLocations.ItemClick += (s, e) => { - ApplicationSettingsForm user = new ApplicationSettingsForm(ApplicationSettingsSelectionType.ExternalLocationsSettings, Settings, FactoriesManager, UpdateManager); + ApplicationSettingsForm user = new ApplicationSettingsForm(ApplicationSettingsSelectionType.ExternalLocationsSettings, Settings, FactoriesManager, FoldersAccess, UpdateManager); user.ShowDialog(this); }; #endregion @@ -768,7 +770,7 @@ private void bbtnItemHelp_ItemClick(object sender, ItemClickEventArgs e) private void bbtnItemSettings_ItemClick(object sender, ItemClickEventArgs e) { - ApplicationSettingsForm user = new ApplicationSettingsForm(Settings, FactoriesManager, UpdateManager); + ApplicationSettingsForm user = new ApplicationSettingsForm(Settings, FactoriesManager, FoldersAccess, UpdateManager); user.ShowDialog(this); } diff --git a/Analogy/Forms/Welcome/WelcomeDataProvidersUC.cs b/Analogy/Forms/Welcome/WelcomeDataProvidersUC.cs index cc5fb8ce..ca43083c 100644 --- a/Analogy/Forms/Welcome/WelcomeDataProvidersUC.cs +++ b/Analogy/Forms/Welcome/WelcomeDataProvidersUC.cs @@ -11,19 +11,21 @@ public partial class WelcomeDataProvidersUC : XtraUserControl { private IAnalogyUserSettings Settings { get; } private IFactoriesManager FactoriesManager { get; } + private IAnalogyFoldersAccess FoldersAccess { get; } private UpdateManager UpdateManager { get; } - public WelcomeDataProvidersUC(IAnalogyUserSettings settings, IFactoriesManager factoriesManager, UpdateManager updateManager) + public WelcomeDataProvidersUC(IAnalogyUserSettings settings, IFactoriesManager factoriesManager,IAnalogyFoldersAccess foldersAccess, UpdateManager updateManager) { Settings = settings; FactoriesManager = factoriesManager; + FoldersAccess = foldersAccess; UpdateManager = updateManager; InitializeComponent(); } private void sbtnDataProvidersSettings_Click(object sender, EventArgs e) { - ApplicationSettingsForm user = new ApplicationSettingsForm(ApplicationSettingsSelectionType.DataProvidersSettings, Settings, FactoriesManager, UpdateManager); + ApplicationSettingsForm user = new ApplicationSettingsForm(ApplicationSettingsSelectionType.DataProvidersSettings, Settings, FactoriesManager, FoldersAccess, UpdateManager); user.ShowDialog(this); } diff --git a/Analogy/Forms/Welcome/WelcomeExtensionsUC.cs b/Analogy/Forms/Welcome/WelcomeExtensionsUC.cs index 8c50611f..2058b5e2 100644 --- a/Analogy/Forms/Welcome/WelcomeExtensionsUC.cs +++ b/Analogy/Forms/Welcome/WelcomeExtensionsUC.cs @@ -10,19 +10,21 @@ public partial class WelcomeExtensionsUC : XtraUserControl { private IAnalogyUserSettings Settings { get; } private IFactoriesManager FactoriesManager { get; } + private IAnalogyFoldersAccess FoldersAccess { get; } private UpdateManager UpdateManager { get; } - public WelcomeExtensionsUC(IAnalogyUserSettings settings, IFactoriesManager factoriesManager, UpdateManager updateManager) + public WelcomeExtensionsUC(IAnalogyUserSettings settings, IFactoriesManager factoriesManager, IAnalogyFoldersAccess foldersAccess, UpdateManager updateManager) { Settings = settings; FactoriesManager = factoriesManager; + FoldersAccess = foldersAccess; UpdateManager = updateManager; InitializeComponent(); } private void sbtnExtensionsSettings_Click(object sender, EventArgs e) { - ApplicationSettingsForm user = new ApplicationSettingsForm(ApplicationSettingsSelectionType.ExtensionsSettings, Settings, FactoriesManager, UpdateManager); + ApplicationSettingsForm user = new ApplicationSettingsForm(ApplicationSettingsSelectionType.ExtensionsSettings, Settings, FactoriesManager, FoldersAccess, UpdateManager); user.ShowDialog(this); } } diff --git a/Analogy/Forms/Welcome/WelcomeForm.cs b/Analogy/Forms/Welcome/WelcomeForm.cs index 0a705258..d6d19c92 100644 --- a/Analogy/Forms/Welcome/WelcomeForm.cs +++ b/Analogy/Forms/Welcome/WelcomeForm.cs @@ -12,18 +12,20 @@ public partial class WelcomeForm : DevExpress.XtraBars.FluentDesignSystem.Fluent { private IAnalogyUserSettings Settings { get; } private IFactoriesManager FactoriesManager { get; } + private IAnalogyFoldersAccess FoldersAccess { get; } private UpdateManager UpdateManager { get; } - public WelcomeForm(IAnalogyUserSettings settings,IFactoriesManager factoriesManager, UpdateManager updateManager) + public WelcomeForm(IAnalogyUserSettings settings, IFactoriesManager factoriesManager, IAnalogyFoldersAccess foldersAccess, UpdateManager updateManager) { Settings = settings; FactoriesManager = factoriesManager; + FoldersAccess = foldersAccess; UpdateManager = updateManager; InitializeComponent(); EnableAcrylicAccent = false; } - + private void AddOrBringToFrontUserControl(ApplicationWelcomeSelectionType type) { string name = type.ToString(); @@ -54,13 +56,13 @@ private UserControl GetUserControlByType(ApplicationWelcomeSelectionType selecti switch (selectionType) { case ApplicationWelcomeSelectionType.General: - return new WelcomeGeneralUC(Settings, FactoriesManager, UpdateManager); + return new WelcomeGeneralUC(Settings, FactoriesManager, FoldersAccess, UpdateManager); case ApplicationWelcomeSelectionType.Theme: - return new WelcomeThemeSelectionUC(Settings, FactoriesManager, UpdateManager); + return new WelcomeThemeSelectionUC(Settings, FactoriesManager, FoldersAccess, UpdateManager); case ApplicationWelcomeSelectionType.DataProvides: - return new WelcomeDataProvidersUC(Settings, FactoriesManager, UpdateManager); + return new WelcomeDataProvidersUC(Settings, FactoriesManager, FoldersAccess, UpdateManager); case ApplicationWelcomeSelectionType.Extensions: - return new WelcomeExtensionsUC(Settings, FactoriesManager, UpdateManager); + return new WelcomeExtensionsUC(Settings, FactoriesManager, FoldersAccess, UpdateManager); case ApplicationWelcomeSelectionType.GlobalTools: return new WelcomeGlobalToolsUC(); case ApplicationWelcomeSelectionType.WhatIsNew: @@ -70,10 +72,10 @@ private UserControl GetUserControlByType(ApplicationWelcomeSelectionType selecti case ApplicationWelcomeSelectionType.Feedback: return new WelcomeFeedbackUC(); default: - { - ServicesProvider.Instance.GetService().LogError($"Selection with {selectionType} was not found"); - throw new Exception($"Selection with {selectionType} was not found"); - } + { + ServicesProvider.Instance.GetService().LogError($"Selection with {selectionType} was not found"); + throw new Exception($"Selection with {selectionType} was not found"); + } } } @@ -90,7 +92,7 @@ private async void WelcomeForm_Load(object sender, EventArgs e) await FactoriesManager.AddExternalDataSources(); AddOrBringToFrontUserControl(ApplicationWelcomeSelectionType.General); } - private void aceGeneral_Click(object sender, EventArgs e) + private void aceGeneral_Click(object sender, EventArgs e) { AddOrBringToFrontUserControl(ApplicationWelcomeSelectionType.General); } diff --git a/Analogy/Forms/Welcome/WelcomeGeneralUC.cs b/Analogy/Forms/Welcome/WelcomeGeneralUC.cs index 30a4751f..b61c203d 100644 --- a/Analogy/Forms/Welcome/WelcomeGeneralUC.cs +++ b/Analogy/Forms/Welcome/WelcomeGeneralUC.cs @@ -10,19 +10,21 @@ public partial class WelcomeGeneralUC : XtraUserControl { private IAnalogyUserSettings Settings { get; } private IFactoriesManager FactoriesManager { get; } + private IAnalogyFoldersAccess FoldersAccess { get; } private UpdateManager UpdateManager { get; } - public WelcomeGeneralUC(IAnalogyUserSettings settings, IFactoriesManager factoriesManager, UpdateManager updateManager) + public WelcomeGeneralUC(IAnalogyUserSettings settings, IFactoriesManager factoriesManager, IAnalogyFoldersAccess foldersAccess, UpdateManager updateManager) { Settings = settings; FactoriesManager = factoriesManager; + FoldersAccess = foldersAccess; UpdateManager = updateManager; InitializeComponent(); } private void sbtnOpenSettings_Click(object sender, EventArgs e) { - ApplicationSettingsForm user = new ApplicationSettingsForm(ApplicationSettingsSelectionType.ApplicationGeneralSettings, Settings, FactoriesManager, UpdateManager); + ApplicationSettingsForm user = new ApplicationSettingsForm(ApplicationSettingsSelectionType.ApplicationGeneralSettings, Settings, FactoriesManager, FoldersAccess, UpdateManager); user.ShowDialog(this); } } diff --git a/Analogy/Forms/Welcome/WelcomeThemeSelectionUC.cs b/Analogy/Forms/Welcome/WelcomeThemeSelectionUC.cs index 99b0b710..e5c6ae6c 100644 --- a/Analogy/Forms/Welcome/WelcomeThemeSelectionUC.cs +++ b/Analogy/Forms/Welcome/WelcomeThemeSelectionUC.cs @@ -10,25 +10,27 @@ public partial class WelcomeThemeSelectionUC : XtraUserControl { private IAnalogyUserSettings Settings { get; } private IFactoriesManager FactoriesManager { get; } + private IAnalogyFoldersAccess FoldersAccess { get; } private UpdateManager UpdateManager { get; } - public WelcomeThemeSelectionUC(IAnalogyUserSettings settings, IFactoriesManager factoriesManager, UpdateManager updateManager) + public WelcomeThemeSelectionUC(IAnalogyUserSettings settings, IFactoriesManager factoriesManager, IAnalogyFoldersAccess foldersAccess, UpdateManager updateManager) { Settings = settings; FactoriesManager = factoriesManager; + FoldersAccess = foldersAccess; UpdateManager = updateManager; InitializeComponent(); } private void WelcomeThemeSelectionUC_Load(object sender, EventArgs e) { - + } private void sbtnSettingsTheme_Click(object sender, EventArgs e) { - ApplicationSettingsForm user = new ApplicationSettingsForm(ApplicationSettingsSelectionType.ApplicationUISettings, Settings, FactoriesManager, UpdateManager); + ApplicationSettingsForm user = new ApplicationSettingsForm(ApplicationSettingsSelectionType.ApplicationUISettings, Settings, FactoriesManager, FoldersAccess, UpdateManager); user.ShowDialog(this); } } diff --git a/Analogy/Interfaces/IAnalogyUserSettings.cs b/Analogy/Interfaces/IAnalogyUserSettings.cs index 97ed86bb..4aef2f6e 100644 --- a/Analogy/Interfaces/IAnalogyUserSettings.cs +++ b/Analogy/Interfaces/IAnalogyUserSettings.cs @@ -2,7 +2,6 @@ using System.Drawing; using Analogy.Common.DataTypes; using Analogy.Common.Interfaces; -using Analogy.CommonUtilities.Github; using Analogy.DataTypes; using Analogy.Interfaces.Factories; using Octokit; diff --git a/Analogy/Managers/FolderAccessManager.cs b/Analogy/Managers/FolderAccessManager.cs index c0d144ca..9dd73cf5 100644 --- a/Analogy/Managers/FolderAccessManager.cs +++ b/Analogy/Managers/FolderAccessManager.cs @@ -10,26 +10,27 @@ namespace Analogy.Managers { - internal class FolderAccessManager : IAnalogyFoldersAccess + public class FolderAccessManager : IAnalogyFoldersAccess { public event EventHandler? RootFolderChanged; - public string WriteableRootFolder { get; } - public string ConfigurationsFolder { get; } - private bool IsRunningFromProgramFileFolder { get; } - public FolderAccessManager(IAnalogyUserSettings settings) + public string WriteableRootFolder { get; private set; } + public string ConfigurationsFolder { get; private set; } + private bool IsRunningFromProgramFileFolder { get; } = Utils.IsRunningFromProgramFileFolder(); + private string ApplicationDataFolder => Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Analogy Log Viewer"); + private string CommonApplicationData => Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), "Analogy Log Viewer"); + public void SetWorkingMode(SettingsMode settingsMode) { - IsRunningFromProgramFileFolder = Utils.IsRunningFromProgramFileFolder(); - switch (settings.SettingsMode) + switch (settingsMode) { case SettingsMode.PerUser: - WriteableRootFolder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Analogy Log Viewer"); + WriteableRootFolder = ApplicationDataFolder; ConfigurationsFolder = Path.Combine(WriteableRootFolder, "Configuration Files"); Directory.CreateDirectory(ConfigurationsFolder); break; case SettingsMode.ApplicationFolder: if (IsRunningFromProgramFileFolder) { - WriteableRootFolder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), "Analogy Log Viewer"); + WriteableRootFolder = CommonApplicationData; ConfigurationsFolder = Path.Combine(WriteableRootFolder, "Configuration Files"); Directory.CreateDirectory(ConfigurationsFolder); } @@ -40,15 +41,15 @@ public FolderAccessManager(IAnalogyUserSettings settings) } break; case SettingsMode.ProgramData: - WriteableRootFolder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), "Analogy Log Viewer"); + WriteableRootFolder = CommonApplicationData; ConfigurationsFolder = Path.Combine(WriteableRootFolder, "Configuration Files"); Directory.CreateDirectory(ConfigurationsFolder); break; default: throw new ArgumentOutOfRangeException(); } + RootFolderChanged?.Invoke(this, EventArgs.Empty); } - private string GetConfigurationFilePath(string folder, string configFile) { if (Path.IsPathRooted(configFile) && !Path.GetPathRoot(configFile) @@ -68,21 +69,23 @@ public string GetConfigurationFilePath(string configFile) => public bool TryGetConfigurationFilePathFromAnyValidLocation(string configFile, out string finalLocation) { - var file = GetConfigurationFilePath(ConfigurationsFolder, configFile); + var file = GetConfigurationFilePath(Utils.ApplicationBaseDirectory, configFile); if (File.Exists(file)) { finalLocation = file; return true; } - - if (IsRunningFromProgramFileFolder) //check also app root folder + file = GetConfigurationFilePath(CommonApplicationData, configFile); + if (File.Exists(file)) + { + finalLocation = file; + return true; + } + file = GetConfigurationFilePath(ApplicationDataFolder, configFile); + if (File.Exists(file)) { - file = GetConfigurationFilePath(Utils.ApplicationBaseDirectory, configFile); - if (File.Exists(file)) - { - finalLocation = file; - return true; - } + finalLocation = file; + return true; } finalLocation = ""; diff --git a/Analogy/Managers/UserSettingsManager.cs b/Analogy/Managers/UserSettingsManager.cs index 9cb70dcd..267e00d4 100644 --- a/Analogy/Managers/UserSettingsManager.cs +++ b/Analogy/Managers/UserSettingsManager.cs @@ -20,6 +20,7 @@ namespace Analogy public class UserSettingsManager : IAnalogyUserSettings { + private FolderAccessManager FolderAccessManager { get; } public event EventHandler OnFactoryOrderChanged; public event EventHandler OnApplicationSkinNameChanged; public event EventHandler? SettingsModeChanged; @@ -91,7 +92,7 @@ public string ApplicationSkinName public List AdditionalProbingLocations { get; set; } public bool SingleInstance { get; set; } public string AnalogyIcon { get; set; } - public string LogGridFileName => Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) ?? string.Empty, "AnalogyGridlayout.xml"); + public string LogGridFileName => FolderAccessManager.GetConfigurationFilePath("AnalogyGridlayout.xml"); public string DateTimePattern { get; set; } public UpdateMode UpdateMode { get; set; } public DateTime LastUpdate { get; set; } @@ -143,7 +144,7 @@ public AnalogyCommandLayout RibbonStyle public bool TrackActiveMessage { get; set; } public float RealTimeRefreshInterval { get; set; } public FilteringExclusion FilteringExclusion { get; set; } - public string LogsLayoutFileName { get; set; } + public string LogsLayoutFileName { get; private set; } public bool UseCustomLogsLayout { get; set; } public bool ViewDetailedMessageWithHTML { get; set; } @@ -158,6 +159,7 @@ public SettingsMode SettingsMode { settingsMode = value; SettingsModeChanged?.Invoke(this, value); + FolderAccessManager.SetWorkingMode(value); } } } @@ -185,26 +187,28 @@ public bool InlineJsonViewer public bool CombineOnlineProviders { get; set; } public bool SupportLinuxFormatting { get; set; } - private Dictionary WindowPositions { get; set; } - public UserSettingsManager() + private Dictionary WindowPositions { get; set; } + public UserSettingsManager(FolderAccessManager folderAccessManager) { - if (File.Exists(LocalSettingFileName)) + FolderAccessManager = folderAccessManager; + folderAccessManager.SetWorkingMode(SettingsMode.PerUser); + if (FolderAccessManager.TryGetConfigurationFilePathFromAnyValidLocation(LocalSettingFileName, out var configFile)) { try { - string data = File.ReadAllText(LocalSettingFileName); + string data = File.ReadAllText(configFile); var settings = JsonConvert.DeserializeObject(data); ApplyLocalSettings(settings); } catch (Exception e) { - AnalogyLogManager.Instance.LogInformation($"Unable to read settings from {LocalSettingFileName}. Error: {e.Message}. Loading per user settings", nameof(UserSettingsManager)); + AnalogyLogManager.Instance.LogInformation($"Unable to read settings from {configFile}. Error: {e.Message}. Loading per user settings", nameof(UserSettingsManager)); LoadPerUserSettings(); } } else { - AnalogyLogManager.Instance.LogInformation($"File {LocalSettingFileName} does not exist. Loading per user settings", nameof(UserSettingsManager)); + AnalogyLogManager.Instance.LogInformation($"File {configFile} does not exist. Loading per user settings", nameof(UserSettingsManager)); LoadPerUserSettings(); } } @@ -213,7 +217,6 @@ public UserSettingsManager() private void LoadPerUserSettings() { SettingsMode = SettingsMode.PerUser; - FilteringExclusion = ParseSettings(Settings.Default.FilteringExclusion); EnableCompressedArchives = true; AnalogyInternalLogPeriod = 5; bool upgradeRequired = false; @@ -224,7 +227,7 @@ private void LoadPerUserSettings() Settings.Default.UpgradeRequired = false; Settings.Default.Save(); } - + FilteringExclusion = ParseSettings(Settings.Default.FilteringExclusion); DateTimePattern = !string.IsNullOrEmpty(Settings.Default.DateTimePattern) ? Settings.Default.DateTimePattern : "yyyy.MM.dd HH:mm:ss.ff"; @@ -317,7 +320,7 @@ private void LoadPerUserSettings() TrackActiveMessage = Settings.Default.TrackActiveMessage; RealTimeRefreshInterval = Settings.Default.RealTimeRefreshInterval; UseCustomLogsLayout = Settings.Default.UseCustomLogsLayout; - LogsLayoutFileName = Settings.Default.LogsLayoutFileName; + SetLogsLayoutFileName(Settings.Default.LogsLayoutFileName); ViewDetailedMessageWithHTML = Settings.Default.ViewDetailedMessageWithHTML; if (Enum.TryParse(Settings.Default.MainFormType, out var layoutVersion)) { @@ -413,7 +416,7 @@ private void ApplyLocalSettings(UserSettings settings) TrackActiveMessage = settings.TrackActiveMessage; RealTimeRefreshInterval = settings.RealTimeRefreshInterval; FilteringExclusion = settings.FilteringExclusion; - LogsLayoutFileName = settings.LogsLayoutFileName; + SetLogsLayoutFileName(settings.LogsLayoutFileName); UseCustomLogsLayout = settings.UseCustomLogsLayout; ViewDetailedMessageWithHTML = settings.ViewDetailedMessageWithHTML; ShowWhatIsNewAtStartup = settings.ShowWhatIsNewAtStartup; @@ -558,11 +561,13 @@ public void Save(string version) private void DeletePortableSettings() { - if (File.Exists(LocalSettingFileName)) + var configFile = FolderAccessManager.GetConfigurationFilePath(LocalSettingFileName); + + if (File.Exists(configFile)) { try { - File.Delete(LocalSettingFileName); + File.Delete(configFile); } catch (Exception e) { @@ -586,16 +591,17 @@ private void DeletePortableSettings() private void SavePortableSettings(string version) { + var configFile = FolderAccessManager.GetConfigurationFilePath(LocalSettingFileName); try { UserSettings settings = CreateUserSettings(); settings.Version = version; string data = JsonConvert.SerializeObject(settings); - File.WriteAllText(LocalSettingFileName, data); + File.WriteAllText(configFile, data); } catch (Exception e) { - AnalogyLogManager.Instance.LogError($"Unable to save setting to {LocalSettingFileName}. Error: {e.Message}. Saving Per user", nameof(UserSettingsManager)); + AnalogyLogManager.Instance.LogError($"Unable to save setting to {configFile}. Error: {e.Message}. Saving Per user", nameof(UserSettingsManager)); SettingsMode = SettingsMode.PerUser; SavePerUserSettings(); } @@ -808,6 +814,12 @@ public Image GetImage() public IEnumerable<(Guid ID, string Path)> GetRecentFolders(Guid offlineAnalogyId) => RecentFolders.Where(itm => itm.ID == offlineAnalogyId); + public void SetLogsLayoutFileName(string filename) + { + LogsLayoutFileName = Path.IsPathRooted(filename) + ? filename + : FolderAccessManager.GetConfigurationFilePath(filename); + } public void ResetSettings() { Settings.Default.Reset(); @@ -831,7 +843,7 @@ public void ResetSettings() } } - public bool TryGetWindowPosition(Guid id,out AnalogyPositionState? position) + public bool TryGetWindowPosition(Guid id, out AnalogyPositionState? position) { return WindowPositions.TryGetValue(id, out position); } diff --git a/Analogy/Program.cs b/Analogy/Program.cs index 48537407..d9e28903 100644 --- a/Analogy/Program.cs +++ b/Analogy/Program.cs @@ -157,11 +157,11 @@ static void Main() return; } - + IAnalogyFoldersAccess fa = ServicesProvider.Instance.GetService(); UpdateManager up = ServicesProvider.Instance.GetService(); if (Settings.IsFirstRun) { - WelcomeForm f = new WelcomeForm(Settings, FactoriesManager, up); + WelcomeForm f = new WelcomeForm(Settings, FactoriesManager, fa, up); f.ShowDialog(); } @@ -171,11 +171,11 @@ static void Main() AnalogyOnDemandPlottingManager pm = ServicesProvider.Instance.GetService(); if (Settings.MainFormType == MainFormType.RibbonForm) { - Application.Run(new MainForm(FactoriesManager, ExtensionsManager, bm, up, fpm, nm, pm)); + Application.Run(new MainForm(FactoriesManager, ExtensionsManager, bm, up, fpm, nm, fa, pm)); } else { - Application.Run(new FluentDesignMainForm(FactoriesManager, ExtensionsManager, bm, up, fpm, nm, pm)); + Application.Run(new FluentDesignMainForm(FactoriesManager, ExtensionsManager, bm, up, fpm, nm, fa, pm)); } } @@ -184,10 +184,11 @@ private static void ConfigureServices() { var services = ServicesProvider.Instance.GetServiceCollection(); var loggerProvider = new AnalogyLoggerProvider(); - UserSettingsManager settings = new UserSettingsManager(); + var folderAccessManager = new FolderAccessManager(); + UserSettingsManager settings = new UserSettingsManager(folderAccessManager); services.AddSingleton(settings); services.AddSingleton(settings); - services.AddSingleton(); + services.AddSingleton(folderAccessManager); services.AddSingleton(loggerProvider.CreateLogger("Analogy")); services.AddSingleton(); services.AddSingleton(); diff --git a/Analogy/Properties/licenses.licx b/Analogy/Properties/licenses.licx index f75b1eef..95fd765c 100644 --- a/Analogy/Properties/licenses.licx +++ b/Analogy/Properties/licenses.licx @@ -1,9 +1,10 @@ DevExpress.XtraTreeList.TreeList, DevExpress.XtraTreeList.v21.2, Version=21.2.12.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a -DevExpress.XtraEditors.TextEdit, DevExpress.XtraEditors.v21.2, Version=21.2.12.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a -DevExpress.XtraBars.BarManager, DevExpress.XtraBars.v21.2, Version=21.2.12.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a -DevExpress.XtraEditors.CheckEdit, DevExpress.XtraEditors.v21.2, Version=21.2.12.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a -DevExpress.XtraBars.Ribbon.RibbonControl, DevExpress.XtraBars.v21.2, Version=21.2.12.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a DevExpress.XtraBars.Docking2010.DocumentManager, DevExpress.XtraBars.v21.2, Version=21.2.12.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a -DevExpress.XtraRichEdit.RichEditControl, DevExpress.XtraRichEdit.v21.2, Version=21.2.12.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a DevExpress.XtraEditors.PictureEdit, DevExpress.XtraEditors.v21.2, Version=21.2.12.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a +DevExpress.XtraEditors.CheckEdit, DevExpress.XtraEditors.v21.2, Version=21.2.12.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a +DevExpress.XtraRichEdit.RichEditControl, DevExpress.XtraRichEdit.v21.2, Version=21.2.12.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a +DevExpress.XtraBars.Ribbon.RibbonControl, DevExpress.XtraBars.v21.2, Version=21.2.12.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a DevExpress.XtraBars.Docking.DockManager, DevExpress.XtraBars.v21.2, Version=21.2.12.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a +DevExpress.XtraEditors.TextEdit, DevExpress.XtraEditors.v21.2, Version=21.2.12.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a +DevExpress.XtraBars.BarManager, DevExpress.XtraBars.v21.2, Version=21.2.12.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a +DevExpress.XtraEditors.CheckEdit, DevExpress.XtraEditors.v23.1, Version=23.1.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a diff --git a/Analogy/UserControls/UCLogs.cs b/Analogy/UserControls/UCLogs.cs index d9bfeadf..a9d9ab24 100644 --- a/Analogy/UserControls/UCLogs.cs +++ b/Analogy/UserControls/UCLogs.cs @@ -16,7 +16,8 @@ public UCLogs() var user = new ApplicationSettingsForm(ApplicationSettingsSelectionType.ColorHighlighting, ServicesProvider.Instance.GetService(), ServicesProvider.Instance.GetService(), - ServicesProvider.Instance.GetService()); + ServicesProvider.Instance.GetService(), + ServicesProvider.Instance.GetService()); user.ShowDialog(this); }); }