Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: .NET Core / .NET 5 compatibility #29

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
19 changes: 19 additions & 0 deletions Enterwell.Clients.Wpf.Notifications.Sample.Net5/App.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<Application x:Class="Enterwell.Clients.Wpf.Notifications.Sample.Net5.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:Enterwell.Clients.Wpf.Notifications.Sample.Net5"
StartupUri="MainWindow.xaml">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<!-- MahApps.Metro resource dictionaries. Make sure that all file names are Case Sensitive! -->
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Fonts.xaml" />
<!-- Theme setting -->
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Themes/Dark.Blue.xaml" />
</ResourceDictionary.MergedDictionaries>
<Style BasedOn="{StaticResource {x:Type ProgressBar}}"
TargetType="{x:Type ProgressBar}" />
</ResourceDictionary>
</Application.Resources>
</Application>
17 changes: 17 additions & 0 deletions Enterwell.Clients.Wpf.Notifications.Sample.Net5/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;

namespace Enterwell.Clients.Wpf.Notifications.Sample.Net5
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
}
}
10 changes: 10 additions & 0 deletions Enterwell.Clients.Wpf.Notifications.Sample.Net5/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using System.Windows;

[assembly: ThemeInfo(
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
//(used if a resource is not found in the page,
// or application resource dictionaries)
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
//(used if a resource is not found in the page,
// app, or any theme specific resource dictionaries)
)]
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net5.0-windows</TargetFramework>
<UseWPF>true</UseWPF>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="MahApps.Metro" Version="2.3.4" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Enterwell.Clients.Wpf.Notifications\Enterwell.Clients.Wpf.Notifications.csproj" />
</ItemGroup>

</Project>
96 changes: 96 additions & 0 deletions Enterwell.Clients.Wpf.Notifications.Sample.Net5/MainWindow.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
<mahapps:MetroWindow x:Class="Enterwell.Clients.Wpf.Notifications.Sample.Net5.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="clr-namespace:Enterwell.Clients.Wpf.Notifications.Controls;assembly=Enterwell.Clients.Wpf.Notifications"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mahapps="http://metro.mahapps.com/winfx/xaml/controls"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
Title="MainWindow"
Width="900"
Height="600"
BorderThickness="0"
GlowBrush="Black"
ResizeMode="CanResizeWithGrip"
ShowTitleBar="False"
WindowStartupLocation="CenterScreen"
WindowTransitionsEnabled="False"
mc:Ignorable="d">
<mahapps:MetroWindow.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/Enterwell.Clients.Wpf.Notifications;component/Themes/Generic.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</mahapps:MetroWindow.Resources>
<mahapps:MetroWindow.WindowButtonCommands>
<mahapps:WindowButtonCommands Style="{DynamicResource MahApps.Metro.Styles.WindowButtonCommands.Win10}" />
</mahapps:MetroWindow.WindowButtonCommands>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="3*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>

<Border Grid.Column="1">
<controls:NotificationMessageContainer Manager="{Binding Manager}" />
</Border>

<WrapPanel Grid.Row="1"
Grid.Column="0"
Grid.ColumnSpan="3"
VerticalAlignment="Bottom"
Orientation="Horizontal">

<Button Margin="8"
Padding="12,8"
HorizontalAlignment="Left"
VerticalAlignment="Top"
Background="#1751C3"
Click="ButtonBaseInfoOnClick"
Content="Info message"
Style="{StaticResource NotificationMessageButtonStyle}" />

<Button Margin="8"
Padding="12,8"
HorizontalAlignment="Left"
VerticalAlignment="Top"
Background="#E0A030"
Click="ButtonBaseWarningOnClick"
Content="Warning (with header)"
Style="{StaticResource NotificationMessageButtonStyle}" />

<Button Margin="8"
Padding="12,8"
HorizontalAlignment="Left"
VerticalAlignment="Top"
Background="#F15B19"
Click="ButtonBaseErrorOnClick"
Content="Error message"
Style="{StaticResource NotificationMessageButtonStyle}" />

