1
1
using System ;
2
- using System . Linq ;
3
2
using System . Windows ;
4
3
using System . Windows . Controls ;
5
4
6
5
using Microsoft . Xaml . Behaviors ;
7
6
8
- using Sagiri . Services . Spotify . Track ;
9
- using Sagiri . Util . Common ;
10
7
using SagiriApp . Interop ;
11
8
using SagiriApp . Views ;
12
9
13
10
namespace SagiriApp . Behavior
14
11
{
15
12
class PostingFormatTextBehavior : Behavior < TextBox >
16
13
{
17
- private Logger _Logger { get ; set ; } = Logger . GetInstance ;
18
14
public string PostingFormat
19
15
{
20
16
get => ( string ) GetValue ( PostingFormatProperty ) ;
@@ -45,16 +41,12 @@ protected override void OnDetaching()
45
41
46
42
private void _OnTextChanged ( object sender , EventArgs e )
47
43
{
48
- var activeWindow = Application . Current . Windows
49
- . OfType < Window > ( )
50
- . SingleOrDefault ( x => x . IsActive ) ;
51
-
52
- if ( activeWindow is SettingWindow sw )
44
+ if ( Helper . GetActiveWindow is SettingWindow sw )
53
45
{
54
46
try
55
47
{
56
48
PostingFormat = sw . PostingFormatText . Text ;
57
- sw . PreviewText . Text = _RenderPreview ( sw ) ;
49
+ sw . PreviewText . Text = Helper . RenderPreview ( sw . PostingFormatText . Text ) ;
58
50
sw . SettingSave . IsEnabled = true ;
59
51
}
60
52
catch
@@ -64,19 +56,5 @@ private void _OnTextChanged(object sender, EventArgs e)
64
56
}
65
57
}
66
58
}
67
-
68
- private string _RenderPreview ( SettingWindow sw )
69
- {
70
- CurrentTrackInfo trackInfo = new ( )
71
- {
72
- Album = "メルト 10th ANNIVERSARY MIX" ,
73
- Artist = "ryo (supercell) - やなぎなぎ" ,
74
- TrackTitle = "メルト 10th ANNIVERSARY MIX" ,
75
- TrackNumber = "1" ,
76
- ReleaseDate = "2017/12/24" ,
77
- } ;
78
-
79
- return Helper . GenerateTrackText ( sw . PostingFormatText . Text , trackInfo ) ;
80
- }
81
59
}
82
60
}
0 commit comments