diff --git a/Saradomin/Infrastructure/Services/PluginDownloadService.cs b/Saradomin/Infrastructure/Services/PluginDownloadService.cs index 551bda9..9971bc4 100644 --- a/Saradomin/Infrastructure/Services/PluginDownloadService.cs +++ b/Saradomin/Infrastructure/Services/PluginDownloadService.cs @@ -153,9 +153,8 @@ namespace Saradomin.Infrastructure.Services if (isUpdateCheck && updatedInfo.Version != info.Version) { - if (writePersistentUpdateFlag) - await File.WriteAllTextAsync(filePath, fileContent + "\r\nUPDATEAVAILABLE=1"); info.UpdateAvailable = true; + if (writePersistentUpdateFlag) WritePluginInfoToFile(info, pluginFolder); } info.Installed = File.Exists(Path.Combine(pluginFolder, "plugin.class")); @@ -170,6 +169,7 @@ namespace Saradomin.Infrastructure.Services foreach (var lineInfo in lines.Select(t => t.Split("="))) { + if (parsedData.ContainsKey(lineInfo[0])) continue; if (lineInfo.Length > 1) { parsedData.Add (lineInfo[0], lineInfo[1].Trim('\'').Trim()); @@ -203,5 +203,18 @@ namespace Saradomin.Infrastructure.Services return info; } + + public static void WritePluginInfoToFile(PluginInfo info, string pluginFolder) + { + var content = $"NAME={info.Name}\r\n" + + $"AUTHOR={info.Author}\r\n" + + $"DESCRIPTION={info.Description.Replace(System.Environment.NewLine, "\\\r\n")}\r\n" + + $"VERSION={info.Version}"; + + if (info.UpdateAvailable) + content += "\r\nUPDATEAVAILABLE=1"; + + File.WriteAllText(Path.Combine(pluginFolder, "plugin.properties"), content); + } } } \ No newline at end of file diff --git a/Saradomin/View/Controls/PluginManagerView.axaml b/Saradomin/View/Controls/PluginManagerView.axaml index 4f0c386..1a0871f 100644 --- a/Saradomin/View/Controls/PluginManagerView.axaml +++ b/Saradomin/View/Controls/PluginManagerView.axaml @@ -83,6 +83,7 @@ BorderThickness="1" Classes="OutsideNavigator" Command="{Binding $parent[local:PluginManagerView].DataContext.UpdateLocalPlugin}" + CommandParameter="{Binding}" VerticalAlignment="Top" Content="Update" IsVisible="{Binding CanUpdate}" /> @@ -100,8 +101,14 @@ Command="{Binding $parent[local:PluginManagerView].DataContext.UninstallLocalPlugin}" CommandParameter="{Binding}" VerticalAlignment="Top" - Content="Uninstall" - IsVisible="{Binding Installed}" /> + Content="Uninstall"> + + + + + + + diff --git a/Saradomin/View/Windows/NotificationBox.axaml b/Saradomin/View/Windows/NotificationBox.axaml index 7d5dda8..f076f6c 100644 --- a/Saradomin/View/Windows/NotificationBox.axaml +++ b/Saradomin/View/Windows/NotificationBox.axaml @@ -4,12 +4,13 @@ xmlns:glitonea="clr-namespace:Glitonea.Controls;assembly=Glitonea" xmlns:mvvm="clr-namespace:Glitonea.Mvvm;assembly=Glitonea" xmlns:windows="clr-namespace:Saradomin.ViewModel.Windows" + xmlns:windows1="clr-namespace:Saradomin.View.Windows" Title="{Binding Title}" Height="120" MaxWidth="400" Background="{StaticResource WindowBackgroundBrush}" CanResize="False" - DataContext="{Binding #NotificationBox}" + DataContext="{mvvm:DataContextSource windows1:NotificationBox}" ShowActivated="True" ShowInTaskbar="False" SizeToContent="WidthAndHeight" @@ -25,7 +26,7 @@ FontSize="14" FontWeight="Light" Foreground="{StaticResource AccentBrush}" - Text="{Binding #NotificationBox.Title}" + Text="{Binding Title}" TextAlignment="Center">