<Button Margin="8"
Padding="12,8"
HorizontalAlignment="Left"
VerticalAlignment="Top"
Background="#1751C3"
Click="ButtonBaseInfoDelayOnClick"
Content="Animated info message with delayed dismiss (5s)"
Style="{StaticResource NotificationMessageButtonStyle}" />

<Button Margin="8"
Padding="12,8"
HorizontalAlignment="Left"
VerticalAlignment="Top"
Background="#1751C3"
Click="ButtonBaseAdditionalContentOnClick"
Content="Additional Content Areas"
Style="{StaticResource NotificationMessageButtonStyle}" />

</WrapPanel>
</Grid>
</mahapps:MetroWindow>
152 changes: 152 additions & 0 deletions Enterwell.Clients.Wpf.Notifications.Sample.Net5/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;

namespace Enterwell.Clients.Wpf.Notifications.Sample.Net5
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow
{
/// <summary>
/// Initializes a new instance of the <see cref="MainWindow"/> class.
/// </summary>
public MainWindow()
{
this.InitializeComponent();
this.DataContext = this;
}

private void ButtonBaseErrorOnClick(object sender, RoutedEventArgs e)
{
this.Manager
.CreateMessage()
.Accent("#F15B19")
.Background("#F15B19")
.HasHeader("Lost connection to server")
.HasMessage("Reconnecting...")
.WithOverlay(new ProgressBar
{
VerticalAlignment = VerticalAlignment.Bottom,
HorizontalAlignment = HorizontalAlignment.Stretch,
Height = 3,
BorderThickness = new Thickness(0),
Foreground = new SolidColorBrush(Color.FromArgb(128, 255, 255, 255)),
Background = Brushes.Transparent,
IsIndeterminate = true,
IsHitTestVisible = false
})
.Queue();
}

private void ButtonBaseWarningOnClick(object sender, RoutedEventArgs e)
{
this.Manager
.CreateMessage()
.Accent("#E0A030")
.Background("#333")
.HasBadge("Warn")
.HasHeader("Error")
.HasMessage("Failed to retrieve data.")
.WithButton("Try again", button => { })
.Dismiss().WithButton("Ignore", button => { })
.Queue();
}

private void ButtonBaseInfoOnClick(object sender, RoutedEventArgs e)
{
this.Manager
.CreateMessage()
.Accent("#1751C3")
.Background("#333")
.HasBadge("Info")
.HasMessage("Update will be installed on next application restart.")
.Dismiss().WithButton("Update now", button => { })
.Dismiss().WithButton("Release notes", button => { })
.Dismiss().WithButton("Later", button => { })
.Queue();
}

private void ButtonBaseInfoDelayOnClick(object sender, RoutedEventArgs e)
{
this.Manager
.CreateMessage()
.Accent("#1751C3")
.Animates(true)
.AnimationInDuration(0.75)
.AnimationOutDuration(2)
.Background("#333")
.HasBadge("Info")
.HasMessage("Update will be installed on next application restart. This message will be dismissed after 5 seconds.")
.Dismiss().WithButton("Update now", button => { })
.Dismiss().WithButton("Release notes", button => { })
.Dismiss().WithDelay(TimeSpan.FromSeconds(5))
.Queue();
}

private void ButtonBaseAdditionalContentOnClick(object sender, RoutedEventArgs e)
{
this.Manager
.CreateMessage()
.Accent("#1751C3")
.Background("#333")
.Foreground("#333")
.HasBadge("Info")
.HasHeader("Header")
.HasMessage("This is the message!")
.WithAdditionalContent(ContentLocation.Top, new Border
{
Height = 25,
VerticalAlignment = VerticalAlignment.Stretch,
HorizontalAlignment = HorizontalAlignment.Stretch,
Background = Brushes.Red
})
.WithAdditionalContent(ContentLocation.Bottom, new Border
{
Height = 25,
VerticalAlignment = VerticalAlignment.Stretch,
HorizontalAlignment = HorizontalAlignment.Stretch,
Background = Brushes.Green
})
.WithAdditionalContent(ContentLocation.Left, new Border
{
Width = 25,
VerticalAlignment = VerticalAlignment.Stretch,
HorizontalAlignment = HorizontalAlignment.Stretch,
Background = Brushes.Yellow
})
.WithAdditionalContent(ContentLocation.Right, new Border
{
Width = 25,
VerticalAlignment = VerticalAlignment.Stretch,
HorizontalAlignment = HorizontalAlignment.Stretch,
Background = Brushes.Violet
})
.WithAdditionalContent(ContentLocation.Main, new Border
{
MinHeight = 50,
VerticalAlignment = VerticalAlignment.Stretch,
HorizontalAlignment = HorizontalAlignment.Stretch,
Background = Brushes.Orange
})
.WithAdditionalContent(ContentLocation.AboveBadge, new Border
{
Height = 40,
Width = 40,
Background = Brushes.Indigo
})
.Dismiss().WithButton("Dismiss", button => { })
.Queue();
}

/// <summary>
/// Gets the notification message manager.
/// </summary>
/// <value>
/// The notification message manager.
/// </value>
public INotificationMessageManager Manager { get; } = new NotificationMessageManager();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,8 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="MahApps.Metro, Version=1.4.3.0, Culture=neutral, PublicKeyToken=f4fb5a3c4d1e5b4f, processorArchitecture=MSIL">
<HintPath>..\packages\MahApps.Metro.1.4.3\lib\net45\MahApps.Metro.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Windows.Interactivity, Version=4.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\MahApps.Metro.1.4.3\lib\net45\System.Windows.Interactivity.dll</HintPath>
</Reference>
<Reference Include="System.Xml" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Core" />
Expand Down Expand Up @@ -91,7 +85,6 @@
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
<None Include="packages.config" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
Expand All @@ -106,5 +99,10 @@
<Name>Enterwell.Clients.Wpf.Notifications</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<PackageReference Include="MahApps.Metro">
<Version>1.4.3</Version>
</PackageReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
4 changes: 0 additions & 4 deletions Enterwell.Clients.Wpf.Notifications.Sample/packages.config

This file was deleted.

10 changes: 8 additions & 2 deletions Enterwell.Clients.Wpf.Notifications.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.26206.0
# Visual Studio Version 16
VisualStudioVersion = 16.0.30709.132
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Enterwell.Clients.Wpf.Notifications", "Enterwell.Clients.Wpf.Notifications\Enterwell.Clients.Wpf.Notifications.csproj", "{CFA27B27-9231-4F6D-804A-C0AE33FA5237}"
EndProject
Expand All @@ -13,6 +13,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
Readme.md = Readme.md
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Enterwell.Clients.Wpf.Notifications.Sample.Net5", "Enterwell.Clients.Wpf.Notifications.Sample.Net5\Enterwell.Clients.Wpf.Notifications.Sample.Net5.csproj", "{1F1B08F8-6BAA-4805-A703-93242F2DDB4F}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -27,6 +29,10 @@ Global
{4B47659C-0B1D-4273-B03F-D335F9B5E802}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4B47659C-0B1D-4273-B03F-D335F9B5E802}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4B47659C-0B1D-4273-B03F-D335F9B5E802}.Release|Any CPU.Build.0 = Release|Any CPU
{1F1B08F8-6BAA-4805-A703-93242F2DDB4F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1F1B08F8-6BAA-4805-A703-93242F2DDB4F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1F1B08F8-6BAA-4805-A703-93242F2DDB4F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1F1B08F8-6BAA-4805-A703-93242F2DDB4F}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
Loading