public static GccToolchainSettings ProvisionGccSettings(IProject project) { var result = GetSettings(project); if (result == null) { result = new GccToolchainSettings(); project.ToolchainSettings.GccToolchainSettings = result; project.Save(); } return(result); }
public static GccToolchainSettings GetSettings(IProject project) { GccToolchainSettings result = null; try { if (project.ToolchainSettings.GccToolchainSettings is ExpandoObject) { result = (project.ToolchainSettings.GccToolchainSettings as ExpandoObject).GetConcreteType <GccToolchainSettings>(); } else { result = project.ToolchainSettings.GccToolchainSettings; } } catch (Exception) { } return(result); }
public SysRootSettingsFormViewModel(IProject project) : base("SysRoot", project) { _settings = project.GetToolchainSettings <GccToolchainSettings>(); _sysRoot = _settings.SysRoot; Dispatcher.UIThread.InvokeAsync(async() => { _initialised = true; try { var packages = await PackageManager.ListPackages("sysroot"); Packages = new ObservableCollection <string>(packages); } catch (System.Exception) { Packages = new ObservableCollection <string>(); } if (!string.IsNullOrEmpty(_settings.SysRoot)) { SysRoot = _settings.SysRoot; } }); this.WhenAnyValue(x => x.SelectedPackage).Subscribe(async x => { if (x != null) { var packages = await PackageManager.ListToolchainPackages(x, true); Versions = new ObservableCollection <Package>(packages); } }); this.WhenAnyValue(x => x.SelectedVersion).Subscribe(x => { if (x != null) { SysRoot = $"Package={x.Name}&Version={x.Version.ToString()}"; } else { SysRoot = ""; } }); this.WhenAnyValue(x => x.SysRoot).Subscribe(x => { _settings.SysRoot = x; project.SetToolchainSettings(_settings); project.Save(); }); ClearCommand = ReactiveCommand.Create(() => { SysRoot = ""; SelectedPackage = null; SelectedVersion = null; Versions = null; }); BrowseCommand = ReactiveCommand.CreateFromTask(async() => { var fbd = new OpenFolderDialog(); fbd.InitialDirectory = Model.CurrentDirectory; var result = await fbd.ShowAsync(Application.Current.MainWindow); if (!string.IsNullOrEmpty(result)) { var localSysrootPath = project.CurrentDirectory.MakeRelativePath(result).ToAvalonPath(); if (localSysrootPath == string.Empty) { localSysrootPath = $"./"; } SysRoot = localSysrootPath; } }); }