Skip to content

Commit 8095a8f

Browse files
authored
Demo app file scoped namespaces (#3272)
1 parent 18df456 commit 8095a8f

File tree

76 files changed

+1623
-1699
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+1623
-1699
lines changed

MainDemo.Wpf/App.xaml.cs

Lines changed: 26 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,37 @@
11
using ShowMeTheXAML;
22

3-
namespace MaterialDesignDemo
3+
namespace MaterialDesignDemo;
4+
5+
/// <summary>
6+
/// Interaction logic for App.xaml
7+
/// </summary>
8+
public partial class App : Application
49
{
5-
/// <summary>
6-
/// Interaction logic for App.xaml
7-
/// </summary>
8-
public partial class App : Application
10+
protected override void OnStartup(StartupEventArgs e)
911
{
10-
protected override void OnStartup(StartupEventArgs e)
11-
{
12-
//This is an alternate way to initialize MaterialDesignInXAML if you don't use the MaterialDesignResourceDictionary in App.xaml
13-
//Color primaryColor = SwatchHelper.Lookup[MaterialDesignColor.DeepPurple];
14-
//Color accentColor = SwatchHelper.Lookup[MaterialDesignColor.Lime];
15-
//ITheme theme = Theme.Create(new MaterialDesignLightTheme(), primaryColor, accentColor);
16-
//Resources.SetTheme(theme);
12+
//This is an alternate way to initialize MaterialDesignInXAML if you don't use the MaterialDesignResourceDictionary in App.xaml
13+
//Color primaryColor = SwatchHelper.Lookup[MaterialDesignColor.DeepPurple];
14+
//Color accentColor = SwatchHelper.Lookup[MaterialDesignColor.Lime];
15+
//ITheme theme = Theme.Create(new MaterialDesignLightTheme(), primaryColor, accentColor);
16+
//Resources.SetTheme(theme);
1717

1818

19-
//Illustration of setting culture info fully in WPF:
20-
/*
21-
Thread.CurrentThread.CurrentCulture = new CultureInfo("fr-FR");
22-
Thread.CurrentThread.CurrentUICulture = new CultureInfo("fr-FR");
23-
FrameworkElement.LanguageProperty.OverrideMetadata(typeof(FrameworkElement), new FrameworkPropertyMetadata(
24-
XmlLanguage.GetLanguage(CultureInfo.CurrentCulture.IetfLanguageTag)));
25-
*/
19+
//Illustration of setting culture info fully in WPF:
20+
/*
21+
Thread.CurrentThread.CurrentCulture = new CultureInfo("fr-FR");
22+
Thread.CurrentThread.CurrentUICulture = new CultureInfo("fr-FR");
23+
FrameworkElement.LanguageProperty.OverrideMetadata(typeof(FrameworkElement), new FrameworkPropertyMetadata(
24+
XmlLanguage.GetLanguage(CultureInfo.CurrentCulture.IetfLanguageTag)));
25+
*/
2626

27-
XamlDisplay.Init();
27+
XamlDisplay.Init();
2828

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

35-
base.OnStartup(e);
36-
}
35+
base.OnStartup(e);
3736
}
3837
}

MainDemo.Wpf/ButtonAssist.cs

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
1-
namespace MaterialDesignDemo
1+
namespace MaterialDesignDemo;
2+
3+
public static class ButtonAssist
24
{
3-
public static class ButtonAssist
4-
{
5-
public static readonly DependencyProperty UniformCornerRadiusProperty = DependencyProperty.RegisterAttached(
6-
"UniformCornerRadius", typeof(double), typeof(ButtonAssist), new PropertyMetadata(2.0, OnUniformCornerRadius));
5+
public static readonly DependencyProperty UniformCornerRadiusProperty = DependencyProperty.RegisterAttached(
6+
"UniformCornerRadius", typeof(double), typeof(ButtonAssist), new PropertyMetadata(2.0, OnUniformCornerRadius));
77

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

11-
public static void SetUniformCornerRadius(DependencyObject element, double value)
12-
=> element.SetValue(UniformCornerRadiusProperty, value);
11+
public static void SetUniformCornerRadius(DependencyObject element, double value)
12+
=> element.SetValue(UniformCornerRadiusProperty, value);
1313

14-
public static double GetUniformCornerRadius(DependencyObject element)
15-
=> (double)element.GetValue(UniformCornerRadiusProperty);
16-
}
14+
public static double GetUniformCornerRadius(DependencyObject element)
15+
=> (double)element.GetValue(UniformCornerRadiusProperty);
1716
}

MainDemo.Wpf/Buttons.xaml.cs

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,32 @@
11
using System.Diagnostics;
22
using MaterialDesignDemo.Domain;
33

4-
namespace MaterialDesignDemo
4+
namespace MaterialDesignDemo;
5+
6+
public partial class Buttons
57
{
6-
public partial class Buttons
8+
public Buttons()
79
{
8-
public Buttons()
9-
{
10-
DataContext = new ButtonsViewModel();
11-
InitializeComponent();
12-
}
10+
DataContext = new ButtonsViewModel();
11+
InitializeComponent();
12+
}
1313

14-
private void ButtonBase_OnClick(object sender, RoutedEventArgs e)
15-
=> Debug.WriteLine("Just checking we haven't suppressed the button.");
14+
private void ButtonBase_OnClick(object sender, RoutedEventArgs e)
15+
=> Debug.WriteLine("Just checking we haven't suppressed the button.");
1616

17-
private void PopupBox_OnOpened(object sender, RoutedEventArgs e)
18-
=> Debug.WriteLine("Just making sure the popup has opened.");
17+
private void PopupBox_OnOpened(object sender, RoutedEventArgs e)
18+
=> Debug.WriteLine("Just making sure the popup has opened.");
1919

20-
private void PopupBox_OnClosed(object sender, RoutedEventArgs e)
21-
=> Debug.WriteLine("Just making sure the popup has closed.");
20+
private void PopupBox_OnClosed(object sender, RoutedEventArgs e)
21+
=> Debug.WriteLine("Just making sure the popup has closed.");
2222

23-
private void CountingButton_OnClick(object sender, RoutedEventArgs e)
24-
{
25-
if (CountingBadge.Badge == null || Equals(CountingBadge.Badge, string.Empty))
26-
CountingBadge.Badge = 0;
23+
private void CountingButton_OnClick(object sender, RoutedEventArgs e)
24+
{
25+
if (CountingBadge.Badge == null || Equals(CountingBadge.Badge, string.Empty))
26+
CountingBadge.Badge = 0;
2727

28-
var next = int.Parse(CountingBadge.Badge.ToString() ?? "0") + 1;
28+
var next = int.Parse(CountingBadge.Badge.ToString() ?? "0") + 1;
2929

30-
CountingBadge.Badge = next < 21 ? (object)next : null;
31-
}
30+
CountingBadge.Badge = next < 21 ? (object)next : null;
3231
}
3332
}

MainDemo.Wpf/Cards.xaml.cs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
namespace MaterialDesignDemo
1+
namespace MaterialDesignDemo;
2+
3+
public partial class Cards
24
{
3-
public partial class Cards
4-
{
5-
public Cards() => InitializeComponent();
5+
public Cards() => InitializeComponent();
66

7-
private void Flipper_OnIsFlippedChanged(object sender, RoutedPropertyChangedEventArgs<bool> e)
8-
=> System.Diagnostics.Debug.WriteLine($"Card is flipped = {e.NewValue}");
9-
}
7+
private void Flipper_OnIsFlippedChanged(object sender, RoutedPropertyChangedEventArgs<bool> e)
8+
=> System.Diagnostics.Debug.WriteLine($"Card is flipped = {e.NewValue}");
109
}

MainDemo.Wpf/Chips.xaml.cs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
1-
namespace MaterialDesignDemo
1+
namespace MaterialDesignDemo;
2+
3+
public partial class Chips
24
{
3-
public partial class Chips
4-
{
5-
public Chips() => InitializeComponent();
5+
public Chips() => InitializeComponent();
66

7-
private void ButtonsDemoChip_OnClick(object sender, RoutedEventArgs e)
8-
=> MainWindow.Snackbar.MessageQueue?.Enqueue("Chip clicked!");
7+
private void ButtonsDemoChip_OnClick(object sender, RoutedEventArgs e)
8+
=> MainWindow.Snackbar.MessageQueue?.Enqueue("Chip clicked!");
99

10-
private void ButtonsDemoChip_OnDeleteClick(object sender, RoutedEventArgs e)
11-
=> MainWindow.Snackbar.MessageQueue?.Enqueue("Chip delete clicked!");
10+
private void ButtonsDemoChip_OnDeleteClick(object sender, RoutedEventArgs e)
11+
=> MainWindow.Snackbar.MessageQueue?.Enqueue("Chip delete clicked!");
1212

13-
}
1413
}

MainDemo.Wpf/ColorScheme.cs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
namespace MaterialDesignDemo
1+
namespace MaterialDesignDemo;
2+
3+
enum ColorScheme
24
{
3-
enum ColorScheme
4-
{
5-
Primary,
6-
Secondary,
7-
PrimaryForeground,
8-
SecondaryForeground
9-
}
5+
Primary,
6+
Secondary,
7+
PrimaryForeground,
8+
SecondaryForeground
109
}

MainDemo.Wpf/ColorTool.xaml.cs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
using MaterialDesignDemo.Domain;
22

3-
namespace MaterialDesignDemo
3+
namespace MaterialDesignDemo;
4+
5+
public partial class ColorTool
46
{
5-
public partial class ColorTool
7+
public ColorTool()
68
{
7-
public ColorTool()
8-
{
9-
DataContext = new ColorToolViewModel();
10-
InitializeComponent();
11-
}
9+
DataContext = new ColorToolViewModel();
10+
InitializeComponent();
1211
}
1312
}

MainDemo.Wpf/ColorZones.xaml.cs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
namespace MaterialDesignDemo
1+
namespace MaterialDesignDemo;
2+
3+
public partial class ColorZones
24
{
3-
public partial class ColorZones
4-
{
5-
public ColorZones() => InitializeComponent();
6-
}
5+
public ColorZones() => InitializeComponent();
76
}

MainDemo.Wpf/Converters/BrushToHexConverter.cs

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,21 @@
22
using System.Windows.Data;
33
using System.Windows.Media;
44

5-
namespace MaterialDesignDemo.Converters
5+
namespace MaterialDesignDemo.Converters;
6+
7+
public class BrushToHexConverter : IValueConverter
68
{
7-
public class BrushToHexConverter : IValueConverter
9+
public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
810
{
9-
public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
10-
{
11-
if (value is null) return null;
12-
string lowerHexString(int i) => i.ToString("X2").ToLower();
13-
var brush = (SolidColorBrush)value;
14-
var hex = lowerHexString(brush.Color.R) +
15-
lowerHexString(brush.Color.G) +
16-
lowerHexString(brush.Color.B);
17-
return "#" + hex;
18-
}
19-
20-
public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
21-
=> throw new NotImplementedException();
11+
if (value is null) return null;
12+
string lowerHexString(int i) => i.ToString("X2").ToLower();
13+
var brush = (SolidColorBrush)value;
14+
var hex = lowerHexString(brush.Color.R) +
15+
lowerHexString(brush.Color.G) +
16+
lowerHexString(brush.Color.B);
17+
return "#" + hex;
2218
}
19+
20+
public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
21+
=> throw new NotImplementedException();
2322
}

MainDemo.Wpf/Converters/ColorToBrushConverter.cs

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,26 @@
22
using System.Windows.Data;
33
using System.Windows.Media;
44

5-
namespace MaterialDesignDemo.Converters
5+
namespace MaterialDesignDemo.Converters;
6+
7+
[ValueConversion(typeof(Color), typeof(Brush))]
8+
public class ColorToBrushConverter : IValueConverter
69
{
7-
[ValueConversion(typeof(Color), typeof(Brush))]
8-
public class ColorToBrushConverter : IValueConverter
10+
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
911
{
10-
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
12+
if (value is Color color)
1113
{
12-
if (value is Color color)
13-
{
14-
return new SolidColorBrush(color);
15-
}
16-
return Binding.DoNothing;
14+
return new SolidColorBrush(color);
1715
}
16+
return Binding.DoNothing;
17+
}
1818

19-
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
19+
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
20+
{
21+
if (value is SolidColorBrush brush)
2022
{
21-
if (value is SolidColorBrush brush)
22-
{
23-
return brush.Color;
24-
}
25-
return default(Color);
23+
return brush.Color;
2624
}
25+
return default(Color);
2726
}
2827
}

0 commit comments

Comments
 (0)