Skip to content

Commit

Permalink
Updates ShowMeTheXaml and fixes the selection color
Browse files Browse the repository at this point in the history
  • Loading branch information
SKProCH committed Mar 28, 2024
1 parent 26d3cbc commit 9b6f057
Show file tree
Hide file tree
Showing 4 changed files with 111 additions and 27 deletions.
3 changes: 1 addition & 2 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
<CentralPackageTransitivePinningEnabled>true</CentralPackageTransitivePinningEnabled>
<AvaloniaVersion>11.0.9</AvaloniaVersion>
<ShowMeTheXamlVersion>1.4.1</ShowMeTheXamlVersion>
<ShowMeTheXamlVersion>1.5.0</ShowMeTheXamlVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Avalonia" />
Expand All @@ -16,7 +16,6 @@
<PackageVersion Include="Avalonia.Desktop" Version="$(AvaloniaVersion)" />
<PackageVersion Include="Avalonia.Themes.Simple" Version="$(AvaloniaVersion)" />
<PackageVersion Include="Avalonia.Browser" Version="$(AvaloniaVersion)" />
<PackageVersion Include="AvaloniaEdit.TextMate" Version="11.0.6" />
<PackageVersion Include="Microsoft.NET.WebAssembly.Threading" Version="8.0.0" />
<!--For Material.Styles-->
<PackageVersion Include="System.Reactive" Version="6.0.0" />
Expand Down
25 changes: 1 addition & 24 deletions Material.Avalonia.Demo/App.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,29 +29,6 @@
<avalonia:MaterialIconStyles />
<dialogHostAvalonia:DialogHostStyles />

<!-- AvaloniaEdit styles -->
<!-- <StyleInclude Source="avares://ShowMeTheXaml.Avalonia/XamlDisplay.xaml" /> -->
<StyleInclude Source="avares://ShowMeTheXaml.Avalonia.AvaloniaEdit/XamlDisplayStyles.axaml" />

<!-- Patching XamlDisplay -->
<Style Selector="showMeTheXaml|XamlDisplay">
<Setter Property="HorizontalAlignment" Value="Stretch" />
<Setter Property="VerticalAlignment" Value="Stretch" />
<Setter Property="ClipToBounds" Value="False" />
<Setter Property="Background" Value="Transparent" />
<Setter Property="avaloniaEdit:XamlDisplayAvaloniaEdit.CodeHighlightThemeName" Value="{DynamicResource AvaloniaEditThemeName}" />
</Style>

<Style Selector="showMeTheXaml|XamlDisplay /template/ Popup#XamlPopup > Border">
<Setter Property="CornerRadius" Value="4" />
</Style>

<Style Selector="showMeTheXaml|XamlDisplay /template/ Popup#XamlPopup > Border > Grid">
<Setter Property="Background" Value="{DynamicResource MaterialCardBackgroundBrush }" />
</Style>

<Style Selector="showMeTheXaml|XamlDisplay /template/ Popup#XamlPopup > Border > Grid > Button">
<Setter Property="Theme" Value="{StaticResource MaterialFlatButton}" />
</Style>
<StyleInclude Source="Styles/ShowMeTheXamlStyles.axaml" />
</Application.Styles>
</Application>
1 change: 0 additions & 1 deletion Material.Avalonia.Demo/Material.Avalonia.Demo.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
<PackageReference Include="Avalonia.Controls.DataGrid"/>
<PackageReference Include="Avalonia.Diagnostics"/>
<PackageReference Include="Avalonia.Themes.Simple"/>
<PackageReference Include="AvaloniaEdit.TextMate" />
<PackageReference Include="Material.Icons.Avalonia"/>
<PackageReference Include="DialogHost.Avalonia"/>
<PackageReference Include="ShowMeTheXaml.Avalonia"/>
Expand Down
109 changes: 109 additions & 0 deletions Material.Avalonia.Demo/Styles/ShowMeTheXamlStyles.axaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
<Styles xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:avaloniaEdit="https://github.com/avaloniaui/avaloniaedit"
xmlns:avaloniaEdit1="clr-namespace:ShowMeTheXaml.Avalonia.AvaloniaEdit;assembly=ShowMeTheXaml.Avalonia.AvaloniaEdit"
xmlns:showMeTheXaml="clr-namespace:ShowMeTheXaml;assembly=ShowMeTheXaml.Avalonia"
xmlns:controls="clr-namespace:Material.Styles.Controls;assembly=Material.Styles">
<StyleInclude Source="avares://ShowMeTheXaml.Avalonia.AvaloniaEdit/XamlDisplayStyles.axaml" />

