-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgram.cs
69 lines (63 loc) · 2.3 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Media.Imaging;
using System.Xml;
class MainWindow : Window
{
public MainWindow()
{
Title = "Halo Infinite Steam RSS Client";
Width = MinWidth = 640;
Height = MinHeight = 480;
ResizeMode = ResizeMode.NoResize;
WindowStartupLocation = WindowStartupLocation.CenterScreen;
UniformGrid uniformGrid = new()
{
VerticalAlignment = VerticalAlignment.Stretch,
HorizontalAlignment = HorizontalAlignment.Stretch,
Columns = 2
};
Content = new ScrollViewer { Content = uniformGrid };
List<Tuple<string, string, string>> tuples = [];
try
{
using WebClient webClient = new();
XmlDocument xmlDocument = new();
xmlDocument.LoadXml(webClient.DownloadString("https://store.steampowered.com/feeds/news/app/1240440"));
foreach (XmlNode xmlNode in xmlDocument.SelectNodes("rss/channel/item"))
tuples.Add(new(xmlNode["enclosure"].GetAttribute("url"), xmlNode["title"].InnerText, xmlNode["link"].InnerText));
}
catch
{
MessageBox.Show("Couldn't fetch RSS Feed.",
"Error",
MessageBoxButton.OK,
MessageBoxImage.Error);
Environment.Exit(1);
}
foreach (Tuple<string, string, string> tuple in tuples)
{
int value = uniformGrid.Rows;
uniformGrid.Rows++;
Image image = new() { Source = new BitmapImage(new Uri(tuple.Item1)) };
Grid.SetColumn(image, 0);
Grid.SetRow(image, value);
uniformGrid.Children.Add(image);
Button button = new() { Content = new TextBlock { Text = tuple.Item2, TextWrapping = TextWrapping.Wrap } };
button.Click += (sender, e) => Process.Start(tuple.Item3);
Grid.SetColumn(button, 1);
Grid.SetRow(button, value);
uniformGrid.Children.Add(button);
}
}
}
class Program
{
[STAThread]
static void Main() { new MainWindow().ShowDialog(); }
}