-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add placeholder blog post to news panel (#187)
* Add placeholder blog post to news * Fix Codacy issues * Fix compile warning
- Loading branch information
1 parent
56ac85c
commit 571c0f8
Showing
6 changed files
with
138 additions
and
25 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
using System; | ||
using System.Diagnostics; | ||
using Avalonia; | ||
using Avalonia.Media.Imaging; | ||
using Avalonia.Platform; | ||
|
||
namespace UnitystationLauncher.ViewModels; | ||
|
||
public class BlogPostViewModel : ViewModelBase | ||
{ | ||
private string Title { get; } | ||
private string PostLink { get; } | ||
private Bitmap PostImage { get; } | ||
private Bitmap DarkenBg { get; } | ||
|
||
public BlogPostViewModel(string title, string postLink, Bitmap? postImage) | ||
{ | ||
Title = title; | ||
PostLink = postLink; | ||
IAssetLoader assets = AvaloniaLocator.Current.GetService<IAssetLoader>() | ||
?? throw new NullReferenceException("No IAssetLoader found, check Autofac configuration."); | ||
// Default image in case one is not provided | ||
postImage ??= new(assets.Open(new("avares://StationHub/Assets/bgnews.png"))); | ||
PostImage = postImage; | ||
DarkenBg = new(assets.Open(new("avares://StationHub/Assets/transparentdark.png"))); | ||
} | ||
|
||
private void OpenLink() | ||
{ | ||
if (string.IsNullOrWhiteSpace(PostLink)) | ||
{ | ||
return; | ||
} | ||
|
||
ProcessStartInfo psi = new() | ||
{ | ||
FileName = PostLink, | ||
UseShellExecute = true | ||
}; | ||
Process.Start(psi); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<UserControl xmlns="https://github.com/avaloniaui" | ||
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" | ||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" | ||
x:Class="UnitystationLauncher.Views.BlogPostView"> | ||
<Button Margin="0 0.6 0 0" Command="{Binding OpenLink}"> | ||
<Panel> | ||
<Image Margin="0.5" Source="{Binding PostImage}" Stretch="UniformToFill" Opacity="0.459" /> | ||
|
||
<Panel VerticalAlignment="Bottom" MaxHeight="50"> | ||
<Image Source="{Binding DarkenBg}" Stretch="UniformToFill" /> | ||
<TextBlock Text="{Binding Title}" VerticalAlignment="Bottom" HorizontalAlignment="Center" FontSize="35" Opacity="1" /> | ||
</Panel> | ||
</Panel> | ||
</Button> | ||
|
||
</UserControl> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
using Avalonia.Controls; | ||
using Avalonia.Markup.Xaml; | ||
|
||
namespace UnitystationLauncher.Views; | ||
|
||
public class BlogPostView : UserControl | ||
{ | ||
public BlogPostView() | ||
{ | ||
InitializeComponent(); | ||
} | ||
|
||
private void InitializeComponent() | ||
{ | ||
AvaloniaXamlLoader.Load(this); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters