This commit is contained in:
rmbgame
2021-08-16 01:20:48 +08:00
parent db80c8e268
commit ee1012c84d
6 changed files with 55 additions and 38 deletions
@@ -108,11 +108,11 @@
</ia:DataTriggerBehavior>
</i:Interaction.Behaviors>
</Ellipse>
<controls:ScrollingTextBlock x:Name="nickname"
Text="{Binding SteamNickName}"
FontSize="24"
Foreground="{DynamicResource HighlightForegroundBrushKey}"
Cursor="Hand"
<controls:ScrollingTextBlock x:Name="nickname"
Text="{Binding SteamNickName}"
FontSize="24"
Foreground="{DynamicResource HighlightForegroundBrushKey}"
Cursor="Hand"
ToolTip.Tip="{ReflectionBinding Path=Res.UserChange_BtnTootlip,Mode=OneWay,Source={x:Static resx:R.Current}}">
<i:Interaction.Behaviors>
<ia:EventTriggerBehavior EventName="Tapped" SourceObject="{ReflectionBinding #nickname}">
@@ -120,23 +120,24 @@
</ia:EventTriggerBehavior>
</i:Interaction.Behaviors>
</controls:ScrollingTextBlock>
<TextBox VerticalAlignment="Center"
VerticalContentAlignment="Center"
Watermark="{ReflectionBinding Path=Res.UserChange_EditRemark,Mode=OneWay,Source={x:Static resx:R.Current}}"
ToolTip.Tip="{ReflectionBinding Path=Res.UserChange_EditRemark,Mode=OneWay,Source={x:Static resx:R.Current}}"
MinWidth="150"
Text="{Binding Remark,Mode=TwoWay}"
Classes="readonlybox"
Foreground="{DynamicResource InactiveForegroundBrushKey}">
<TextBox.InnerRightContent>
<PathIcon Data="{StaticResource EditDrawing}"
Width="10" Height="10"
Opacity="0.8"
VerticalAlignment="Center" HorizontalAlignment="Left"
Margin="0"
IsVisible="{Binding Remark,Converter={StaticResource IsNullConverter}}"/>
</TextBox.InnerRightContent>
</TextBox>
<TextBlock VerticalAlignment="Center"
Margin="5 0"
Text="{Binding Remark,Mode=TwoWay}"
Foreground="{DynamicResource InactiveForegroundBrushKey}">
</TextBlock>
<Button Cursor="Hand"
Command="{ReflectionBinding #u.DataContext.EditRemarkAsync}"
CommandParameter="{Binding}"
Classes="plain"
ToolTip.Tip="{ReflectionBinding Path=Res.UserChange_EditRemark,Mode=OneWay,Source={x:Static resx:R.Current}}"
VerticalAlignment="Center"
VerticalContentAlignment="Center">
<PathIcon Data="{StaticResource EditDrawing}"
Width="10" Height="10"
Opacity="0.8"
VerticalAlignment="Center" HorizontalAlignment="Left"
Margin="0"/>
</Button>
</WrapPanel>
<WrapPanel Orientation="Horizontal">
@@ -1,4 +1,5 @@
using System.Application.Serialization;
using System.Collections.Concurrent;
using System.Collections.Generic;
using Compat = System.Application.Models.Settings.GameLibrarySettings;
@@ -9,8 +10,8 @@ namespace System.Application.Models.Settings
/// <summary>
/// Steam账号备注字典
/// </summary>
public static SerializableProperty<IReadOnlyDictionary<long, string?>> AccountRemarks { get; }
= Compat.GetProperty(defaultValue: (IReadOnlyDictionary<long, string?>?)null, autoSave: false);
public static SerializableProperty<ConcurrentDictionary<long, string?>> AccountRemarks { get; }
= Compat.GetProperty(defaultValue: new ConcurrentDictionary<long, string?>(), autoSave: false);
// ----- AccountRemarks ClassName 之前用的 GameLibrarySettings 需要兼容已发行的版本,将错就错,之后新增的还是使用 GetProperty 而不是 Compat.GetProperty -----
}
+2 -2
View File
@@ -1,4 +1,4 @@
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// <auto-generated>
// 此代码由工具生成。
// 运行时版本:4.0.30319.42000
@@ -4169,7 +4169,7 @@ namespace System.Application.UI.Resx {
}
/// <summary>
/// 查找类似 点此修改备注 的本地化字符串。
/// 查找类似 修改账号备注 的本地化字符串。
/// </summary>
public static string UserChange_EditRemark {
get {
@@ -1254,7 +1254,7 @@
<value>确定要删除这条本地记录帐户吗?</value>
</data>
<data name="UserChange_EditRemark" xml:space="preserve">
<value>点此修改备注</value>
<value>修改账号备注</value>
</data>
<data name="UserChange_LoginNewAccount" xml:space="preserve">
<value>登录新 Steam 账号</value>
@@ -137,15 +137,15 @@ namespace System.Application.UI.ViewModels
_SteamUsersSourceList.Refresh();
this.WhenAnyValue(x => x.SteamUsers)
.Subscribe(items => items?
.ToObservableChangeSet()
.AutoRefresh(x => x.Remark)
.WhenValueChanged(x => x.Remark, false)
.Subscribe(_ =>
{
SteamAccountSettings.AccountRemarks.Value = items?.Where(x => !string.IsNullOrEmpty(x.Remark)).ToDictionary(k => k.SteamId64, v => v.Remark);
}));
//this.WhenAnyValue(x => x.SteamUsers)
// .Subscribe(items => items?
// .ToObservableChangeSet()
// .AutoRefresh(x => x.Remark)
// .WhenValueChanged(x => x.Remark, false)
// .Subscribe(_ =>
// {
// SteamAccountSettings.AccountRemarks.Value = items?.Where(x => !string.IsNullOrEmpty(x.Remark)).ToDictionary(k => k.SteamId64, v => v.Remark);
// }));
}
public void SteamId_Click(SteamUser user)
@@ -215,5 +215,20 @@ namespace System.Application.UI.ViewModels
}
});
}
public async void EditRemarkAsync(SteamUser user)
{
var value = await TextBoxWindowViewModel.ShowDialogAsync(new()
{
Value = user.Remark,
Title = AppResources.UserChange_EditRemark,
});
if (value == null)
return;
user.Remark = value;
SteamAccountSettings.AccountRemarks.Value!.AddOrUpdate(user.SteamId64, user.Remark, (oldkey, oldvalue) => user.Remark);
SteamAccountSettings.AccountRemarks.RaiseValueChanged();
}
}
}
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
@@ -115,4 +115,4 @@
</ProjectReference>
</ItemGroup>
<ItemGroup />
</Project>
</Project>