Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add MaterialDesign3Demo with own namespace
  • Loading branch information
MichelMichels committed Dec 13, 2021
commit 89d6a801c731a68cd38ae05e6a3b3bc894a53105
9 changes: 9 additions & 0 deletions MaterialDesign3.Demo.Wpf/App.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2"/>
</startup>
<appSettings>
<add key="GitHub" value="https://github.com/ButchersBoy/MaterialDesignInXamlToolkit"/>
</appSettings>
</configuration>
80 changes: 80 additions & 0 deletions MaterialDesign3.Demo.Wpf/App.manifest
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
<?xml version="1.0" encoding="utf-8"?>
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
<assemblyIdentity version="1.0.0.0" name="MaterialDesign3Demo.app"/>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
<security>
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
<!-- UAC Manifest Options
If you want to change the Windows User Account Control level replace the
requestedExecutionLevel node with one of the following.

<requestedExecutionLevel level="asInvoker" uiAccess="false" />
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
<requestedExecutionLevel level="highestAvailable" uiAccess="false" />

Specifying requestedExecutionLevel element will disable file and registry virtualization.
Remove this element if your application requires this virtualization for backwards
compatibility.
-->
<requestedExecutionLevel level="asInvoker" uiAccess="false" />
</requestedPrivileges>
</security>
</trustInfo>

<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
<!-- A list of the Windows versions that this application has been tested on and is
is designed to work with. Uncomment the appropriate elements and Windows will
automatically selected the most compatible environment. -->

<!-- Windows Vista -->
<!--<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}" />-->

<!-- Windows 7 -->
<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}" />

<!-- Windows 8 -->
<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}" />

<!-- Windows 8.1 -->
<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}" />

<!-- Windows 10 -->
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}" />

</application>
</compatibility>

<!-- Indicates that the application is DPI-aware and will not be automatically scaled by Windows at higher
DPIs. Windows Presentation Foundation (WPF) applications are automatically DPI-aware and do not need
to opt in. Windows Forms applications targeting .NET Framework 4.6 that opt into this setting, should
also set the 'EnableWindowsFormsHighDpiAutoResizing' setting to 'true' in their app.config. -->

<application xmlns="urn:schemas-microsoft-com:asm.v3">
<windowsSettings>
<!-- The combination of below two tags have the following effect :
1) Per-Monitor for >= RS1 (Windows 10 Anniversary Update)
2) System < RS1 -->
<dpiAwareness xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">PerMonitorV2, PerMonitor, System</dpiAwareness>
<dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true</dpiAware>
</windowsSettings>
</application>


<!-- Enable themes for Windows common controls and dialogs (Windows XP and later) -->
<!--
<dependency>
<dependentAssembly>
<assemblyIdentity
type="win32"
name="Microsoft.Windows.Common-Controls"
version="6.0.0.0"
processorArchitecture="*"
publicKeyToken="6595b64144ccf1df"
language="*"
/>
</dependentAssembly>
</dependency>
-->

</assembly>
177 changes: 177 additions & 0 deletions MaterialDesign3.Demo.Wpf/App.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,177 @@
<Application
x:Class="MaterialDesign3Demo.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:smtx="clr-namespace:ShowMeTheXAML;assembly=ShowMeTheXAML"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
xmlns:avalonEdit="http://icsharpcode.net/sharpdevelop/avalonedit"
xmlns:smtxAe="clr-namespace:ShowMeTheXAML.AvalonEdit;assembly=ShowMeTheXAML.AvalonEdit"
xmlns:system="clr-namespace:System;assembly=mscorlib"
xmlns:materialDesignDemo="clr-namespace:MaterialDesign3Demo"
StartupUri="MainWindow.xaml">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<!-- This is the current way to setup your app's initial theme -->
<materialDesign:BundledTheme
BaseTheme="Inherit"
PrimaryColor="DeepPurple"
SecondaryColor="Lime"
ColorAdjustment="{materialDesign:ColorAdjustment}" />

<!-- If you would prefer to use your own colors there is an option for that as well -->
<!--<materialDesign:CustomColorTheme BaseTheme="Light" PrimaryColor="Aqua" SecondaryColor="DarkGreen" />-->

<!-- You can also use the built in theme dictionaries as well
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Light.xaml" />
<ResourceDictionary Source="pack://application:,,,/MaterialDesignColors;component/Themes/Recommended/Primary/MaterialDesignColor.DeepPurple.xaml" />
<ResourceDictionary Source="pack://application:,,,/MaterialDesignColors;component/Themes/Recommended/Accent/MaterialDesignColor.Lime.xaml" />
-->

<ResourceDictionary
Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesign3.Defaults.xaml" />

<ResourceDictionary
Source="pack://application:,,,/ShowMeTheXAML.AvalonEdit;component/Themes/xamldisplayer.xaml" />
</ResourceDictionary.MergedDictionaries>

<Style
TargetType="smtx:XamlDisplay"
BasedOn="{StaticResource {x:Type smtx:XamlDisplay}}">
<Style.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary
Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Button.xaml" />
<ResourceDictionary
Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.ToggleButton.xaml" />
</ResourceDictionary.MergedDictionaries>