<Style Selector="showMeTheXaml|XamlDisplay">
<Setter Property="HorizontalAlignment" Value="Stretch" />
<Setter Property="VerticalAlignment" Value="Stretch" />
<Setter Property="ClipToBounds" Value="False" />
<Setter Property="avaloniaEdit1:XamlDisplayAvaloniaEdit.CodeHighlightThemeName" Value="{DynamicResource AvaloniaEditThemeName}" />
</Style>

<Style Selector="avaloniaEdit|TextArea">
<Setter Property="SelectionBrush" Value="{DynamicResource MaterialSelectionColor}" />
</Style>

<Style Selector="showMeTheXaml|XamlDisplay[IsEditable=True] /template/ Popup#XamlPopup">
<Setter Property="Child">
<Template>
<controls:Card Margin="6">
<Grid RowDefinitions="* 4 Auto" ColumnDefinitions="* 8 Auto 8 Auto" Margin="2">
<ScrollViewer Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="5"
HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Visible"
MaxHeight="600">
<avaloniaEdit:TextEditor x:Name="MarkupTextEditor"
IsModified="False"
MinWidth="300" MaxWidth="800"
HorizontalAlignment="Left"
VerticalAlignment="Stretch"
HorizontalScrollBarVisibility="Disabled"
VerticalScrollBarVisibility="Disabled"
WordWrap="True"
ShowLineNumbers="True"
Foreground="{Binding $parent[showMeTheXaml:XamlDisplay].Foreground}"
Background="{Binding $parent[showMeTheXaml:XamlDisplay].Background}">
<Interaction.Behaviors>
<avaloniaEdit1:CustomizeEditorBehavior />
<avaloniaEdit1:XamlDisplayAvaloniaEditThemeBehavior />
</Interaction.Behaviors>
</avaloniaEdit:TextEditor>
</ScrollViewer>
<Rectangle Grid.Column="0" Grid.Row="2"
Name="MaxSizer"
VerticalAlignment="Top" HorizontalAlignment="Stretch" />
<TextBox Grid.Column="0" Grid.Row="2"
BorderThickness="0"
ScrollViewer.HorizontalScrollBarVisibility="Disabled"
ScrollViewer.VerticalScrollBarVisibility="Disabled"
MaxWidth="{Binding #MaxSizer.Bounds.Width}"
IsReadOnly="True" TextWrapping="Wrap"
IsVisible="False"
Name="CommonErrorsTextBox" />
<Button Grid.Column="2" Grid.Row="2"
Theme="{StaticResource MaterialFlatButton}"
Name="ResetButton">
Reset
</Button>
<Button Grid.Column="4" Grid.Row="2"
Theme="{StaticResource MaterialFlatButton}"
Name="ApplyButton">
Apply
</Button>
<Interaction.Behaviors>
<avaloniaEdit1:XamlDisplayAvaloniaEditPopupBehavior
MarkupTextEditor="{Binding ElementName=MarkupTextEditor}"
CommonErrorsTextBox="{Binding ElementName=CommonErrorsTextBox}"
ApplyButton="{Binding ElementName=ApplyButton}"
ResetButton="{Binding ElementName=ResetButton}" />
</Interaction.Behaviors>
</Grid>
</controls:Card>
</Template>
</Setter>
</Style>

<Style Selector="showMeTheXaml|XamlDisplay[IsEditable=False] /template/ Popup#XamlPopup">
<Setter Property="Child">
<Template>
<controls:Card Margin="6">
<ScrollViewer HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Visible"
MaxHeight="600">
<avaloniaEdit:TextEditor x:Name="MarkupTextEditor"
IsModified="True"
IsReadOnly="True"
MinWidth="300" MaxWidth="800"
HorizontalAlignment="Left"
VerticalAlignment="Stretch"
HorizontalScrollBarVisibility="Disabled"
VerticalScrollBarVisibility="Disabled"
WordWrap="True"
ShowLineNumbers="True"
Foreground="{Binding $parent[showMeTheXaml:XamlDisplay].Foreground}"
Background="{Binding $parent[showMeTheXaml:XamlDisplay].Background}">
<Interaction.Behaviors>
<avaloniaEdit1:CustomizeEditorBehavior />
<avaloniaEdit1:XamlDisplayAvaloniaEditTextBindingBehavior
MarkupTextEditor="{Binding ElementName=MarkupTextEditor}" />
<avaloniaEdit1:XamlDisplayAvaloniaEditThemeBehavior />
</Interaction.Behaviors>
</avaloniaEdit:TextEditor>
</ScrollViewer>
</controls:Card>
</Template>
</Setter>
</Style>
</Styles>

0 comments on commit 9b6f057

Please sign in to comment.