-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
daf23cb
commit ad7744e
Showing
6 changed files
with
104 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
using OneWare.Settings.ViewModels.SettingTypes; | ||
|
||
namespace OneWare.Quartus.Helper; | ||
|
||
public interface IQsfSetting | ||
{ | ||
public SettingViewModel GetViewModel(); | ||
public void Save(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
using OneWare.Settings; | ||
using OneWare.Settings.ViewModels.SettingTypes; | ||
|
||
namespace OneWare.Quartus.Helper; | ||
|
||
public class QsfSettingComboBox : IQsfSetting | ||
{ | ||
private readonly string _name; | ||
private readonly QsfFile _qsfFile; | ||
private readonly Dictionary<string, string> _options; | ||
private readonly ComboBoxSetting _setting; | ||
|
||
public QsfSettingComboBox(QsfFile file, string name, string title, string description, Dictionary<string, string> options, string defaultValue) | ||
{ | ||
_qsfFile = file; | ||
_name = name; | ||
_options = options; | ||
|
||
_setting = new ComboBoxSetting(title, description, defaultValue, options.Values); | ||
|
||
var setting = file.GetGlobalAssignment(name); | ||
|
||
if (!string.IsNullOrWhiteSpace(setting)) | ||
{ | ||
options.TryAdd(setting, setting); | ||
_setting.Value = options[setting]; | ||
} | ||
} | ||
|
||
public SettingViewModel GetViewModel() | ||
{ | ||
return new ComboBoxSettingViewModel(_setting); | ||
} | ||
|
||
public void Save() | ||
{ | ||
if(_setting.Value.ToString() != "Default") | ||
_qsfFile.SetGlobalAssignment(_name, _options.FirstOrDefault(x => x.Value == (string)_setting.Value).Key); | ||
else | ||
_qsfFile.RemoveGlobalAssignment(_name); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters