-
Notifications
You must be signed in to change notification settings - Fork 45
/
Copy pathmain.cs
865 lines (844 loc) · 34.3 KB
/
main.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
using BigoSitePlugin;
using LineLiveSitePlugin;
using MildomSitePlugin;
using MirrativSitePlugin;
using NicoSitePlugin;
using OpenrecSitePlugin;
using MixchSitePlugin;
using PeriscopeSitePlugin;
using Plugin;
using PluginCommon;
using ShowRoomSitePlugin;
using SitePlugin;
using System;
using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.Diagnostics;
using System.Runtime.Remoting.Contexts;
using System.Runtime.Remoting.Messaging;
using TwicasSitePlugin;
using TwitchSitePlugin;
using WhowatchSitePlugin;
using YouTubeLiveSitePlugin;
namespace BouyomiPlugin
{
static class MessageParts
{
public static string ToTextWithImageAlt(this IEnumerable<IMessagePart> parts)
{
string s = "";
if (parts != null)
{
foreach (var part in parts)
{
if (part is IMessageText text)
{
s += text;
}
else if (part is IMessageImage image)
{
s += image.Alt;
}
else if(part is IMessageRemoteSvg remoteSvg)
{
s += remoteSvg.Alt;
}
else
{
}
}
}
return s;
}
public static string ToTextWithImageAlt(this IEnumerable<IMessagePart> parts, int maxImages, bool skipSameImage)
{
int n = 0;
string s = "";
string previousImage = "";
if (parts != null)
{
foreach (var part in parts)
{
if (part is IMessageText text)
{
if (!string.IsNullOrWhiteSpace(text.Text))
{
previousImage = "";
}
s += text;
}
else if (part is IMessageImage image)
{
if ((n < maxImages) && (!skipSameImage || !string.Equals(previousImage, image.Alt)))
{
s += image.Alt;
n++;
}
previousImage = image.Alt;
}
else if(part is IMessageRemoteSvg remoteSvg)
{
if ((n < maxImages) && (!skipSameImage || !string.Equals(previousImage, remoteSvg.Alt)))
{
s += remoteSvg.Alt;
n++;
}
previousImage = remoteSvg.Alt;
}
else
{
}
}
}
return s;
}
}
[Export(typeof(IPlugin))]
public class BouyomiPlugin : IPlugin, IDisposable
{
private readonly FNF.Utility.BouyomiChanClient _bouyomiChanClient;
private Options _options;
Process _bouyomiChanProcess;
public string Name => "棒読みちゃん連携";
public string Description => "棒読みソフトとうまく連携できるか試してみるプラグインです。";
public void OnTopmostChanged(bool isTopmost)
{
if (_settingsView != null)
{
_settingsView.Topmost = isTopmost;
}
}
public void OnLoaded()
{
try
{
var s = Host.LoadOptions(GetSettingsFilePath());
_options.Deserialize(s);
}
catch (System.IO.FileNotFoundException) { }
try
{
if (_options.IsExecBouyomiChanAtBoot && !IsExecutingProcess("BouyomiChan"))
{
StartBouyomiChan();
}
}
catch (Exception) { }
}
/// <summary>
/// 指定したプロセス名を持つプロセスが起動中か
/// </summary>
/// <param name="processName">プロセス名</param>
/// <returns></returns>
private bool IsExecutingProcess(string processName)
{
return Process.GetProcessesByName(processName).Length > 0;
}
public void OnClosing()
{
_settingsView?.ForceClose();
var s = _options.Serialize();
Host.SaveOptions(GetSettingsFilePath(), s);
if (_bouyomiChanProcess != null && _options.IsKillBouyomiChan)
{
try
{
_bouyomiChanProcess.Kill();
}
catch (Exception) { }
}
}
private void StartBouyomiChan()
{
if (_bouyomiChanProcess == null && System.IO.File.Exists(_options.BouyomiChanPath))
{
_bouyomiChanProcess = Process.Start(_options.BouyomiChanPath);
_bouyomiChanProcess.EnableRaisingEvents = true;
_bouyomiChanProcess.Exited += BouyomiChanProcess_Exited;
}
}
private void BouyomiChanProcess_Exited(object sender, EventArgs e)
{
try
{
_bouyomiChanProcess?.Close();//2018/03/25ここで_bouyomiChanProcessがnullになる場合があった
}
catch { }
_bouyomiChanProcess = null;
}
private static (string name, string comment) GetData(ISiteMessage message, Options options)
{
string name = null;
string comment = null;
if (false) { }
else if (message is IYouTubeLiveMessage youTubeLiveMessage)
{
switch (youTubeLiveMessage.YouTubeLiveMessageType)
{
case YouTubeLiveMessageType.Connected:
if (options.IsYouTubeLiveConnect)
{
name = null;
comment = (youTubeLiveMessage as IYouTubeLiveConnected).Text;
}
break;
case YouTubeLiveMessageType.Disconnected:
if (options.IsYouTubeLiveDisconnect)
{
name = null;
comment = (youTubeLiveMessage as IYouTubeLiveDisconnected).Text;
}
break;
case YouTubeLiveMessageType.Comment:
if (options.IsYouTubeLiveComment)
{
if (options.IsYouTubeLiveCommentNickname)
{
name = (youTubeLiveMessage as IYouTubeLiveComment).NameItems.ToText();
}
if (options.IsYouTubeLiveCommentStamp)
{
comment = (youTubeLiveMessage as IYouTubeLiveComment).CommentItems.ToTextWithImageAlt();
}
else
{
comment = (youTubeLiveMessage as IYouTubeLiveComment).CommentItems.ToText();
}
}
break;
case YouTubeLiveMessageType.Superchat:
if (options.IsYouTubeLiveSuperchat)
{
var superChat = youTubeLiveMessage as IYouTubeLiveSuperchat;
if (options.IsYouTubeLiveSuperchatNickname)
{
name = superChat.NameItems.ToText();
}
//TODO:superchat中のスタンプも読ませるべきでは?
var text = superChat.CommentItems.ToText();
var amount = superChat.PurchaseAmount;
comment = amount + Environment.NewLine + text;
}
break;
case YouTubeLiveMessageType.Membership:
if (options.IsYouTubeLiveMembership)
{
var membership = youTubeLiveMessage as IYouTubeLiveMembership;
if (options.IsYouTubeLiveMembershipNickname)
{
name = membership.NameItems.ToText();
}
comment = membership.CommentItems.ToText();
}
break;
}
}
else if (message is IOpenrecMessage openrecMessage)
{
switch (openrecMessage.OpenrecMessageType)
{
case OpenrecMessageType.Connected:
if (options.IsOpenrecConnect)
{
name = null;
comment = (openrecMessage as IOpenrecConnected).Text;
}
break;
case OpenrecMessageType.Disconnected:
if (options.IsOpenrecDisconnect)
{
name = null;
comment = (openrecMessage as IOpenrecDisconnected).Text;
}
break;
case OpenrecMessageType.Comment:
if (options.IsOpenrecComment)
{
if (options.IsOpenrecCommentNickname)
{
name = (openrecMessage as IOpenrecComment).NameItems.ToText();
}
comment = (openrecMessage as IOpenrecComment).MessageItems.ToText();
}
break;
}
}
else if (message is IMixchMessage mixchMessage)
{
switch (mixchMessage.MixchMessageType)
{
case MixchMessageType.Comment:
if (options.IsMixchComment && (!options.IsMixchCommentOnlyFirst || mixchMessage.IsFirstComment))
{
if (options.IsMixchCommentNickname)
{
name = mixchMessage.NameItems.ToText();
}
comment = mixchMessage.MessageItems.ToText();
}
break;
case MixchMessageType.SuperComment:
case MixchMessageType.Stamp:
case MixchMessageType.PoiPoi:
case MixchMessageType.Item:
case MixchMessageType.CoinBox:
if (options.IsMixchItem)
{
if (options.IsMixchItemNickname)
{
name = mixchMessage.NameItems.ToText();
}
comment = mixchMessage.MessageItems.ToText();
}
break;
case MixchMessageType.Share:
case MixchMessageType.EnterNewbie:
case MixchMessageType.EnterLevel:
case MixchMessageType.Follow:
case MixchMessageType.EnterFanclub:
if (options.IsMixchSystem)
{
comment = mixchMessage.MessageItems.ToText();
}
break;
}
}
else if (message is ITwitchMessage twitchMessage)
{
switch (twitchMessage.TwitchMessageType)
{
case TwitchMessageType.Connected:
if (options.IsTwitchConnect)
{
name = null;
comment = (twitchMessage as ITwitchConnected).Text;
}
break;
case TwitchMessageType.Disconnected:
if (options.IsTwitchDisconnect)
{
name = null;
comment = (twitchMessage as ITwitchDisconnected).Text;
}
break;
case TwitchMessageType.Comment:
if (options.IsTwitchComment)
{
if (options.IsTwitchCommentNickname)
{
name = (twitchMessage as ITwitchComment).DisplayName;
}
if (options.IsTwitchCommentEmoteId)
{
comment = (twitchMessage as ITwitchComment).CommentItems.ToTextWithImageAlt(options.TwitchMaxEmotes, options.IsTwitchSkipSameEmote);
}
else
{
comment = (twitchMessage as ITwitchComment).CommentItems.ToText();
}
}
break;
}
}
else if (message is INicoMessage NicoMessage)
{
switch (NicoMessage.NicoMessageType)
{
case NicoMessageType.Connected:
if (options.IsNicoConnect)
{
name = null;
comment = (NicoMessage as INicoConnected).Text;
}
break;
case NicoMessageType.Disconnected:
if (options.IsNicoDisconnect)
{
name = null;
comment = (NicoMessage as INicoDisconnected).Text;
}
break;
case NicoMessageType.Comment:
if (options.IsNicoComment)
{
if (options.IsNicoCommentNickname)
{
name = (NicoMessage as INicoComment).UserName;
}
comment = (NicoMessage as INicoComment).Text;
}
break;
case NicoMessageType.Item:
if (options.IsNicoItem)
{
if (options.IsNicoItemNickname)
{
//name = (NicoMessage as INicoItem).NameItems.ToText();
}
comment = (NicoMessage as INicoGift).Text;
}
break;
case NicoMessageType.Ad:
if (options.IsNicoAd)
{
name = null;
comment = (NicoMessage as INicoAd).Text;
}
break;
case NicoMessageType.Spi:
if (options.IsNicoSpi)
{
name = null;
comment = (NicoMessage as INicoSpi).Text;
}
break;
}
}
else if (message is ITwicasMessage twicasMessage)
{
switch (twicasMessage.TwicasMessageType)
{
case TwicasMessageType.Connected:
if (options.IsTwicasConnect)
{
name = null;
comment = (twicasMessage as ITwicasConnected).Text;
}
break;
case TwicasMessageType.Disconnected:
if (options.IsTwicasDisconnect)
{
name = null;
comment = (twicasMessage as ITwicasDisconnected).Text;
}
break;
case TwicasMessageType.Comment:
if (options.IsTwicasComment)
{
if (options.IsTwicasCommentNickname)
{
name = (twicasMessage as ITwicasComment).UserName;
}
comment = (twicasMessage as ITwicasComment).CommentItems.ToText();
}
break;
case TwicasMessageType.Item:
if (options.IsTwicasItem)
{
if (options.IsTwicasItemNickname)
{
name = (twicasMessage as ITwicasItem).UserName;
}
comment = (twicasMessage as ITwicasItem).CommentItems.ToTextWithImageAlt();
}
break;
}
}
else if (message is ILineLiveMessage lineLiveMessage)
{
switch (lineLiveMessage.LineLiveMessageType)
{
case LineLiveMessageType.Connected:
if (options.IsLineLiveConnect)
{
name = null;
comment = (lineLiveMessage as ILineLiveConnected).Text;
}
break;
case LineLiveMessageType.Disconnected:
if (options.IsLineLiveDisconnect)
{
name = null;
comment = (lineLiveMessage as ILineLiveDisconnected).Text;
}
break;
case LineLiveMessageType.Comment:
if (options.IsLineLiveComment)
{
if (options.IsLineLiveCommentNickname)
{
name = (lineLiveMessage as ILineLiveComment).DisplayName;
}
comment = (lineLiveMessage as ILineLiveComment).Text;
}
break;
}
}
else if (message is IWhowatchMessage whowatchMessage)
{
switch (whowatchMessage.WhowatchMessageType)
{
case WhowatchMessageType.Connected:
if (options.IsWhowatchConnect)
{
name = null;
comment = (whowatchMessage as IWhowatchConnected).Text;
}
break;
case WhowatchMessageType.Disconnected:
if (options.IsWhowatchDisconnect)
{
name = null;
comment = (whowatchMessage as IWhowatchDisconnected).Text;
}
break;
case WhowatchMessageType.Comment:
if (options.IsWhowatchComment)
{
if (options.IsWhowatchCommentNickname)
{
name = (whowatchMessage as IWhowatchComment).UserName;
}
comment = (whowatchMessage as IWhowatchComment).Comment;
}
break;
case WhowatchMessageType.Item:
if (options.IsWhowatchItem)
{
if (options.IsWhowatchItemNickname)
{
name = (whowatchMessage as IWhowatchItem).UserName;
}
comment = (whowatchMessage as IWhowatchItem).Comment;
}
break;
}
}
else if (message is IMirrativMessage mirrativMessage)
{
switch (mirrativMessage.MirrativMessageType)
{
case MirrativMessageType.Connected:
if (options.IsMirrativConnect)
{
name = null;
comment = (mirrativMessage as IMirrativConnected).Text;
}
break;
case MirrativMessageType.Disconnected:
if (options.IsMirrativDisconnect)
{
name = null;
comment = (mirrativMessage as IMirrativDisconnected).Text;
}
break;
case MirrativMessageType.Comment:
if (options.IsMirrativComment)
{
if (options.IsMirrativCommentNickname)
{
name = (mirrativMessage as IMirrativComment).UserName;
}
comment = (mirrativMessage as IMirrativComment).Text;
}
break;
case MirrativMessageType.JoinRoom:
if (options.IsMirrativJoinRoom)
{
name = null;
comment = (mirrativMessage as IMirrativJoinRoom).Text;
}
break;
case MirrativMessageType.Item:
if (options.IsMirrativItem)
{
name = null;
comment = (mirrativMessage as IMirrativItem).Text;
}
break;
}
}
else if (message is IPeriscopeMessage PeriscopeMessage)
{
switch (PeriscopeMessage.PeriscopeMessageType)
{
case PeriscopeMessageType.Connected:
if (options.IsPeriscopeConnect)
{
name = null;
comment = (PeriscopeMessage as IPeriscopeConnected).Text;
}
break;
case PeriscopeMessageType.Disconnected:
if (options.IsPeriscopeDisconnect)
{
name = null;
comment = (PeriscopeMessage as IPeriscopeDisconnected).Text;
}
break;
case PeriscopeMessageType.Comment:
if (options.IsPeriscopeComment)
{
if (options.IsPeriscopeCommentNickname)
{
name = (PeriscopeMessage as IPeriscopeComment).DisplayName;
}
comment = (PeriscopeMessage as IPeriscopeComment).Text;
}
break;
case PeriscopeMessageType.Join:
if (options.IsPeriscopeJoin)
{
name = null;
comment = (PeriscopeMessage as IPeriscopeJoin).Text;
}
break;
case PeriscopeMessageType.Leave:
if (options.IsPeriscopeLeave)
{
name = null;
comment = (PeriscopeMessage as IPeriscopeLeave).Text;
}
break;
}
}
else if (message is IMildomMessage MildomMessage)
{
switch (MildomMessage.MildomMessageType)
{
case MildomMessageType.Connected:
if (options.IsMildomConnect)
{
name = null;
comment = (MildomMessage as IMildomConnected).Text;
}
break;
case MildomMessageType.Disconnected:
if (options.IsMildomDisconnect)
{
name = null;
comment = (MildomMessage as IMildomDisconnected).Text;
}
break;
case MildomMessageType.Comment:
if (options.IsMildomComment)
{
if (options.IsMildomCommentNickname)
{
name = (MildomMessage as IMildomComment).UserName;
}
if (options.IsMildomCommentStampId)
{
comment = (MildomMessage as IMildomComment).CommentItems.ToTextWithImageAlt();
}
else
{
comment = (MildomMessage as IMildomComment).CommentItems.ToText();
}
}
break;
case MildomMessageType.JoinRoom:
if (options.IsMildomJoin)
{
name = null;
comment = (MildomMessage as IMildomJoinRoom).CommentItems.ToText();
}
break;
//case MildomMessageType.Leave:
// if (_options.IsMildomLeave)
// {
// name = null;
// comment = (MildomMessage as IMildomLeave).CommentItems.ToText();
// }
// break;
case MildomMessageType.Gift:
if (options.IsMildomGift)
{
if (options.IsMildomGiftNickname)
{
name = (MildomMessage as IMildomGift).UserName;
}
var giftName = ((IMildomGift)MildomMessage).GiftName;
comment = $"{giftName}を贈りました";
}
break;
}
}
else if (message is IShowRoomMessage showroomMessage)
{
switch (showroomMessage.ShowRoomMessageType)
{
case ShowRoomMessageType.Comment:
if (options.IsShowRoomComment)
{
if (options.IsShowRoomCommentNickname)
{
name = (showroomMessage as IShowRoomComment).UserName;
}
comment = (showroomMessage as IShowRoomComment).Text;
}
break;
default:
break;
}
}
else if (message is IBigoMessage bigoMessage)
{
switch (bigoMessage.BigoMessageType)
{
case BigoMessageType.Comment:
if (options.IsBigoLiveComment)
{
if (options.IsBigoLiveCommentNickname)
{
name = (bigoMessage as IBigoComment).Name;
}
comment = (bigoMessage as IBigoComment).Message;
}
break;
default:
break;
}
}
else
{
}
return (name, comment);
}
public void OnMessageReceived(ISiteMessage message, IMessageMetadata messageMetadata)
{
if (!_options.IsEnabled || messageMetadata.IsNgUser || messageMetadata.IsInitialComment || (messageMetadata.Is184 && !_options.Want184Read))
return;
var (name, comment) = GetData(message, _options);
//nameがnullでは無い場合かつUser.Nicknameがある場合はNicknameを採用
if (!string.IsNullOrEmpty(name) && messageMetadata.User != null && !string.IsNullOrEmpty(messageMetadata.User.Nickname))
{
name = messageMetadata.User.Nickname;
}
try
{
//棒読みちゃんが事前に起動されていたらそれを使いたい。
//起動していなかったら起動させて、準備ができ次第それ以降のコメントを読んで貰う
//とりあえず何も確認せずにコメントを送信する。起動していなかったら例外が起きる。
var dataToRead = "";//棒読みちゃんに読んでもらう文字列
if (_options.IsReadHandleName && !string.IsNullOrEmpty(name))
{
dataToRead += name;
if (_options.IsAppendNickTitle)
{
dataToRead += _options.NickTitle;
}
}
if (_options.IsReadComment && !string.IsNullOrEmpty(comment))
{
if (!string.IsNullOrEmpty(dataToRead))//空欄で無い場合、つまり名前も読み上げる場合は名前とコメントの間にスペースを入れる。こうすると名前とコメントの間で一呼吸入れてくれる
{
dataToRead += " ";
}
dataToRead += comment;
}
if (string.IsNullOrEmpty(dataToRead))
{
return;
}
TalkText(dataToRead);
}
catch (System.Runtime.Remoting.RemotingException)
{
//多分棒読みちゃんが起動していない。
if (_bouyomiChanProcess == null && System.IO.File.Exists(_options.BouyomiChanPath))
{
_bouyomiChanProcess = Process.Start(_options.BouyomiChanPath);
_bouyomiChanProcess.EnableRaisingEvents = true;
_bouyomiChanProcess.Exited += (s, e) =>
{
try
{
_bouyomiChanProcess?.Close();//2018/03/25ここで_bouyomiChanProcessがnullになる場合があった
}
catch { }
_bouyomiChanProcess = null;
};
}
//起動するまでの間にコメントが投稿されたらここに来てしまうが諦める。
}
catch (Exception)
{
}
}
private int TalkText(string text)
{
if (_options.IsVoiceTypeSpecfied)
{
return _bouyomiChanClient.AddTalkTask2(
text,
_options.VoiceSpeed,
_options.VoiceTone,
_options.VoiceVolume,
(FNF.Utility.VoiceType)Enum.ToObject(typeof(FNF.Utility.VoiceType), _options.VoiceTypeIndex)
);
}
else
{
return _bouyomiChanClient.AddTalkTask2(text);
}
}
public IPluginHost Host { get; set; }
public string GetSettingsFilePath()
{
//ここでRemotingExceptionが発生。終了時の処理だが、既にHostがDisposeされてるのかも。
var dir = Host.SettingsDirPath;
return System.IO.Path.Combine(dir, $"{Name}.xml");
}
ConfigView _settingsView;
public void ShowSettingView()
{
if (_settingsView == null)
{
_settingsView = new ConfigView
{
DataContext = new ConfigViewModel(_options)
};
}
_settingsView.Topmost = Host.IsTopmost;
_settingsView.Left = Host.MainViewLeft;
_settingsView.Top = Host.MainViewTop;
_settingsView.Show();
}
public BouyomiPlugin()
{
_bouyomiChanClient = new FNF.Utility.BouyomiChanClient();
_options = new Options();
}
#region IDisposable Support
private bool _disposedValue = false; // To detect redundant calls
protected virtual void Dispose(bool disposing)
{
if (!_disposedValue)
{
if (disposing)
{
}
_bouyomiChanClient.Dispose();
if (_bouyomiChanProcess != null)
{
_bouyomiChanProcess.Close();
_bouyomiChanProcess = null;
}
_disposedValue = true;
}
}
~BouyomiPlugin()
{
Dispose(false);
}
// This code added to correctly implement the disposable pattern.
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
#endregion
}
class OptionsLoader
{
public Options Load(string path)
{
var options = new Options();
return options;
}
public void Save(Options options, string path)
{
}
}
}