Skip to content

Commit

Permalink
.NET 9 (#7)
Browse files Browse the repository at this point in the history
* Dotnet 9 and partial warning handling

* More warning handling

* Updated nuget.yml

* More cleanup
  • Loading branch information
carl-andersson-at-westermo authored Dec 2, 2024
1 parent 9c9fd64 commit 705d9b1
Show file tree
Hide file tree
Showing 225 changed files with 4,394 additions and 4,817 deletions.
14 changes: 9 additions & 5 deletions .github/workflows/nuget.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,13 @@ jobs:
create_nuget:
runs-on: windows-latest
env:
COMMIT_SHA: ${{ github.sha || github.event.pull_request.head.sha }}
COMMIT_SHA: ${{ github.sha || github.event.pull_request.head.sha }}
steps:
- uses: actions/checkout@v3
- name: Setup .NET
uses: actions/setup-dotnet@v3
- name: Setup dotnet ${{ matrix.dotnet-version }}
uses: actions/setup-dotnet@v4
with:
dotnet-version: "9.0.x"
- run: |
If (('${{ github.event_name }}' -eq 'release') -and ('${{ github.ref_name }}' -match '^(?<version>\d+\.\d+\.\d+)')) {
Add-Content -Path $Env:GITHUB_ENV -Value "VERSION=$($Matches.version)"
Expand All @@ -57,8 +59,10 @@ jobs:
runs-on: windows-latest
needs: [ create_nuget ]
steps:
- name: Setup .NET
uses: actions/setup-dotnet@v3
- name: Setup dotnet ${{ matrix.dotnet-version }}
uses: actions/setup-dotnet@v4
with:
dotnet-version: "9.0.x"
- uses: actions/download-artifact@v3
with:
name: nuget
Expand Down
13 changes: 3 additions & 10 deletions Examples/ShowcaseApp.WPF/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,9 @@
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Windows;

namespace ShowcaseApp.WPF
namespace ShowcaseApp.WPF
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
public partial class App
{
}
}
}
3 changes: 1 addition & 2 deletions Examples/ShowcaseApp.WPF/Assets/ModernUI.Snowflakes.xaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mui="http://firstfloorsoftware.com/ModernUI">
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/FirstFloor.ModernUI;component/Assets/ModernUI.Light.xaml" />
Expand Down
29 changes: 17 additions & 12 deletions Examples/ShowcaseApp.WPF/Content/SettingsAppearance.xaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
<UserControl x:Class="ShowcaseApp.WPF.Content.SettingsAppearance"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mui="http://firstfloorsoftware.com/ModernUI"
mc:Ignorable="d"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300">
<Grid>
<ScrollViewer>
Expand All @@ -21,7 +20,7 @@
</ListBox.ItemsPanel>
<ListBox.ItemTemplate>
<DataTemplate>
<Rectangle Width="40" Height="40" Margin="2" >
<Rectangle Width="40" Height="40" Margin="2">
<Rectangle.Fill>
<SolidColorBrush x:Name="Brush" Color="{Binding}" />
</Rectangle.Fill>
Expand All @@ -33,7 +32,7 @@
<Grid HorizontalAlignment="Left">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition MinWidth="120"/>
<ColumnDefinition MinWidth="120" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition />
Expand All @@ -42,15 +41,21 @@
</Grid.RowDefinitions>

<TextBlock Text="Palette:" VerticalAlignment="Center" Margin="0,0,16,4" />
<ComboBox Grid.Column="1" ItemsSource="{Binding Palettes}" SelectedItem="{Binding SelectedPalette, Mode=TwoWay}" VerticalAlignment="Center" Margin="0,0,0,4" />
<ComboBox Grid.Row="0" Grid.Column="1" ItemsSource="{Binding Palettes}"
SelectedItem="{Binding SelectedPalette, Mode=TwoWay}" VerticalAlignment="Center"
Margin="0,0,0,4" />

<TextBlock Grid.Row="1" Text="Theme:" VerticalAlignment="Center" Margin="0,0,16,4" />
<ComboBox Grid.Row="1" Grid.Column="1" ItemsSource="{Binding Themes}" SelectedItem="{Binding SelectedTheme, Mode=TwoWay}" DisplayMemberPath="DisplayName" VerticalAlignment="Center" Margin="0,0,0,4" />
<TextBlock Grid.Column="0" Grid.Row="1" Text="Theme:" VerticalAlignment="Center" Margin="0,0,16,4" />
<ComboBox Grid.Row="1" Grid.Column="1" ItemsSource="{Binding Themes}"
SelectedItem="{Binding SelectedTheme, Mode=TwoWay}" DisplayMemberPath="DisplayName"
VerticalAlignment="Center" Margin="0,0,0,4" />

<TextBlock Grid.Row="2" Text="Font size:" VerticalAlignment="Center" Margin="0,0,16,0" />
<ComboBox Grid.Row="2" Grid.Column="1" ItemsSource="{Binding FontSizes}" SelectedItem="{Binding SelectedFontSize, Mode=TwoWay}" VerticalAlignment="Center" />
<TextBlock Grid.Column="0" Grid.Row="2" Text="Font size:" VerticalAlignment="Center"
Margin="0,0,16,0" />
<ComboBox Grid.Row="2" Grid.Column="1" ItemsSource="{Binding FontSizes}"
SelectedItem="{Binding SelectedFontSize, Mode=TwoWay}" VerticalAlignment="Center" />
</Grid>
</StackPanel>
</ScrollViewer>
</Grid>
</UserControl>
</UserControl>
10 changes: 4 additions & 6 deletions Examples/ShowcaseApp.WPF/Content/SettingsAppearance.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
using System.Windows.Controls;

namespace ShowcaseApp.WPF.Content
namespace ShowcaseApp.WPF.Content
{
/// <summary>
/// Interaction logic for SettingsAppearance.xaml
/// </summary>
public partial class SettingsAppearance : UserControl
public partial class SettingsAppearance
{
public SettingsAppearance()
{
InitializeComponent();

// a simple view model for appearance configuration
this.DataContext = new SettingsAppearanceViewModel();
DataContext = new SettingsAppearanceViewModel();
}
}
}
}
74 changes: 32 additions & 42 deletions Examples/ShowcaseApp.WPF/Content/SettingsAppearanceViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ public class SettingsAppearanceViewModel
private const string PaletteWP = "windows phone";

// 9 accent colors from metro design principles
private Color[] metroAccentColors = new Color[]{
private readonly Color[] metroAccentColors =
[
Color.FromRgb(0x33, 0x99, 0xff), // blue
Color.FromRgb(0x00, 0xab, 0xa9), // teal
Color.FromRgb(0x33, 0x99, 0x33), // green
Expand All @@ -28,11 +29,12 @@ public class SettingsAppearanceViewModel
Color.FromRgb(0xff, 0x45, 0x00), // orange red
Color.FromRgb(0xe5, 0x14, 0x00), // red
Color.FromRgb(0xff, 0x00, 0x97), // magenta
Color.FromRgb(0xa2, 0x00, 0xff), // purple
};
Color.FromRgb(0xa2, 0x00, 0xff) // purple
];

// 20 accent colors from Windows Phone 8
private Color[] wpAccentColors = new Color[]{
private readonly Color[] wpAccentColors =
[
Color.FromRgb(0xa4, 0xc4, 0x00), // lime
Color.FromRgb(0x60, 0xa9, 0x17), // green
Color.FromRgb(0x00, 0x8a, 0x00), // emerald
Expand All @@ -52,26 +54,26 @@ public class SettingsAppearanceViewModel
Color.FromRgb(0x6d, 0x87, 0x64), // olive
Color.FromRgb(0x64, 0x76, 0x87), // steel
Color.FromRgb(0x76, 0x60, 0x8a), // mauve
Color.FromRgb(0x87, 0x79, 0x4e), // taupe
};
Color.FromRgb(0x87, 0x79, 0x4e) // taupe
];

private string selectedPalette = PaletteWP;

private Color selectedAccentColor;
private LinkCollection themes = new LinkCollection();
private readonly LinkCollection themes = [];
private Link selectedTheme;
private string selectedFontSize;

public SettingsAppearanceViewModel()
{
// add the default themes
this.themes.Add(new Link { DisplayName = "dark", Source = AppearanceManager.DarkThemeSource });
this.themes.Add(new Link { DisplayName = "light", Source = AppearanceManager.LightThemeSource });
themes.Add(new Link { DisplayName = "dark", Source = AppearanceManager.DarkThemeSource });
themes.Add(new Link { DisplayName = "light", Source = AppearanceManager.LightThemeSource });

// add additional themes
this.themes.Add(new Link { DisplayName = "snowflakes", Source = new Uri("/ShowcaseApp.WPF;component/Assets/ModernUI.Snowflakes.xaml", UriKind.Relative) });
themes.Add(new Link { DisplayName = "snowflakes", Source = new Uri("/ShowcaseApp.WPF;component/Assets/ModernUI.Snowflakes.xaml", UriKind.Relative) });

this.SelectedFontSize = AppearanceManager.Current.FontSize == FontSize.Large ? FontLarge : FontSmall;
SelectedFontSize = AppearanceManager.Current.FontSize == FontSize.Large ? FontLarge : FontSmall;
SyncThemeAndColor();

AppearanceManager.Current.PropertyChanged += OnAppearanceManagerPropertyChanged;
Expand All @@ -80,10 +82,10 @@ public SettingsAppearanceViewModel()
private void SyncThemeAndColor()
{
// synchronizes the selected viewmodel theme with the actual theme used by the appearance manager.
this.SelectedTheme = this.themes.FirstOrDefault(l => l.Source.Equals(AppearanceManager.Current.ThemeSource));
SelectedTheme = themes.FirstOrDefault(l => l.Source.Equals(AppearanceManager.Current.ThemeSource));

// and make sure accent color is up-to-date
this.SelectedAccentColor = AppearanceManager.Current.AccentColor;
SelectedAccentColor = AppearanceManager.Current.AccentColor;
}

private void OnAppearanceManagerPropertyChanged(object sender, PropertyChangedEventArgs e)
Expand All @@ -93,47 +95,35 @@ private void OnAppearanceManagerPropertyChanged(object sender, PropertyChangedEv
}
}

public LinkCollection Themes
{
get { return this.themes; }
}
public LinkCollection Themes => themes;

public string[] FontSizes
{
get { return new string[] { FontSmall, FontLarge }; }
}
public string[] FontSizes => [FontSmall, FontLarge];

public string[] Palettes
{
get { return new string[] { PaletteMetro, PaletteWP }; }
}
public string[] Palettes => [PaletteMetro, PaletteWP];

public Color[] AccentColors
{
get { return this.selectedPalette == PaletteMetro ? this.metroAccentColors : this.wpAccentColors; }
}
public Color[] AccentColors => selectedPalette == PaletteMetro ? metroAccentColors : wpAccentColors;

public string SelectedPalette
{
get { return this.selectedPalette; }
get => selectedPalette;
set
{
if (this.selectedPalette != value) {
this.selectedPalette = value;
if (selectedPalette != value) {
selectedPalette = value;
OnPropertyChanged("AccentColors");

this.SelectedAccentColor = this.AccentColors.FirstOrDefault();
SelectedAccentColor = AccentColors.FirstOrDefault();
}
}
}

public Link SelectedTheme
{
get { return this.selectedTheme; }
get => selectedTheme;
set
{
if (this.selectedTheme != value) {
this.selectedTheme = value;
if (selectedTheme != value) {
selectedTheme = value;
OnPropertyChanged("SelectedTheme");

// and update the actual theme
Expand All @@ -144,11 +134,11 @@ public Link SelectedTheme

public string SelectedFontSize
{
get { return this.selectedFontSize; }
get => selectedFontSize;
set
{
if (this.selectedFontSize != value) {
this.selectedFontSize = value;
if (selectedFontSize != value) {
selectedFontSize = value;
OnPropertyChanged("SelectedFontSize");

AppearanceManager.Current.FontSize = value == FontLarge ? FontSize.Large : FontSize.Small;
Expand All @@ -158,11 +148,11 @@ public string SelectedFontSize

public Color SelectedAccentColor
{
get { return this.selectedAccentColor; }
get => selectedAccentColor;
set
{
if (this.selectedAccentColor != value) {
this.selectedAccentColor = value;
if (selectedAccentColor != value) {
selectedAccentColor = value;
OnPropertyChanged("SelectedAccentColor");

AppearanceManager.Current.AccentColor = value;
Expand Down
2 changes: 1 addition & 1 deletion Examples/ShowcaseApp.WPF/Controls/MiniContentPage.xaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<UserControl x:Class="ShowcaseApp.WPF.Pages.MiniContentPage"
<UserControl x:Class="ShowcaseApp.WPF.Controls.MiniContentPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
Expand Down
22 changes: 15 additions & 7 deletions Examples/ShowcaseApp.WPF/Controls/MiniContentPage.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
using System.ComponentModel;
using System.Windows.Controls;
using ShowcaseApp.WPF.Controls;

namespace ShowcaseApp.WPF.Pages
namespace ShowcaseApp.WPF.Controls
{
/// <summary>
/// Interaction logic for MiniContentPage.xaml
/// </summary>
public partial class MiniContentPage : UserControl, ISpecialWindowContentIntro, INotifyPropertyChanged
public partial class MiniContentPage : ISpecialWindowContentIntro, INotifyPropertyChanged
{
public MiniContentPage()
{
Expand All @@ -16,13 +14,23 @@ public MiniContentPage()
}

private string _text;
public string IntroText { get { return _text; } set { _text = value; OnPropertyChanged("IntroText"); } }

public string IntroText
{
get => _text;
set
{
_text = value;
OnPropertyChanged(nameof(IntroText));
}
}

public event PropertyChangedEventHandler PropertyChanged;

protected virtual void OnPropertyChanged(string propertyName)
{
var handler = PropertyChanged;
if (handler != null) handler(this, new PropertyChangedEventArgs(propertyName));
handler?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
}
}
}
2 changes: 1 addition & 1 deletion Examples/ShowcaseApp.WPF/Controls/MiniXamlPage.xaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<UserControl x:Class="ShowcaseApp.WPF.Pages.MiniXamlPage"
<UserControl x:Class="ShowcaseApp.WPF.Controls.MiniXamlPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
Expand Down
Loading

0 comments on commit 705d9b1

Please sign in to comment.