Skip to content

Commit 4a16b38

Browse files
committed
MvvmLightLibsからCommunityToolkit.Mvvmに移行
1 parent 555b14f commit 4a16b38

File tree

49 files changed

+480
-413
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+480
-413
lines changed

BigoSitePlugin/CommentPostPanelViewModel.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
using Common;
2-
using GalaSoft.MvvmLight;
3-
using GalaSoft.MvvmLight.Command;
2+
using CommunityToolkit.Mvvm.ComponentModel;
3+
using CommunityToolkit.Mvvm.Input;
44
using System;
55
using System.Windows;
66
using System.Windows.Input;
77

88
namespace BigoSitePlugin
99
{
10-
class CommentPostPanelViewModel:ViewModelBase
10+
class CommentPostPanelViewModel : ObservableObject
1111
{
1212

1313
private bool _canPostComment;
@@ -18,7 +18,7 @@ public bool CanPostComment
1818
{
1919
if (_canPostComment == value) return;
2020
_canPostComment = value;
21-
RaisePropertyChanged();
21+
OnPropertyChanged();
2222
}
2323
}
2424
public ICommand PostCommentCommand { get; }
@@ -53,7 +53,7 @@ public string Comment
5353
{
5454
if (_comment == value) return;
5555
_comment = value;
56-
RaisePropertyChanged();
56+
OnPropertyChanged();
5757
}
5858
}
5959
public CommentPostPanelViewModel(CommentProvider commentProvider, ILogger logger)

BouyomiPlugin/ConfigViewModel.cs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
using GalaSoft.MvvmLight;
2-
using GalaSoft.MvvmLight.Command;
1+
using CommunityToolkit.Mvvm.ComponentModel;
2+
using CommunityToolkit.Mvvm.Input;
33
using System;
44
using System.Diagnostics;
55
using System.Windows.Input;
@@ -14,7 +14,7 @@ public enum VoiceType { Default = 0, Female1 = 1, Female2 = 2, Male1 = 3, Male2
1414
}
1515
namespace BouyomiPlugin
1616
{
17-
class ConfigViewModel : ViewModelBase
17+
class ConfigViewModel : ObservableObject
1818
{
1919
private const int VoiceTypeSapi5Offset = 10001;
2020
private readonly int VoiceTypeLength = Enum.GetNames(typeof(FNF.Utility.VoiceType)).Length;
@@ -896,7 +896,6 @@ public ConfigViewModel()
896896
// throw new NotSupportedException();
897897
//}
898898
}
899-
[GalaSoft.MvvmLight.Ioc.PreferredConstructor]
900899
public ConfigViewModel(Options options)
901900
{
902901
_options = options;
@@ -905,19 +904,19 @@ public ConfigViewModel(Options options)
905904
switch (e.PropertyName)
906905
{
907906
case nameof(_options.IsEnabled):
908-
RaisePropertyChanged(nameof(IsEnabled));
907+
OnPropertyChanged(nameof(IsEnabled));
909908
break;
910909
case nameof(_options.BouyomiChanPath):
911-
RaisePropertyChanged(nameof(ExeLocation));
910+
OnPropertyChanged(nameof(ExeLocation));
912911
break;
913912
case nameof(_options.IsReadHandleName):
914-
RaisePropertyChanged(nameof(IsReadHandleName));
913+
OnPropertyChanged(nameof(IsReadHandleName));
915914
break;
916915
case nameof(_options.IsReadComment):
917-
RaisePropertyChanged(nameof(IsReadComment));
916+
OnPropertyChanged(nameof(IsReadComment));
918917
break;
919918
case nameof(_options.IsVoiceTypeSpecfied):
920-
RaisePropertyChanged(nameof(IsVoiceTypeSpecfied));
919+
OnPropertyChanged(nameof(IsVoiceTypeSpecfied));
921920
break;
922921
}
923922
};

CommentGeneratorPlugin/ConfigViewModel.cs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@
2020
using System.Collections;
2121
using System.Globalization;
2222
using System.Collections.Concurrent;
23-
using GalaSoft.MvvmLight;
24-
using GalaSoft.MvvmLight.Command;
25-
using GalaSoft.MvvmLight.Messaging;
2623
using System.Diagnostics;
2724
using System.Net;
25+
using CommunityToolkit.Mvvm.ComponentModel;
26+
using CommunityToolkit.Mvvm.Input;
27+
2828
namespace CommentViewer.Plugin
2929
{
30-
public sealed class ConfigViewModel : ViewModelBase
30+
public sealed class ConfigViewModel : ObservableObject
3131
{
3232
private readonly Options _options;
3333
public bool IsEnabled
@@ -73,7 +73,6 @@ public ConfigViewModel()
7373
throw new NotSupportedException();
7474
}
7575
}
76-
[GalaSoft.MvvmLight.Ioc.PreferredConstructor]
7776
public ConfigViewModel(Options options)
7877
{
7978
_options = options;
@@ -82,13 +81,13 @@ public ConfigViewModel(Options options)
8281
switch (e.PropertyName)
8382
{
8483
case nameof(_options.IsEnabled):
85-
RaisePropertyChanged(nameof(IsEnabled));
84+
OnPropertyChanged(nameof(IsEnabled));
8685
break;
8786
case nameof(_options.HcgSettingFilePath):
88-
RaisePropertyChanged(nameof(HcgSettingFilePath));
87+
OnPropertyChanged(nameof(HcgSettingFilePath));
8988
break;
9089
case nameof(_options.IsMirrativeJoin):
91-
RaisePropertyChanged(nameof(IsMirrativJoin));
90+
OnPropertyChanged(nameof(IsMirrativJoin));
9291
break;
9392
}
9493
};

CommentGeneratorPlugin/Options.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
using System.Windows;
77
using System.Windows.Input;
88
using System.Windows.Media;
9-
using GalaSoft.MvvmLight;
109
using System.Runtime.Serialization;
1110
namespace CommentViewer.Plugin
1211
{
@@ -40,7 +39,7 @@ public virtual string HcgSettingFilePath
4039
}
4140
}
4241
[DataMember]
43-
private bool _isMirrativeJoin=false;
42+
private bool _isMirrativeJoin = false;
4443
public bool IsMirrativeJoin
4544
{
4645
get

Common/AutoUpdate/Message.cs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,27 @@
11
using System;
2-
using GalaSoft.MvvmLight.Messaging;
2+
using CommunityToolkit.Mvvm.Messaging;
3+
using CommunityToolkit.Mvvm.Messaging.Messages;
4+
35
namespace Common.AutoUpdate
46
{
5-
[Obsolete]
6-
public class ShowUpdateDialogMessage : MessageBase
7+
public class ShowUpdateDialogMessageItems
78
{
89
public Version CurrentVersion { get; }
910
public LatestVersionInfo LatestVersionInfo { get; }
1011
public bool IsUpdateExists { get; private set; }
1112
public ILogger Logger { get; }
1213
public string UserAgent { get; }
13-
14-
public ShowUpdateDialogMessage(bool isUpdateExists, Version currentVersion, AutoUpdate.LatestVersionInfo latestInfo, ILogger logger, string userAgent)
14+
public ShowUpdateDialogMessageItems(bool isUpdateExists, Version currentVersion, AutoUpdate.LatestVersionInfo latestInfo, ILogger logger, string userAgent)
1515
{
16-
this.IsUpdateExists = isUpdateExists;
16+
IsUpdateExists = isUpdateExists;
1717
CurrentVersion = currentVersion;
1818
LatestVersionInfo = latestInfo;
1919
Logger = logger;
2020
UserAgent = userAgent;
2121
}
2222
}
23+
public class ShowUpdateDialogMessage : ValueChangedMessage<ShowUpdateDialogMessageItems>
24+
{
25+
public ShowUpdateDialogMessage(ShowUpdateDialogMessageItems value) : base(value) { }
26+
}
2327
}

Common/CommentViewModelBase.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
using SitePlugin;
99
using System.Text.RegularExpressions;
1010
using System.Windows.Input;
11-
using GalaSoft.MvvmLight.CommandWpf;
1211
using System.Diagnostics;
12+
using CommunityToolkit.Mvvm.Input;
1313

1414
namespace Common
1515
{
@@ -115,7 +115,7 @@ public virtual SolidColorBrush Foreground
115115
{
116116
return new SolidColorBrush(_options.InfoForeColor);
117117
}
118-
else if(MessageType == MessageType.BroadcastInfo)
118+
else if (MessageType == MessageType.BroadcastInfo)
119119
{
120120
return new SolidColorBrush(_options.BroadcastInfoForeColor);
121121
}
@@ -162,7 +162,7 @@ protected string ExtractNickname(string text)
162162
var matches = Regex.Matches(text, "(?:@|@)(\\S+)", RegexOptions.Singleline);
163163
if (matches.Count > 0)
164164
{
165-
foreach(Match match in matches.Cast<Match>().Reverse())
165+
foreach (Match match in matches.Cast<Match>().Reverse())
166166
{
167167
var val = match.Groups[1].Value;
168168
if (!int.TryParse(val, out _))

Common/Common.csproj

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
<PropertyGroup>
33
<UseWPF>true</UseWPF>
44
<TargetFramework>net60-windows</TargetFramework>
5-
<LangVersion>8.0</LangVersion>
65
<Configurations>Release;Beta;Alpha;Debug</Configurations>
76
<ContentSQLiteInteropFiles>true</ContentSQLiteInteropFiles>
87
<CopySQLiteInteropFiles>false</CopySQLiteInteropFiles>
@@ -43,7 +42,7 @@
4342
<DebugSymbols>true</DebugSymbols>
4443
</PropertyGroup>
4544
<ItemGroup>
46-
<PackageReference Include="MvvmLightLibs" Version="5.4.1.1" />
45+
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.1.0" />
4746
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
4847
<PackageReference Include="SharpVectors" Version="1.7.6" />
4948
<PackageReference Include="System.Data.SQLite.Core" Version="1.0.117" />

Common/FontSelectorView.xaml.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using System;
1+
using CommunityToolkit.Mvvm.Messaging;
2+
using System;
23
using System.Collections.Generic;
34
using System.ComponentModel;
45
using System.Linq;
@@ -12,7 +13,7 @@
1213
using System.Windows.Media;
1314
using System.Windows.Media.Imaging;
1415
using System.Windows.Shapes;
15-
using GalaSoft.MvvmLight.Messaging;
16+
1617
namespace Common.Wpf
1718
{
1819
/// <summary>
@@ -23,12 +24,12 @@ public partial class FontSelectorView : Window
2324
public FontSelectorView()
2425
{
2526
InitializeComponent();
26-
Messenger.Default.Register<FontSelectorViewOkMessage>(this, _ =>
27+
WeakReferenceMessenger.Default.Register<FontSelectorViewOkMessage>(this, (_, _) =>
2728
{
2829
//DialogResultに値を入れると一回目は正常に動作するが、2回目は例外が発生してしまう。DialogResultに2回以上値を入れてはいけないらしい。
2930
this.Close();
3031
});
31-
Messenger.Default.Register<FontSelectorViewCancelMessage>(this, _ =>
32+
WeakReferenceMessenger.Default.Register<FontSelectorViewCancelMessage>(this, (_, _) =>
3233
{
3334
this.Close();
3435
});

0 commit comments

Comments
 (0)