mirror of
https://github.com/tribufu/ServerManagers
synced 2026-05-18 09:35:48 +00:00
source code checkin
This commit is contained in:
parent
5f8fb2c825
commit
7e57b72e35
675 changed files with 168433 additions and 0 deletions
81
src/Plugin.Discord/Windows/VersionFeedWindow.xaml.cs
Normal file
81
src/Plugin.Discord/Windows/VersionFeedWindow.xaml.cs
Normal file
|
|
@ -0,0 +1,81 @@
|
|||
using ServerManagerTool.Plugin.Common;
|
||||
using System;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
|
||||
namespace ServerManagerTool.Plugin.Discord.Windows
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for VersionFeedWindow.xaml
|
||||
/// </summary>
|
||||
public partial class VersionFeedWindow : Window
|
||||
{
|
||||
public static readonly DependencyProperty FeedEntriesProperty = DependencyProperty.Register(nameof(FeedEntries), typeof(ObservableCollection<VersionFeedEntry>), typeof(VersionFeedWindow), new PropertyMetadata(new ObservableCollection<VersionFeedEntry>()));
|
||||
public static readonly DependencyProperty SelectedFeedEntryProperty = DependencyProperty.Register(nameof(SelectedFeedEntry), typeof(VersionFeedEntry), typeof(VersionFeedWindow), new PropertyMetadata(null));
|
||||
|
||||
private string feedUri = string.Empty;
|
||||
|
||||
public VersionFeedWindow(DiscordPlugin plugin, string feedUri)
|
||||
{
|
||||
this.Plugin = plugin ?? new DiscordPlugin();
|
||||
this.feedUri = feedUri;
|
||||
|
||||
InitializeComponent();
|
||||
|
||||
this.DataContext = this;
|
||||
}
|
||||
|
||||
private DiscordPlugin Plugin
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public ObservableCollection<VersionFeedEntry> FeedEntries
|
||||
{
|
||||
get { return (ObservableCollection<VersionFeedEntry>)GetValue(FeedEntriesProperty); }
|
||||
set { SetValue(FeedEntriesProperty, value); }
|
||||
}
|
||||
|
||||
public VersionFeedEntry SelectedFeedEntry
|
||||
{
|
||||
get { return (VersionFeedEntry)GetValue(SelectedFeedEntryProperty); }
|
||||
set { SetValue(SelectedFeedEntryProperty, value); }
|
||||
}
|
||||
|
||||
private void Window_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
LoadFeed();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, ResourceUtils.GetResourceString(this.Resources, "VersionFeedWindow_Load_FailedTitle"), MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void LoadFeed()
|
||||
{
|
||||
FeedEntries.Clear();
|
||||
|
||||
if (string.IsNullOrWhiteSpace(this.feedUri))
|
||||
return;
|
||||
|
||||
var versionFeed = VersionFeedUtils.LoadVersionFeed(this.feedUri, Plugin.PluginVersion.ToString());
|
||||
if (versionFeed == null)
|
||||
return;
|
||||
|
||||
foreach (var entry in versionFeed.Entries)
|
||||
{
|
||||
if (entry == null)
|
||||
continue;
|
||||
|
||||
FeedEntries.Add(entry);
|
||||
}
|
||||
|
||||
SelectedFeedEntry = FeedEntries.OrderByDescending(e => e.Updated).FirstOrDefault();
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue