Skip to content

Commit

Permalink
Refactor and update packages, add MainUIPage
Browse files Browse the repository at this point in the history
Updated package references in multiple project files, including `Microsoft.WindowsAppSDK` and `Microsoft.Windows.SDK.BuildTools`. Added new resource entry for `MenuItemMainUI.Content`. Cleaned up unused `using` directives and namespaces. Modified `MainWindow.xaml` to use `Binding` instead of `x:Bind` and added a new `NavigationViewItem` for `MainUI`. Added event handler for `MainUIPage` navigation. Removed `WinUIPage` and introduced `MainUIPage` with `WebView2` control. Updated project files accordingly. Made minor UI changes in `SitemapPage.xaml` and cleaned up unused XML namespaces in `MainPage.xaml`. Upgraded `Mapsui` packages to version `4.1.6`.
  • Loading branch information
hoffe86 committed Sep 30, 2024
1 parent 6ec136e commit c997f7d
Show file tree
Hide file tree
Showing 16 changed files with 65 additions and 98 deletions.
4 changes: 2 additions & 2 deletions src/openHAB.Common/openHAB.Common.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.5.240311000" />
<PackageReference Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.22621.3233" />
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.5.240607001" />
<PackageReference Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.26100.1" />
</ItemGroup>
</Project>
4 changes: 2 additions & 2 deletions src/openHAB.Core.Client/openHAB.Core.Client.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
<ItemGroup>
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.2.2" />
<PackageReference Include="CommunityToolkit.WinUI.Helpers" Version="8.0.240109" />
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.5.240311000" />
<PackageReference Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.22621.3233" />
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.5.240607001" />
<PackageReference Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.26100.1" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.1" />
<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers">
<Version>8.0.0</Version>
Expand Down
6 changes: 3 additions & 3 deletions src/openHAB.Core/Openhab.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@
</PackageReference>
<PackageReference Include="Microsoft.Toolkit.Uwp.Notifications" Version="7.1.3" />
<PackageReference Include="Microsoft.WindowsAppSDK">
<Version>1.5.240311000</Version>
<Version>1.5.240607001</Version>
</PackageReference>
<PackageReference Include="Newtonsoft.Json">
<Version>13.0.3</Version>
</PackageReference>
<PackageReference Include="NLog.Extensions.Logging">
<Version>5.3.8</Version>
<Version>5.3.11</Version>
</PackageReference>
<PackageReference Include="StyleCop.Analyzers">
<Version>1.1.118</Version>
Expand All @@ -46,7 +46,7 @@
<PackageReference Include="Microsoft.DotNet.UpgradeAssistant.Extensions.Default.Analyzers" Version="0.4.421302">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.Windows.Compatibility" Version="8.0.3" />
<PackageReference Include="Microsoft.Windows.Compatibility" Version="8.0.6" />
</ItemGroup>
<ItemGroup>
<Compile Remove="App.xaml.old.cs" />
Expand Down
3 changes: 3 additions & 0 deletions src/openHAB.Core/Strings/de-de/Resources.resw
Original file line number Diff line number Diff line change
Expand Up @@ -341,4 +341,7 @@ Bitte wählen Sie den Demomodus oder die Lokale-/Remote-Verbindungsinformation z
<data name="SVGIcons.Header" xml:space="preserve">
<value>Hochauflösende Icons</value>
</data>
<data name="MenuItemMainUI.Content" xml:space="preserve">
<value>MainUI</value>
</data>
</root>
3 changes: 3 additions & 0 deletions src/openHAB.Core/Strings/en-us/Resources.resw
Original file line number Diff line number Diff line change
Expand Up @@ -348,4 +348,7 @@ Please select demo mode or configure local/remote connection.</value>
<data name="SVGIcons.Header" xml:space="preserve">
<value>High resolution icons</value>
</data>
<data name="MenuItemMainUI.Content" xml:space="preserve">
<value>MainUI</value>
</data>
</root>
6 changes: 1 addition & 5 deletions src/openHAB.Windows/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
using System;
using System.Diagnostics;
using Microsoft.Extensions.Logging;
using Microsoft.Toolkit.Uwp.Notifications;
using Microsoft.UI.Dispatching;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Media;
using Microsoft.Windows.AppLifecycle;
using openHAB.Core.Notification.Contracts;
using openHAB.Core.Services.Contracts;
using openHAB.Windows.Services;
using openHAB.Windows.View;

