Wire up secondary commands for settings etc
This commit is contained in:
@@ -19,11 +19,11 @@
|
|||||||
</UserControl.Resources>
|
</UserControl.Resources>
|
||||||
<Button
|
<Button
|
||||||
x:Name="Button"
|
x:Name="Button"
|
||||||
Width="{StaticResource ButtonWidth}"
|
Width="{ThemeResource ButtonWidth}"
|
||||||
Height="{StaticResource ButtonHeight}"
|
Height="{ThemeResource ButtonHeight}"
|
||||||
Padding="{StaticResource ButtonPadding}"
|
Padding="{ThemeResource ButtonPadding}"
|
||||||
Command="{x:Bind ViewModel.InvokeCommand}"
|
Command="{x:Bind ViewModel.InvokeCommand}"
|
||||||
FontFamily="{StaticResource SymbolThemeFontFamily}"
|
FontFamily="{ThemeResource SymbolThemeFontFamily}"
|
||||||
FontSize="16"
|
FontSize="16"
|
||||||
IsEnabled="False">
|
IsEnabled="False">
|
||||||
<interactivity:Interaction.Behaviors>
|
<interactivity:Interaction.Behaviors>
|
||||||
|
|||||||
@@ -51,6 +51,8 @@ public partial class App :
|
|||||||
services.AddContentTemplate<PrimaryViewModel, PrimaryView>();
|
services.AddContentTemplate<PrimaryViewModel, PrimaryView>();
|
||||||
services.AddContentTemplate<SecondaryViewModel, SecondaryView>();
|
services.AddContentTemplate<SecondaryViewModel, SecondaryView>();
|
||||||
|
|
||||||
|
services.AddContentTemplate<SettingsButtonViewModel, SettingsButtonView>();
|
||||||
|
|
||||||
services.AddTransient<IInitializer, AppInitializer>();
|
services.AddTransient<IInitializer, AppInitializer>();
|
||||||
})
|
})
|
||||||
.Build();
|
.Build();
|
||||||
|
|||||||
@@ -4,13 +4,24 @@
|
|||||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
xmlns:windows="using:Hyperbar.UI.Windows">
|
xmlns:windows="using:Hyperbar.UI.Windows">
|
||||||
|
<UserControl.Resources>
|
||||||
|
<SolidColorBrush x:Key="ButtonBackground" Color="Transparent" />
|
||||||
|
<SolidColorBrush x:Key="ButtonBorderBrush" Color="Transparent" />
|
||||||
|
<SolidColorBrush x:Key="ButtonBorderBrushPointerOver" Color="Transparent" />
|
||||||
|
<SolidColorBrush x:Key="ButtonBorderBrushPressed" Color="Transparent" />
|
||||||
|
<SolidColorBrush x:Key="ButtonBackgroundDisabled" Color="Transparent" />
|
||||||
|
<SolidColorBrush x:Key="ButtonBorderBrushDisabled" Color="Transparent" />
|
||||||
|
<Thickness x:Key="ButtonPadding">0</Thickness>
|
||||||
|
<x:Double x:Key="ButtonWidth">40</x:Double>
|
||||||
|
<x:Double x:Key="ButtonHeight">40</x:Double>
|
||||||
|
</UserControl.Resources>
|
||||||
<ItemsControl ItemTemplateSelector="{Binding Converter={windows:DataTemplateConverter}}" ItemsSource="{Binding}">
|
<ItemsControl ItemTemplateSelector="{Binding Converter={windows:DataTemplateConverter}}" ItemsSource="{Binding}">
|
||||||
<ItemsControl.ItemsPanel>
|
<ItemsControl.ItemsPanel>
|
||||||
<ItemsPanelTemplate>
|
<ItemsPanelTemplate>
|
||||||
<Grid>
|
<Grid>
|
||||||
<Grid.ColumnDefinitions>
|
<Grid.ColumnDefinitions>
|
||||||
<ColumnDefinition Width="*" />
|
<ColumnDefinition Width="*" />
|
||||||
<ColumnDefinition Width="400" />
|
<ColumnDefinition Width="Auto" />
|
||||||
</Grid.ColumnDefinitions>
|
</Grid.ColumnDefinitions>
|
||||||
</Grid>
|
</Grid>
|
||||||
</ItemsPanelTemplate>
|
</ItemsPanelTemplate>
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
<None Remove="ApplicationBarView.xaml" />
|
<None Remove="ApplicationBarView.xaml" />
|
||||||
<None Remove="PrimaryView.xaml" />
|
<None Remove="PrimaryView.xaml" />
|
||||||
<None Remove="SecondaryView.xaml" />
|
<None Remove="SecondaryView.xaml" />
|
||||||
|
<None Remove="SettingsButtonView.xaml" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Content Include="Assets\SplashScreen.scale-200.png" />
|
<Content Include="Assets\SplashScreen.scale-200.png" />
|
||||||
@@ -53,6 +54,11 @@
|
|||||||
<ProjectReference Include="..\Hyperbar.Widget\Hyperbar.Widget.csproj" />
|
<ProjectReference Include="..\Hyperbar.Widget\Hyperbar.Widget.csproj" />
|
||||||
<ProjectReference Include="..\Hyperbar\Hyperbar.csproj" />
|
<ProjectReference Include="..\Hyperbar\Hyperbar.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Page Update="SettingsButtonView.xaml">
|
||||||
|
<Generator>MSBuild:Compile</Generator>
|
||||||
|
</Page>
|
||||||
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Page Update="SecondaryView.xaml">
|
<Page Update="SecondaryView.xaml">
|
||||||
<Generator>MSBuild:Compile</Generator>
|
<Generator>MSBuild:Compile</Generator>
|
||||||
|
|||||||
@@ -4,14 +4,13 @@
|
|||||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
xmlns:windows="using:Hyperbar.UI.Windows">
|
xmlns:windows="using:Hyperbar.UI.Windows">
|
||||||
<ItemsControl
|
<Grid Width="300" Background="red">
|
||||||
HorizontalAlignment="Center"
|
<ItemsControl ItemTemplateSelector="{Binding Converter={windows:DataTemplateConverter}}" ItemsSource="{Binding}">
|
||||||
ItemTemplateSelector="{Binding Converter={windows:DataTemplateConverter}}"
|
<ItemsControl.ItemsPanel>
|
||||||
ItemsSource="{Binding}">
|
<ItemsPanelTemplate>
|
||||||
<ItemsControl.ItemsPanel>
|
<ItemsStackPanel Orientation="Horizontal" />
|
||||||
<ItemsPanelTemplate>
|
</ItemsPanelTemplate>
|
||||||
<ItemsStackPanel Orientation="Horizontal" />
|
</ItemsControl.ItemsPanel>
|
||||||
</ItemsPanelTemplate>
|
</ItemsControl>
|
||||||
</ItemsControl.ItemsPanel>
|
</Grid>
|
||||||
</ItemsControl>
|
|
||||||
</UserControl>
|
</UserControl>
|
||||||
|
|||||||
@@ -1,17 +1,26 @@
|
|||||||
using CommunityToolkit.Mvvm.ComponentModel;
|
using CommunityToolkit.Mvvm.ComponentModel;
|
||||||
|
using Hyperbar.Windows;
|
||||||
|
|
||||||
namespace Hyperbar.Widget;
|
namespace Hyperbar.Widget;
|
||||||
|
|
||||||
public partial class SecondaryViewModel(ITemplateFactory templateFactory,
|
public partial class SecondaryViewModel :
|
||||||
IServiceFactory serviceFactory,
|
ObservableCollectionViewModel<IDisposable>,
|
||||||
IMediator mediator,
|
|
||||||
IDisposer disposer,
|
|
||||||
int index) :
|
|
||||||
ObservableCollectionViewModel<IDisposable>(serviceFactory, mediator, disposer),
|
|
||||||
ITemplatedViewModel
|
ITemplatedViewModel
|
||||||
{
|
{
|
||||||
[ObservableProperty]
|
[ObservableProperty]
|
||||||
private int index = index;
|
private int index;
|
||||||
|
|
||||||
public ITemplateFactory TemplateFactory => templateFactory;
|
public SecondaryViewModel(ITemplateFactory templateFactory,
|
||||||
|
IServiceFactory serviceFactory,
|
||||||
|
IMediator mediator,
|
||||||
|
IDisposer disposer,
|
||||||
|
int index) : base(serviceFactory, mediator, disposer)
|
||||||
|
{
|
||||||
|
this.index = index;
|
||||||
|
this.TemplateFactory = templateFactory;
|
||||||
|
|
||||||
|
Add<SettingsButtonViewModel>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public ITemplateFactory TemplateFactory { get; }
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
|
<UserControl
|
||||||
|
x:Class="Hyperbar.Windows.SettingsButtonView"
|
||||||
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||||
|
<Button Content="dfffffff" />
|
||||||
|
</UserControl>
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
using Microsoft.UI.Xaml.Controls;
|
||||||
|
|
||||||
|
namespace Hyperbar.Windows;
|
||||||
|
|
||||||
|
public sealed partial class SettingsButtonView :
|
||||||
|
UserControl
|
||||||
|
{
|
||||||
|
public SettingsButtonView() =>
|
||||||
|
this.InitializeComponent();
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
namespace Hyperbar.Windows;
|
||||||
|
|
||||||
|
public class SettingsButtonViewModel(ITemplateFactory templateFactory,
|
||||||
|
IServiceFactory serviceFactory,
|
||||||
|
IMediator mediator,
|
||||||
|
IDisposer disposer) :
|
||||||
|
ObservableViewModel(serviceFactory, mediator, disposer),
|
||||||
|
ITemplatedViewModel
|
||||||
|
{
|
||||||
|
public ITemplateFactory TemplateFactory => templateFactory;
|
||||||
|
}
|
||||||
@@ -2,9 +2,15 @@
|
|||||||
|
|
||||||
namespace Hyperbar;
|
namespace Hyperbar;
|
||||||
|
|
||||||
public class ObservableViewModel(IDisposer disposer) :
|
public class ObservableViewModel(IServiceFactory serviceFactory,
|
||||||
|
IMediator mediator,
|
||||||
|
IDisposer disposer) :
|
||||||
ObservableObject,
|
ObservableObject,
|
||||||
IDisposable
|
IDisposable
|
||||||
{
|
{
|
||||||
|
public IServiceFactory ServiceFactory => serviceFactory;
|
||||||
|
|
||||||
|
public IMediator Mediator => mediator;
|
||||||
|
|
||||||
public void Dispose() => disposer.Dispose(this);
|
public void Dispose() => disposer.Dispose(this);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user