From b9ff3e2b899b22090b5d206c1f95189aa7fd7ecb Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Wed, 16 May 2018 18:22:47 +0300 Subject: New Settings Library. --- Software/DB/Tango.mdf | Bin 75497472 -> 75497472 bytes Software/DB/Tango_log.ldf | Bin 1572864 -> 1572864 bytes .../ViewModels/MainViewVM.cs | 2 +- .../DeveloperModuleSettings.cs | 16 ++ .../Tango.MachineStudio.Developer.csproj | 1 + .../ViewModels/MainViewVM.cs | 15 +- .../Parsing/EmbeddedLogFileParser.cs | 2 +- .../StubsModuleSettings.cs | 30 ++++ .../Tango.MachineStudio.Stubs.csproj | 1 + .../ViewModels/MainViewVM.cs | 13 +- .../SynchronizationModuleSettings.cs | 27 +++ .../Tango.MachineStudio.Synchronization.csproj | 1 + .../ViewModels/LocalSynchronizationViewVM.cs | 17 +- .../ViewModels/RemoteSynchronizationViewVM.cs | 11 +- .../Helpers/GraphsHelper.cs | 6 +- .../Navigation/TechNavigationManager.cs | 24 --- .../Navigation/TechNavigationView.cs | 18 -- .../Tango.MachineStudio.Technician.csproj | 33 +--- .../TechItems/MultiGraphItem.cs | 3 +- .../TechItems/SingleGraphItem.cs | 3 +- .../TechnicianModuleSettings.cs | 36 ++++ .../ViewModelLocator.cs | 23 --- .../ViewModels/MachineTechViewVM.cs | 17 +- .../ViewModels/MainViewVM.cs | 56 ------ .../ViewModels/SensorsViewVM.cs | 193 --------------------- .../Views/MainView.xaml | 102 ----------- .../Views/MainView.xaml.cs | 31 ---- .../Views/MotorsView.xaml | 12 -- .../Views/MotorsView.xaml.cs | 28 --- .../Views/OverviewView.xaml | 12 -- .../Views/OverviewView.xaml.cs | 28 --- .../Views/SensorsView.xaml | 173 ------------------ .../Views/SensorsView.xaml.cs | 53 ------ .../Controls/RealTimeGraphControl.xaml | 56 +++--- .../Controls/RealTimeGraphMultiControl.xaml | 56 +++--- .../Helpers/GraphsHelper.cs | 6 +- .../Helpers/OutlookHelper.cs | 13 -- .../MachineStudioSettings.cs | 52 ++++++ .../Tango.MachineStudio.Common.csproj | 6 +- .../Update/UpdateServiceHelper.cs | 2 +- .../Tango.MachineStudio.Publisher/MainWindowVM.cs | 7 +- .../Tango.MachineStudio.UI/App.config | 8 + .../Tango.MachineStudio.UI/App.xaml.cs | 15 +- .../DefaultStudioApplicationManager.cs | 2 +- .../ViewModels/LoadingViewVM.cs | 2 +- .../ViewModels/LoginViewVM.cs | 18 +- .../ViewModels/MachineSerialViewVM.cs | 6 +- .../ViewModels/MainViewVM.cs | 7 +- .../PanelPC/Tango.PanelPC.UI/App.config | 10 +- .../Tango.BL/ObservablesContextExtension.cs | 3 +- Software/Visual_Studio/Tango.Core/CoreSettings.cs | 25 +++ .../Visual_Studio/Tango.Core/Tango.Core.csproj | 5 + .../Tango.DAL.Remote/Partials/RemoteDB.cs | 3 +- .../Tango.Integration/IntegrationSettings.cs | 43 +++++ .../Tango.Integration/Operation/MachineOperator.cs | 2 +- .../Services/ExternalBridgeScanner.cs | 6 +- .../Services/ExternalBridgeTcpClient.cs | 2 +- .../Tango.Integration/Tango.Integration.csproj | 1 + Software/Visual_Studio/Tango.Settings/DataBase.cs | 28 --- .../Visual_Studio/Tango.Settings/Integration.cs | 45 ----- .../MachineStudioSettings/DeveloperModule.cs | 15 -- .../MachineStudioSettings/MachineStudio.cs | 85 --------- .../MachineStudioSettings/StubsModule.cs | 32 ---- .../MachineStudioSettings/SynchronizationModule.cs | 29 ---- .../MachineStudioSettings/TechnicianModule.cs | 23 --- .../Visual_Studio/Tango.Settings/OLD/DataBase.cs | 28 +++ .../Tango.Settings/OLD/Integration.cs | 45 +++++ .../OLD/MachineStudioSettings/DeveloperModule.cs | 15 ++ .../OLD/MachineStudioSettings/MachineStudio.cs | 85 +++++++++ .../OLD/MachineStudioSettings/StubsModule.cs | 32 ++++ .../MachineStudioSettings/SynchronizationModule.cs | 29 ++++ .../OLD/MachineStudioSettings/TechnicianModule.cs | 23 +++ .../Tango.Settings/OLD/SettingsCollection.cs | 46 +++++ .../Tango.Settings/OLD/SettingsManager.cs | 162 +++++++++++++++++ .../Visual_Studio/Tango.Settings/OLD/StubsUI.cs | 43 +++++ .../Visual_Studio/Tango.Settings/SettingsBase.cs | 28 +++ .../Tango.Settings/SettingsCollection.cs | 46 ----- .../Tango.Settings/SettingsManager.cs | 190 +++++++++----------- Software/Visual_Studio/Tango.Settings/StubsUI.cs | 43 ----- .../Tango.Settings/Tango.Settings.csproj | 24 +-- .../Visual_Studio/Tango.Settings/packages.config | 4 + .../Remote/RemoteDBSynchronizer.cs | 3 +- .../Visual_Studio/Tango.UnitTesting/DAL_TST.cs | 5 +- .../Tango.UnitTesting/Synchronization_TST.cs | 5 +- .../ObservablesGenerator.cs | 5 +- .../Utilities/Tango.SQLiteGenerator.CLI/Program.cs | 3 +- .../Tango.SQLiteGenerator.CLI.csproj | 4 + .../Utilities/Tango.Stubs.UI/StubsUISettings.cs | 42 +++++ .../Utilities/Tango.Stubs.UI/Tango.Stubs.UI.csproj | 1 + .../Tango.Stubs.UI/ViewModels/MainViewVM.cs | 23 +-- 90 files changed, 1116 insertions(+), 1418 deletions(-) create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/DeveloperModuleSettings.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Stubs/StubsModuleSettings.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/SynchronizationModuleSettings.cs delete mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Navigation/TechNavigationManager.cs delete mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Navigation/TechNavigationView.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechnicianModuleSettings.cs delete mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/ViewModels/MainViewVM.cs delete mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/ViewModels/SensorsViewVM.cs delete mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Views/MainView.xaml delete mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Views/MainView.xaml.cs delete mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Views/MotorsView.xaml delete mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Views/MotorsView.xaml.cs delete mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Views/OverviewView.xaml delete mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Views/OverviewView.xaml.cs delete mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Views/SensorsView.xaml delete mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Views/SensorsView.xaml.cs delete mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Helpers/OutlookHelper.cs create mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/MachineStudioSettings.cs create mode 100644 Software/Visual_Studio/Tango.Core/CoreSettings.cs create mode 100644 Software/Visual_Studio/Tango.Integration/IntegrationSettings.cs delete mode 100644 Software/Visual_Studio/Tango.Settings/DataBase.cs delete mode 100644 Software/Visual_Studio/Tango.Settings/Integration.cs delete mode 100644 Software/Visual_Studio/Tango.Settings/MachineStudioSettings/DeveloperModule.cs delete mode 100644 Software/Visual_Studio/Tango.Settings/MachineStudioSettings/MachineStudio.cs delete mode 100644 Software/Visual_Studio/Tango.Settings/MachineStudioSettings/StubsModule.cs delete mode 100644 Software/Visual_Studio/Tango.Settings/MachineStudioSettings/SynchronizationModule.cs delete mode 100644 Software/Visual_Studio/Tango.Settings/MachineStudioSettings/TechnicianModule.cs create mode 100644 Software/Visual_Studio/Tango.Settings/OLD/DataBase.cs create mode 100644 Software/Visual_Studio/Tango.Settings/OLD/Integration.cs create mode 100644 Software/Visual_Studio/Tango.Settings/OLD/MachineStudioSettings/DeveloperModule.cs create mode 100644 Software/Visual_Studio/Tango.Settings/OLD/MachineStudioSettings/MachineStudio.cs create mode 100644 Software/Visual_Studio/Tango.Settings/OLD/MachineStudioSettings/StubsModule.cs create mode 100644 Software/Visual_Studio/Tango.Settings/OLD/MachineStudioSettings/SynchronizationModule.cs create mode 100644 Software/Visual_Studio/Tango.Settings/OLD/MachineStudioSettings/TechnicianModule.cs create mode 100644 Software/Visual_Studio/Tango.Settings/OLD/SettingsCollection.cs create mode 100644 Software/Visual_Studio/Tango.Settings/OLD/SettingsManager.cs create mode 100644 Software/Visual_Studio/Tango.Settings/OLD/StubsUI.cs create mode 100644 Software/Visual_Studio/Tango.Settings/SettingsBase.cs delete mode 100644 Software/Visual_Studio/Tango.Settings/SettingsCollection.cs delete mode 100644 Software/Visual_Studio/Tango.Settings/StubsUI.cs create mode 100644 Software/Visual_Studio/Tango.Settings/packages.config create mode 100644 Software/Visual_Studio/Utilities/Tango.Stubs.UI/StubsUISettings.cs (limited to 'Software') diff --git a/Software/DB/Tango.mdf b/Software/DB/Tango.mdf index 3bd55f847..7fcf108c9 100644 Binary files a/Software/DB/Tango.mdf and b/Software/DB/Tango.mdf differ diff --git a/Software/DB/Tango_log.ldf b/Software/DB/Tango_log.ldf index 4732977f1..b8e0906c2 100644 Binary files a/Software/DB/Tango_log.ldf and b/Software/DB/Tango_log.ldf differ diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DataCapture/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DataCapture/ViewModels/MainViewVM.cs index fdd0fed5b..427d1d003 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DataCapture/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DataCapture/ViewModels/MainViewVM.cs @@ -206,7 +206,7 @@ namespace Tango.MachineStudio.DataCapture.ViewModels MediaSeekCommand = new RelayCommand(MediaSeek, (x) => Player.IsPlaying); MediaSeekHoldCommand = new RelayCommand(MediaSeekHold, () => Player.IsPlaying); - _recordingsFolder = Path.Combine(SettingsManager.DefaultFolder, "Recordings"); + _recordingsFolder = Path.Combine(SettingsManager.Default.Folder, "Recordings"); Directory.CreateDirectory(_recordingsFolder); _frameProvider.FrameReceived += _frameProvider_FrameReceived; diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/DeveloperModuleSettings.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/DeveloperModuleSettings.cs new file mode 100644 index 000000000..73d979662 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/DeveloperModuleSettings.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.Settings; + +namespace Tango.MachineStudio.Developer +{ + public class DeveloperModuleSettings : SettingsBase + { + public String LastSelectedMachineGuid { get; set; } + + public String LastSelectedJobGuid { get; set; } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Tango.MachineStudio.Developer.csproj b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Tango.MachineStudio.Developer.csproj index ddea73858..5a81c358f 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Tango.MachineStudio.Developer.csproj +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Tango.MachineStudio.Developer.csproj @@ -108,6 +108,7 @@ + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs index 739f0bcde..106848b7a 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs @@ -63,6 +63,7 @@ namespace Tango.MachineStudio.Developer.ViewModels private ISpeechProvider _speech; private DataCapture.ViewModels.MainViewVM _dataCaptureVM; private bool _isRecording; + private DeveloperModuleSettings _settings; #region Properties @@ -620,6 +621,8 @@ namespace Tango.MachineStudio.Developer.ViewModels /// The notification provider. public MainViewVM(IStudioApplicationManager applicationManager, INotificationProvider notificationProvider, IDiagnosticsFrameProvider diagnosticsFrameProvider, IVideoCaptureProvider videoCaptureProvider, DeveloperNavigationManager navigation, IAuthenticationProvider authentication, IEventLogger eventLogger, ISpeechProvider speech) { + _settings = SettingsManager.Default.GetOrCreate(); + SelectedJobs = new ObservableCollection(); JobEvents = new ObservableCollection(); @@ -629,16 +632,16 @@ namespace Tango.MachineStudio.Developer.ViewModels Machines = _machineDbContext.Machines.ToObservableCollection(); - if (SettingsManager.Default.MachineStudio.DeveloperModule.LastSelectedMachineGuid != null) + if (_settings.LastSelectedMachineGuid != null) { LogManager.Log("Setting last selected machine from settings..."); - SelectedMachine = _machineDbContext.Machines.SingleOrDefault(x => x.Guid == SettingsManager.Default.MachineStudio.DeveloperModule.LastSelectedMachineGuid); + SelectedMachine = _machineDbContext.Machines.SingleOrDefault(x => x.Guid == _settings.LastSelectedMachineGuid); } - if (SettingsManager.Default.MachineStudio.DeveloperModule.LastSelectedJobGuid != null && SelectedMachine != null) + if (_settings.LastSelectedJobGuid != null && SelectedMachine != null) { LogManager.Log("Setting last selected job from settings..."); - SelectedMachineJob = SelectedMachine.Jobs.SingleOrDefault(x => x.Guid == SettingsManager.Default.MachineStudio.DeveloperModule.LastSelectedJobGuid); + SelectedMachineJob = SelectedMachine.Jobs.SingleOrDefault(x => x.Guid == _settings.LastSelectedJobGuid); } _authentication = authentication; @@ -1907,8 +1910,8 @@ namespace Tango.MachineStudio.Developer.ViewModels public override void OnShuttingDown() { - SettingsManager.Default.MachineStudio.DeveloperModule.LastSelectedMachineGuid = SelectedMachine != null ? SelectedMachine.Guid : null; - SettingsManager.Default.MachineStudio.DeveloperModule.LastSelectedJobGuid = SelectedMachineJob != null ? SelectedMachineJob.Guid : null; + _settings.LastSelectedMachineGuid = SelectedMachine != null ? SelectedMachine.Guid : null; + _settings.LastSelectedJobGuid = SelectedMachineJob != null ? SelectedMachineJob.Guid : null; } #endregion diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/Parsing/EmbeddedLogFileParser.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/Parsing/EmbeddedLogFileParser.cs index e97ffb249..09cb9a8b6 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/Parsing/EmbeddedLogFileParser.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/Parsing/EmbeddedLogFileParser.cs @@ -22,7 +22,7 @@ namespace Tango.MachineStudio.Logging.Parsing String logFile = logger != null ? logger.LogFile : null; - foreach (var file in Directory.GetFiles(SettingsManager.DefaultFolder + "\\embedded logs", "*.log").Where(x => Path.GetFileName(x).StartsWith("embedded") && x != logFile)) + foreach (var file in Directory.GetFiles(SettingsManager.Default.Folder + "\\embedded logs", "*.log").Where(x => Path.GetFileName(x).StartsWith("embedded") && x != logFile)) { String dateString = Path.GetFileNameWithoutExtension(file).Replace("embedded-", ""); DateTime date = DateTime.ParseExact(dateString, "dd-MM-yyyy_HH-mm-ss", CultureInfo.InvariantCulture); diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Stubs/StubsModuleSettings.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Stubs/StubsModuleSettings.cs new file mode 100644 index 000000000..1aa775fdc --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Stubs/StubsModuleSettings.cs @@ -0,0 +1,30 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.Settings; + +namespace Tango.MachineStudio.Stubs +{ + public class StubsModuleSettings : SettingsBase + { + /// + /// Gets or sets the last selected port. + /// + public String SelectedPort { get; set; } + + /// + /// Gets or sets the last tabs. + /// + public List LastTabs { get; set; } + + /// + /// Initializes a new instance of the class. + /// + public StubsModuleSettings() + { + LastTabs = new List(); + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Stubs/Tango.MachineStudio.Stubs.csproj b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Stubs/Tango.MachineStudio.Stubs.csproj index eb2248f61..ca3e77628 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Stubs/Tango.MachineStudio.Stubs.csproj +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Stubs/Tango.MachineStudio.Stubs.csproj @@ -71,6 +71,7 @@ + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Stubs/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Stubs/ViewModels/MainViewVM.cs index df47273d0..afd5e4d70 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Stubs/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Stubs/ViewModels/MainViewVM.cs @@ -30,6 +30,7 @@ namespace Tango.MachineStudio.Stubs.ViewModels private UsbTransportAdapter _adapter; //Holds the USB transport adapter. private StubManager _stubManager; private INotificationProvider _notification; + private StubsModuleSettings _settings; #region Properties @@ -220,6 +221,8 @@ namespace Tango.MachineStudio.Stubs.ViewModels /// public MainViewVM(IStudioApplicationManager applicationManager, INotificationProvider notification) { + _settings = SettingsManager.Default.GetOrCreate(); + ApplicationManager = applicationManager; _notification = notification; @@ -264,13 +267,13 @@ namespace Tango.MachineStudio.Stubs.ViewModels "COM9", }; - SelectedPort = SettingsManager.Default.MachineStudio.StubsModule.SelectedPort != null ? SettingsManager.Default.MachineStudio.StubsModule.SelectedPort : Ports.First(); + SelectedPort = _settings.SelectedPort != null ? _settings.SelectedPort : Ports.First(); Status = "Ready"; - if (SettingsManager.Default.MachineStudio.StubsModule.LastTabs.Count > 0) + if (_settings.LastTabs.Count > 0) { - foreach (var file in SettingsManager.Default.MachineStudio.StubsModule.LastTabs) + foreach (var file in _settings.LastTabs) { if (File.Exists(file)) { @@ -534,8 +537,8 @@ namespace Tango.MachineStudio.Stubs.ViewModels /// public override void OnShuttingDown() { - SettingsManager.Default.MachineStudio.StubsModule.SelectedPort = SelectedPort; - SettingsManager.Default.MachineStudio.StubsModule.LastTabs = CodeTabs.Select(x => x.File).ToList(); + _settings.SelectedPort = SelectedPort; + _settings.LastTabs = CodeTabs.Select(x => x.File).ToList(); } #endregion diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/SynchronizationModuleSettings.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/SynchronizationModuleSettings.cs new file mode 100644 index 000000000..9b9e10a7f --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/SynchronizationModuleSettings.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.Settings; + +namespace Tango.MachineStudio.Synchronization +{ + public class SynchronizationModuleSettings : SettingsBase + { + /// + /// Gets or sets the local master database file. + /// + public String LocalMasterDBFile { get; set; } + + /// + /// Gets or sets the local slave database file. + /// + public String LocalSlaveDBFile { get; set; } + + /// + /// Gets or sets the remote SQLite file. + /// + public String RemoteSQLiteFile { get; set; } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/Tango.MachineStudio.Synchronization.csproj b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/Tango.MachineStudio.Synchronization.csproj index f863df9c2..f38fe5dbf 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/Tango.MachineStudio.Synchronization.csproj +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/Tango.MachineStudio.Synchronization.csproj @@ -93,6 +93,7 @@ + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/ViewModels/LocalSynchronizationViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/ViewModels/LocalSynchronizationViewVM.cs index d3cb23d64..879f6e493 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/ViewModels/LocalSynchronizationViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/ViewModels/LocalSynchronizationViewVM.cs @@ -33,6 +33,7 @@ namespace Tango.MachineStudio.Synchronization.ViewModels private INotificationProvider _notification; private bool _isWorking; private MainViewVM _mainView; + private SynchronizationModuleSettings _settings; #region Constructors @@ -43,6 +44,8 @@ namespace Tango.MachineStudio.Synchronization.ViewModels /// The notification. public LocalSynchronizationViewVM(SyncNavigationManager navigation, INotificationProvider notification) { + _settings = SettingsManager.Default.GetOrCreate(); + _navigation = navigation; _notification = notification; @@ -57,15 +60,15 @@ namespace Tango.MachineStudio.Synchronization.ViewModels CommitAllCommand = new RelayCommand(CommitAll, (x) => Differences.Count > 0 && !_isWorking); CleanCommand = new RelayCommand(CleanSlave, (x) => !_isWorking && SlaveDBFile != null); - if (File.Exists(SettingsManager.Default.MachineStudio.SynchronizationModule.LocalMasterDBFile)) + if (File.Exists(_settings.LocalMasterDBFile)) { - MasterDBFile = SettingsManager.Default.MachineStudio.SynchronizationModule.LocalMasterDBFile; + MasterDBFile = _settings.LocalMasterDBFile; MasterDBName = Path.GetFileName(MasterDBFile); } - if (File.Exists(SettingsManager.Default.MachineStudio.SynchronizationModule.LocalSlaveDBFile)) + if (File.Exists(_settings.LocalSlaveDBFile)) { - SlaveDBFile = SettingsManager.Default.MachineStudio.SynchronizationModule.LocalSlaveDBFile; + SlaveDBFile = _settings.LocalSlaveDBFile; SlaveDBName = Path.GetFileName(SlaveDBFile); } } @@ -268,9 +271,9 @@ namespace Tango.MachineStudio.Synchronization.ViewModels SelectedDifference = null; InvalidateRelayCommands(); - SettingsManager.Default.MachineStudio.SynchronizationModule.LocalMasterDBFile = MasterDBFile; - SettingsManager.Default.MachineStudio.SynchronizationModule.LocalSlaveDBFile = SlaveDBFile; - SettingsManager.SaveDefaultSettings(); + _settings.LocalMasterDBFile = MasterDBFile; + _settings.LocalSlaveDBFile = SlaveDBFile; + _settings.Save(); } } }); diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/ViewModels/RemoteSynchronizationViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/ViewModels/RemoteSynchronizationViewVM.cs index 75b5fe95a..2896f3e58 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/ViewModels/RemoteSynchronizationViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/ViewModels/RemoteSynchronizationViewVM.cs @@ -41,6 +41,7 @@ namespace Tango.MachineStudio.Synchronization.ViewModels private RemoteDB _remoteDB; private LocalDB _localDB; private MainViewVM _mainView; + private SynchronizationModuleSettings _settings; #region Constructors @@ -51,6 +52,8 @@ namespace Tango.MachineStudio.Synchronization.ViewModels /// The notification. public RemoteSynchronizationViewVM(SyncNavigationManager navigation, INotificationProvider notification) { + _settings = SettingsManager.Default.GetOrCreate(); + _navigation = navigation; _notification = notification; @@ -64,9 +67,9 @@ namespace Tango.MachineStudio.Synchronization.ViewModels CommitAllCommand = new RelayCommand(CommitAll, (x) => Differences.Count > 0 && !_isWorking && SelectedMachine != null); CleanCommand = new RelayCommand(CleanSlave, (x) => !_isWorking && SlaveDBFile != null); - if (File.Exists(SettingsManager.Default.MachineStudio.SynchronizationModule.RemoteSQLiteFile)) + if (File.Exists(_settings.RemoteSQLiteFile)) { - SlaveDBFile = SettingsManager.Default.MachineStudio.SynchronizationModule.RemoteSQLiteFile; + SlaveDBFile = _settings.RemoteSQLiteFile; SlaveDBName = Path.GetFileName(SlaveDBFile); } } @@ -266,8 +269,8 @@ namespace Tango.MachineStudio.Synchronization.ViewModels SelectedDifference = null; InvalidateRelayCommands(); - SettingsManager.Default.MachineStudio.SynchronizationModule.RemoteSQLiteFile = SlaveDBFile; - SettingsManager.SaveDefaultSettings(); + _settings.RemoteSQLiteFile = SlaveDBFile; + _settings.Save(); } } }); diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Helpers/GraphsHelper.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Helpers/GraphsHelper.cs index 78466ace8..0cd14f917 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Helpers/GraphsHelper.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Helpers/GraphsHelper.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using Tango.MachineStudio.Common; using Tango.Settings; namespace Tango.MachineStudio.Technician.Helpers @@ -21,8 +22,9 @@ namespace Tango.MachineStudio.Technician.Helpers { try { - double seconds = SettingsManager.Default.MachineStudio.TechnicianModule.GraphsDuration; - double pullRate = SettingsManager.Default.MachineStudio.TechnicianModule.GraphsPullingInterval; + var settings = SettingsManager.Default.GetOrCreate(); + double seconds = settings.GraphsViewDurationSeconds; + double pullRate = settings.DiagnosticsResponseIntervalMilli; return (int)(((pullRate * pointsPerFrame * 10 * seconds) * (10 / pullRate)) * 0.65); } catch (Exception) diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Navigation/TechNavigationManager.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Navigation/TechNavigationManager.cs deleted file mode 100644 index ddfb84920..000000000 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Navigation/TechNavigationManager.cs +++ /dev/null @@ -1,24 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Tango.MachineStudio.Technician.Views; - -namespace Tango.MachineStudio.Technician.Navigation -{ - /// - /// Represents the technician module navigation manager. - /// - public class TechNavigationManager - { - /// - /// Navigates to the specified view. - /// - /// The view. - public void NavigateTo(TechNavigationView view) - { - MainView.Instance.TransitionControl.AutoNavigate(view.ToString()); - } - } -} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Navigation/TechNavigationView.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Navigation/TechNavigationView.cs deleted file mode 100644 index b4a85f92a..000000000 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Navigation/TechNavigationView.cs +++ /dev/null @@ -1,18 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Tango.MachineStudio.Technician.Navigation -{ - /// - /// Represents the available technician module views. - /// - public enum TechNavigationView - { - Overview, - Motors, - Sensors, - } -} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Tango.MachineStudio.Technician.csproj b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Tango.MachineStudio.Technician.csproj index 93a99667a..f7bf69bc8 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Tango.MachineStudio.Technician.csproj +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Tango.MachineStudio.Technician.csproj @@ -198,30 +198,15 @@ - - + - - MachineTechView.xaml - - MotorsView.xaml - - - OverviewView.xaml - - - SensorsView.xaml - - - MainView.xaml - GlobalVersionInfo.cs @@ -353,22 +338,6 @@ MSBuild:Compile Designer - - Designer - MSBuild:Compile - - - Designer - MSBuild:Compile - - - Designer - MSBuild:Compile - - - Designer - MSBuild:Compile - diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/MultiGraphItem.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/MultiGraphItem.cs index 887417cf8..bd165623a 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/MultiGraphItem.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/MultiGraphItem.cs @@ -6,6 +6,7 @@ using System.Threading.Tasks; using System.Xml.Serialization; using Tango.BL.Entities; using Tango.MachineStudio.Technician.Editors; +using Tango.MachineStudio.Technician.Helpers; using Tango.SharedUI.Helpers; namespace Tango.MachineStudio.Technician.TechItems @@ -34,7 +35,7 @@ namespace Tango.MachineStudio.Technician.TechItems if (_techMonitor != old && Editor != null) { - Editor.InnerGraph.InnerGraph.MaxPoints = Common.Helpers.GraphsHelper.GetMaxPoints(TechMonitor.PointsPerFrame); + Editor.InnerGraph.InnerGraph.MaxPoints = GraphsHelper.GetMaxPoints(TechMonitor.PointsPerFrame); Editor.InnerGraph.InvalidateGraph(); } diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/SingleGraphItem.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/SingleGraphItem.cs index 648d8eda3..19cbab426 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/SingleGraphItem.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/SingleGraphItem.cs @@ -7,6 +7,7 @@ using System.Windows.Media; using System.Xml.Serialization; using Tango.BL.Entities; using Tango.MachineStudio.Technician.Editors; +using Tango.MachineStudio.Technician.Helpers; using Tango.SharedUI.Helpers; namespace Tango.MachineStudio.Technician.TechItems @@ -35,7 +36,7 @@ namespace Tango.MachineStudio.Technician.TechItems if (_techMonitor != old && Editor != null) { - Editor.InnerGraph.InnerGraph.MaxPoints = Common.Helpers.GraphsHelper.GetMaxPoints(TechMonitor.PointsPerFrame); + Editor.InnerGraph.InnerGraph.MaxPoints = GraphsHelper.GetMaxPoints(TechMonitor.PointsPerFrame); Editor.InnerGraph.InvalidateGraph(); } diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechnicianModuleSettings.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechnicianModuleSettings.cs new file mode 100644 index 000000000..12acaf3ee --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechnicianModuleSettings.cs @@ -0,0 +1,36 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.Settings; + +namespace Tango.MachineStudio.Technician +{ + public class TechnicianModuleSettings : SettingsBase + { + /// + /// Gets or sets the graphs view duration in seconds. + /// + public int GraphsViewDurationSeconds { get; set; } + + /// + /// Gets or sets the diagnostics response interval in milliseconds. + /// + public int DiagnosticsResponseIntervalMilli { get; set; } + + /// + /// Gets or sets the las tech project file. + /// + public String LastTechProjectFile { get; set; } + + /// + /// Initializes a new instance of the class. + /// + public TechnicianModuleSettings() + { + GraphsViewDurationSeconds = 10; + DiagnosticsResponseIntervalMilli = 30; + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/ViewModelLocator.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/ViewModelLocator.cs index 5921a2f15..a7d08eb45 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/ViewModelLocator.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/ViewModelLocator.cs @@ -1,5 +1,4 @@ using Tango.Core.DI; -using Tango.MachineStudio.Technician.Navigation; using Tango.MachineStudio.Technician.ViewModels; namespace Tango.MachineStudio.Technician @@ -15,29 +14,7 @@ namespace Tango.MachineStudio.Technician /// static ViewModelLocator() { - TangoIOC.Default.Register(); - TangoIOC.Default.Register(); TangoIOC.Default.Register(); - - TangoIOC.Default.Unregister(); - - TangoIOC.Default.Register(); - } - - public static MainViewVM MainViewVM - { - get - { - return TangoIOC.Default.GetInstance(); - } - } - - public static SensorsViewVM SensorsViewVM - { - get - { - return TangoIOC.Default.GetInstance(); - } } public static MachineTechViewVM MachineTechViewVM diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/ViewModels/MachineTechViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/ViewModels/MachineTechViewVM.cs index ac78ef488..d8369ea7b 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/ViewModels/MachineTechViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/ViewModels/MachineTechViewVM.cs @@ -31,6 +31,7 @@ using Tango.BL; using Tango.MachineStudio.Common.EventLogging; using Tango.MachineStudio.Common; using Tango.Core.Commands; +using Tango.MachineStudio.Technician.Helpers; namespace Tango.MachineStudio.Technician.ViewModels { @@ -50,6 +51,8 @@ namespace Tango.MachineStudio.Technician.ViewModels private IEventLogger _eventLogger; private DateTime _lastDiagnosticsResponseUpdate; private const int MIN_DIAGNOSTICS_UPDATE_MILI = 500; + private TechnicianModuleSettings _settings; + #region Properties @@ -191,6 +194,8 @@ namespace Tango.MachineStudio.Technician.ViewModels /// The notification provider. public MachineTechViewVM(IStudioApplicationManager applicationManager, INotificationProvider notificationProvider, IDiagnosticsFrameProvider _diagnosticsFrameProvider, IEventLogger eventLogger) { + _settings = SettingsManager.Default.GetOrCreate(); + _notification = notificationProvider; _eventLogger = eventLogger; _singleControllers = new Dictionary(); @@ -208,7 +213,7 @@ namespace Tango.MachineStudio.Technician.ViewModels SaveAsProjectCommand = new RelayCommand(SaveAsProject); SaveProjectCommand = new RelayCommand(SaveProject); - _lastTechProjectFile = SettingsManager.Default.MachineStudio.TechnicianModule.LasTechProjectFile; + _lastTechProjectFile = _settings.LastTechProjectFile; if (File.Exists(_lastTechProjectFile)) { @@ -680,7 +685,7 @@ namespace Tango.MachineStudio.Technician.ViewModels var graphItem = element.HostedElement as SingleGraphItem; var editor = element as SingleGraphElementEditor; graphItem.Editor = editor; - editor.InnerGraph.InnerGraph.MaxPoints = Common.Helpers.GraphsHelper.GetMaxPoints(graphItem.TechMonitor.PointsPerFrame); + editor.InnerGraph.InnerGraph.MaxPoints = GraphsHelper.GetMaxPoints(graphItem.TechMonitor.PointsPerFrame); GraphController controller = new GraphController(); editor.InnerGraph.Controller = controller; @@ -691,7 +696,7 @@ namespace Tango.MachineStudio.Technician.ViewModels { var graphItem = element.HostedElement as MultiGraphItem; var editor = element as MultiGraphElementEditor; - editor.InnerGraph.InnerGraph.MaxPoints = Common.Helpers.GraphsHelper.GetMaxPoints(graphItem.TechMonitor.PointsPerFrame); + editor.InnerGraph.InnerGraph.MaxPoints = GraphsHelper.GetMaxPoints(graphItem.TechMonitor.PointsPerFrame); graphItem.Editor = editor; @@ -923,7 +928,7 @@ namespace Tango.MachineStudio.Technician.ViewModels /// The editor. private void InitSingleGraphitem(SingleGraphItem item, SingleGraphElementEditor editor) { - editor.InnerGraph.InnerGraph.MaxPoints = Common.Helpers.GraphsHelper.GetMaxPoints(item.TechMonitor.PointsPerFrame); + editor.InnerGraph.InnerGraph.MaxPoints = GraphsHelper.GetMaxPoints(item.TechMonitor.PointsPerFrame); item.Editor = editor; GraphController controller = new GraphController(); @@ -939,7 +944,7 @@ namespace Tango.MachineStudio.Technician.ViewModels /// The editor. private void InitMultiGraphItem(MultiGraphItem item, MultiGraphElementEditor editor) { - editor.InnerGraph.InnerGraph.MaxPoints = Common.Helpers.GraphsHelper.GetMaxPoints(item.TechMonitor.PointsPerFrame); + editor.InnerGraph.InnerGraph.MaxPoints = GraphsHelper.GetMaxPoints(item.TechMonitor.PointsPerFrame); item.Editor = editor; GraphMultiController controller = new GraphMultiController(); @@ -1280,7 +1285,7 @@ namespace Tango.MachineStudio.Technician.ViewModels { InvokeUINow(() => { - SettingsManager.Default.MachineStudio.TechnicianModule.LasTechProjectFile = _lastTechProjectFile; + _settings.LastTechProjectFile = _lastTechProjectFile; }); } diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/ViewModels/MainViewVM.cs deleted file mode 100644 index 306f15c5c..000000000 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/ViewModels/MainViewVM.cs +++ /dev/null @@ -1,56 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Tango.Core.Commands; -using Tango.MachineStudio.Technician.Navigation; -using Tango.SharedUI; - -namespace Tango.MachineStudio.Technician.ViewModels -{ - /// - /// Represents the technician module main view, view model. - /// - /// - public class MainViewVM : ViewModel - { - private TechNavigationManager _navigation; - - #region Constructors - - /// - /// Initializes a new instance of the class. - /// - /// The navigation manager. - public MainViewVM(TechNavigationManager navigationManager) - { - _navigation = navigationManager; - NavigateToViewCommand = new RelayCommand(NavigateToView); - } - - #endregion - - #region Commands - - /// - /// Gets or sets the navigate to view command. - /// - public RelayCommand NavigateToViewCommand { get; set; } - - #endregion - - #region Private Methods - - /// - /// Navigates to the specified view. - /// - /// The view. - private void NavigateToView(string view) - { - _navigation.NavigateTo((TechNavigationView)Enum.Parse(typeof(TechNavigationView), view, true)); - } - - #endregion - } -} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/ViewModels/SensorsViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/ViewModels/SensorsViewVM.cs deleted file mode 100644 index 403a6d510..000000000 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/ViewModels/SensorsViewVM.cs +++ /dev/null @@ -1,193 +0,0 @@ -using RealTimeGraphEx.Controllers; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Tango.Integration.Operation; -using Tango.Integration.Services; -using Tango.Logging; -using Tango.MachineStudio.Common.Modules; -using Tango.MachineStudio.Common.StudioApplication; -using Tango.PMR.Diagnostics; -using Tango.Settings; -using Tango.SharedUI; - -namespace Tango.MachineStudio.Technician.ViewModels -{ - /// - /// Represents the technician module sensors view, view model. - /// - /// - public class SensorsViewVM : ViewModel - { - private List _controllers; - - #region Properties - - /// - /// Gets or sets the application manager. - /// - public IStudioApplicationManager ApplicationManager { get; set; } - - private IMachineOperator _machineOperator; - /// - /// Gets or sets the machine operator. - /// - public IMachineOperator MachineOperator - { - get { return _machineOperator; } - set { _machineOperator = value; RaisePropertyChangedAuto(); } - } - - private int _graphSeconds; - /// - /// Gets or sets the graphs number of seconds to complete FIFO capacity. - /// - public int GraphSeconds - { - get { return _graphSeconds; } - set { _graphSeconds = value; RaisePropertyChanged(nameof(GraphSeconds)); } - } - - /// - /// Clears the graphs. - /// - public void ClearGraphs() - { - _controllers.ForEach(x => x.Clear()); - } - - #endregion - - #region Constructors - - /// - /// Initializes a new instance of the class. - /// - /// The application manager. - /// The module loader. - public SensorsViewVM(IStudioApplicationManager applicationManager, IStudioModuleLoader moduleLoader) - { - ApplicationManager = applicationManager; - ApplicationManager.ConnectedMachineChanged += ApplicationManager_ConnectedMachineChanged; - - InitializeConnectedMachine(ApplicationManager.ConnectedMachine); - - if (!DesignMode) - { - //Set graphs FIFO capacity by seconds (this will be converted to MaxPoints by the view). - GraphSeconds = SettingsManager.Default.MachineStudio.TechnicianModule.GraphsDuration; - - _controllers = new List(); - - TemperatureController = new GraphController(); - PressureController = new GraphController(); - VelocityController = new GraphController(); - - _controllers.Add(TemperatureController); - _controllers.Add(PressureController); - _controllers.Add(VelocityController); - - var module = moduleLoader.GetStudioModule(); - - if (module != null) - { - module.IsLoadedChanged += Module_IsLoadedChanged; - } - } - } - - #endregion - - #region Event Handlers - - /// - /// Handles the technician module IsLoaded changed event. - /// - /// The sender. - /// if set to true [loaded]. - private void Module_IsLoadedChanged(object sender, bool loaded) - { - _controllers.ForEach(x => x.ChangeRenderMode(loaded)); - } - - /// - /// Handles the application manager connected machine changed event. - /// - /// The sender. - /// The machine operator. - private void ApplicationManager_ConnectedMachineChanged(object sender, IExternalBridgeClient machineOperator) - { - InitializeConnectedMachine(machineOperator); - } - - /// - /// Handles the machine operator diagnostics data available event - /// - /// The sender. - /// The data. - private void MachineOperator_DiagnosticsDataAvailable(object sender, StartDiagnosticsResponse data) - { - //TemperatureController.PushData(data.Temperature.ToArray()); - //PressureController.PushData(data.Temperature.ToArray()); - //VelocityController.PushData(data.Velocity.ToArray()); - } - - #endregion - - #region Private Methods - - /// - /// Initializes the connected machine. - /// - /// The machine operator. - private void InitializeConnectedMachine(IMachineOperator machineOperator) - { - //MachineOperator = machineOperator; - - //if (MachineOperator != null) - //{ - // MachineOperator.EnableSensorsUpdate = true; - // MachineOperator.DiagnosticsDataAvailable -= MachineOperator_DiagnosticsDataAvailable; - // MachineOperator.DiagnosticsDataAvailable += MachineOperator_DiagnosticsDataAvailable; - //} - } - - #endregion - - #region Graphs Controllers - - private GraphController _temperatureController; - /// - /// Gets or sets the temperature sensor graph controller . - /// - public GraphController TemperatureController - { - get { return _temperatureController; } - set { _temperatureController = value; RaisePropertyChanged(nameof(TemperatureController)); } - } - - private GraphController _pressureController; - /// - /// Gets or sets the pressure sensor graph controller . - /// - public GraphController PressureController - { - get { return _pressureController; } - set { _pressureController = value; RaisePropertyChanged(nameof(PressureController)); } - } - - private GraphController _velocityController; - /// - /// Gets or sets the velocity sensor graph controller . - /// - public GraphController VelocityController - { - get { return _velocityController; } - set { _velocityController = value; RaisePropertyChanged(nameof(VelocityController)); } - } - - #endregion - } -} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Views/MainView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Views/MainView.xaml deleted file mode 100644 index 6b84881fd..000000000 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Views/MainView.xaml +++ /dev/null @@ -1,102 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Views/MainView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Views/MainView.xaml.cs deleted file mode 100644 index b07fc597e..000000000 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Views/MainView.xaml.cs +++ /dev/null @@ -1,31 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows; -using System.Windows.Controls; -using System.Windows.Data; -using System.Windows.Documents; -using System.Windows.Input; -using System.Windows.Media; -using System.Windows.Media.Imaging; -using System.Windows.Navigation; -using System.Windows.Shapes; - -namespace Tango.MachineStudio.Technician.Views -{ - /// - /// Interaction logic for MainView.xaml - /// - public partial class MainView : UserControl - { - public static MainView Instance { get; set; } - - public MainView() - { - InitializeComponent(); - Instance = this; - } - } -} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Views/MotorsView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Views/MotorsView.xaml deleted file mode 100644 index 3fb49d457..000000000 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Views/MotorsView.xaml +++ /dev/null @@ -1,12 +0,0 @@ - - - MOTORS - - diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Views/MotorsView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Views/MotorsView.xaml.cs deleted file mode 100644 index bd548766c..000000000 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Views/MotorsView.xaml.cs +++ /dev/null @@ -1,28 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows; -using System.Windows.Controls; -using System.Windows.Data; -using System.Windows.Documents; -using System.Windows.Input; -using System.Windows.Media; -using System.Windows.Media.Imaging; -using System.Windows.Navigation; -using System.Windows.Shapes; - -namespace Tango.MachineStudio.Technician.Views -{ - /// - /// Interaction logic for MotorsView.xaml - /// - public partial class MotorsView : UserControl - { - public MotorsView() - { - InitializeComponent(); - } - } -} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Views/OverviewView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Views/OverviewView.xaml deleted file mode 100644 index 3c064346d..000000000 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Views/OverviewView.xaml +++ /dev/null @@ -1,12 +0,0 @@ - - - OVERVIEW - - diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Views/OverviewView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Views/OverviewView.xaml.cs deleted file mode 100644 index aeba42c00..000000000 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Views/OverviewView.xaml.cs +++ /dev/null @@ -1,28 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows; -using System.Windows.Controls; -using System.Windows.Data; -using System.Windows.Documents; -using System.Windows.Input; -using System.Windows.Media; -using System.Windows.Media.Imaging; -using System.Windows.Navigation; -using System.Windows.Shapes; - -namespace Tango.MachineStudio.Technician.Views -{ - /// - /// Interaction logic for OverviewView.xaml - /// - public partial class OverviewView : UserControl - { - public OverviewView() - { - InitializeComponent(); - } - } -} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Views/SensorsView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Views/SensorsView.xaml deleted file mode 100644 index 63feae2f3..000000000 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Views/SensorsView.xaml +++ /dev/null @@ -1,173 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Views/SensorsView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Views/SensorsView.xaml.cs deleted file mode 100644 index e60deacbd..000000000 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Views/SensorsView.xaml.cs +++ /dev/null @@ -1,53 +0,0 @@ -using RealTimeGraphEx.Synchronization; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows; -using System.Windows.Controls; -using System.Windows.Data; -using System.Windows.Documents; -using System.Windows.Input; -using System.Windows.Media; -using System.Windows.Media.Imaging; -using System.Windows.Navigation; -using System.Windows.Shapes; - -namespace Tango.MachineStudio.Technician.Views -{ - /// - /// Interaction logic for DebugView.xaml - /// - public partial class SensorsView : UserControl - { - private SyncManager _syncManager; - - public SensorsView() - { - InitializeComponent(); - - _syncManager = new SyncManager(); - _syncManager.AddGraph(graphTemperature); - _syncManager.AddGraph(graphPressure); - _syncManager.AddGraph(graphVelocity); - _syncManager.RefreshRate = 30; - _syncManager.Start(); - } - - private void OnGraphFullScreen(object sender, RoutedEventArgs e) - { - - } - - private void Graph_MouseEnter(object sender, MouseEventArgs e) - { - - } - - private void Graph_MouseLeave(object sender, MouseEventArgs e) - { - - } - } -} diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Controls/RealTimeGraphControl.xaml b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Controls/RealTimeGraphControl.xaml index 2f43869d5..fc36b28d3 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Controls/RealTimeGraphControl.xaml +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Controls/RealTimeGraphControl.xaml @@ -18,36 +18,32 @@ - - - - - - - - + + + + diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Controls/RealTimeGraphMultiControl.xaml b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Controls/RealTimeGraphMultiControl.xaml index 5548c452e..657cc2683 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Controls/RealTimeGraphMultiControl.xaml +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Controls/RealTimeGraphMultiControl.xaml @@ -18,36 +18,32 @@ - - - - - - - - + + + + diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Helpers/GraphsHelper.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Helpers/GraphsHelper.cs index 53e832eb5..80e54d143 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Helpers/GraphsHelper.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Helpers/GraphsHelper.cs @@ -21,8 +21,10 @@ namespace Tango.MachineStudio.Common.Helpers { try { - double seconds = SettingsManager.Default.MachineStudio.TechnicianModule.GraphsDuration; - double pullRate = SettingsManager.Default.MachineStudio.TechnicianModule.GraphsPullingInterval; + var settings = SettingsManager.Default.GetOrCreate(); + + double seconds = settings.GraphsViewDurationSeconds; + double pullRate = settings.DiagnosticsResponseIntervalMilli; return (int)(((pullRate * pointsPerFrame * 10 * seconds) * (10 / pullRate)) * 0.65); } catch (Exception) diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Helpers/OutlookHelper.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Helpers/OutlookHelper.cs deleted file mode 100644 index 58138b625..000000000 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Helpers/OutlookHelper.cs +++ /dev/null @@ -1,13 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Tango.MachineStudio.Common.Helpers -{ - public static class OutlookHelper - { - - } -} diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/MachineStudioSettings.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/MachineStudioSettings.cs new file mode 100644 index 000000000..b12d9a580 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/MachineStudioSettings.cs @@ -0,0 +1,52 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.Logging; +using Tango.Settings; + +namespace Tango.MachineStudio.Common +{ + public class MachineStudioSettings : SettingsBase + { + /// + /// Gets or sets the last login email. + /// + public String LastLoginEmail { get; set; } + + /// + /// Gets or sets the last login password. + /// + public String LastLoginPassword { get; set; } + + /// + /// Gets or sets a value indicating whether to save the user credentials. + /// + public bool RememberMe { get; set; } + + /// + /// Gets or sets the last virtual machine serial number. + /// + public String LastVirtualMachineSerialNumber { get; set; } + + /// + /// Gets or sets the update service address. + /// + public String UpdateServiceAddress { get; set; } + + /// + /// Gets or sets the logging categories. + /// + public List LoggingCategories { get; set; } + + /// + /// Initializes a new instance of the class. + /// + public MachineStudioSettings() + { + LoggingCategories = new List(); + UpdateServiceAddress = "http://twine01/MachineStudioUpdateService/MachineStudioUpdateService.svc"; + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Tango.MachineStudio.Common.csproj b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Tango.MachineStudio.Common.csproj index df1ee23dc..a635e17ed 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Tango.MachineStudio.Common.csproj +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Tango.MachineStudio.Common.csproj @@ -90,17 +90,17 @@ - + - - + + diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Update/UpdateServiceHelper.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Update/UpdateServiceHelper.cs index 87b974b99..2194ec5cf 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Update/UpdateServiceHelper.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Update/UpdateServiceHelper.cs @@ -23,7 +23,7 @@ namespace Tango.MachineStudio.Common.Update binding.ReaderQuotas.MaxArrayLength = 6553600; binding.ReaderQuotas.MaxBytesPerRead = 6553600; - return new ChannelFactory(binding, SettingsManager.Default.MachineStudio.UpdateServiceAddress); + return new ChannelFactory(binding, SettingsManager.Default.GetOrCreate().UpdateServiceAddress); } } } diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Publisher/MainWindowVM.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Publisher/MainWindowVM.cs index 3b92ac686..847503e42 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Publisher/MainWindowVM.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Publisher/MainWindowVM.cs @@ -13,6 +13,7 @@ using System.Windows; using Tango.Core.Commands; using Tango.Core.Cryptography; using Tango.Core.Helpers; +using Tango.MachineStudio.Common; using Tango.MachineStudio.Common.Update; using Tango.Settings; using Tango.SharedUI; @@ -102,10 +103,12 @@ namespace Tango.MachineStudio.Publisher UpdateVersions(); - Email = SettingsManager.Default.MachineStudio.LastLoginEmail; + var settings = SettingsManager.Default.GetOrCreate(); + + Email = settings.LastLoginEmail; var cryptographer = new Rfc2898Cryptographer(); - Password = cryptographer.Decrypt(SettingsManager.Default.MachineStudio.LastLoginPassword); + Password = cryptographer.Decrypt(settings.LastLoginPassword); } private void UpdateVersions() diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/App.config b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/App.config index 1a0e57043..1775bf7d1 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/App.config +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/App.config @@ -67,6 +67,14 @@ + + + + + + + + \ No newline at end of file diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/App.xaml.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/App.xaml.cs index f124ebb54..568529534 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/App.xaml.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/App.xaml.cs @@ -20,6 +20,7 @@ using Tango.TFS; using Tango.MachineStudio.Common.Notifications; using Tango.MachineStudio.UI.ViewModels; using Tango.MachineStudio.UI.Views; +using Tango.MachineStudio.Common; namespace Tango.MachineStudio.UI { @@ -42,15 +43,17 @@ namespace Tango.MachineStudio.UI LogManager.Categories.Clear(); - if (SettingsManager.Default.MachineStudio.LoggingCategories.Count == 0) + var settings = SettingsManager.Default.GetOrCreate(); + + if (settings.LoggingCategories.Count == 0) { - SettingsManager.Default.MachineStudio.LoggingCategories.Add(LogCategory.Critical); - SettingsManager.Default.MachineStudio.LoggingCategories.Add(LogCategory.Error); - SettingsManager.Default.MachineStudio.LoggingCategories.Add(LogCategory.Info); - SettingsManager.Default.MachineStudio.LoggingCategories.Add(LogCategory.Warning); + settings.LoggingCategories.Add(LogCategory.Critical); + settings.LoggingCategories.Add(LogCategory.Error); + settings.LoggingCategories.Add(LogCategory.Info); + settings.LoggingCategories.Add(LogCategory.Warning); } - LogManager.Categories.AddRange(SettingsManager.Default.MachineStudio.LoggingCategories); + LogManager.Categories.AddRange(settings.LoggingCategories); exceptionTrapper = new WpfGlobalExceptionTrapper(); exceptionTrapper.Initialize(this); diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/StudioApplication/DefaultStudioApplicationManager.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/StudioApplication/DefaultStudioApplicationManager.cs index 4c02be2b2..48b0fdada 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/StudioApplication/DefaultStudioApplicationManager.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/StudioApplication/DefaultStudioApplicationManager.cs @@ -175,7 +175,7 @@ namespace Tango.MachineStudio.UI.StudioApplication try { - SettingsManager.SaveDefaultSettings(); + SettingsManager.Default.Save(); } catch (Exception ex) { diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoadingViewVM.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoadingViewVM.cs index 29f9102ac..5c8fb80ba 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoadingViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoadingViewVM.cs @@ -107,7 +107,7 @@ namespace Tango.MachineStudio.UI.ViewModels } else { - Environment.Exit(0); + ApplicationManager.ShutDown(); } }); } diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoginViewVM.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoginViewVM.cs index fafa752c5..786951b06 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoginViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoginViewVM.cs @@ -8,6 +8,7 @@ using System.Text; using System.Threading.Tasks; using Tango.Core.Commands; using Tango.Core.Cryptography; +using Tango.MachineStudio.Common; using Tango.MachineStudio.Common.Authentication; using Tango.MachineStudio.Common.EventLogging; using Tango.MachineStudio.Common.Navigation; @@ -28,6 +29,7 @@ namespace Tango.MachineStudio.UI.ViewModels private INotificationProvider _notificationProvider; private IEventLogger _eventLogger; private Rfc2898Cryptographer cryptographer; + private MachineStudioSettings _settings; private String _email; /// @@ -73,6 +75,8 @@ namespace Tango.MachineStudio.UI.ViewModels /// The notification provider. public LoginViewVM(IAuthenticationProvider authenticationProvider, INavigationManager navigationManager, INotificationProvider notificationProvider, IEventLogger eventLogger) { + _settings = SettingsManager.Default.GetOrCreate(); + _notificationProvider = notificationProvider; _navigationManager = navigationManager; _authenticationProvider = authenticationProvider; @@ -80,9 +84,9 @@ namespace Tango.MachineStudio.UI.ViewModels LoginCommand = new RelayCommand(Login); cryptographer = new Rfc2898Cryptographer(); - Email = SettingsManager.Default.MachineStudio.LastLoginEmail; - RememberMe = SettingsManager.Default.MachineStudio.RememberMe; - Password = cryptographer.Decrypt(SettingsManager.Default.MachineStudio.LastLoginPassword); + Email = _settings.LastLoginEmail; + RememberMe = _settings.RememberMe; + Password = cryptographer.Decrypt(_settings.LastLoginPassword); } /// @@ -96,11 +100,11 @@ namespace Tango.MachineStudio.UI.ViewModels { _authenticationProvider.Login(Email, Password); _navigationManager.NavigateTo(NavigationView.MainView); - SettingsManager.Default.MachineStudio.LastLoginEmail = Email; - SettingsManager.Default.MachineStudio.RememberMe = RememberMe; + _settings.LastLoginEmail = Email; + _settings.RememberMe = RememberMe; - SettingsManager.Default.MachineStudio.LastLoginPassword = RememberMe ? cryptographer.Encrypt(Password) : null; - SettingsManager.SaveDefaultSettings(); + _settings.LastLoginPassword = RememberMe ? cryptographer.Encrypt(Password) : null; + _settings.Save(); _eventLogger.Log("User logged in"); } diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MachineSerialViewVM.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MachineSerialViewVM.cs index 9f366829a..ad4cfa96d 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MachineSerialViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MachineSerialViewVM.cs @@ -6,6 +6,7 @@ using System.Threading.Tasks; using Tango.BL; using Tango.BL.Entities; using Tango.Core.Commands; +using Tango.MachineStudio.Common; using Tango.MachineStudio.Common.Notifications; using Tango.Settings; @@ -24,7 +25,10 @@ namespace Tango.MachineStudio.UI.ViewModels public MachineSerialViewVM() { OKCommand = new RelayCommand(Accept, () => SelectedMachine != null); - SelectedMachine = ObservablesEntitiesAdapter.Instance.Machines.SingleOrDefault(x => x.SerialNumber == SettingsManager.Default.MachineStudio.LastVirtualMachineSerialNumber); + + var settings = SettingsManager.Default.GetOrCreate(); + + SelectedMachine = ObservablesEntitiesAdapter.Instance.Machines.SingleOrDefault(x => x.SerialNumber == settings.LastVirtualMachineSerialNumber); } } } diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs index 04b973f23..d3d90c0cc 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs @@ -53,6 +53,7 @@ namespace Tango.MachineStudio.UI.ViewModels private Thread _updateCheckThread; private IEventLogger _eventLogger; private IHtmlPresenter _htmlPresenter; + private MachineStudioSettings _settings; /// /// Gets or sets the current loaded module. @@ -281,6 +282,8 @@ namespace Tango.MachineStudio.UI.ViewModels SpeechProvider = speechProvider; _htmlPresenter = htmlPresenter; + _settings = SettingsManager.Default.GetOrCreate(); + StartModuleCommand = new RelayCommand(StartModule); HomeCommand = new RelayCommand(Home); @@ -473,8 +476,8 @@ namespace Tango.MachineStudio.UI.ViewModels PostMessage(new MachineConnectionChangedMessage() { Machine = x.SelectedMachine }); _eventLogger.Log(String.Format("Successfully connected to machine {0} via USB", x.SelectedMachine.SerialNumber)); - SettingsManager.Default.MachineStudio.LastVirtualMachineSerialNumber = vm.SelectedMachine.SerialNumber; - SettingsManager.SaveDefaultSettings(); + _settings.LastVirtualMachineSerialNumber = vm.SelectedMachine.SerialNumber; + _settings.Save(); } catch (Exception ex) { diff --git a/Software/Visual_Studio/PanelPC/Tango.PanelPC.UI/App.config b/Software/Visual_Studio/PanelPC/Tango.PanelPC.UI/App.config index 8324aa6ff..f2af62f53 100644 --- a/Software/Visual_Studio/PanelPC/Tango.PanelPC.UI/App.config +++ b/Software/Visual_Studio/PanelPC/Tango.PanelPC.UI/App.config @@ -1,6 +1,14 @@ - + + + + + + + + + \ No newline at end of file diff --git a/Software/Visual_Studio/Tango.BL/ObservablesContextExtension.cs b/Software/Visual_Studio/Tango.BL/ObservablesContextExtension.cs index 584e6c783..83c8ab69b 100644 --- a/Software/Visual_Studio/Tango.BL/ObservablesContextExtension.cs +++ b/Software/Visual_Studio/Tango.BL/ObservablesContextExtension.cs @@ -5,6 +5,7 @@ using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; +using Tango.Core; using Tango.Settings; namespace Tango.BL @@ -55,7 +56,7 @@ namespace Tango.BL /// public static ObservablesContext CreateDefault() { - return new ObservablesContext(SettingsManager.Default.DataBase.SQLServerAddress); + return new ObservablesContext(SettingsManager.Default.GetOrCreate().SQLServerAddress); } /// diff --git a/Software/Visual_Studio/Tango.Core/CoreSettings.cs b/Software/Visual_Studio/Tango.Core/CoreSettings.cs new file mode 100644 index 000000000..82261183a --- /dev/null +++ b/Software/Visual_Studio/Tango.Core/CoreSettings.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.Settings; + +namespace Tango.Core +{ + public class CoreSettings : SettingsBase + { + /// + /// Gets or sets the SQL server address. + /// + public String SQLServerAddress { get; set; } + + /// + /// Initializes a new instance of the class. + /// + public CoreSettings() + { + SQLServerAddress = "twine01\\SQLTWINE"; + } + } +} diff --git a/Software/Visual_Studio/Tango.Core/Tango.Core.csproj b/Software/Visual_Studio/Tango.Core/Tango.Core.csproj index 97fbe7fd8..b68925208 100644 --- a/Software/Visual_Studio/Tango.Core/Tango.Core.csproj +++ b/Software/Visual_Studio/Tango.Core/Tango.Core.csproj @@ -63,6 +63,7 @@ + @@ -121,6 +122,10 @@ {22f87980-e990-4686-be81-be63d562c4d5} Tango.Serialization + + {d8f1ad85-526a-4f50-b6dc-d437af63d8d8} + Tango.Settings + diff --git a/Software/Visual_Studio/Tango.DAL.Remote/Partials/RemoteDB.cs b/Software/Visual_Studio/Tango.DAL.Remote/Partials/RemoteDB.cs index 96ddf9550..3508e1137 100644 --- a/Software/Visual_Studio/Tango.DAL.Remote/Partials/RemoteDB.cs +++ b/Software/Visual_Studio/Tango.DAL.Remote/Partials/RemoteDB.cs @@ -4,6 +4,7 @@ using System.Data.Entity; using System.Linq; using System.Text; using System.Threading.Tasks; +using Tango.Core; using Tango.Settings; namespace Tango.DAL.Remote.DB @@ -48,7 +49,7 @@ namespace Tango.DAL.Remote.DB /// public static RemoteDB CreateDefault() { - return new RemoteDB(SettingsManager.Default.DataBase.SQLServerAddress, false); + return new RemoteDB(SettingsManager.Default.GetOrCreate().SQLServerAddress, false); } } } diff --git a/Software/Visual_Studio/Tango.Integration/IntegrationSettings.cs b/Software/Visual_Studio/Tango.Integration/IntegrationSettings.cs new file mode 100644 index 000000000..778a03d7b --- /dev/null +++ b/Software/Visual_Studio/Tango.Integration/IntegrationSettings.cs @@ -0,0 +1,43 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.Settings; + +namespace Tango.Integration +{ + public class IntegrationSettings : SettingsBase + { + /// + /// Gets or sets the external bridge service port. + /// + public int ExternalBridgeServicePort { get; set; } + + /// + /// Gets or sets the external bridge service discovery port. + /// + public int ExternalBridgeServiceDiscoveryPort { get; set; } + + /// + /// Gets or sets the name of the embedded device. + /// + public String EmbeddedDeviceName { get; set; } + + /// + /// Gets or sets a value indicating whether filter the detected USB machines via . + /// + public bool FilterExternalBridgeUsbMachines { get; set; } + + /// + /// Initializes a new instance of the class. + /// + public IntegrationSettings() + { + ExternalBridgeServicePort = 1984; + ExternalBridgeServiceDiscoveryPort = 8888; + EmbeddedDeviceName = "Tango USB Serial Port"; + FilterExternalBridgeUsbMachines = true; + } + } +} diff --git a/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs b/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs index 4ba69cc4c..a01375212 100644 --- a/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs +++ b/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs @@ -40,7 +40,7 @@ namespace Tango.Integration.Operation { EmbeddedLogManager = new LogManager(); - String folder = SettingsManager.DefaultFolder + "\\embedded logs"; + String folder = SettingsManager.Default.Folder + "\\embedded logs"; Directory.CreateDirectory(folder); FileLogger fileLogger = new FileLogger(folder, "embedded") { Enabled = true }; EmbeddedLogManager.RegisterLogger(fileLogger); diff --git a/Software/Visual_Studio/Tango.Integration/Services/ExternalBridgeScanner.cs b/Software/Visual_Studio/Tango.Integration/Services/ExternalBridgeScanner.cs index 43ce83b89..dfef25775 100644 --- a/Software/Visual_Studio/Tango.Integration/Services/ExternalBridgeScanner.cs +++ b/Software/Visual_Studio/Tango.Integration/Services/ExternalBridgeScanner.cs @@ -30,6 +30,7 @@ namespace Tango.Integration.Services private Thread _tcpDiscoveryThread; private Thread _usbDiscoveryThread; private UdpClient _server; + private IntegrationSettings _settings; private ObservableCollection _availableMachines; /// @@ -56,7 +57,8 @@ namespace Tango.Integration.Services /// public ExternalBridgeScanner() { - _server = new UdpClient(SettingsManager.Default.Integration.ExternalBridgeServiceDiscoveryPort); + _settings = SettingsManager.Default.GetOrCreate(); + _server = new UdpClient(_settings.ExternalBridgeServiceDiscoveryPort); AvailableMachines = new ObservableCollection(); } @@ -102,7 +104,7 @@ namespace Tango.Integration.Services { foreach (var device in COMPortInfo.EnumerateComPorts()) { - if (device.Description.Contains(SettingsManager.Default.Integration.EmbeddedDeviceName) || !SettingsManager.Default.Integration.FilterExternalBridgeUsbMachines) + if (device.Description.Contains(_settings.EmbeddedDeviceName) || !_settings.FilterExternalBridgeUsbMachines) { if (!AvailableMachines.OfType().ToList().Exists(x => x.ComPort == device.Port)) { diff --git a/Software/Visual_Studio/Tango.Integration/Services/ExternalBridgeTcpClient.cs b/Software/Visual_Studio/Tango.Integration/Services/ExternalBridgeTcpClient.cs index 12f3f1b64..579484418 100644 --- a/Software/Visual_Studio/Tango.Integration/Services/ExternalBridgeTcpClient.cs +++ b/Software/Visual_Studio/Tango.Integration/Services/ExternalBridgeTcpClient.cs @@ -71,7 +71,7 @@ namespace Tango.Integration.Services public override async Task Connect() { await Disconnect(); - Adapter = new TcpTransportAdapter(IPAddress, SettingsManager.Default.Integration.ExternalBridgeServicePort); + Adapter = new TcpTransportAdapter(IPAddress, SettingsManager.Default.GetOrCreate().ExternalBridgeServicePort); await base.Connect(); } diff --git a/Software/Visual_Studio/Tango.Integration/Tango.Integration.csproj b/Software/Visual_Studio/Tango.Integration/Tango.Integration.csproj index 29f5a8b5e..32ad179a9 100644 --- a/Software/Visual_Studio/Tango.Integration/Tango.Integration.csproj +++ b/Software/Visual_Studio/Tango.Integration/Tango.Integration.csproj @@ -82,6 +82,7 @@ + diff --git a/Software/Visual_Studio/Tango.Settings/DataBase.cs b/Software/Visual_Studio/Tango.Settings/DataBase.cs deleted file mode 100644 index 22bbfe9a9..000000000 --- a/Software/Visual_Studio/Tango.Settings/DataBase.cs +++ /dev/null @@ -1,28 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Tango.Settings -{ - /// - /// Represents global database settings. - /// - [Serializable] - public class DataBase - { - /// - /// Gets or sets the SQL server address. - /// - public String SQLServerAddress { get; set; } - - /// - /// Initializes a new instance of the class. - /// - public DataBase() - { - SQLServerAddress = "twine01\\SQLTWINE"; - } - } -} diff --git a/Software/Visual_Studio/Tango.Settings/Integration.cs b/Software/Visual_Studio/Tango.Settings/Integration.cs deleted file mode 100644 index d670cad8e..000000000 --- a/Software/Visual_Studio/Tango.Settings/Integration.cs +++ /dev/null @@ -1,45 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Tango.Settings -{ - /// - /// Represents the global integration settings. - /// - public class Integration - { - /// - /// Gets or sets the external bridge service port. - /// - public int ExternalBridgeServicePort { get; set; } - - /// - /// Gets or sets the external bridge service discovery port. - /// - public int ExternalBridgeServiceDiscoveryPort { get; set; } - - /// - /// Gets or sets the name of the embedded device. - /// - public String EmbeddedDeviceName { get; set; } - - /// - /// Gets or sets a value indicating whether filter the detected USB machines via . - /// - public bool FilterExternalBridgeUsbMachines { get; set; } - - /// - /// Initializes a new instance of the class. - /// - public Integration() - { - ExternalBridgeServicePort = 1984; - ExternalBridgeServiceDiscoveryPort = 8888; - EmbeddedDeviceName = "Tango USB Serial Port"; - FilterExternalBridgeUsbMachines = true; - } - } -} diff --git a/Software/Visual_Studio/Tango.Settings/MachineStudioSettings/DeveloperModule.cs b/Software/Visual_Studio/Tango.Settings/MachineStudioSettings/DeveloperModule.cs deleted file mode 100644 index 837dfcc2e..000000000 --- a/Software/Visual_Studio/Tango.Settings/MachineStudioSettings/DeveloperModule.cs +++ /dev/null @@ -1,15 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Tango.Settings.MachineStudioSettings -{ - public class DeveloperModule - { - public String LastSelectedMachineGuid { get; set; } - - public String LastSelectedJobGuid { get; set; } - } -} diff --git a/Software/Visual_Studio/Tango.Settings/MachineStudioSettings/MachineStudio.cs b/Software/Visual_Studio/Tango.Settings/MachineStudioSettings/MachineStudio.cs deleted file mode 100644 index 6895f30a1..000000000 --- a/Software/Visual_Studio/Tango.Settings/MachineStudioSettings/MachineStudio.cs +++ /dev/null @@ -1,85 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Tango.Core.Cryptography; -using Tango.Logging; - -namespace Tango.Settings.MachineStudioSettings -{ - /// - /// Represents the machine studio settings. - /// - public class MachineStudio - { - /// - /// Gets or sets the last login email. - /// - public String LastLoginEmail { get; set; } - - /// - /// Gets or sets the last login password. - /// - public String LastLoginPassword { get; set; } - - /// - /// Gets or sets a value indicating whether to save the user credentials. - /// - public bool RememberMe { get; set; } - - /// - /// Gets or sets the last virtual machine serial number. - /// - public String LastVirtualMachineSerialNumber { get; set; } - - /// - /// Gets or sets the update service address. - /// - public String UpdateServiceAddress { get; set; } - - /// - /// Gets or sets the logging categories. - /// - public List LoggingCategories { get; set; } - - /// - /// Gets or sets the synchronization module settings. - /// - public SynchronizationModule SynchronizationModule { get; set; } - - /// - /// Gets or sets the stubs module settings. - /// - public StubsModule StubsModule { get; set; } - - /// - /// Gets or sets the technician module settings. - /// - public TechnicianModule TechnicianModule { get; set; } - - /// - /// Gets or sets the developer module settings. - /// - public DeveloperModule DeveloperModule { get; set; } - - /// - /// Initializes a new instance of the class. - /// - public MachineStudio() - { - LoggingCategories = new List(); - - //LoggingCategories.Add(LogCategory.Critical); - //LoggingCategories.Add(LogCategory.Error); - //LoggingCategories.Add(LogCategory.General); - //LoggingCategories.Add(LogCategory.Warning); - - SynchronizationModule = new SynchronizationModule(); - StubsModule = new StubsModule(); - TechnicianModule = new TechnicianModule(); - DeveloperModule = new DeveloperModule(); - UpdateServiceAddress = "http://twine01/MachineStudioUpdateService/MachineStudioUpdateService.svc"; - } - } -} diff --git a/Software/Visual_Studio/Tango.Settings/MachineStudioSettings/StubsModule.cs b/Software/Visual_Studio/Tango.Settings/MachineStudioSettings/StubsModule.cs deleted file mode 100644 index b9263237a..000000000 --- a/Software/Visual_Studio/Tango.Settings/MachineStudioSettings/StubsModule.cs +++ /dev/null @@ -1,32 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Tango.Settings.MachineStudioSettings -{ - /// - /// Represents the machine studio stubs module settings. - /// - public class StubsModule - { - /// - /// Gets or sets the last selected port. - /// - public String SelectedPort { get; set; } - - /// - /// Gets or sets the last tabs. - /// - public List LastTabs { get; set; } - - /// - /// Initializes a new instance of the class. - /// - public StubsModule() - { - LastTabs = new List(); - } - } -} diff --git a/Software/Visual_Studio/Tango.Settings/MachineStudioSettings/SynchronizationModule.cs b/Software/Visual_Studio/Tango.Settings/MachineStudioSettings/SynchronizationModule.cs deleted file mode 100644 index c487fdd42..000000000 --- a/Software/Visual_Studio/Tango.Settings/MachineStudioSettings/SynchronizationModule.cs +++ /dev/null @@ -1,29 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Tango.Settings.MachineStudioSettings -{ - /// - /// Represents the machine studio synchronization module settings. - /// - public class SynchronizationModule - { - /// - /// Gets or sets the local master database file. - /// - public String LocalMasterDBFile { get; set; } - - /// - /// Gets or sets the local slave database file. - /// - public String LocalSlaveDBFile { get; set; } - - /// - /// Gets or sets the remote SQLite file. - /// - public String RemoteSQLiteFile { get; set; } - } -} diff --git a/Software/Visual_Studio/Tango.Settings/MachineStudioSettings/TechnicianModule.cs b/Software/Visual_Studio/Tango.Settings/MachineStudioSettings/TechnicianModule.cs deleted file mode 100644 index 4f3ced8d7..000000000 --- a/Software/Visual_Studio/Tango.Settings/MachineStudioSettings/TechnicianModule.cs +++ /dev/null @@ -1,23 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Tango.Settings.MachineStudioSettings -{ - public class TechnicianModule - { - public int GraphsDuration { get; set; } - - public int GraphsPullingInterval { get; set; } - - public String LasTechProjectFile { get; set; } - - public TechnicianModule() - { - GraphsDuration = 10; - GraphsPullingInterval = 30; - } - } -} diff --git a/Software/Visual_Studio/Tango.Settings/OLD/DataBase.cs b/Software/Visual_Studio/Tango.Settings/OLD/DataBase.cs new file mode 100644 index 000000000..22bbfe9a9 --- /dev/null +++ b/Software/Visual_Studio/Tango.Settings/OLD/DataBase.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.Settings +{ + /// + /// Represents global database settings. + /// + [Serializable] + public class DataBase + { + /// + /// Gets or sets the SQL server address. + /// + public String SQLServerAddress { get; set; } + + /// + /// Initializes a new instance of the class. + /// + public DataBase() + { + SQLServerAddress = "twine01\\SQLTWINE"; + } + } +} diff --git a/Software/Visual_Studio/Tango.Settings/OLD/Integration.cs b/Software/Visual_Studio/Tango.Settings/OLD/Integration.cs new file mode 100644 index 000000000..d670cad8e --- /dev/null +++ b/Software/Visual_Studio/Tango.Settings/OLD/Integration.cs @@ -0,0 +1,45 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.Settings +{ + /// + /// Represents the global integration settings. + /// + public class Integration + { + /// + /// Gets or sets the external bridge service port. + /// + public int ExternalBridgeServicePort { get; set; } + + /// + /// Gets or sets the external bridge service discovery port. + /// + public int ExternalBridgeServiceDiscoveryPort { get; set; } + + /// + /// Gets or sets the name of the embedded device. + /// + public String EmbeddedDeviceName { get; set; } + + /// + /// Gets or sets a value indicating whether filter the detected USB machines via . + /// + public bool FilterExternalBridgeUsbMachines { get; set; } + + /// + /// Initializes a new instance of the class. + /// + public Integration() + { + ExternalBridgeServicePort = 1984; + ExternalBridgeServiceDiscoveryPort = 8888; + EmbeddedDeviceName = "Tango USB Serial Port"; + FilterExternalBridgeUsbMachines = true; + } + } +} diff --git a/Software/Visual_Studio/Tango.Settings/OLD/MachineStudioSettings/DeveloperModule.cs b/Software/Visual_Studio/Tango.Settings/OLD/MachineStudioSettings/DeveloperModule.cs new file mode 100644 index 000000000..837dfcc2e --- /dev/null +++ b/Software/Visual_Studio/Tango.Settings/OLD/MachineStudioSettings/DeveloperModule.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.Settings.MachineStudioSettings +{ + public class DeveloperModule + { + public String LastSelectedMachineGuid { get; set; } + + public String LastSelectedJobGuid { get; set; } + } +} diff --git a/Software/Visual_Studio/Tango.Settings/OLD/MachineStudioSettings/MachineStudio.cs b/Software/Visual_Studio/Tango.Settings/OLD/MachineStudioSettings/MachineStudio.cs new file mode 100644 index 000000000..6895f30a1 --- /dev/null +++ b/Software/Visual_Studio/Tango.Settings/OLD/MachineStudioSettings/MachineStudio.cs @@ -0,0 +1,85 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.Core.Cryptography; +using Tango.Logging; + +namespace Tango.Settings.MachineStudioSettings +{ + /// + /// Represents the machine studio settings. + /// + public class MachineStudio + { + /// + /// Gets or sets the last login email. + /// + public String LastLoginEmail { get; set; } + + /// + /// Gets or sets the last login password. + /// + public String LastLoginPassword { get; set; } + + /// + /// Gets or sets a value indicating whether to save the user credentials. + /// + public bool RememberMe { get; set; } + + /// + /// Gets or sets the last virtual machine serial number. + /// + public String LastVirtualMachineSerialNumber { get; set; } + + /// + /// Gets or sets the update service address. + /// + public String UpdateServiceAddress { get; set; } + + /// + /// Gets or sets the logging categories. + /// + public List LoggingCategories { get; set; } + + /// + /// Gets or sets the synchronization module settings. + /// + public SynchronizationModule SynchronizationModule { get; set; } + + /// + /// Gets or sets the stubs module settings. + /// + public StubsModule StubsModule { get; set; } + + /// + /// Gets or sets the technician module settings. + /// + public TechnicianModule TechnicianModule { get; set; } + + /// + /// Gets or sets the developer module settings. + /// + public DeveloperModule DeveloperModule { get; set; } + + /// + /// Initializes a new instance of the class. + /// + public MachineStudio() + { + LoggingCategories = new List(); + + //LoggingCategories.Add(LogCategory.Critical); + //LoggingCategories.Add(LogCategory.Error); + //LoggingCategories.Add(LogCategory.General); + //LoggingCategories.Add(LogCategory.Warning); + + SynchronizationModule = new SynchronizationModule(); + StubsModule = new StubsModule(); + TechnicianModule = new TechnicianModule(); + DeveloperModule = new DeveloperModule(); + UpdateServiceAddress = "http://twine01/MachineStudioUpdateService/MachineStudioUpdateService.svc"; + } + } +} diff --git a/Software/Visual_Studio/Tango.Settings/OLD/MachineStudioSettings/StubsModule.cs b/Software/Visual_Studio/Tango.Settings/OLD/MachineStudioSettings/StubsModule.cs new file mode 100644 index 000000000..b9263237a --- /dev/null +++ b/Software/Visual_Studio/Tango.Settings/OLD/MachineStudioSettings/StubsModule.cs @@ -0,0 +1,32 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.Settings.MachineStudioSettings +{ + /// + /// Represents the machine studio stubs module settings. + /// + public class StubsModule + { + /// + /// Gets or sets the last selected port. + /// + public String SelectedPort { get; set; } + + /// + /// Gets or sets the last tabs. + /// + public List LastTabs { get; set; } + + /// + /// Initializes a new instance of the class. + /// + public StubsModule() + { + LastTabs = new List(); + } + } +} diff --git a/Software/Visual_Studio/Tango.Settings/OLD/MachineStudioSettings/SynchronizationModule.cs b/Software/Visual_Studio/Tango.Settings/OLD/MachineStudioSettings/SynchronizationModule.cs new file mode 100644 index 000000000..c487fdd42 --- /dev/null +++ b/Software/Visual_Studio/Tango.Settings/OLD/MachineStudioSettings/SynchronizationModule.cs @@ -0,0 +1,29 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.Settings.MachineStudioSettings +{ + /// + /// Represents the machine studio synchronization module settings. + /// + public class SynchronizationModule + { + /// + /// Gets or sets the local master database file. + /// + public String LocalMasterDBFile { get; set; } + + /// + /// Gets or sets the local slave database file. + /// + public String LocalSlaveDBFile { get; set; } + + /// + /// Gets or sets the remote SQLite file. + /// + public String RemoteSQLiteFile { get; set; } + } +} diff --git a/Software/Visual_Studio/Tango.Settings/OLD/MachineStudioSettings/TechnicianModule.cs b/Software/Visual_Studio/Tango.Settings/OLD/MachineStudioSettings/TechnicianModule.cs new file mode 100644 index 000000000..4f3ced8d7 --- /dev/null +++ b/Software/Visual_Studio/Tango.Settings/OLD/MachineStudioSettings/TechnicianModule.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.Settings.MachineStudioSettings +{ + public class TechnicianModule + { + public int GraphsDuration { get; set; } + + public int GraphsPullingInterval { get; set; } + + public String LasTechProjectFile { get; set; } + + public TechnicianModule() + { + GraphsDuration = 10; + GraphsPullingInterval = 30; + } + } +} diff --git a/Software/Visual_Studio/Tango.Settings/OLD/SettingsCollection.cs b/Software/Visual_Studio/Tango.Settings/OLD/SettingsCollection.cs new file mode 100644 index 000000000..f72e70647 --- /dev/null +++ b/Software/Visual_Studio/Tango.Settings/OLD/SettingsCollection.cs @@ -0,0 +1,46 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.Serialization; +using Tango.Settings.MachineStudioSettings; + +namespace Tango.Settings +{ + [Serializable] + public class SettingsCollection + { + /// + /// Gets or sets the data base settings. + /// + public DataBase DataBase { get; set; } + + /// + /// Gets or sets the machine studio settings. + /// + public MachineStudio MachineStudio { get; set; } + + /// + /// Gets or sets the stubs UI utility settings. + /// + public StubsUI StubsUI { get; set; } + + /// + /// Gets or sets the integration settings. + /// + public Integration Integration { get; set; } + + /// + /// Initializes a new instance of the class. + /// + public SettingsCollection() + { + DataBase = new DataBase(); + MachineStudio = new MachineStudio(); + StubsUI = new StubsUI(); + Integration = new Integration(); + } + } +} diff --git a/Software/Visual_Studio/Tango.Settings/OLD/SettingsManager.cs b/Software/Visual_Studio/Tango.Settings/OLD/SettingsManager.cs new file mode 100644 index 000000000..7bc15d950 --- /dev/null +++ b/Software/Visual_Studio/Tango.Settings/OLD/SettingsManager.cs @@ -0,0 +1,162 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +using Tango.Logging; +using Tango.Serialization; + +namespace Tango.Settings +{ + /// + /// Represents a settings manager for loading and saving application settings. + /// + public static class SettingsManager + { + private static LogManager LogManager = LogManager.Default; + + /// + /// Gets or sets a value indicating whether the settings manager is initialized. + /// + public static bool IsInitialized { get; private set; } + + /// + /// Gets or sets the default settings. + /// + /// + /// The default. + /// + public static SettingsCollection Default { get; private set; } + + /// + /// Gets or sets the default file path. + /// + /// + /// The default file path. + /// + public static String DefaultFilePath { get; private set; } + + /// + /// Gets or sets the default folder for application settings. + /// + public static String DefaultFolder { get; private set; } + + /// + /// Saves application settings to XML file. + /// + /// The path to the XML file. + /// The instance of the SettingsCollection to save. + public static void SaveToXML(String filePath, SettingsCollection stCollection) + { + LogManager.Log("Saving application configuration to " + "'" + filePath + "'"); + XmlDataSerializer serializer = new XmlDataSerializer(); + serializer.SerializeToFile(stCollection, filePath); + } + + /// + /// Loads application settings from XML file. + /// + /// The file path. + /// + public static SettingsCollection LoadFromXML(String filePath) + { + LogManager.Log("Loading application configuration from " + "'" + filePath + "'"); + XmlDataSerializer serialier = new XmlDataSerializer(); + return serialier.DeserializeFromFile(filePath); + } + + /// + /// Saves the default settings. + /// + public static void SaveDefaultSettings() + { + SaveToXML(DefaultFilePath, Default); + } + + /// + /// Restores to default. + /// + public static void RestoreToDefault() + { + Default = new SettingsCollection(); + SaveDefaultSettings(); + } + + /// + /// Initializes the class. + /// + static SettingsManager() + { + Initialize(); + } + + /// + /// Initializes the settings manager. + /// + private static void Initialize() + { + if (IsInitialized) return; + + IsInitialized = true; + + LogManager.Log("Initializing application configuration..."); + + DefaultFilePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Twine", "Tango", "Settings.xml"); + DefaultFolder = Path.GetDirectoryName(DefaultFilePath); + + bool waited = false; + + Retry: + + try + { + Default = LoadFromXML(DefaultFilePath); + } + catch (Exception ex) + { + if (!waited) + { + LogManager.Log(ex, "Could not load application configuration. Retrying in 1 second..."); + waited = true; + Thread.Sleep(1000); + goto Retry; + } + else + { + LogManager.Log(ex, "Could not load application configuration."); + } + + try + { + LogManager.Log("Creating application configuration directory structure..."); + Directory.CreateDirectory(DefaultFolder); + } + catch (Exception ex2) + { + LogManager.Log(ex2, "Could not generate directory structure."); + } + } + + if (Default == null) + { + Default = new SettingsCollection(); + + try + { + LogManager.Log("Generating default configuration file."); + SaveToXML(DefaultFilePath, Default); + } + catch (Exception ex) + { + LogManager.Log(ex, "Could not generate default configuration file."); + } + } + else + { + LogManager.Log("Application configuration loaded successfully."); + } + } + } +} diff --git a/Software/Visual_Studio/Tango.Settings/OLD/StubsUI.cs b/Software/Visual_Studio/Tango.Settings/OLD/StubsUI.cs new file mode 100644 index 000000000..9944ffc11 --- /dev/null +++ b/Software/Visual_Studio/Tango.Settings/OLD/StubsUI.cs @@ -0,0 +1,43 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.Settings +{ + /// + /// Represents the stubs UI utility settings. + /// + public class StubsUI + { + /// + /// Gets or sets the selected port. + /// + public String SelectedPort { get; set; } + + /// + /// Gets or sets the baud rate. + /// + public int BaudRate { get; set; } + + /// + /// Gets or sets the last tabs. + /// + public List LastTabs { get; set; } + + /// + /// Gets or sets a value indicating whether [automatic log response]. + /// + public bool AutoLogResponse { get; set; } + + /// + /// Initializes a new instance of the class. + /// + public StubsUI() + { + BaudRate = 9600; + LastTabs = new List(); + } + } +} diff --git a/Software/Visual_Studio/Tango.Settings/SettingsBase.cs b/Software/Visual_Studio/Tango.Settings/SettingsBase.cs new file mode 100644 index 000000000..29ec767c9 --- /dev/null +++ b/Software/Visual_Studio/Tango.Settings/SettingsBase.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.Settings +{ + /// + /// Represents a settings object base class. + /// + public abstract class SettingsBase + { + internal Action SaveAction { get; set; } + + /// + /// Saves settings. + /// + /// This settings instance is not registered with any settings manager. + public virtual void Save() + { + if (SaveAction == null) + { + throw new InvalidOperationException("This settings instance is not registered with any settings manager."); + } + } + } +} diff --git a/Software/Visual_Studio/Tango.Settings/SettingsCollection.cs b/Software/Visual_Studio/Tango.Settings/SettingsCollection.cs deleted file mode 100644 index f72e70647..000000000 --- a/Software/Visual_Studio/Tango.Settings/SettingsCollection.cs +++ /dev/null @@ -1,46 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Tango.Serialization; -using Tango.Settings.MachineStudioSettings; - -namespace Tango.Settings -{ - [Serializable] - public class SettingsCollection - { - /// - /// Gets or sets the data base settings. - /// - public DataBase DataBase { get; set; } - - /// - /// Gets or sets the machine studio settings. - /// - public MachineStudio MachineStudio { get; set; } - - /// - /// Gets or sets the stubs UI utility settings. - /// - public StubsUI StubsUI { get; set; } - - /// - /// Gets or sets the integration settings. - /// - public Integration Integration { get; set; } - - /// - /// Initializes a new instance of the class. - /// - public SettingsCollection() - { - DataBase = new DataBase(); - MachineStudio = new MachineStudio(); - StubsUI = new StubsUI(); - Integration = new Integration(); - } - } -} diff --git a/Software/Visual_Studio/Tango.Settings/SettingsManager.cs b/Software/Visual_Studio/Tango.Settings/SettingsManager.cs index 7bc15d950..1f0083bb5 100644 --- a/Software/Visual_Studio/Tango.Settings/SettingsManager.cs +++ b/Software/Visual_Studio/Tango.Settings/SettingsManager.cs @@ -1,162 +1,128 @@ -using System; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Text; -using System.Threading; using System.Threading.Tasks; -using Tango.Logging; -using Tango.Serialization; namespace Tango.Settings { /// - /// Represents a settings manager for loading and saving application settings. + /// Represents a settings manager capable of holding a collection of settings objects, saving and loading them using JSON. /// - public static class SettingsManager + public class SettingsManager { - private static LogManager LogManager = LogManager.Default; + #region Singleton + private static SettingsManager _default; /// - /// Gets or sets a value indicating whether the settings manager is initialized. + /// Gets the default settings manager instance. /// - public static bool IsInitialized { get; private set; } + public static SettingsManager Default + { + get + { + if (_default == null) + { + _default = new SettingsManager(); + } - /// - /// Gets or sets the default settings. - /// - /// - /// The default. - /// - public static SettingsCollection Default { get; private set; } + return _default; + } + } - /// - /// Gets or sets the default file path. - /// - /// - /// The default file path. - /// - public static String DefaultFilePath { get; private set; } + #endregion - /// - /// Gets or sets the default folder for application settings. - /// - public static String DefaultFolder { get; private set; } + private List _settingsCollection; + private JsonSerializerSettings _jsonSettings; + private bool _loaded; /// - /// Saves application settings to XML file. + /// Gets or sets the settings file path. /// - /// The path to the XML file. - /// The instance of the SettingsCollection to save. - public static void SaveToXML(String filePath, SettingsCollection stCollection) - { - LogManager.Log("Saving application configuration to " + "'" + filePath + "'"); - XmlDataSerializer serializer = new XmlDataSerializer(); - serializer.SerializeToFile(stCollection, filePath); - } + public String FilePath { get; protected set; } /// - /// Loads application settings from XML file. + /// Gets or sets the settings folder. /// - /// The file path. - /// - public static SettingsCollection LoadFromXML(String filePath) - { - LogManager.Log("Loading application configuration from " + "'" + filePath + "'"); - XmlDataSerializer serialier = new XmlDataSerializer(); - return serialier.DeserializeFromFile(filePath); - } + public String Folder { get; protected set; } /// - /// Saves the default settings. + /// Prevents a default instance of the class from being created. /// - public static void SaveDefaultSettings() + private SettingsManager() { - SaveToXML(DefaultFilePath, Default); - } + FilePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Twine", "Tango", "Settings.json"); + Folder = Path.GetDirectoryName(FilePath); + _settingsCollection = new List(); - /// - /// Restores to default. - /// - public static void RestoreToDefault() - { - Default = new SettingsCollection(); - SaveDefaultSettings(); + _jsonSettings = new JsonSerializerSettings + { + TypeNameHandling = TypeNameHandling.All, + Formatting = Formatting.Indented, + }; + + _jsonSettings.Converters.Add(new StringEnumConverter(false)); } - /// - /// Initializes the class. - /// - static SettingsManager() + private void EnsureLoaded() { - Initialize(); + if (!_loaded) + { + Load(); + } } /// - /// Initializes the settings manager. + /// Gets or creates the specified settings object type. /// - private static void Initialize() + /// + /// + public T GetOrCreate() where T : SettingsBase { - if (IsInitialized) return; - - IsInitialized = true; + EnsureLoaded(); - LogManager.Log("Initializing application configuration..."); + var settings = _settingsCollection.SingleOrDefault(x => x.GetType() == typeof(T)) as T; - DefaultFilePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Twine", "Tango", "Settings.xml"); - DefaultFolder = Path.GetDirectoryName(DefaultFilePath); - - bool waited = false; - - Retry: - - try + if (settings == null) { - Default = LoadFromXML(DefaultFilePath); + settings = Activator.CreateInstance(); + settings.SaveAction = Save; + _settingsCollection.Add(settings); } - catch (Exception ex) - { - if (!waited) - { - LogManager.Log(ex, "Could not load application configuration. Retrying in 1 second..."); - waited = true; - Thread.Sleep(1000); - goto Retry; - } - else - { - LogManager.Log(ex, "Could not load application configuration."); - } - try - { - LogManager.Log("Creating application configuration directory structure..."); - Directory.CreateDirectory(DefaultFolder); - } - catch (Exception ex2) - { - LogManager.Log(ex2, "Could not generate directory structure."); - } - } + return settings; + } - if (Default == null) + /// + /// Loads the settings from the . + /// + protected virtual void Load() + { + if (File.Exists(FilePath)) { - Default = new SettingsCollection(); + _settingsCollection = JsonConvert.DeserializeObject>(File.ReadAllText(FilePath), _jsonSettings); - try + foreach (var settings in _settingsCollection) { - LogManager.Log("Generating default configuration file."); - SaveToXML(DefaultFilePath, Default); + settings.SaveAction = Save; } - catch (Exception ex) - { - LogManager.Log(ex, "Could not generate default configuration file."); - } - } - else - { - LogManager.Log("Application configuration loaded successfully."); } + + _loaded = true; + } + + /// + /// Saves settings. + /// + public virtual void Save() + { + EnsureLoaded(); + + String json = JsonConvert.SerializeObject(_settingsCollection, _jsonSettings); + File.WriteAllText(FilePath, json); } } } diff --git a/Software/Visual_Studio/Tango.Settings/StubsUI.cs b/Software/Visual_Studio/Tango.Settings/StubsUI.cs deleted file mode 100644 index 9944ffc11..000000000 --- a/Software/Visual_Studio/Tango.Settings/StubsUI.cs +++ /dev/null @@ -1,43 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Tango.Settings -{ - /// - /// Represents the stubs UI utility settings. - /// - public class StubsUI - { - /// - /// Gets or sets the selected port. - /// - public String SelectedPort { get; set; } - - /// - /// Gets or sets the baud rate. - /// - public int BaudRate { get; set; } - - /// - /// Gets or sets the last tabs. - /// - public List LastTabs { get; set; } - - /// - /// Gets or sets a value indicating whether [automatic log response]. - /// - public bool AutoLogResponse { get; set; } - - /// - /// Initializes a new instance of the class. - /// - public StubsUI() - { - BaudRate = 9600; - LastTabs = new List(); - } - } -} diff --git a/Software/Visual_Studio/Tango.Settings/Tango.Settings.csproj b/Software/Visual_Studio/Tango.Settings/Tango.Settings.csproj index fa9eb1f61..6cfa77c3a 100644 --- a/Software/Visual_Studio/Tango.Settings/Tango.Settings.csproj +++ b/Software/Visual_Studio/Tango.Settings/Tango.Settings.csproj @@ -30,6 +30,9 @@ 4 + + ..\packages\Newtonsoft.Json.8.0.3\lib\net45\Newtonsoft.Json.dll + @@ -43,31 +46,18 @@ GlobalVersionInfo.cs - - - - - - - - + - - - {a34ee0f0-649d-41c8-8489-b6f1cc6924ee} - Tango.Core - {bc932dbd-7cdb-488c-99e4-f02cf441f55e} Tango.Logging - - {22f87980-e990-4686-be81-be63d562c4d5} - Tango.Serialization - + + + \ No newline at end of file diff --git a/Software/Visual_Studio/Tango.Settings/packages.config b/Software/Visual_Studio/Tango.Settings/packages.config new file mode 100644 index 000000000..92167d083 --- /dev/null +++ b/Software/Visual_Studio/Tango.Settings/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/Software/Visual_Studio/Tango.Synchronization/Remote/RemoteDBSynchronizer.cs b/Software/Visual_Studio/Tango.Synchronization/Remote/RemoteDBSynchronizer.cs index 75d28af5b..09f7fe619 100644 --- a/Software/Visual_Studio/Tango.Synchronization/Remote/RemoteDBSynchronizer.cs +++ b/Software/Visual_Studio/Tango.Synchronization/Remote/RemoteDBSynchronizer.cs @@ -7,6 +7,7 @@ using remote = Tango.DAL.Remote.DB; using local = Tango.DAL.Local.DB; using Tango.Settings; using Tango.Synchronization.Local; +using Tango.Core; namespace Tango.Synchronization.Remote { @@ -31,7 +32,7 @@ namespace Tango.Synchronization.Remote sqlite.ClearDataBase(); } - using (var remoteDB = new remote.RemoteDB(SettingsManager.Default.DataBase.SQLServerAddress, false)) + using (var remoteDB = new remote.RemoteDB(SettingsManager.Default.GetOrCreate().SQLServerAddress, false)) { using (var localDB = new local.LocalDB(sqliteDbFile)) { diff --git a/Software/Visual_Studio/Tango.UnitTesting/DAL_TST.cs b/Software/Visual_Studio/Tango.UnitTesting/DAL_TST.cs index 88ea53900..df6028b2e 100644 --- a/Software/Visual_Studio/Tango.UnitTesting/DAL_TST.cs +++ b/Software/Visual_Studio/Tango.UnitTesting/DAL_TST.cs @@ -3,6 +3,7 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; using Tango.DAL; using System.Linq; using Tango.Settings; +using Tango.Core; namespace Tango.UnitTesting { @@ -15,7 +16,7 @@ namespace Tango.UnitTesting { String guid = Guid.NewGuid().ToString(); - using (var db = new DAL.Remote.DB.RemoteDB(SettingsManager.Default.DataBase.SQLServerAddress, false)) + using (var db = new DAL.Remote.DB.RemoteDB(SettingsManager.Default.GetOrCreate().SQLServerAddress, false)) { var action = new DAL.Remote.DB.ACTION_TYPES(); action.CODE = 1; @@ -28,7 +29,7 @@ namespace Tango.UnitTesting db.SaveChanges(); } - using (var db = new DAL.Remote.DB.RemoteDB(SettingsManager.Default.DataBase.SQLServerAddress, false)) + using (var db = new DAL.Remote.DB.RemoteDB(SettingsManager.Default.GetOrCreate().SQLServerAddress, false)) { var action = db.ACTION_TYPES.Single(x => x.GUID == guid); db.ACTION_TYPES.Remove(action); diff --git a/Software/Visual_Studio/Tango.UnitTesting/Synchronization_TST.cs b/Software/Visual_Studio/Tango.UnitTesting/Synchronization_TST.cs index 3b949cf90..5135c5954 100644 --- a/Software/Visual_Studio/Tango.UnitTesting/Synchronization_TST.cs +++ b/Software/Visual_Studio/Tango.UnitTesting/Synchronization_TST.cs @@ -8,6 +8,7 @@ using remote = Tango.DAL.Remote.DB; using local = Tango.DAL.Local.DB; using Tango.Synchronization.Remote; using Tango.Settings; +using Tango.Core; namespace Tango.UnitTesting { @@ -20,7 +21,7 @@ namespace Tango.UnitTesting { var console = Helper.InitializeLogging(true); - using (var remoteDB = new remote.RemoteDB(SettingsManager.Default.DataBase.SQLServerAddress, false)) + using (var remoteDB = new remote.RemoteDB(SettingsManager.Default.GetOrCreate().SQLServerAddress, false)) { using (var localDB = new local.LocalDB(Helper.GetSQLiteFilePath())) { @@ -44,7 +45,7 @@ namespace Tango.UnitTesting [TestMethod] public void Generate_Demo_Remote_Machine() { - using (var remoteDB = new remote.RemoteDB(SettingsManager.Default.DataBase.SQLServerAddress, false)) + using (var remoteDB = new remote.RemoteDB(SettingsManager.Default.GetOrCreate().SQLServerAddress, false)) { var organization = new remote.ORGANIZATION() { diff --git a/Software/Visual_Studio/Utilities/Tango.DBObservablesGenerator.CLI/ObservablesGenerator.cs b/Software/Visual_Studio/Utilities/Tango.DBObservablesGenerator.CLI/ObservablesGenerator.cs index 75cfffe50..fbe3af2e5 100644 --- a/Software/Visual_Studio/Utilities/Tango.DBObservablesGenerator.CLI/ObservablesGenerator.cs +++ b/Software/Visual_Studio/Utilities/Tango.DBObservablesGenerator.CLI/ObservablesGenerator.cs @@ -12,6 +12,7 @@ using Tango.DAL.Remote.DB; using Tango.Settings; using Humanizer; using System.Globalization; +using Tango.Core; namespace Tango.DBObservablesGenerator.CLI { @@ -99,7 +100,7 @@ namespace Tango.DBObservablesGenerator.CLI //Generate Entities... //Generate Enumerations... - using (RemoteDB db = new RemoteDB(SettingsManager.Default.DataBase.SQLServerAddress, false)) + using (RemoteDB db = new RemoteDB(SettingsManager.Default.GetOrCreate().SQLServerAddress, false)) { foreach (var tableProp in db.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance).Where(x => x.PropertyType.IsGenericType)) { @@ -266,7 +267,7 @@ namespace Tango.DBObservablesGenerator.CLI //Generate Entities... //Generate Enumerations... - using (RemoteDB db = new RemoteDB(SettingsManager.Default.DataBase.SQLServerAddress, false)) + using (RemoteDB db = new RemoteDB(SettingsManager.Default.GetOrCreate().SQLServerAddress, false)) { foreach (var tableProp in db.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance).Where(x => x.PropertyType.IsGenericType)) { diff --git a/Software/Visual_Studio/Utilities/Tango.SQLiteGenerator.CLI/Program.cs b/Software/Visual_Studio/Utilities/Tango.SQLiteGenerator.CLI/Program.cs index 242cdcfa9..9c39eeac6 100644 --- a/Software/Visual_Studio/Utilities/Tango.SQLiteGenerator.CLI/Program.cs +++ b/Software/Visual_Studio/Utilities/Tango.SQLiteGenerator.CLI/Program.cs @@ -4,6 +4,7 @@ using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; +using Tango.Core; using Tango.DAL.Remote.DB; using Tango.Settings; using Tango.Synchronization; @@ -21,7 +22,7 @@ namespace Tango.SQLiteGenerator.CLI bool completed = false; - String connectionString = SettingsManager.Default.DataBase.SQLServerAddress; + String connectionString = SettingsManager.Default.GetOrCreate().SQLServerAddress; Console.WriteLine("Connecting to " + connectionString + "..."); diff --git a/Software/Visual_Studio/Utilities/Tango.SQLiteGenerator.CLI/Tango.SQLiteGenerator.CLI.csproj b/Software/Visual_Studio/Utilities/Tango.SQLiteGenerator.CLI/Tango.SQLiteGenerator.CLI.csproj index 46b458c90..e19a15436 100644 --- a/Software/Visual_Studio/Utilities/Tango.SQLiteGenerator.CLI/Tango.SQLiteGenerator.CLI.csproj +++ b/Software/Visual_Studio/Utilities/Tango.SQLiteGenerator.CLI/Tango.SQLiteGenerator.CLI.csproj @@ -57,6 +57,10 @@ + + {a34ee0f0-649d-41c8-8489-b6f1cc6924ee} + Tango.Core + {38197109-8610-4d3f-92b9-16d48df94d7c} Tango.DAL.Remote diff --git a/Software/Visual_Studio/Utilities/Tango.Stubs.UI/StubsUISettings.cs b/Software/Visual_Studio/Utilities/Tango.Stubs.UI/StubsUISettings.cs new file mode 100644 index 000000000..62d77a012 --- /dev/null +++ b/Software/Visual_Studio/Utilities/Tango.Stubs.UI/StubsUISettings.cs @@ -0,0 +1,42 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.Settings; +using Tango.Transport.Adapters; + +namespace Tango.Stubs.UI +{ + public class StubsUISettings : SettingsBase + { + /// + /// Gets or sets the selected port. + /// + public String SelectedPort { get; set; } + + /// + /// Gets or sets the baud rate. + /// + public UsbSerialBaudRates BaudRate { get; set; } + + /// + /// Gets or sets the last tabs. + /// + public List LastTabs { get; set; } + + /// + /// Gets or sets a value indicating whether [automatic log response]. + /// + public bool AutoLogResponse { get; set; } + + /// + /// Initializes a new instance of the class. + /// + public StubsUISettings() + { + BaudRate = UsbSerialBaudRates.BR_9600; + LastTabs = new List(); + } + } +} diff --git a/Software/Visual_Studio/Utilities/Tango.Stubs.UI/Tango.Stubs.UI.csproj b/Software/Visual_Studio/Utilities/Tango.Stubs.UI/Tango.Stubs.UI.csproj index 1fb840e90..d4b6391db 100644 --- a/Software/Visual_Studio/Utilities/Tango.Stubs.UI/Tango.Stubs.UI.csproj +++ b/Software/Visual_Studio/Utilities/Tango.Stubs.UI/Tango.Stubs.UI.csproj @@ -87,6 +87,7 @@ + diff --git a/Software/Visual_Studio/Utilities/Tango.Stubs.UI/ViewModels/MainViewVM.cs b/Software/Visual_Studio/Utilities/Tango.Stubs.UI/ViewModels/MainViewVM.cs index 3bcdc823f..a2a9cf811 100644 --- a/Software/Visual_Studio/Utilities/Tango.Stubs.UI/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/Utilities/Tango.Stubs.UI/ViewModels/MainViewVM.cs @@ -32,6 +32,7 @@ namespace Tango.Stubs.UI.ViewModels private UsbTransportAdapter _adapter; //Holds the USB transport adapter. private StubManager _stubManager; private TextBox _logTextBox; + private StubsUISettings _settings; #region Properties @@ -234,6 +235,8 @@ namespace Tango.Stubs.UI.ViewModels /// public MainViewVM() { + _settings = SettingsManager.Default.GetOrCreate(); + Examples = new List(); CodeTabs = new ObservableCollection(); NewCommand = new RelayCommand(CreateNewTab); @@ -317,15 +320,15 @@ namespace Tango.Stubs.UI.ViewModels Ports.Add("COM" + i); } - SelectedPort = SettingsManager.Default.StubsUI.SelectedPort != null ? SettingsManager.Default.StubsUI.SelectedPort : Ports.First(); - BaudRate = (UsbSerialBaudRates)SettingsManager.Default.StubsUI.BaudRate; - AppendLogAuto = SettingsManager.Default.StubsUI.AutoLogResponse; + SelectedPort = _settings.SelectedPort != null ? _settings.SelectedPort : Ports.First(); + BaudRate = _settings.BaudRate; + AppendLogAuto = _settings.AutoLogResponse; Status = "Ready"; - if (SettingsManager.Default.StubsUI.LastTabs.Count > 0) + if (_settings.LastTabs.Count > 0) { - foreach (var file in SettingsManager.Default.StubsUI.LastTabs) + foreach (var file in _settings.LastTabs) { if (File.Exists(file)) { @@ -754,11 +757,11 @@ namespace Tango.Stubs.UI.ViewModels private void Current_Exit(object sender, ExitEventArgs e) { - SettingsManager.Default.StubsUI.AutoLogResponse = AppendLogAuto; - SettingsManager.Default.StubsUI.SelectedPort = SelectedPort; - SettingsManager.Default.StubsUI.BaudRate = BaudRate.ToInt32(); - SettingsManager.Default.StubsUI.LastTabs = CodeTabs.Select(x => x.File).ToList(); - SettingsManager.SaveDefaultSettings(); + _settings.AutoLogResponse = AppendLogAuto; + _settings.SelectedPort = SelectedPort; + _settings.BaudRate = BaudRate; + _settings.LastTabs = CodeTabs.Select(x => x.File).ToList(); + _settings.Save(); } private void AppendTextLog(String log) -- cgit v1.3.1