Skip to content

Commit

Permalink
Merge pull request #8 from atc-net/feature/wpf-app-continue
Browse files Browse the repository at this point in the history
Atc.Azure.IoT.Wpf.App - Introduce AboutBoxDialog
  • Loading branch information
perkops authored May 29, 2024
2 parents 6789a8c + a547455 commit 7e1c27c
Show file tree
Hide file tree
Showing 10 changed files with 179 additions and 7 deletions.
1 change: 1 addition & 0 deletions src/Atc.Azure.IoT.Wpf.App/.editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ dotnet_diagnostic.MA0048.severity = none # To support partial classes

dotnet_diagnostic.MA0049.severity = none # Type name should not match containing namespace (https://github.com/meziantou/Meziantou.Analyzer/blob/main/docs/Rules/MA0049.md)

dotnet_diagnostic.S1075.severity = none #
dotnet_diagnostic.S4487.severity = none #

dotnet_diagnostic.CA1724.severity = none #
Expand Down
1 change: 1 addition & 0 deletions src/Atc.Azure.IoT.Wpf.App/App.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/Atc.Wpf.Controls;component/Styles/Controls.xaml" />
<ResourceDictionary Source="pack://application:,,,/Atc.Wpf.Theming;component/Styles/Default.xaml" />
<ResourceDictionary Source="pack://application:,,,/Fluent;component/Themes/Generic.xaml" />
</ResourceDictionary.MergedDictionaries>

</ResourceDictionary>
Expand Down
2 changes: 2 additions & 0 deletions src/Atc.Azure.IoT.Wpf.App/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ public partial class App
private readonly IHost host;
private IConfiguration? configuration;

public static readonly BitmapImage DefaultIcon = new(new Uri("pack://application:,,,/Resources/AppIcon.ico", UriKind.Absolute));

public App()
{
host = Host.CreateDefaultBuilder()
Expand Down
6 changes: 6 additions & 0 deletions src/Atc.Azure.IoT.Wpf.App/Atc.Azure.IoT.Wpf.App.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

<ItemGroup>
<None Remove="appsettings.json" />
<None Remove="Resources\AppIcon.ico" />
</ItemGroup>

<ItemGroup>
Expand All @@ -20,6 +21,7 @@
<ItemGroup>
<PackageReference Include="Atc.Wpf" Version="2.0.505" />
<PackageReference Include="Atc.Wpf.Controls" Version="2.0.505" />
<PackageReference Include="Atc.Wpf.FontIcons" Version="2.0.505" />
<PackageReference Include="Atc.Wpf.Theming" Version="2.0.505" />
<PackageReference Include="Fluent.Ribbon" Version="10.1.0" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="8.0.0" />
Expand All @@ -30,4 +32,8 @@
<PackageReference Include="Microsoft.Extensions.Http" Version="8.0.0" />
</ItemGroup>

<ItemGroup>
<Resource Include="Resources\AppIcon.ico" />
</ItemGroup>

</Project>
64 changes: 64 additions & 0 deletions src/Atc.Azure.IoT.Wpf.App/Dialogs/AboutBoxDialog.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<atcDialogs:NiceDialogBox
x:Class="Atc.Azure.IoT.Wpf.App.Dialogs.AboutBoxDialog"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:atc="https://github.com/atc-net/atc-wpf/tree/main/schemas"
xmlns:atcDialogs="clr-namespace:Atc.Wpf.Theming.Themes.Dialogs;assembly=Atc.Wpf.Theming"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
Title="About Atc.Azure.IoT"
Width="350"
Height="220"
Background="{DynamicResource AtcApps.Brushes.Dialog.Background}"
ResizeMode="NoResize"
ShowCloseButton="False"
ShowMaxRestoreButton="False"
ShowMinButton="False"
WindowStartupLocation="CenterScreen"
WindowStyle="SingleBorderWindow"
mc:Ignorable="d">
<DockPanel>
<Border
Height="50"
Background="{DynamicResource AtcApps.Brushes.ThemeBackground1}"
BorderBrush="{DynamicResource AtcApps.Brushes.Accent}"
BorderThickness="0,1,0,0"
DockPanel.Dock="Bottom">
<atc:UniformSpacingPanel
HorizontalAlignment="Center"
Orientation="Horizontal"
Spacing="20">
<Button
Width="100"
Height="30"
Background="{DynamicResource AtcApps.Brushes.ThemeBackground}"
Click="OnOk"
Content="OK"
Foreground="{DynamicResource AtcApps.Brushes.Text}"
IsDefault="True" />
</atc:UniformSpacingPanel>
</Border>


<atc:UniformSpacingPanel
Margin="20"
Orientation="Horizontal"
Spacing="20">
<Image
x:Name="IconImage"
MaxWidth="64"
MaxHeight="64" />
<atc:UniformSpacingPanel
Margin="20"
Orientation="Vertical"
Spacing="20">
<TextBlock FontWeight="Bold" Text="Atc.Azure.IoT" />
<StackPanel Orientation="Horizontal">
<TextBlock Text="Version: " />
<TextBlock x:Name="VersionTextBlock" Text="1.0.0.0" />
</StackPanel>
<TextBlock Text="© 2024 ATC" />
</atc:UniformSpacingPanel>
</atc:UniformSpacingPanel>
</DockPanel>
</atcDialogs:NiceDialogBox>
27 changes: 27 additions & 0 deletions src/Atc.Azure.IoT.Wpf.App/Dialogs/AboutBoxDialog.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
namespace Atc.Azure.IoT.Wpf.App.Dialogs;

/// <summary>
/// Interaction logic for AboutBoxDialog.
/// </summary>
public partial class AboutBoxDialog
{
public AboutBoxDialog()
{
InitializeComponent();

IconImage.Source = App.DefaultIcon;

VersionTextBlock.Text = Assembly
.GetExecutingAssembly()
.GetName()
.Version!
.ToString();
}

private void OnOk(
object sender,
RoutedEventArgs e)
{
Close();
}
}
4 changes: 4 additions & 0 deletions src/Atc.Azure.IoT.Wpf.App/GlobalUsings.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
global using System.ComponentModel;
global using System.IO;
global using System.Reflection;
global using System.Windows;
global using System.Windows.Input;
global using System.Windows.Media.Imaging;
global using Atc.Azure.IoT.Wpf.App.Dialogs;
global using Atc.Azure.IoT.Wpf.App.UserControls;
global using Atc.Wpf.Command;
global using Atc.Wpf.Mvvm;
global using ControlzEx.Theming;
global using Microsoft.Extensions.Configuration;
Expand Down
67 changes: 60 additions & 7 deletions src/Atc.Azure.IoT.Wpf.App/MainWindow.xaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
<atcTheming:NiceWindow
<atc:NiceWindow
x:Class="Atc.Azure.IoT.Wpf.App.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:atcTheming="https://github.com/atc-net/atc-wpf/tree/main/schemas"
xmlns:atc="https://github.com/atc-net/atc-wpf/tree/main/schemas"
xmlns:atcFontIconsValueConverters="https://github.com/atc-net/atc-wpf/tree/main/schemas/value-converters"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:fluent="urn:fluent-ribbon"
xmlns:fontIcons="clr-namespace:Atc.Wpf.FontIcons;assembly=Atc.Wpf.FontIcons"
xmlns:local="clr-namespace:Atc.Azure.IoT.Wpf.App"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:userControls="clr-namespace:Atc.Azure.IoT.Wpf.App.UserControls"
Expand All @@ -17,9 +20,59 @@
WindowStartupLocation="CenterScreen"
WindowState="{Binding Path=WindowState}"
mc:Ignorable="d">
<atcTheming:BusyOverlay IsBusy="{Binding Path=IsBusy}">
<atcTheming:GridEx Rows="Auto,*,Auto">

<atc:NiceWindow.Resources>
<ResourceDictionary>
<atcFontIconsValueConverters:FontIconImageSourceValueConverter x:Key="FontIconImageConverter" />
</ResourceDictionary>
</atc:NiceWindow.Resources>

<atc:BusyOverlay IsBusy="{Binding Path=IsBusy}">
<atc:GridEx Rows="Auto,*,Auto">
<fluent:Ribbon
Grid.Row="0"
AutomaticStateManagement="True"
CanCustomizeQuickAccessToolBar="False"
IsQuickAccessToolBarMenuDropDownVisible="False"
IsQuickAccessToolBarVisible="False">

<!-- Backstage -->
<fluent:Ribbon.Menu>
<fluent:Backstage Header="Application" KeyTip="A">
<fluent:BackstageTabControl>
<fluent:Button
Command="{Binding Path=OpenApplicationAboutCommand}"
Header="About"
Icon="{Binding Source={x:Static fontIcons:FontAwesomeSolidType.InfoCircle}, Converter={StaticResource FontIconImageConverter}, ConverterParameter={StaticResource AtcApps.Brushes.ThemeForeground}}" />
<Separator />
<fluent:Button
Command="{Binding Path=ApplicationExitCommand}"
Header="Exit"
Icon="{Binding Source={x:Static fontIcons:FontAwesomeRegularType.TimesCircle}, Converter={StaticResource FontIconImageConverter}, ConverterParameter={StaticResource AtcApps.Brushes.ThemeForeground}}"
KeyTip="X" />
</fluent:BackstageTabControl>
</fluent:Backstage>
</fluent:Ribbon.Menu>

<!-- Tabs -->
<fluent:RibbonTabItem Header="Device Provisioning Service (DPS)" KeyTip="D">
<fluent:RibbonGroupBox Header="XXX">
<StackPanel Orientation="Horizontal">
<TextBlock>Hej</TextBlock>
</StackPanel>
</fluent:RibbonGroupBox>
</fluent:RibbonTabItem>
<fluent:RibbonTabItem Header="IoTHub" KeyTip="I">
<fluent:RibbonGroupBox Header="XXX">
<StackPanel Orientation="Horizontal">
<TextBlock>Hej 2</TextBlock>
</StackPanel>
</fluent:RibbonGroupBox>
</fluent:RibbonTabItem>
</fluent:Ribbon>

<atc:GridEx Grid.Row="1" Rows="Auto,*" />
<userControls:StatusBarView Grid.Row="2" DataContext="{Binding Path=StatusBarViewModel}" />
</atcTheming:GridEx>
</atcTheming:BusyOverlay>
</atcTheming:NiceWindow>
</atc:GridEx>
</atc:BusyOverlay>
</atc:NiceWindow>
14 changes: 14 additions & 0 deletions src/Atc.Azure.IoT.Wpf.App/MainWindowViewModel_Commands.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
namespace Atc.Azure.IoT.Wpf.App;

public partial class MainWindowViewModel
{
public IRelayCommand OpenApplicationAboutCommand => new RelayCommand(OpenApplicationAboutCommandHandler);

private void OpenApplicationAboutCommandHandler()
{
// ReSharper disable once UseObjectOrCollectionInitializer
var aboutBoxDialog = new AboutBoxDialog();
aboutBoxDialog.IconImage.Source = App.DefaultIcon;
aboutBoxDialog.ShowDialog();
}
}
Binary file added src/Atc.Azure.IoT.Wpf.App/Resources/AppIcon.ico
Binary file not shown.

0 comments on commit 7e1c27c

Please sign in to comment.