Skip to content

Commit

Permalink
修复显示问题
Browse files Browse the repository at this point in the history
  • Loading branch information
aiqinxuancai committed Feb 21, 2024
1 parent f3a58ae commit e14ed4b
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 7 deletions.
7 changes: 6 additions & 1 deletion Aria2Fast/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
x:Class="Aria2Fast.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:converter="clr-namespace:Aria2Fast.View.Contver"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:dialogs="clr-namespace:Aria2Fast.Dialogs"
xmlns:local="clr-namespace:Aria2Fast"
Expand All @@ -28,6 +29,7 @@
</Style>-->

<Window.Resources>

<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/Style/AQButton.xaml" />
Expand All @@ -36,6 +38,9 @@
</Window.Resources>

<Grid>
<Grid.Resources>
<converter:Aria2HostEmptyStringConverter x:Key="Aria2HostEmptyStringConverter" />
</Grid.Resources>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="60" />
<ColumnDefinition Width="77*" />
Expand Down Expand Up @@ -219,7 +224,7 @@
Margin="5,0,5,0"
VerticalAlignment="Center"
Foreground="White"
Text="{Binding Source={x:Static service:AppConfig.Instance}, Path=ConfigData.Aria2RpcHost}" />
Text="{Binding Source={x:Static service:AppConfig.Instance}, Path=ConfigData.Aria2RpcHost, Converter={StaticResource Aria2HostEmptyStringConverter}}" />

</Grid>

Expand Down
7 changes: 1 addition & 6 deletions Aria2Fast/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -198,18 +198,13 @@ private void UpdateConnectionStatus(LinkStatus status)
LinkStatusProgressBar.Visibility = Visibility.Collapsed;
myBrush.Color = (Color)ColorConverter.ConvertFromString("#ffed4014");
LinkStatusBorder.Background = myBrush;

if (string.IsNullOrWhiteSpace(AppConfig.Instance.ConfigData.Aria2RpcHost))
{
Aria2RpcHostTextBlock.Text = "请在设置中添加Aria2Rpc地址";
}
break;
case LinkStatus.Success:
LinkStatusProgressBar.IsIndeterminate = false;
LinkStatusProgressBar.Visibility = Visibility.Collapsed;
myBrush.Color = (Color)ColorConverter.ConvertFromString("#ff19be6b");
LinkStatusBorder.Background = myBrush;


break;

Expand Down
33 changes: 33 additions & 0 deletions Aria2Fast/View/Contver/TextContver.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;

namespace Aria2Fast.View.Contver
{
class TextContver
{
}

public class Aria2HostEmptyStringConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
if (value is String && String.IsNullOrWhiteSpace(value as String))
{
return "请在设置中添加Aria2Rpc地址";
}
else
{
return value;
}
}

public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
throw new NotSupportedException();
}
}
}

0 comments on commit e14ed4b

Please sign in to comment.