mirror of
https://github.com/Stone-Red-Code/DesktopMagic.git
synced 2026-09-04 08:56:15 +02:00
Add basic plugin manager UI
This commit is contained in:
+1
-1
@@ -3,7 +3,7 @@
|
||||
using System.ComponentModel;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace DesktopMagic;
|
||||
namespace DesktopMagic.DataContexts;
|
||||
|
||||
internal class MainWindowDataContext : INotifyPropertyChanged
|
||||
{
|
||||
@@ -0,0 +1,16 @@
|
||||
using Modio.NET.Models;
|
||||
|
||||
using System;
|
||||
|
||||
namespace DesktopMagic.DataContexts;
|
||||
internal class ModEntryDataContext(Mod mod)
|
||||
{
|
||||
public string Name => mod.Name!;
|
||||
|
||||
public string Description => mod.DescriptionPlaintext!;
|
||||
|
||||
public string? Logo => mod.Logo?.Thumb320x180?.ToString();
|
||||
|
||||
public DateTime FormattedDateAdded => DateTimeOffset.FromUnixTimeSeconds(mod.DateAdded).LocalDateTime;
|
||||
public DateTime FormattedDateUpdated => DateTimeOffset.FromUnixTimeSeconds(mod.DateUpdated).LocalDateTime;
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
using System.Collections.ObjectModel;
|
||||
using System.ComponentModel;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace DesktopMagic.DataContexts;
|
||||
internal class PluginManagerDataContext : INotifyPropertyChanged
|
||||
{
|
||||
public event PropertyChangedEventHandler? PropertyChanged;
|
||||
|
||||
public ObservableCollection<ModEntryDataContext> Mods { get; } = [];
|
||||
|
||||
protected void OnPropertyChanged([CallerMemberName] string? name = null)
|
||||
{
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));
|
||||
}
|
||||
}
|
||||
@@ -31,6 +31,7 @@
|
||||
<PackageReference Include="Extended.Wpf.Toolkit" Version="4.5.1" />
|
||||
<PackageReference Include="Google.Apis.Calendar.v3" Version="1.64.0.3171" />
|
||||
<PackageReference Include="MaterialDesignThemes" Version="4.9.0" />
|
||||
<PackageReference Include="Modio.NET" Version="1.1.1" />
|
||||
<PackageReference Include="NAudio" Version="2.2.1" />
|
||||
<PackageReference Include="Stone_Red-C-Sharp-Utilities" Version="1.0.3.1" />
|
||||
<PackageReference Include="System.Management" Version="8.0.0" />
|
||||
|
||||
@@ -6,7 +6,8 @@
|
||||
mc:Ignorable="d"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:DesktopMagic"
|
||||
d:DataContext="{d:DesignInstance Type=local:MainWindowDataContext}"
|
||||
xmlns:dataContext="clr-namespace:DesktopMagic.DataContexts"
|
||||
d:DataContext="{d:DesignInstance Type=dataContext:PluginManagerDataContext}"
|
||||
Closing="Window_Closing"
|
||||
Closed="Window_Closed"
|
||||
ShowInTaskbar="True"
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using DesktopMagic.BuiltInWindowElements;
|
||||
using DesktopMagic.DataContexts;
|
||||
using DesktopMagic.Dialogs;
|
||||
using DesktopMagic.Helpers;
|
||||
using DesktopMagic.Plugins;
|
||||
@@ -642,6 +643,10 @@ namespace DesktopMagic
|
||||
|
||||
private void DownloadPluginsButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
PluginManager pluginManager = new PluginManager();
|
||||
pluginManager.ShowDialog();
|
||||
|
||||
return;
|
||||
string uri = "https://github.com/Stone-Red-Code/DesktopMagic-Plugins";
|
||||
ProcessStartInfo psi = new ProcessStartInfo
|
||||
{
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
<UserControl x:Class="DesktopMagic.Plugins.ModEntry"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:DesktopMagic.Plugins"
|
||||
xmlns:dataContext="clr-namespace:DesktopMagic.DataContexts"
|
||||
d:DataContext="{d:DesignInstance Type=dataContext:ModEntryDataContext}"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450" d:DesignWidth="800">
|
||||
<Grid Background="White" Margin="10">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition/>
|
||||
<RowDefinition/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition/>
|
||||
<ColumnDefinition/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<Border HorizontalAlignment="Left" Width="100" Height="100" BorderThickness="1" BorderBrush="Black">
|
||||
<Image Source="{Binding Logo}" Width="100" Height="100"/>
|
||||
</Border>
|
||||
|
||||
|
||||
<StackPanel Grid.Column="1" HorizontalAlignment="Right">
|
||||
<Label Content="{Binding FormattedDateAdded}" ContentStringFormat="Added: {0}"/>
|
||||
<Label Content="{Binding FormattedDateUpdated}" ContentStringFormat="Updated: {0}"/>
|
||||
<Button Margin="10" Content="Download"/>
|
||||
</StackPanel>
|
||||
|
||||
<StackPanel Grid.Row="1">
|
||||
<Label Content="{Binding Name}" FontSize="20"/>
|
||||
<Label Content="{Binding Description}"/>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
@@ -0,0 +1,13 @@
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace DesktopMagic.Plugins;
|
||||
/// <summary>
|
||||
/// Interaction logic for ModEntry.xaml
|
||||
/// </summary>
|
||||
public partial class ModEntry : UserControl
|
||||
{
|
||||
public ModEntry()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<Window x:Class="DesktopMagic.Plugins.PluginManager"
|
||||
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"
|
||||
xmlns:local="clr-namespace:DesktopMagic.Plugins"
|
||||
xmlns:dataContexts="clr-namespace:DesktopMagic.DataContexts"
|
||||
mc:Ignorable="d"
|
||||
d:DataContext="{d:DesignInstance Type=dataContexts:PluginManagerDataContext}"
|
||||
Title="PluginManager" Height="450" Width="800">
|
||||
<Grid>
|
||||
<ItemsControl ItemsSource="{Binding Mods}">
|
||||
<ItemsControl.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<Border BorderBrush="LightGray" BorderThickness="1">
|
||||
<local:ModEntry/>
|
||||
</Border>
|
||||
</DataTemplate>
|
||||
</ItemsControl.ItemTemplate>
|
||||
</ItemsControl>
|
||||
</Grid>
|
||||
</Window>
|
||||
@@ -0,0 +1,39 @@
|
||||
using DesktopMagic.DataContexts;
|
||||
|
||||
using Modio.NET;
|
||||
using Modio.NET.Models;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Windows;
|
||||
|
||||
namespace DesktopMagic.Plugins;
|
||||
/// <summary>
|
||||
/// Interaction logic for PluginManager.xaml
|
||||
/// </summary>
|
||||
public partial class PluginManager : Window
|
||||
{
|
||||
private readonly Client client = new Client(new Credentials("88e6ea774c3a502b06114e7fee0829ac"));
|
||||
|
||||
private readonly PluginManagerDataContext pluginManagerDataContext = new();
|
||||
|
||||
public PluginManager()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
DataContext = pluginManagerDataContext;
|
||||
}
|
||||
|
||||
protected override async void OnInitialized(EventArgs e)
|
||||
{
|
||||
base.OnInitialized(e);
|
||||
|
||||
IReadOnlyList<Mod> mods = await client.Games[5665].Mods.Search().ToListAsync();
|
||||
foreach (Mod mod in mods)
|
||||
{
|
||||
pluginManagerDataContext.Mods.Add(new ModEntryDataContext(mod));
|
||||
}
|
||||
|
||||
pluginManagerDataContext.Mods.Add(new ModEntryDataContext(new Mod() { Name = "yes", DescriptionPlaintext = "treoith34895z93" }));
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using DesktopMagic.Plugins;
|
||||
using DesktopMagic.DataContexts;
|
||||
using DesktopMagic.Plugins;
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
|
||||
Reference in New Issue
Block a user