diff --git a/ILSpy/Options/DisplaySettings.cs b/ILSpy/Options/DisplaySettings.cs index f59c31a95..d2f00189b 100644 --- a/ILSpy/Options/DisplaySettings.cs +++ b/ILSpy/Options/DisplaySettings.cs @@ -16,18 +16,20 @@ // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -using System.ComponentModel; -using System.Runtime.CompilerServices; using System.Windows.Media; +using System.Xml.Linq; using ICSharpCode.ILSpy.Themes; +using ICSharpCode.ILSpyX.Settings; + +using TomsToolbox.Wpf; namespace ICSharpCode.ILSpy.Options { /// /// Description of DisplaySettings. /// - public class DisplaySettings : INotifyPropertyChanged + public class DisplaySettings : ObservableObject { public DisplaySettings() { @@ -41,291 +43,151 @@ namespace ICSharpCode.ILSpy.Options this.highlightMatchingBraces = true; } - #region INotifyPropertyChanged implementation - public event PropertyChangedEventHandler PropertyChanged; - - protected virtual void OnPropertyChanged(PropertyChangedEventArgs e) - { - PropertyChanged?.Invoke(this, e); - } - - protected void OnPropertyChanged([CallerMemberName] string propertyName = null) - { - OnPropertyChanged(new PropertyChangedEventArgs(propertyName)); - } - #endregion - string theme; public string Theme { - get { return theme; } - set { - if (theme != value) - { - theme = value; - OnPropertyChanged(); - } - } + get => theme; + set => SetProperty(ref theme, value); } FontFamily selectedFont; public FontFamily SelectedFont { - get { return selectedFont; } - set { - if (selectedFont != value) - { - selectedFont = value; - OnPropertyChanged(); - } - } + get => selectedFont; + set => SetProperty(ref selectedFont, value); } double selectedFontSize; public double SelectedFontSize { - get { return selectedFontSize; } - set { - if (selectedFontSize != value) - { - selectedFontSize = value; - OnPropertyChanged(); - } - } + get => selectedFontSize; + set => SetProperty(ref selectedFontSize, value); } bool showLineNumbers; public bool ShowLineNumbers { - get { return showLineNumbers; } - set { - if (showLineNumbers != value) - { - showLineNumbers = value; - OnPropertyChanged(); - } - } + get => showLineNumbers; + set => SetProperty(ref showLineNumbers, value); } bool showMetadataTokens; public bool ShowMetadataTokens { - get { return showMetadataTokens; } - set { - if (showMetadataTokens != value) - { - showMetadataTokens = value; - OnPropertyChanged(); - } - } + get => showMetadataTokens; + set => SetProperty(ref showMetadataTokens, value); } bool showMetadataTokensInBase10; public bool ShowMetadataTokensInBase10 { - get { return showMetadataTokensInBase10; } - set { - if (showMetadataTokensInBase10 != value) - { - showMetadataTokensInBase10 = value; - OnPropertyChanged(); - } - } + get => showMetadataTokensInBase10; + set => SetProperty(ref showMetadataTokensInBase10, value); } bool enableWordWrap; public bool EnableWordWrap { - get { return enableWordWrap; } - set { - if (enableWordWrap != value) - { - enableWordWrap = value; - OnPropertyChanged(); - } - } + get => enableWordWrap; + set => SetProperty(ref enableWordWrap, value); } - bool sortResults = true; + bool sortResults; public bool SortResults { - get { return sortResults; } - set { - if (sortResults != value) - { - sortResults = value; - OnPropertyChanged(); - } - } + get => sortResults; + set => SetProperty(ref sortResults, value); } - bool foldBraces = false; + bool foldBraces; public bool FoldBraces { - get { return foldBraces; } - set { - if (foldBraces != value) - { - foldBraces = value; - OnPropertyChanged(); - } - } + get => foldBraces; + set => SetProperty(ref foldBraces, value); } - bool expandMemberDefinitions = false; + bool expandMemberDefinitions; public bool ExpandMemberDefinitions { - get { return expandMemberDefinitions; } - set { - if (expandMemberDefinitions != value) - { - expandMemberDefinitions = value; - OnPropertyChanged(); - } - } + get => expandMemberDefinitions; + set => SetProperty(ref expandMemberDefinitions, value); } - bool expandUsingDeclarations = false; + bool expandUsingDeclarations; public bool ExpandUsingDeclarations { - get { return expandUsingDeclarations; } - set { - if (expandUsingDeclarations != value) - { - expandUsingDeclarations = value; - OnPropertyChanged(); - } - } + get => expandUsingDeclarations; + set => SetProperty(ref expandUsingDeclarations, value); } bool showDebugInfo; public bool ShowDebugInfo { - get { return showDebugInfo; } - set { - if (showDebugInfo != value) - { - showDebugInfo = value; - OnPropertyChanged(); - } - } + get => showDebugInfo; + set => SetProperty(ref showDebugInfo, value); } - bool indentationUseTabs = true; + bool indentationUseTabs; public bool IndentationUseTabs { - get { return indentationUseTabs; } - set { - if (indentationUseTabs != value) - { - indentationUseTabs = value; - OnPropertyChanged(); - } - } + get => indentationUseTabs; + set => SetProperty(ref indentationUseTabs, value); } - int indentationTabSize = 4; + int indentationTabSize; public int IndentationTabSize { - get { return indentationTabSize; } - set { - if (indentationTabSize != value) - { - indentationTabSize = value; - OnPropertyChanged(); - } - } + get => indentationTabSize; + set => SetProperty(ref indentationTabSize, value); } - int indentationSize = 4; + int indentationSize; public int IndentationSize { - get { return indentationSize; } - set { - if (indentationSize != value) - { - indentationSize = value; - OnPropertyChanged(); - } - } + get => indentationSize; + set => SetProperty(ref indentationSize, value); } - bool highlightMatchingBraces = true; + bool highlightMatchingBraces; public bool HighlightMatchingBraces { - get { return highlightMatchingBraces; } - set { - if (highlightMatchingBraces != value) - { - highlightMatchingBraces = value; - OnPropertyChanged(); - } - } + get => highlightMatchingBraces; + set => SetProperty(ref highlightMatchingBraces, value); } - bool highlightCurrentLine = false; + bool highlightCurrentLine; public bool HighlightCurrentLine { - get { return highlightCurrentLine; } - set { - if (highlightCurrentLine != value) - { - highlightCurrentLine = value; - OnPropertyChanged(); - } - } + get => highlightCurrentLine; + set => SetProperty(ref highlightCurrentLine, value); } - bool hideEmptyMetadataTables = true; + bool hideEmptyMetadataTables; public bool HideEmptyMetadataTables { - get { return hideEmptyMetadataTables; } - set { - if (hideEmptyMetadataTables != value) - { - hideEmptyMetadataTables = value; - OnPropertyChanged(); - } - } + get => hideEmptyMetadataTables; + set => SetProperty(ref hideEmptyMetadataTables, value); } - bool useNestedNamespaceNodes = true; + bool useNestedNamespaceNodes; public bool UseNestedNamespaceNodes { - get { return useNestedNamespaceNodes; } - set { - if (useNestedNamespaceNodes != value) - { - useNestedNamespaceNodes = value; - OnPropertyChanged(); - } - } + get => useNestedNamespaceNodes; + set => SetProperty(ref useNestedNamespaceNodes, value); } private bool styleWindowTitleBar; public bool StyleWindowTitleBar { - get { return styleWindowTitleBar; } - set { - if (styleWindowTitleBar != value) - { - styleWindowTitleBar = value; - OnPropertyChanged(); - } - } + get => styleWindowTitleBar; + set => SetProperty(ref styleWindowTitleBar, value); } private bool showRawOffsetsAndBytesBeforeInstruction; public bool ShowRawOffsetsAndBytesBeforeInstruction { - get { return showRawOffsetsAndBytesBeforeInstruction; } - set { - if (showRawOffsetsAndBytesBeforeInstruction != value) - { - showRawOffsetsAndBytesBeforeInstruction = value; - OnPropertyChanged(); - } - } + get => showRawOffsetsAndBytesBeforeInstruction; + set => SetProperty(ref showRawOffsetsAndBytesBeforeInstruction, value); } public void CopyValues(DisplaySettings s) @@ -352,5 +214,79 @@ namespace ICSharpCode.ILSpy.Options this.ShowRawOffsetsAndBytesBeforeInstruction = s.showRawOffsetsAndBytesBeforeInstruction; this.StyleWindowTitleBar = s.styleWindowTitleBar; } + + public static DisplaySettings Load(ILSpySettings settings, SessionSettings sessionSettings = null) + { + XElement e = settings["DisplaySettings"]; + var s = new DisplaySettings { + SelectedFont = new FontFamily((string)e.Attribute("Font") ?? "Consolas"), + SelectedFontSize = (double?)e.Attribute("FontSize") ?? 10.0 * 4 / 3, + ShowLineNumbers = (bool?)e.Attribute("ShowLineNumbers") ?? false, + ShowMetadataTokens = (bool?)e.Attribute("ShowMetadataTokens") ?? false, + ShowMetadataTokensInBase10 = (bool?)e.Attribute("ShowMetadataTokensInBase10") ?? false, + ShowDebugInfo = (bool?)e.Attribute("ShowDebugInfo") ?? false, + EnableWordWrap = (bool?)e.Attribute("EnableWordWrap") ?? false, + SortResults = (bool?)e.Attribute("SortResults") ?? true, + FoldBraces = (bool?)e.Attribute("FoldBraces") ?? false, + ExpandMemberDefinitions = (bool?)e.Attribute("ExpandMemberDefinitions") ?? false, + ExpandUsingDeclarations = (bool?)e.Attribute("ExpandUsingDeclarations") ?? false, + IndentationUseTabs = (bool?)e.Attribute("IndentationUseTabs") ?? true, + IndentationSize = (int?)e.Attribute("IndentationSize") ?? 4, + IndentationTabSize = (int?)e.Attribute("IndentationTabSize") ?? 4, + HighlightMatchingBraces = (bool?)e.Attribute("HighlightMatchingBraces") ?? true, + HighlightCurrentLine = (bool?)e.Attribute("HighlightCurrentLine") ?? false, + HideEmptyMetadataTables = (bool?)e.Attribute("HideEmptyMetadataTables") ?? true, + UseNestedNamespaceNodes = (bool?)e.Attribute("UseNestedNamespaceNodes") ?? false, + ShowRawOffsetsAndBytesBeforeInstruction = (bool?)e.Attribute("ShowRawOffsetsAndBytesBeforeInstruction") ?? false, + StyleWindowTitleBar = (bool?)e.Attribute("StyleWindowTitleBar") ?? false, + Theme = (sessionSettings ?? SettingsService.Instance.SessionSettings).Theme + }; + + return s; + } + + public void Save(XElement root) + { + var s = this; + + var section = new XElement("DisplaySettings"); + section.SetAttributeValue("Font", s.SelectedFont.Source); + section.SetAttributeValue("FontSize", s.SelectedFontSize); + section.SetAttributeValue("ShowLineNumbers", s.ShowLineNumbers); + section.SetAttributeValue("ShowMetadataTokens", s.ShowMetadataTokens); + section.SetAttributeValue("ShowMetadataTokensInBase10", s.ShowMetadataTokensInBase10); + section.SetAttributeValue("ShowDebugInfo", s.ShowDebugInfo); + section.SetAttributeValue("EnableWordWrap", s.EnableWordWrap); + section.SetAttributeValue("SortResults", s.SortResults); + section.SetAttributeValue("FoldBraces", s.FoldBraces); + section.SetAttributeValue("ExpandMemberDefinitions", s.ExpandMemberDefinitions); + section.SetAttributeValue("ExpandUsingDeclarations", s.ExpandUsingDeclarations); + section.SetAttributeValue("IndentationUseTabs", s.IndentationUseTabs); + section.SetAttributeValue("IndentationSize", s.IndentationSize); + section.SetAttributeValue("IndentationTabSize", s.IndentationTabSize); + section.SetAttributeValue("HighlightMatchingBraces", s.HighlightMatchingBraces); + section.SetAttributeValue("HighlightCurrentLine", s.HighlightCurrentLine); + section.SetAttributeValue("HideEmptyMetadataTables", s.HideEmptyMetadataTables); + section.SetAttributeValue("UseNestedNamespaceNodes", s.UseNestedNamespaceNodes); + section.SetAttributeValue("ShowRawOffsetsAndBytesBeforeInstruction", s.ShowRawOffsetsAndBytesBeforeInstruction); + section.SetAttributeValue("StyleWindowTitleBar", s.StyleWindowTitleBar); + + SettingsService.Instance.SessionSettings.Theme = s.Theme; + var sessionSettings = SettingsService.Instance.SessionSettings.ToXml(); + + SettingsService.Instance.DisplaySettings.CopyValues(s); + + Update(section); + Update(sessionSettings); + + void Update(XElement element) + { + var existingElement = root.Element(element.Name); + if (existingElement != null) + existingElement.ReplaceWith(element); + else + root.Add(element); + } + } } } diff --git a/ILSpy/Options/DisplaySettingsPanel.xaml b/ILSpy/Options/DisplaySettingsPanel.xaml index 1170a8f5b..a8cd5c871 100644 --- a/ILSpy/Options/DisplaySettingsPanel.xaml +++ b/ILSpy/Options/DisplaySettingsPanel.xaml @@ -7,15 +7,12 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:themes="clr-namespace:ICSharpCode.ILSpy.Themes" - d:DataContext="{d:DesignInstance local:DisplaySettings}"> - - - + d:DataContext="{d:DesignInstance local:DisplaySettingsViewModel}"> @@ -30,78 +27,58 @@ - + - - - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - 15 - 16 - 17 - 18 - 19 - 20 - 21 - 22 - 23 - 24 - - - + + + + - + - + - + - - - - - - - - - + + + + + + + + + - - - - + + + + - - + + diff --git a/ILSpy/Options/DisplaySettingsPanel.xaml.cs b/ILSpy/Options/DisplaySettingsPanel.xaml.cs index 7c8f2954b..3b51a16ba 100644 --- a/ILSpy/Options/DisplaySettingsPanel.xaml.cs +++ b/ILSpy/Options/DisplaySettingsPanel.xaml.cs @@ -29,14 +29,17 @@ using System.Xml.Linq; using ICSharpCode.ILSpyX.Settings; +using TomsToolbox.Wpf.Composition.Mef; +using TomsToolbox.Wpf.Converters; + namespace ICSharpCode.ILSpy.Options { /// /// Interaction logic for DisplaySettingsPanel.xaml /// - [ExportOptionPage(Order = 20)] [PartCreationPolicy(CreationPolicy.NonShared)] - public partial class DisplaySettingsPanel : UserControl, IOptionPage + [DataTemplate(typeof(DisplaySettingsViewModel))] + public partial class DisplaySettingsPanel { public DisplaySettingsPanel() { @@ -44,134 +47,6 @@ namespace ICSharpCode.ILSpy.Options DataObject.AddPastingHandler(tabSizeTextBox, OnPaste); DataObject.AddPastingHandler(indentSizeTextBox, OnPaste); - - Task task = new Task(FontLoader); - task.Start(); - task.ContinueWith( - delegate (Task continuation) { - App.Current.Dispatcher.Invoke( - DispatcherPriority.Normal, - (Action)( - () => { - fontSelector.ItemsSource = task.Result; - if (continuation.Exception != null) - { - foreach (var ex in continuation.Exception.InnerExceptions) - { - MessageBox.Show(ex.ToString()); - } - } - }) - ); - } - ); - } - - public string Title => Properties.Resources.Display; - - public void Load(ILSpySettings spySettings) - { - this.DataContext = LoadDisplaySettings(spySettings); - } - - static bool IsSymbolFont(FontFamily fontFamily) - { - foreach (var tf in fontFamily.GetTypefaces()) - { - GlyphTypeface glyph; - try - { - if (tf.TryGetGlyphTypeface(out glyph)) - return glyph.Symbol; - } - catch (Exception) - { - return true; - } - } - return false; - } - - static FontFamily[] FontLoader() - { - return (from ff in Fonts.SystemFontFamilies - where !IsSymbolFont(ff) - orderby ff.Source - select ff).ToArray(); - } - - public static DisplaySettings LoadDisplaySettings(ILSpySettings settings, SessionSettings sessionSettings = null) - { - XElement e = settings["DisplaySettings"]; - var s = new DisplaySettings(); - s.SelectedFont = new FontFamily((string)e.Attribute("Font") ?? "Consolas"); - s.SelectedFontSize = (double?)e.Attribute("FontSize") ?? 10.0 * 4 / 3; - s.ShowLineNumbers = (bool?)e.Attribute("ShowLineNumbers") ?? false; - s.ShowMetadataTokens = (bool?)e.Attribute("ShowMetadataTokens") ?? false; - s.ShowMetadataTokensInBase10 = (bool?)e.Attribute("ShowMetadataTokensInBase10") ?? false; - s.ShowDebugInfo = (bool?)e.Attribute("ShowDebugInfo") ?? false; - s.EnableWordWrap = (bool?)e.Attribute("EnableWordWrap") ?? false; - s.SortResults = (bool?)e.Attribute("SortResults") ?? true; - s.FoldBraces = (bool?)e.Attribute("FoldBraces") ?? false; - s.ExpandMemberDefinitions = (bool?)e.Attribute("ExpandMemberDefinitions") ?? false; - s.ExpandUsingDeclarations = (bool?)e.Attribute("ExpandUsingDeclarations") ?? false; - s.IndentationUseTabs = (bool?)e.Attribute("IndentationUseTabs") ?? true; - s.IndentationSize = (int?)e.Attribute("IndentationSize") ?? 4; - s.IndentationTabSize = (int?)e.Attribute("IndentationTabSize") ?? 4; - s.HighlightMatchingBraces = (bool?)e.Attribute("HighlightMatchingBraces") ?? true; - s.HighlightCurrentLine = (bool?)e.Attribute("HighlightCurrentLine") ?? false; - s.HideEmptyMetadataTables = (bool?)e.Attribute("HideEmptyMetadataTables") ?? true; - s.UseNestedNamespaceNodes = (bool?)e.Attribute("UseNestedNamespaceNodes") ?? false; - s.ShowRawOffsetsAndBytesBeforeInstruction = (bool?)e.Attribute("ShowRawOffsetsAndBytesBeforeInstruction") ?? false; - s.StyleWindowTitleBar = (bool?)e.Attribute("StyleWindowTitleBar") ?? false; - - s.Theme = (sessionSettings ?? SettingsService.Instance.SessionSettings).Theme; - - return s; - } - - public void Save(XElement root) - { - var s = (DisplaySettings)this.DataContext; - - var section = new XElement("DisplaySettings"); - section.SetAttributeValue("Font", s.SelectedFont.Source); - section.SetAttributeValue("FontSize", s.SelectedFontSize); - section.SetAttributeValue("ShowLineNumbers", s.ShowLineNumbers); - section.SetAttributeValue("ShowMetadataTokens", s.ShowMetadataTokens); - section.SetAttributeValue("ShowMetadataTokensInBase10", s.ShowMetadataTokensInBase10); - section.SetAttributeValue("ShowDebugInfo", s.ShowDebugInfo); - section.SetAttributeValue("EnableWordWrap", s.EnableWordWrap); - section.SetAttributeValue("SortResults", s.SortResults); - section.SetAttributeValue("FoldBraces", s.FoldBraces); - section.SetAttributeValue("ExpandMemberDefinitions", s.ExpandMemberDefinitions); - section.SetAttributeValue("ExpandUsingDeclarations", s.ExpandUsingDeclarations); - section.SetAttributeValue("IndentationUseTabs", s.IndentationUseTabs); - section.SetAttributeValue("IndentationSize", s.IndentationSize); - section.SetAttributeValue("IndentationTabSize", s.IndentationTabSize); - section.SetAttributeValue("HighlightMatchingBraces", s.HighlightMatchingBraces); - section.SetAttributeValue("HighlightCurrentLine", s.HighlightCurrentLine); - section.SetAttributeValue("HideEmptyMetadataTables", s.HideEmptyMetadataTables); - section.SetAttributeValue("UseNestedNamespaceNodes", s.UseNestedNamespaceNodes); - section.SetAttributeValue("ShowRawOffsetsAndBytesBeforeInstruction", s.ShowRawOffsetsAndBytesBeforeInstruction); - section.SetAttributeValue("StyleWindowTitleBar", s.StyleWindowTitleBar); - - SettingsService.Instance.SessionSettings.Theme = s.Theme; - var sessionSettings = SettingsService.Instance.SessionSettings.ToXml(); - - SettingsService.Instance.DisplaySettings.CopyValues(s); - - Update(section); - Update(sessionSettings); - - void Update(XElement element) - { - var existingElement = root.Element(element.Name); - if (existingElement != null) - existingElement.ReplaceWith(element); - else - root.Add(element); - } } private void TextBox_PreviewTextInput(object sender, System.Windows.Input.TextCompositionEventArgs e) @@ -180,44 +55,39 @@ namespace ICSharpCode.ILSpy.Options e.Handled = true; } - private void OnPaste(object sender, DataObjectPastingEventArgs e) + private static void OnPaste(object sender, DataObjectPastingEventArgs e) { if (!e.SourceDataObject.GetDataPresent(DataFormats.UnicodeText, true)) return; + var text = (string)e.SourceDataObject.GetData(DataFormats.UnicodeText, true) ?? string.Empty; + if (!text.All(char.IsDigit)) e.CancelCommand(); } - - public void LoadDefaults() - { - SettingsService.Instance.DisplaySettings.CopyValues(new DisplaySettings()); - this.DataContext = SettingsService.Instance.DisplaySettings; - } } - public class FontSizeConverter : IValueConverter + public sealed class FontSizeConverter : ValueConverter { - public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) + protected override object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { if (value is double d) { return Math.Round(d / 4 * 3); } - throw new NotImplementedException(); + return DependencyProperty.UnsetValue; } - public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) + protected override object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { - if (value is string s) - { - if (double.TryParse(s, out double d)) - return d * 4 / 3; - return 11.0 * 4 / 3; - } + if (value is not string s) + return DependencyProperty.UnsetValue; + + if (double.TryParse(s, out double d)) + return d * 4 / 3; - throw new NotImplementedException(); + return 11.0 * 4 / 3; } } } \ No newline at end of file diff --git a/ILSpy/Options/DisplaySettingsViewModel.cs b/ILSpy/Options/DisplaySettingsViewModel.cs new file mode 100644 index 000000000..69505fb9f --- /dev/null +++ b/ILSpy/Options/DisplaySettingsViewModel.cs @@ -0,0 +1,90 @@ +using ICSharpCode.ILSpyX.Settings; +using System.Windows.Media; +using System.Xml.Linq; +using System; +using System.ComponentModel.Composition; +using System.Linq; +using System.Threading.Tasks; +using System.Windows; + +using TomsToolbox.Wpf; + +namespace ICSharpCode.ILSpy.Options +{ + [ExportOptionPage(Order = 20)] + [PartCreationPolicy(CreationPolicy.NonShared)] + public class DisplaySettingsViewModel : ObservableObject, IOptionPage + { + private DisplaySettings settings = new(); + private FontFamily[] fontFamilies; + + public DisplaySettingsViewModel() + { + fontFamilies = [settings.SelectedFont]; + + Task.Run(FontLoader).ContinueWith(continuation => { + FontFamilies = continuation.Result; + if (continuation.Exception == null) + return; + foreach (var ex in continuation.Exception.InnerExceptions) + { + MessageBox.Show(ex.ToString()); + } + }); + } + + public string Title => Properties.Resources.Display; + + public DisplaySettings Settings { + get => settings; + set => SetProperty(ref settings, value); + } + + public FontFamily[] FontFamilies { + get => fontFamilies; + set => SetProperty(ref fontFamilies, value); + } + + public int[] FontSizes { get; } = Enumerable.Range(6, 24 - 6 + 1).ToArray(); + + public void Load(ILSpySettings spySettings) + { + Settings = DisplaySettings.Load(spySettings); + } + + static bool IsSymbolFont(FontFamily fontFamily) + { + foreach (var tf in fontFamily.GetTypefaces()) + { + try + { + if (tf.TryGetGlyphTypeface(out GlyphTypeface glyph)) + return glyph.Symbol; + } + catch (Exception) + { + return true; + } + } + return false; + } + + static FontFamily[] FontLoader() + { + return Fonts.SystemFontFamilies + .Where(ff => !IsSymbolFont(ff)) + .OrderBy(ff => ff.Source) + .ToArray(); + } + + public void Save(XElement root) + { + Settings.Save(root); + } + + public void LoadDefaults() + { + Settings = new(); + } + } +} diff --git a/ILSpy/Util/SettingsService.cs b/ILSpy/Util/SettingsService.cs index 6d0f2547d..23c047458 100644 --- a/ILSpy/Util/SettingsService.cs +++ b/ILSpy/Util/SettingsService.cs @@ -17,7 +17,7 @@ namespace ICSharpCode.ILSpy.Util SpySettings = ILSpySettings.Load(); SessionSettings = new(SpySettings); DecompilerSettings = ISettingsProvider.LoadDecompilerSettings(SpySettings); - DisplaySettings = DisplaySettingsPanel.LoadDisplaySettings(SpySettings, SessionSettings); + DisplaySettings = DisplaySettings.Load(SpySettings, SessionSettings); MiscSettings = MiscSettings.Load(SpySettings); AssemblyListManager = new(SpySettings) { ApplyWinRTProjections = DecompilerSettings.ApplyWindowsRuntimeProjections,