Skip to content

Commit d8abdc7

Browse files
committed
removed unnecessary property
1 parent 01c7417 commit d8abdc7

File tree

4 files changed

+27
-9
lines changed

4 files changed

+27
-9
lines changed

src/Addons/Addons/BaseAddonEntity.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,6 @@ public abstract class BaseAddonEntity : IAddon
6868
/// <inheritdoc/>
6969
public string? FileName => PathToFile is null ? null : Path.GetFileName(PathToFile);
7070

71-
/// <inheritdoc/>
72-
public string TitleWithNewLines => Title.Replace(" ", Environment.NewLine);
73-
7471
public override string ToString() => Title;
7572

7673

src/Avalonia.Desktop/Controls/CampaignsControl.axaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@
1010
x:DataType="vm:CampaignsViewModel"
1111
x:Class="Avalonia.Desktop.Controls.CampaignsControl">
1212

13+
<UserControl.Resources>
14+
<helpers:StringToWrappedConverter x:Key="StringToWrappedConverter"/>
15+
</UserControl.Resources>
16+
1317
<Grid RowDefinitions="auto,*,auto" ColumnDefinitions="2*,*">
1418

1519
<Grid ColumnDefinitions="auto,*,auto"
@@ -141,7 +145,7 @@
141145
FontSize="500"
142146
FontWeight="Bold"
143147
TextAlignment="Center"
144-
Text="{Binding TitleWithNewLines}"/>
148+
Text="{Binding Title, Converter={StaticResource StringToWrappedConverter}}"/>
145149
</Viewbox >
146150
</Grid>
147151

src/Avalonia.Desktop/Helpers/Converters.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using Avalonia.Desktop.Misc;
44
using Common.Common.Helpers;
55
using Common.Enums;
6+
using CommunityToolkit.Diagnostics;
67
using System.Globalization;
78

89
namespace Avalonia.Desktop.Helpers;
@@ -80,3 +81,24 @@ public object ConvertBack(object? value, Type targetType, object? parameter, Cul
8081
return gameEnum;
8182
}
8283
}
84+
85+
/// <summary>
86+
/// Converts a string by replacing spaces with newline characters.
87+
/// </summary>
88+
public sealed class StringToWrappedConverter : IValueConverter
89+
{
90+
public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
91+
{
92+
if (value is not string valueStr)
93+
{
94+
return false;
95+
}
96+
97+
return valueStr.Replace(" ", Environment.NewLine);
98+
}
99+
100+
public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
101+
{
102+
return ThrowHelper.ThrowNotSupportedException<object>();
103+
}
104+
}

src/Common.Common/Interfaces/IAddon.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -100,11 +100,6 @@ public interface IAddon
100100
/// </summary>
101101
bool IsFolder { get; init; }
102102

103-
/// <summary>
104-
/// Addon title with text wraping
105-
/// </summary>
106-
string TitleWithNewLines { get; }
107-
108103

109104
/// <summary>
110105
/// Create markdown description of the addon

0 commit comments

Comments
 (0)