@ -19,9 +19,6 @@
using System.Windows.Media ;
using System.Windows.Media ;
using System.Xml.Linq ;
using System.Xml.Linq ;
using ICSharpCode.ILSpy.Themes ;
using ICSharpCode.ILSpyX.Settings ;
using TomsToolbox.Wpf ;
using TomsToolbox.Wpf ;
namespace ICSharpCode.ILSpy.Options
namespace ICSharpCode.ILSpy.Options
@ -29,264 +26,176 @@ namespace ICSharpCode.ILSpy.Options
/// <summary>
/// <summary>
/// Description of DisplaySettings.
/// Description of DisplaySettings.
/// </summary>
/// </summary>
public class DisplaySettings : ObservableObject
public class DisplaySettings : ObservableObject , ISettingsSection
{
public DisplaySettings ( )
{
{
this . theme = ThemeManager . Current . DefaultTheme ;
this . selectedFont = new FontFamily ( "Consolas" ) ;
this . selectedFontSize = 1 0.0 * 4 / 3 ;
this . sortResults = true ;
this . indentationUseTabs = true ;
this . indentationSize = 4 ;
this . indentationTabSize = 4 ;
this . highlightMatchingBraces = true ;
}
string theme ;
public string Theme {
get = > theme ;
set = > SetProperty ( ref theme , value ) ;
}
FontFamily selectedFont ;
FontFamily selectedFont ;
public FontFamily SelectedFont {
public FontFamily SelectedFont {
get = > selectedFont ;
get = > selectedFont ;
set = > SetProperty ( ref selectedFont , value ) ;
set = > SetProperty ( ref selectedFont , value ) ;
}
}
double selectedFontSize ;
double selectedFontSize ;
public double SelectedFontSize {
public double SelectedFontSize {
get = > selectedFontSize ;
get = > selectedFontSize ;
set = > SetProperty ( ref selectedFontSize , value ) ;
set = > SetProperty ( ref selectedFontSize , value ) ;
}
}
bool showLineNumbers ;
bool showLineNumbers ;
public bool ShowLineNumbers {
public bool ShowLineNumbers {
get = > showLineNumbers ;
get = > showLineNumbers ;
set = > SetProperty ( ref showLineNumbers , value ) ;
set = > SetProperty ( ref showLineNumbers , value ) ;
}
}
bool showMetadataTokens ;
bool showMetadataTokens ;
public bool ShowMetadataTokens {
public bool ShowMetadataTokens {
get = > showMetadataTokens ;
get = > showMetadataTokens ;
set = > SetProperty ( ref showMetadataTokens , value ) ;
set = > SetProperty ( ref showMetadataTokens , value ) ;
}
}
bool showMetadataTokensInBase10 ;
bool showMetadataTokensInBase10 ;
public bool ShowMetadataTokensInBase10 {
public bool ShowMetadataTokensInBase10 {
get = > showMetadataTokensInBase10 ;
get = > showMetadataTokensInBase10 ;
set = > SetProperty ( ref showMetadataTokensInBase10 , value ) ;
set = > SetProperty ( ref showMetadataTokensInBase10 , value ) ;
}
}
bool enableWordWrap ;
bool enableWordWrap ;
public bool EnableWordWrap {
public bool EnableWordWrap {
get = > enableWordWrap ;
get = > enableWordWrap ;
set = > SetProperty ( ref enableWordWrap , value ) ;
set = > SetProperty ( ref enableWordWrap , value ) ;
}
}
bool sortResults ;
bool sortResults ;
public bool SortResults {
public bool SortResults {
get = > sortResults ;
get = > sortResults ;
set = > SetProperty ( ref sortResults , value ) ;
set = > SetProperty ( ref sortResults , value ) ;
}
}
bool foldBraces ;
bool foldBraces ;
public bool FoldBraces {
public bool FoldBraces {
get = > foldBraces ;
get = > foldBraces ;
set = > SetProperty ( ref foldBraces , value ) ;
set = > SetProperty ( ref foldBraces , value ) ;
}
}
bool expandMemberDefinitions ;
bool expandMemberDefinitions ;
public bool ExpandMemberDefinitions {
public bool ExpandMemberDefinitions {
get = > expandMemberDefinitions ;
get = > expandMemberDefinitions ;
set = > SetProperty ( ref expandMemberDefinitions , value ) ;
set = > SetProperty ( ref expandMemberDefinitions , value ) ;
}
}
bool expandUsingDeclarations ;
bool expandUsingDeclarations ;
public bool ExpandUsingDeclarations {
public bool ExpandUsingDeclarations {
get = > expandUsingDeclarations ;
get = > expandUsingDeclarations ;
set = > SetProperty ( ref expandUsingDeclarations , value ) ;
set = > SetProperty ( ref expandUsingDeclarations , value ) ;
}
}
bool showDebugInfo ;
bool showDebugInfo ;
public bool ShowDebugInfo {
public bool ShowDebugInfo {
get = > showDebugInfo ;
get = > showDebugInfo ;
set = > SetProperty ( ref showDebugInfo , value ) ;
set = > SetProperty ( ref showDebugInfo , value ) ;
}
}
bool indentationUseTabs ;
bool indentationUseTabs ;
public bool IndentationUseTabs {
public bool IndentationUseTabs {
get = > indentationUseTabs ;
get = > indentationUseTabs ;
set = > SetProperty ( ref indentationUseTabs , value ) ;
set = > SetProperty ( ref indentationUseTabs , value ) ;
}
}
int indentationTabSize ;
int indentationTabSize ;
public int IndentationTabSize {
public int IndentationTabSize {
get = > indentationTabSize ;
get = > indentationTabSize ;
set = > SetProperty ( ref indentationTabSize , value ) ;
set = > SetProperty ( ref indentationTabSize , value ) ;
}
}
int indentationSize ;
int indentationSize ;
public int IndentationSize {
public int IndentationSize {
get = > indentationSize ;
get = > indentationSize ;
set = > SetProperty ( ref indentationSize , value ) ;
set = > SetProperty ( ref indentationSize , value ) ;
}
}
bool highlightMatchingBraces ;
bool highlightMatchingBraces ;
public bool HighlightMatchingBraces {
public bool HighlightMatchingBraces {
get = > highlightMatchingBraces ;
get = > highlightMatchingBraces ;
set = > SetProperty ( ref highlightMatchingBraces , value ) ;
set = > SetProperty ( ref highlightMatchingBraces , value ) ;
}
}
bool highlightCurrentLine ;
bool highlightCurrentLine ;
public bool HighlightCurrentLine {
public bool HighlightCurrentLine {
get = > highlightCurrentLine ;
get = > highlightCurrentLine ;
set = > SetProperty ( ref highlightCurrentLine , value ) ;
set = > SetProperty ( ref highlightCurrentLine , value ) ;
}
}
bool hideEmptyMetadataTables ;
bool hideEmptyMetadataTables ;
public bool HideEmptyMetadataTables {
public bool HideEmptyMetadataTables {
get = > hideEmptyMetadataTables ;
get = > hideEmptyMetadataTables ;
set = > SetProperty ( ref hideEmptyMetadataTables , value ) ;
set = > SetProperty ( ref hideEmptyMetadataTables , value ) ;
}
}
bool useNestedNamespaceNodes ;
bool useNestedNamespaceNodes ;
public bool UseNestedNamespaceNodes {
public bool UseNestedNamespaceNodes {
get = > useNestedNamespaceNodes ;
get = > useNestedNamespaceNodes ;
set = > SetProperty ( ref useNestedNamespaceNodes , value ) ;
set = > SetProperty ( ref useNestedNamespaceNodes , value ) ;
}
}
private bool styleWindowTitleBar ;
private bool styleWindowTitleBar ;
public bool StyleWindowTitleBar {
public bool StyleWindowTitleBar {
get = > styleWindowTitleBar ;
get = > styleWindowTitleBar ;
set = > SetProperty ( ref styleWindowTitleBar , value ) ;
set = > SetProperty ( ref styleWindowTitleBar , value ) ;
}
}
private bool showRawOffsetsAndBytesBeforeInstruction ;
private bool showRawOffsetsAndBytesBeforeInstruction ;
public bool ShowRawOffsetsAndBytesBeforeInstruction {
public bool ShowRawOffsetsAndBytesBeforeInstruction {
get = > showRawOffsetsAndBytesBeforeInstruction ;
get = > showRawOffsetsAndBytesBeforeInstruction ;
set = > SetProperty ( ref showRawOffsetsAndBytesBeforeInstruction , value ) ;
set = > SetProperty ( ref showRawOffsetsAndBytesBeforeInstruction , value ) ;
}
}
public void CopyValues ( DisplaySettings s )
public XName SectionName = > "DisplaySettings" ;
{
this . Theme = s . Theme ;
this . SelectedFont = s . selectedFont ;
this . SelectedFontSize = s . selectedFontSize ;
this . ShowLineNumbers = s . showLineNumbers ;
this . ShowMetadataTokens = s . showMetadataTokens ;
this . ShowMetadataTokensInBase10 = s . showMetadataTokensInBase10 ;
this . ShowDebugInfo = s . showDebugInfo ;
this . EnableWordWrap = s . enableWordWrap ;
this . SortResults = s . sortResults ;
this . FoldBraces = s . foldBraces ;
this . ExpandMemberDefinitions = s . expandMemberDefinitions ;
this . ExpandUsingDeclarations = s . expandUsingDeclarations ;
this . IndentationUseTabs = s . indentationUseTabs ;
this . IndentationTabSize = s . indentationTabSize ;
this . IndentationSize = s . indentationSize ;
this . HighlightMatchingBraces = s . highlightMatchingBraces ;
this . HighlightCurrentLine = s . highlightCurrentLine ;
this . HideEmptyMetadataTables = s . hideEmptyMetadataTables ;
this . UseNestedNamespaceNodes = s . useNestedNamespaceNodes ;
this . ShowRawOffsetsAndBytesBeforeInstruction = s . showRawOffsetsAndBytesBeforeInstruction ;
this . StyleWindowTitleBar = s . styleWindowTitleBar ;
}
public static DisplaySettings Load ( ILSpySettings settings , SessionSettings sessionSettings = null )
public void LoadFromSection ( XElement section )
{
{
XElement e = settings [ "DisplaySettings" ] ;
SelectedFont = new FontFamily ( ( string ) section . Attribute ( "Font" ) ? ? "Consolas" ) ;
var s = new DisplaySettings {
SelectedFontSize = ( double? ) section . Attribute ( "FontSize" ) ? ? 1 0.0 * 4 / 3 ;
SelectedFont = new FontFamily ( ( string ) e . Attribute ( "Font" ) ? ? "Consolas" ) ,
ShowLineNumbers = ( bool? ) section . Attribute ( "ShowLineNumbers" ) ? ? false ;
SelectedFontSize = ( double? ) e . Attribute ( "FontSize" ) ? ? 1 0.0 * 4 / 3 ,
ShowMetadataTokens = ( bool? ) section . Attribute ( "ShowMetadataTokens" ) ? ? false ;
ShowLineNumbers = ( bool? ) e . Attribute ( "ShowLineNumbers" ) ? ? false ,
ShowMetadataTokensInBase10 = ( bool? ) section . Attribute ( "ShowMetadataTokensInBase10" ) ? ? false ;
ShowMetadataTokens = ( bool? ) e . Attribute ( "ShowMetadataTokens" ) ? ? false ,
ShowDebugInfo = ( bool? ) section . Attribute ( "ShowDebugInfo" ) ? ? false ;
ShowMetadataTokensInBase10 = ( bool? ) e . Attribute ( "ShowMetadataTokensInBase10" ) ? ? false ,
EnableWordWrap = ( bool? ) section . Attribute ( "EnableWordWrap" ) ? ? false ;
ShowDebugInfo = ( bool? ) e . Attribute ( "ShowDebugInfo" ) ? ? false ,
SortResults = ( bool? ) section . Attribute ( "SortResults" ) ? ? true ;
EnableWordWrap = ( bool? ) e . Attribute ( "EnableWordWrap" ) ? ? false ,
FoldBraces = ( bool? ) section . Attribute ( "FoldBraces" ) ? ? false ;
SortResults = ( bool? ) e . Attribute ( "SortResults" ) ? ? true ,
ExpandMemberDefinitions = ( bool? ) section . Attribute ( "ExpandMemberDefinitions" ) ? ? false ;
FoldBraces = ( bool? ) e . Attribute ( "FoldBraces" ) ? ? false ,
ExpandUsingDeclarations = ( bool? ) section . Attribute ( "ExpandUsingDeclarations" ) ? ? false ;
ExpandMemberDefinitions = ( bool? ) e . Attribute ( "ExpandMemberDefinitions" ) ? ? false ,
IndentationUseTabs = ( bool? ) section . Attribute ( "IndentationUseTabs" ) ? ? true ;
ExpandUsingDeclarations = ( bool? ) e . Attribute ( "ExpandUsingDeclarations" ) ? ? false ,
IndentationSize = ( int? ) section . Attribute ( "IndentationSize" ) ? ? 4 ;
IndentationUseTabs = ( bool? ) e . Attribute ( "IndentationUseTabs" ) ? ? true ,
IndentationTabSize = ( int? ) section . Attribute ( "IndentationTabSize" ) ? ? 4 ;
IndentationSize = ( int? ) e . Attribute ( "IndentationSize" ) ? ? 4 ,
HighlightMatchingBraces = ( bool? ) section . Attribute ( "HighlightMatchingBraces" ) ? ? true ;
IndentationTabSize = ( int? ) e . Attribute ( "IndentationTabSize" ) ? ? 4 ,
HighlightCurrentLine = ( bool? ) section . Attribute ( "HighlightCurrentLine" ) ? ? false ;
HighlightMatchingBraces = ( bool? ) e . Attribute ( "HighlightMatchingBraces" ) ? ? true ,
HideEmptyMetadataTables = ( bool? ) section . Attribute ( "HideEmptyMetadataTables" ) ? ? true ;
HighlightCurrentLine = ( bool? ) e . Attribute ( "HighlightCurrentLine" ) ? ? false ,
UseNestedNamespaceNodes = ( bool? ) section . Attribute ( "UseNestedNamespaceNodes" ) ? ? false ;
HideEmptyMetadataTables = ( bool? ) e . Attribute ( "HideEmptyMetadataTables" ) ? ? true ,
ShowRawOffsetsAndBytesBeforeInstruction = ( bool? ) section . Attribute ( "ShowRawOffsetsAndBytesBeforeInstruction" ) ? ? false ;
UseNestedNamespaceNodes = ( bool? ) e . Attribute ( "UseNestedNamespaceNodes" ) ? ? false ,
StyleWindowTitleBar = ( bool? ) section . Attribute ( "StyleWindowTitleBar" ) ? ? false ;
ShowRawOffsetsAndBytesBeforeInstruction = ( bool? ) e . Attribute ( "ShowRawOffsetsAndBytesBeforeInstruction" ) ? ? false ,
}
StyleWindowTitleBar = ( bool? ) e . Attribute ( "StyleWindowTitleBar" ) ? ? false ,
Theme = ( sessionSettings ? ? SettingsService . Instance . SessionSettings ) . Theme
public void SaveToSection ( XElement section )
} ;
return s ;
}
public void Save ( XElement root )
{
{
var s = this ;
section . SetAttributeValue ( "Font" , SelectedFont . Source ) ;
section . SetAttributeValue ( "FontSize" , SelectedFontSize ) ;
var section = new XElement ( "DisplaySettings" ) ;
section . SetAttributeValue ( "ShowLineNumbers" , ShowLineNumbers ) ;
section . SetAttributeValue ( "Font" , s . SelectedFont . Source ) ;
section . SetAttributeValue ( "ShowMetadataTokens" , ShowMetadataTokens ) ;
section . SetAttributeValue ( "FontSize" , s . SelectedFontSize ) ;
section . SetAttributeValue ( "ShowMetadataTokensInBase10" , ShowMetadataTokensInBase10 ) ;
section . SetAttributeValue ( "ShowLineNumbers" , s . ShowLineNumbers ) ;
section . SetAttributeValue ( "ShowDebugInfo" , ShowDebugInfo ) ;
section . SetAttributeValue ( "ShowMetadataTokens" , s . ShowMetadataTokens ) ;
section . SetAttributeValue ( "EnableWordWrap" , EnableWordWrap ) ;
section . SetAttributeValue ( "ShowMetadataTokensInBase10" , s . ShowMetadataTokensInBase10 ) ;
section . SetAttributeValue ( "SortResults" , SortResults ) ;
section . SetAttributeValue ( "ShowDebugInfo" , s . ShowDebugInfo ) ;
section . SetAttributeValue ( "FoldBraces" , FoldBraces ) ;
section . SetAttributeValue ( "EnableWordWrap" , s . EnableWordWrap ) ;
section . SetAttributeValue ( "ExpandMemberDefinitions" , ExpandMemberDefinitions ) ;
section . SetAttributeValue ( "SortResults" , s . SortResults ) ;
section . SetAttributeValue ( "ExpandUsingDeclarations" , ExpandUsingDeclarations ) ;
section . SetAttributeValue ( "FoldBraces" , s . FoldBraces ) ;
section . SetAttributeValue ( "IndentationUseTabs" , IndentationUseTabs ) ;
section . SetAttributeValue ( "ExpandMemberDefinitions" , s . ExpandMemberDefinitions ) ;
section . SetAttributeValue ( "IndentationSize" , IndentationSize ) ;
section . SetAttributeValue ( "ExpandUsingDeclarations" , s . ExpandUsingDeclarations ) ;
section . SetAttributeValue ( "IndentationTabSize" , IndentationTabSize ) ;
section . SetAttributeValue ( "IndentationUseTabs" , s . IndentationUseTabs ) ;
section . SetAttributeValue ( "HighlightMatchingBraces" , HighlightMatchingBraces ) ;
section . SetAttributeValue ( "IndentationSize" , s . IndentationSize ) ;
section . SetAttributeValue ( "HighlightCurrentLine" , HighlightCurrentLine ) ;
section . SetAttributeValue ( "IndentationTabSize" , s . IndentationTabSize ) ;
section . SetAttributeValue ( "HideEmptyMetadataTables" , HideEmptyMetadataTables ) ;
section . SetAttributeValue ( "HighlightMatchingBraces" , s . HighlightMatchingBraces ) ;
section . SetAttributeValue ( "UseNestedNamespaceNodes" , UseNestedNamespaceNodes ) ;
section . SetAttributeValue ( "HighlightCurrentLine" , s . HighlightCurrentLine ) ;
section . SetAttributeValue ( "ShowRawOffsetsAndBytesBeforeInstruction" , ShowRawOffsetsAndBytesBeforeInstruction ) ;
section . SetAttributeValue ( "HideEmptyMetadataTables" , s . HideEmptyMetadataTables ) ;
section . SetAttributeValue ( "StyleWindowTitleBar" , StyleWindowTitleBar ) ;
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 ) ;
}
}
}
}
}
}
}