public override bool Equals(Object other) { SettingsPath path = other as SettingsPath; if (path != null) { return(this.Path.Equals(path.Path)); } return(false); }
public SettingsPathViewModel(SettingsPath path, SettingsPathType type) { if (path == null) throw new ArgumentNullException("path"); m_path = path; m_path.PropertyChanged += new PropertyChangedEventHandler(m_path_PropertyChanged); m_type = type; }
protected void saveChangesClickedHandler (object sender, EventArgs ev) { //this could use some validation, but really- someone would have to be very silly to screw this up! settingsRef.DefaultExperiment = tbx_defaultExperimentPath.Text; settingsRef.DefaultExperimentsDirectory = tbx_defaultExperimentDirectory.Text; // get and store the components directories: settingsRef.ComponentPaths.Clear(); foreach(SettingsPath sp in temporaryComponentDirectories) settingsRef.ComponentPaths.Add(sp); Gtk.TreeIter iter; componentDirectoryModel.GetIterFirst(out iter); if(iter.Stamp!=0) do { SettingsPath sp = new SettingsPath(false,componentDirectoryModel.GetValue (iter, 0).ToString()); settingsRef.ComponentPaths.Add(sp); }while(componentDirectoryModel.IterNext(ref iter)); // get and store the type directories settingsRef.TypePaths.Clear(); foreach(SettingsPath sp in temporaryTypesDirectories) settingsRef.TypePaths.Add(sp); typeDirectoryModel.GetIterFirst(out iter); if(iter.Stamp!=0) do { SettingsPath sp = new SettingsPath(false,typeDirectoryModel.GetValue(iter,0).ToString()); settingsRef.TypePaths.Add(sp); }while(typeDirectoryModel.IterNext(ref iter)); TraceLab.Core.Settings.Settings.SaveSettings(this.settingsRef); this.Destroy(); }
private bool InitViewModel() { bool startTraceLab = true; var settings = TraceLab.Core.Settings.Settings.GetSettings(); for (int i = 0; i < TypeDirectories.Count; ++i) { var newSettingPath = new TraceLab.Core.Settings.SettingsPath(true, TypeDirectories[i]); if (!settings.TypePaths.Contains(newSettingPath)) { settings.TypePaths.Insert(i, newSettingPath); } } for (int i = 0; i < ComponentDirectories.Count; ++i) { var newSettingPath = new TraceLab.Core.Settings.SettingsPath(true, ComponentDirectories[i]); if (!settings.ComponentPaths.Contains(newSettingPath)) { settings.ComponentPaths.Insert(i, newSettingPath); } } for (int i = 0; i < PackageDirectories.Count; ++i) { settings.PackagePaths.Insert(i, new TraceLab.Core.Settings.SettingsPath(true, PackageDirectories[i])); } TraceLab.Core.PackageSystem.PackageManager.Instance.SetPackageLocations(settings.PackagePaths); TraceLab.Core.PackageSystem.PackageManager.Instance.ScanForPackages(); // Install any packages that were queued at the start var packagesDir = settings.PackagePaths.LastOrDefault(); if (PackagesToInstall.Count > 0) { UnpackNewPackagesIn((string)packagesDir); } /* * if (UnpackNewPackagesIn((string)packagesDir)) * { * System.Windows.Forms.MessageBox.Show("New package(s) have been installed. TraceLab needs to be re-launched.", * "Closing TraceLab", System.Windows.Forms.MessageBoxButtons.OK, * System.Windows.Forms.MessageBoxIcon.Exclamation); * startTraceLab = false; * } * else * { * System.Windows.Forms.DialogResult result = System.Windows.Forms.MessageBox.Show("Would you like to continue openning TraceLab?", * "Start TraceLab", System.Windows.Forms.MessageBoxButtons.YesNo, * System.Windows.Forms.MessageBoxIcon.Question); * if (result == System.Windows.Forms.DialogResult.No) * { * startTraceLab = false; * } * } * } * * if (TraceLabSDK.RuntimeInfo.IsRunInMono) { * // we force Tracelab execution because if Tracelab runs in mono when one opens a package mono.exe remains in execution * // also after the unpacking operation is done * startTraceLab = true; * } */ if (startTraceLab) { // Append all the type directories from the package locations. var typeDirectories = new List <string>(settings.TypePaths.Select(path => path.Path)); Workspace = InitWorkspace(typeDirectories, WorkspaceDirectory, CacheDirectory); MainViewModel = new ApplicationViewModel(Workspace); MainViewModel.LogViewModel = initialLogViewModel; MainViewModel.Settings = settings; MainViewModel.PropertyChanged += MainViewModel_PropertyChanged; var componentLibrary = CreateComponentLibraryViewModel(PackageManager.Instance, settings, DecisionDirectory, UserDirectory); Workspace.RegisterPackageTypes(componentLibrary.PackageTypeDirectories); MainViewModel.ComponentLibraryViewModel = componentLibrary; MainViewModel.BenchmarkWizard = new BenchmarkWizard(BenchmarkDirectory, ComponentsLibrary.Instance, Workspace, typeDirectories, UserDirectory, settings); if (String.IsNullOrEmpty(ExperimentFileToBeOpen) == false || string.IsNullOrEmpty(settings.DefaultExperiment) == false) { string file = string.IsNullOrEmpty(ExperimentFileToBeOpen) ? settings.DefaultExperiment : ExperimentFileToBeOpen; try { var w2 = new List <string>(settings.TypePaths.Select(path => path.Path)); ComponentsLibrary.Instance.Rescan(PackageManager.Instance, w2, false); MainViewModel.Experiment = TraceLab.Core.Experiments.ExperimentManager.Load(file, ComponentsLibrary.Instance); RecentExperimentsHelper.UpdateRecentExperimentList(TraceLab.Core.Settings.Settings.RecentExperimentsPath, file); } catch (TraceLab.Core.Exceptions.ExperimentLoadException ex) { string msg = String.Format("Unable to open the file {0}. Error: {1}", file, ex.Message); NLog.LogManager.GetCurrentClassLogger().Warn(msg); if (!TraceLabSDK.RuntimeInfo.IsRunInMono) { System.Windows.Forms.MessageBox.Show(msg, "Experiment Loading Failure", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Exclamation); } } } } return(startTraceLab); }