namespace openHAB.Windows
{
Expand Down Expand Up @@ -82,7 +78,7 @@ protected override async void OnLaunched(Microsoft.UI.Xaml.LaunchActivatedEventA

// Initialize MainWindow here
MainWindow = new MainWindow();
//Frame rootFrame = MainWindow.RootFrame;
//Frame rootFrame = MainWindow.Content;

//if (rootFrame == null)
//{
Expand Down
18 changes: 6 additions & 12 deletions src/openHAB.Windows/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,7 @@
<converters:MenuItemTemplateSelector x:Key="Selector">
<converters:MenuItemTemplateSelector.DefaultItemTemlate>
<DataTemplate x:DataType="muxc:NavigationViewItem">
<muxc:NavigationViewItem Content="{x:Bind Content}"
Icon="{x:Bind Icon}"></muxc:NavigationViewItem>
<muxc:NavigationViewItem Margin="-15,0,0,0" Content="{Binding}" />
</DataTemplate>
</converters:MenuItemTemplateSelector.DefaultItemTemlate>
<converters:MenuItemTemplateSelector.SiteMapMenuItemTemplate>
Expand Down Expand Up @@ -247,22 +246,17 @@
</Grid>
<TextBlock Margin="10,10,10,0"
x:Uid="NoItemsOrOpenHabNotAvailable"
Visibility="{Binding Path=Sitemaps.Count, Converter={StaticResource ZeroToVisibility}, Mode=OneWay}"
Visibility="{Binding DataContext.Sitemaps.Count, Converter={StaticResource ZeroToVisibility}, Mode=OneWay, ElementName=ContentFrame}"
TextWrapping="Wrap"
Foreground="{StaticResource TextFillColorPrimaryBrush}"
Style="{StaticResource FlyoutPickerTitleTextBlockStyle}" />
</StackPanel>
</muxc:NavigationView.PaneCustomContent>
<muxc:NavigationView.FooterMenuItems>
<NavigationViewItem Icon="Home"
Content="MainUI"
Tag="openHAB.Windows.View.WinUIPage">
<interactivity:Interaction.Behaviors>
<core:EventTriggerBehavior EventName="Tapped">
<core:NavigateToPageAction TargetPage="openHAB.Windows.View.SettingsPage" />
</core:EventTriggerBehavior>
</interactivity:Interaction.Behaviors>
</NavigationViewItem>
<muxc:NavigationViewItem Icon="Home"
x:Uid="MenuItemMainUI"
Tag="openHAB.Windows.View.MainUIPage"
Tapped="NavigationViewItemMainUI_Tapped" />
</muxc:NavigationView.FooterMenuItems>
<Frame x:Name="ContentFrame" />
</muxc:NavigationView>
Expand Down
11 changes: 7 additions & 4 deletions src/openHAB.Windows/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
using System;
using System.Threading.Tasks;
using CommunityToolkit.Mvvm.Messaging;
using CommunityToolkit.WinUI;
using Microsoft.Extensions.Logging;
Expand All @@ -15,8 +17,6 @@
using openHAB.Windows.Services;
using openHAB.Windows.View;
using openHAB.Windows.ViewModel;
using System;
using System.Threading.Tasks;
using Windows.ApplicationModel;
using Windows.Foundation;
using Windows.Graphics;
Expand Down Expand Up @@ -55,8 +55,6 @@ public MainWindow()
Vm.LoadSitemapsAndItemData();
}



/// <summary>
/// Gets the root frame.
/// </summary>
Expand Down Expand Up @@ -222,5 +220,10 @@ private RectInt32 GetRect(Rect bounds, double scale)
}

#endregion