<smtxAe:TextDocumentValueConverter
x:Key="TextDocumentValueConverter" />
</ResourceDictionary>
</Style.Resources>
<Setter
Property="IsTabStop"
Value="False" />
<Setter
Property="VerticalContentAlignment"
Value="Bottom" />
<Setter
Property="HorizontalContentAlignment"
Value="Right" />
<Setter
Property="materialDesignDemo:XamlDisplayEx.ButtonDock"
Value="Right" />
<Setter
Property="Formatter">
<Setter.Value>
<smtx:XamlFormatter
NewLineOnAttributes="True"
Indent=" ">
<smtx:XamlFormatter.NamespacesToRemove>
<system:String>http://materialdesigninxaml.net/winfx/xaml/themes</system:String>
</smtx:XamlFormatter.NamespacesToRemove>
</smtx:XamlFormatter>
</Setter.Value>
</Setter>
<Setter
Property="Template">
<Setter.Value>
<ControlTemplate
TargetType="smtx:XamlDisplay">
<DockPanel>
<materialDesign:PopupBox
DockPanel.Dock="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(materialDesignDemo:XamlDisplayEx.ButtonDock)}"
IsTabStop="False"
Padding="10"
StaysOpen="True"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
x:Name="PopupBox">
<materialDesign:PopupBox.ToggleContent>
<materialDesign:PackIcon
Kind="Xml"
Cursor="Hand"
ToolTip="View XAML"
Foreground="{DynamicResource PrimaryHueDarkBrush}"
Background="Transparent"
Margin="3">
<materialDesign:PackIcon.Style>
<Style
TargetType="materialDesign:PackIcon"
BasedOn="{StaticResource {x:Type materialDesign:PackIcon}}">
<Setter
Property="Opacity"
Value="0.4" />
<Style.Triggers>
<Trigger
Property="IsMouseOver"
Value="True">
<Setter
Property="Opacity"
Value="1" />
</Trigger>
</Style.Triggers>
</Style>
</materialDesign:PackIcon.Style>
</materialDesign:PackIcon>
</materialDesign:PopupBox.ToggleContent>
<Border
MaxHeight="600"
MaxWidth="800">
<DockPanel>
<Button
Margin="0 10 0 0"
Tag="{Binding Xaml, RelativeSource={RelativeSource TemplatedParent}}"
HorizontalAlignment="Right"
Command="Copy"
CommandParameter="{Binding Xaml, RelativeSource={RelativeSource TemplatedParent}}"
Content="_COPY"
DockPanel.Dock="Bottom"
Style="{StaticResource MaterialDesignRaisedButton}">
</Button>
<avalonEdit:TextEditor
Document="{Binding Xaml, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource TextDocumentValueConverter}}"
Style="{StaticResource AvalonTextEditorXamlDisplay}" />
</DockPanel>
</Border>

</materialDesign:PopupBox>
<Grid>
<AdornerDecorator>
<Border
BorderBrush="{DynamicResource SecondaryHueMidBrush}"
Opacity=".4"
Margin="-5">
<Border.Style>
<Style
TargetType="Border">
<Setter
Property="BorderThickness"
Value="0" />
<Style.Triggers>
<DataTrigger
Binding="{Binding ElementName=PopupBox, Path=IsPopupOpen}"
Value="True">
<Setter
Property="BorderThickness"
Value="5" />
</DataTrigger>
</Style.Triggers>
</Style>
</Border.Style>
</Border>
</AdornerDecorator>
<ContentPresenter />
</Grid>
</DockPanel>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>
</Application.Resources>
</Application>


39 changes: 39 additions & 0 deletions MaterialDesign3.Demo.Wpf/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
using System.Windows;
using ShowMeTheXAML;

namespace MaterialDesign3Demo
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
protected override void OnStartup(StartupEventArgs e)
{
//This is an alternate way to initialize MaterialDesignInXAML if you don't use the MaterialDesignResourceDictionary in App.xaml
//Color primaryColor = SwatchHelper.Lookup[MaterialDesignColor.DeepPurple];
//Color accentColor = SwatchHelper.Lookup[MaterialDesignColor.Lime];
//ITheme theme = Theme.Create(new MaterialDesignLightTheme(), primaryColor, accentColor);
//Resources.SetTheme(theme);


//Illustration of setting culture info fully in WPF:
/*
Thread.CurrentThread.CurrentCulture = new CultureInfo("fr-FR");
Thread.CurrentThread.CurrentUICulture = new CultureInfo("fr-FR");
FrameworkElement.LanguageProperty.OverrideMetadata(typeof(FrameworkElement), new FrameworkPropertyMetadata(
XmlLanguage.GetLanguage(CultureInfo.CurrentCulture.IetfLanguageTag)));
*/

XamlDisplay.Init();

// test setup for Persian culture settings
/*System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("fa-Ir");
System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("fa-Ir");
FrameworkElement.LanguageProperty.OverrideMetadata(typeof(FrameworkElement), new FrameworkPropertyMetadata(
System.Windows.Markup.XmlLanguage.GetLanguage(System.Globalization.CultureInfo.CurrentCulture.IetfLanguageTag)));*/

base.OnStartup(e);
}
}
}
19 changes: 19 additions & 0 deletions MaterialDesign3.Demo.Wpf/ButtonAssist.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using System.Windows;

namespace MaterialDesign3Demo
{
public static class ButtonAssist
{
public static readonly DependencyProperty UniformCornerRadiusProperty = DependencyProperty.RegisterAttached(
"UniformCornerRadius", typeof(double), typeof(ButtonAssist), new PropertyMetadata(2.0, OnUniformCornerRadius));

private static void OnUniformCornerRadius(DependencyObject d, DependencyPropertyChangedEventArgs e)
=> MaterialDesignThemes.Wpf.ButtonAssist.SetCornerRadius(d, new CornerRadius((double)e.NewValue));

public static void SetUniformCornerRadius(DependencyObject element, double value)
=> element.SetValue(UniformCornerRadiusProperty, value);

public static double GetUniformCornerRadius(DependencyObject element)
=> (double)element.GetValue(UniformCornerRadiusProperty);
}
}
Loading