This commit is contained in:
TheXamlGuy
2024-01-06 14:34:25 +00:00
parent 53537aa4c7
commit e1c7846e45
73 changed files with 251 additions and 198 deletions
+1 -1
View File
@@ -14,4 +14,4 @@
</DataTemplate>
</ResourceDictionary>
</Application.Resources>
</Application>
</Application>
+9 -8
View File
@@ -1,14 +1,15 @@
using Hyperbar.Windows.Controls;
using Hyperbar.Extensions;
using Hyperbar.Widget.Contextual;
using Hyperbar.Windows.Controls;
using Hyperbar.Windows.Primary;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.UI.Xaml;
using Hyperbar.Widget.Contextual;
using Hyperbar.Windows.Primary;
namespace Hyperbar.Windows;
public partial class App :
public partial class App :
Application
{
public App() => InitializeComponent();
@@ -28,7 +29,7 @@ public partial class App :
})
.ConfigureServices((context, services) =>
{
services.AddSingleton<IServiceFactory>(provider =>
services.AddSingleton<IServiceFactory>(provider =>
new ServiceFactory((type, parameters) => ActivatorUtilities.CreateInstance(provider, type, parameters!)));
services.AddHostedService<AppService>();
@@ -48,7 +49,7 @@ public partial class App :
{
foreach (IWidgetContext widgetContext in services.GetServices<IWidgetContext>())
{
if (widgetContext.ServiceProvider.GetService<IWidgetViewModel>() is
if (widgetContext.ServiceProvider.GetService<IWidgetViewModel>() is
IWidgetViewModel viewModel)
{
yield return viewModel;
@@ -56,11 +57,11 @@ public partial class App :
}
}
return Resolve(provider);
return Resolve(provider);
});
})
.Build();
await host.RunAsync();
}
}
}
@@ -5,7 +5,7 @@ namespace Hyperbar.Windows;
public class AppInitializer([FromKeyedServices(nameof(CommandViewModel))] CommandView view,
[FromKeyedServices(nameof(CommandViewModel))] CommandViewModel viewModel,
DesktopFlyout desktopFlyout) :
DesktopFlyout desktopFlyout) :
IInitializer
{
public Task InitializeAsync()
@@ -17,4 +17,4 @@ public class AppInitializer([FromKeyedServices(nameof(CommandViewModel))] Comman
return Task.CompletedTask;
}
}
}
@@ -1,4 +1,5 @@
using Microsoft.Extensions.DependencyInjection;
using Hyperbar.Extensions;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
namespace Hyperbar.Windows
@@ -2,7 +2,6 @@
namespace Hyperbar.Windows
{
public interface ITemplateGeneratorFactory
{
DataTemplate Create();
@@ -3,7 +3,7 @@ using Microsoft.UI.Xaml.Controls;
namespace Hyperbar.Windows;
public class TemplateGeneratorControl :
public class TemplateGeneratorControl :
ContentControl
{
public TemplateGeneratorControl()
@@ -18,4 +18,4 @@ public class TemplateGeneratorControl :
Content = templatedViewModel.TemplateFactory.Create(DataContext.GetType().Name);
}
}
}
}
@@ -3,17 +3,17 @@ using Microsoft.UI.Xaml.Markup;
namespace Hyperbar.Windows;
public class TemplateGeneratorFactory :
public class TemplateGeneratorFactory :
ITemplateGeneratorFactory
{
public DataTemplate Create()
{
string xamlString = @"
<DataTemplate xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation'
<DataTemplate xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation'
xmlns:desktop='using:Hyperbar.Windows'>
<desktop:TemplateGeneratorControl />
</DataTemplate>";
return (DataTemplate)XamlReader.Load(xamlString);
}
}
}
+1 -1
View File
@@ -10,4 +10,4 @@
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
</ItemsControl>
</UserControl>
</UserControl>
+2 -2
View File
@@ -3,7 +3,7 @@ using Microsoft.UI.Xaml.Input;
namespace Hyperbar.Windows;
public sealed partial class CommandView :
public sealed partial class CommandView :
UserControl
{
public CommandView() => InitializeComponent();
@@ -12,4 +12,4 @@ public sealed partial class CommandView :
{
base.OnKeyDown(e);
}
}
}
+2 -2
View File
@@ -1,6 +1,6 @@
namespace Hyperbar.Windows;
public partial class CommandViewModel :
public partial class CommandViewModel :
ObservableCollectionViewModel<IWidgetViewModel>,
ITemplatedViewModel
{
@@ -13,4 +13,4 @@ public partial class CommandViewModel :
}
public ITemplateFactory TemplateFactory { get; }
}
}
+1 -1
View File
@@ -17,4 +17,4 @@
Height="{StaticResource ButtonHeight}"
Command="{Binding Click}"
Content="{Binding Icon}" />
</UserControl>
</UserControl>
@@ -2,8 +2,8 @@ using Microsoft.UI.Xaml.Controls;
namespace Hyperbar.Windows;
public sealed partial class WidgetButtonView :
public sealed partial class WidgetButtonView :
UserControl
{
public WidgetButtonView() => InitializeComponent();
}
}
+1 -1
View File
@@ -10,4 +10,4 @@
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
</ItemsControl>
</UserControl>
</UserControl>
+1 -1
View File
@@ -7,4 +7,4 @@ public sealed partial class WidgetView :
IWidgetView
{
public WidgetView() => InitializeComponent();
}
}