private void NavigationViewItemMainUI_Tapped(object sender, Microsoft.UI.Xaml.Input.TappedRoutedEventArgs e)
{
ContentFrame.Navigate(typeof(MainUIPage));
}
}
}
9 changes: 0 additions & 9 deletions src/openHAB.Windows/View/MainPage.xaml
Original file line number Diff line number Diff line change
@@ -1,17 +1,8 @@
<Page x:Class="openHAB.Windows.View.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:converters="using:openHAB.Windows.Converters"
xmlns:core="using:Microsoft.Xaml.Interactions.Core"
xmlns:community="using:CommunityToolkit.WinUI.UI.Controls"
xmlns:muxc="using:Microsoft.UI.Xaml.Controls"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:interactivity="using:Microsoft.Xaml.Interactivity"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:viewModel="using:openHAB.Windows.ViewModel"
xmlns:controls="using:openHAB.Windows.Controls"
xmlns:media="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:model="using:openHAB.Core.Client.Models"
mc:Ignorable="d"
Name="Page">
<Grid>
Expand Down
11 changes: 11 additions & 0 deletions src/openHAB.Windows/View/MainUIPage.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<Page x:Class="openHAB.Windows.View.MainUIPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
NavigationCacheMode="Enabled">
<Grid>
<WebView2 Source="http://containerhost:8081" />
</Grid>
</Page>
15 changes: 15 additions & 0 deletions src/openHAB.Windows/View/MainUIPage.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using Microsoft.UI.Xaml.Controls;

namespace openHAB.Windows.View
{
/// <summary>
/// An empty page that can be used on its own or navigated to within a Frame.
/// </summary>
public sealed partial class MainUIPage : Page
{
public MainUIPage()
{
InitializeComponent();
}
}
}
3 changes: 0 additions & 3 deletions src/openHAB.Windows/View/SitemapPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@
SelectionMode="None">
<GridView.ItemsPanel>
<ItemsPanelTemplate>
<!--<VariableSizedWrapGrid ItemWidth="335"
ItemHeight="106"
Orientation="Horizontal" />-->
<controls:WrapPanel Orientation="Horizontal"
VerticalSpacing="10"
HorizontalSpacing="10" />
Expand Down
15 changes: 0 additions & 15 deletions src/openHAB.Windows/View/WinUIPage.xaml

This file was deleted.

31 changes: 0 additions & 31 deletions src/openHAB.Windows/View/WinUIPage.xaml.cs

This file was deleted.

12 changes: 6 additions & 6 deletions src/openHAB.Windows/ViewModel/MainViewModel.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using CommunityToolkit.Mvvm.Messaging;
using CommunityToolkit.WinUI;
using Microsoft.Extensions.Logging;
Expand All @@ -11,12 +17,6 @@
using openHAB.Core.Services.Contracts;
using openHAB.Windows.Messages;
using openHAB.Windows.Services;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;

namespace openHAB.Windows.ViewModel
{
Expand Down
12 changes: 6 additions & 6 deletions src/openHAB.Windows/openHAB.Windows.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@
<PackageReference Include="CommunityToolkit.WinUI.Controls.Primitives" Version="8.0.240109" />
<PackageReference Include="CommunityToolkit.WinUI.Controls.SettingsControls" Version="8.0.240109" />
<PackageReference Include="CommunityToolkit.WinUI.Helpers" Version="8.0.240109" />
<PackageReference Include="Mapsui" Version="4.1.4" />
<PackageReference Include="Mapsui.WinUI" Version="4.1.4" />
<PackageReference Include="Mapsui" Version="4.1.6" />
<PackageReference Include="Mapsui.WinUI" Version="4.1.6" />
<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers">
<Version>8.0.0</Version>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand All @@ -70,11 +70,11 @@
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.0" />
<PackageReference Include="Microsoft.Services.Store.SDK" Version="10.1705.16001" />
<PackageReference Include="Microsoft.WindowsAppSDK">
<Version>1.5.240311000</Version>
<Version>1.5.240607001</Version>
</PackageReference>
<PackageReference Include="Microsoft.Xaml.Behaviors.WinUI.Managed" Version="2.0.9" />
<PackageReference Include="NLog.Extensions.Logging">
<Version>5.3.8</Version>
<Version>5.3.11</Version>
</PackageReference>
<PackageReference Include="StyleCop.Analyzers">
<Version>1.1.118</Version>
Expand All @@ -87,8 +87,8 @@
</ItemGroup>
<ItemGroup>
<None Remove="Controls\MapViewWidget.xaml" />
<None Remove="View\MainUIPage.xaml" />
<None Remove="View\SitemapPage.xaml" />
<None Remove="View\WinUIPage.xaml" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\openHAB.Core\openHAB.Core.csproj" />
Expand All @@ -99,7 +99,7 @@
</Page>
</ItemGroup>
<ItemGroup>
<Page Update="View\WinUIPage.xaml">
<Page Update="View\MainUIPage.xaml">
<Generator>MSBuild:Compile</Generator>
</Page>
</ItemGroup>
Expand Down

0 comments on commit c997f7d

Please sign in to comment.