回答編集履歴
2
見直しキャンペーン中
test
CHANGED
@@ -1,169 +1,85 @@
|
|
1
1
|
`Storyboard`には`Completed`イベントがあります。
|
2
|
-
|
3
2
|
[Storyboard クラス (System.Windows.Media.Animation) | Microsoft Docs](https://docs.microsoft.com/ja-jp/dotnet/api/system.windows.media.animation.storyboard#events)
|
4
3
|
|
5
|
-
|
6
|
-
|
7
|
-
```
|
4
|
+
```cs
|
8
|
-
|
9
5
|
private void Click_Greeting(object sender, RoutedEventArgs e)
|
10
|
-
|
11
6
|
{
|
12
|
-
|
13
7
|
ph.ChangePhrase();
|
14
8
|
|
9
|
+
Storyboard sb;
|
10
|
+
switch(ph.Now)
|
11
|
+
{
|
12
|
+
case Period.MORNING:
|
13
|
+
sb = FindResource("MorningAnimation") as Storyboard;
|
14
|
+
break;
|
15
|
+
case Period.EVENING:
|
16
|
+
sb = FindResource("EveningAnimation") as Storyboard;
|
17
|
+
break;
|
18
|
+
default:
|
19
|
+
sb = FindResource("NightAnimation") as Storyboard;
|
20
|
+
break;
|
21
|
+
}
|
15
22
|
|
23
|
+
sb.Completed += Completed;
|
24
|
+
BeginStoryboard(sb);
|
16
25
|
|
26
|
+
void Completed(object _, EventArgs __)
|
27
|
+
{
|
28
|
+
sb.Completed -= Completed;
|
29
|
+
ph.ChangePhraseAfterAnimation();
|
30
|
+
}
|
31
|
+
}
|
32
|
+
```
|
33
|
+
|
34
|
+
`Storyboard`に組み込めるようなものなら、入れてしまってもよさそうですが。
|
35
|
+
|
36
|
+
---
|
37
|
+
|
38
|
+
もちろんxamlでイベントつけてもいいですよ。
|
39
|
+
```xml
|
40
|
+
<Storyboard x:Key="MorningAnimation" Completed="Storyboard_Completed">
|
41
|
+
<ColorAnimationUsingKeyFrames Storyboard.TargetName="window" Storyboard.TargetProperty="(Panel.Background).(SolidColorBrush.Color)">
|
42
|
+
<EasingColorKeyFrame KeyTime="0:0:1" Value="#FFFFA400" />
|
43
|
+
</ColorAnimationUsingKeyFrames>
|
17
|
-
|
44
|
+
</Storyboard>
|
45
|
+
<Storyboard x:Key="EveningAnimation" Completed="Storyboard_Completed">
|
46
|
+
<ColorAnimationUsingKeyFrames Storyboard.TargetName="window" Storyboard.TargetProperty="(Panel.Background).(SolidColorBrush.Color)">
|
47
|
+
<EasingColorKeyFrame KeyTime="0:0:1" Value="#FF0388FF" />
|
48
|
+
</ColorAnimationUsingKeyFrames>
|
49
|
+
</Storyboard>
|
50
|
+
<Storyboard x:Key="NightAnimation" Completed="Storyboard_Completed">
|
51
|
+
<ColorAnimationUsingKeyFrames Storyboard.TargetName="window" Storyboard.TargetProperty="(Panel.Background).(SolidColorBrush.Color)">
|
52
|
+
<EasingColorKeyFrame KeyTime="0:0:1" Value="#FF02067A" />
|
53
|
+
</ColorAnimationUsingKeyFrames>
|
54
|
+
</Storyboard>
|
55
|
+
```
|
56
|
+
|
57
|
+
```cs
|
58
|
+
private void Click_Greeting(object sender, RoutedEventArgs e)
|
59
|
+
{
|
60
|
+
ph.ChangePhrase();
|
18
61
|
|
19
62
|
switch(ph.Now)
|
20
|
-
|
21
63
|
{
|
22
|
-
|
23
64
|
case Period.MORNING:
|
24
|
-
|
25
|
-
sb = FindResource("MorningAnimation") as Storyboard;
|
65
|
+
var sb = FindResource("MorningAnimation") as Storyboard;
|
26
|
-
|
66
|
+
BeginStoryboard(sb);
|
27
67
|
break;
|
28
68
|
|
29
69
|
case Period.EVENING:
|
30
|
-
|
31
70
|
sb = FindResource("EveningAnimation") as Storyboard;
|
32
|
-
|
71
|
+
BeginStoryboard(sb);
|
33
72
|
break;
|
34
73
|
|
35
|
-
d
|
74
|
+
case Period.NIGHT:
|
36
|
-
|
37
75
|
sb = FindResource("NightAnimation") as Storyboard;
|
38
|
-
|
76
|
+
BeginStoryboard(sb);
|
39
77
|
break;
|
40
|
-
|
41
78
|
}
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
sb.Completed += Completed;
|
46
|
-
|
47
|
-
BeginStoryboard(sb);
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
void Completed(object _, EventArgs __)
|
52
|
-
|
53
|
-
{
|
54
|
-
|
55
|
-
sb.Completed -= Completed;
|
56
|
-
|
57
|
-
ph.ChangePhraseAfterAnimation();
|
58
|
-
|
59
|
-
}
|
60
|
-
|
61
79
|
}
|
62
80
|
|
81
|
+
private void Storyboard_Completed(object sender, EventArgs e)
|
82
|
+
{
|
83
|
+
ph.ChangePhraseAfterAnimation();
|
84
|
+
}
|
63
85
|
```
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
`Storyboard`に組み込めるようなものなら、入れてしまってもよさそうですが。
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
---
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
もちろんxamlでイベントつけてもいいですよ。
|
76
|
-
|
77
|
-
```xaml
|
78
|
-
|
79
|
-
<Storyboard x:Key="MorningAnimation" Completed="Storyboard_Completed">
|
80
|
-
|
81
|
-
<ColorAnimationUsingKeyFrames Storyboard.TargetName="window" Storyboard.TargetProperty="(Panel.Background).(SolidColorBrush.Color)">
|
82
|
-
|
83
|
-
<EasingColorKeyFrame KeyTime="0:0:1" Value="#FFFFA400" />
|
84
|
-
|
85
|
-
</ColorAnimationUsingKeyFrames>
|
86
|
-
|
87
|
-
</Storyboard>
|
88
|
-
|
89
|
-
<Storyboard x:Key="EveningAnimation" Completed="Storyboard_Completed">
|
90
|
-
|
91
|
-
<ColorAnimationUsingKeyFrames Storyboard.TargetName="window" Storyboard.TargetProperty="(Panel.Background).(SolidColorBrush.Color)">
|
92
|
-
|
93
|
-
<EasingColorKeyFrame KeyTime="0:0:1" Value="#FF0388FF" />
|
94
|
-
|
95
|
-
</ColorAnimationUsingKeyFrames>
|
96
|
-
|
97
|
-
</Storyboard>
|
98
|
-
|
99
|
-
<Storyboard x:Key="NightAnimation" Completed="Storyboard_Completed">
|
100
|
-
|
101
|
-
<ColorAnimationUsingKeyFrames Storyboard.TargetName="window" Storyboard.TargetProperty="(Panel.Background).(SolidColorBrush.Color)">
|
102
|
-
|
103
|
-
<EasingColorKeyFrame KeyTime="0:0:1" Value="#FF02067A" />
|
104
|
-
|
105
|
-
</ColorAnimationUsingKeyFrames>
|
106
|
-
|
107
|
-
</Storyboard>
|
108
|
-
|
109
|
-
```
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
```C#
|
114
|
-
|
115
|
-
private void Click_Greeting(object sender, RoutedEventArgs e)
|
116
|
-
|
117
|
-
{
|
118
|
-
|
119
|
-
ph.ChangePhrase();
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
switch(ph.Now)
|
124
|
-
|
125
|
-
{
|
126
|
-
|
127
|
-
case Period.MORNING:
|
128
|
-
|
129
|
-
var sb = FindResource("MorningAnimation") as Storyboard;
|
130
|
-
|
131
|
-
BeginStoryboard(sb);
|
132
|
-
|
133
|
-
break;
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
case Period.EVENING:
|
138
|
-
|
139
|
-
sb = FindResource("EveningAnimation") as Storyboard;
|
140
|
-
|
141
|
-
BeginStoryboard(sb);
|
142
|
-
|
143
|
-
break;
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
case Period.NIGHT:
|
148
|
-
|
149
|
-
sb = FindResource("NightAnimation") as Storyboard;
|
150
|
-
|
151
|
-
BeginStoryboard(sb);
|
152
|
-
|
153
|
-
break;
|
154
|
-
|
155
|
-
}
|
156
|
-
|
157
|
-
}
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
private void Storyboard_Completed(object sender, EventArgs e)
|
162
|
-
|
163
|
-
{
|
164
|
-
|
165
|
-
ph.ChangePhraseAfterAnimation();
|
166
|
-
|
167
|
-
}
|
168
|
-
|
169
|
-
```
|
1
追記
test
CHANGED
@@ -1,4 +1,8 @@
|
|
1
1
|
`Storyboard`には`Completed`イベントがあります。
|
2
|
+
|
3
|
+
[Storyboard クラス (System.Windows.Media.Animation) | Microsoft Docs](https://docs.microsoft.com/ja-jp/dotnet/api/system.windows.media.animation.storyboard#events)
|
4
|
+
|
5
|
+
|
2
6
|
|
3
7
|
```C#
|
4
8
|
|
@@ -61,3 +65,105 @@
|
|
61
65
|
|
62
66
|
|
63
67
|
`Storyboard`に組み込めるようなものなら、入れてしまってもよさそうですが。
|
68
|
+
|
69
|
+
|
70
|
+
|
71
|
+
---
|
72
|
+
|
73
|
+
|
74
|
+
|
75
|
+
もちろんxamlでイベントつけてもいいですよ。
|
76
|
+
|
77
|
+
```xaml
|
78
|
+
|
79
|
+
<Storyboard x:Key="MorningAnimation" Completed="Storyboard_Completed">
|
80
|
+
|
81
|
+
<ColorAnimationUsingKeyFrames Storyboard.TargetName="window" Storyboard.TargetProperty="(Panel.Background).(SolidColorBrush.Color)">
|
82
|
+
|
83
|
+
<EasingColorKeyFrame KeyTime="0:0:1" Value="#FFFFA400" />
|
84
|
+
|
85
|
+
</ColorAnimationUsingKeyFrames>
|
86
|
+
|
87
|
+
</Storyboard>
|
88
|
+
|
89
|
+
<Storyboard x:Key="EveningAnimation" Completed="Storyboard_Completed">
|
90
|
+
|
91
|
+
<ColorAnimationUsingKeyFrames Storyboard.TargetName="window" Storyboard.TargetProperty="(Panel.Background).(SolidColorBrush.Color)">
|
92
|
+
|
93
|
+
<EasingColorKeyFrame KeyTime="0:0:1" Value="#FF0388FF" />
|
94
|
+
|
95
|
+
</ColorAnimationUsingKeyFrames>
|
96
|
+
|
97
|
+
</Storyboard>
|
98
|
+
|
99
|
+
<Storyboard x:Key="NightAnimation" Completed="Storyboard_Completed">
|
100
|
+
|
101
|
+
<ColorAnimationUsingKeyFrames Storyboard.TargetName="window" Storyboard.TargetProperty="(Panel.Background).(SolidColorBrush.Color)">
|
102
|
+
|
103
|
+
<EasingColorKeyFrame KeyTime="0:0:1" Value="#FF02067A" />
|
104
|
+
|
105
|
+
</ColorAnimationUsingKeyFrames>
|
106
|
+
|
107
|
+
</Storyboard>
|
108
|
+
|
109
|
+
```
|
110
|
+
|
111
|
+
|
112
|
+
|
113
|
+
```C#
|
114
|
+
|
115
|
+
private void Click_Greeting(object sender, RoutedEventArgs e)
|
116
|
+
|
117
|
+
{
|
118
|
+
|
119
|
+
ph.ChangePhrase();
|
120
|
+
|
121
|
+
|
122
|
+
|
123
|
+
switch(ph.Now)
|
124
|
+
|
125
|
+
{
|
126
|
+
|
127
|
+
case Period.MORNING:
|
128
|
+
|
129
|
+
var sb = FindResource("MorningAnimation") as Storyboard;
|
130
|
+
|
131
|
+
BeginStoryboard(sb);
|
132
|
+
|
133
|
+
break;
|
134
|
+
|
135
|
+
|
136
|
+
|
137
|
+
case Period.EVENING:
|
138
|
+
|
139
|
+
sb = FindResource("EveningAnimation") as Storyboard;
|
140
|
+
|
141
|
+
BeginStoryboard(sb);
|
142
|
+
|
143
|
+
break;
|
144
|
+
|
145
|
+
|
146
|
+
|
147
|
+
case Period.NIGHT:
|
148
|
+
|
149
|
+
sb = FindResource("NightAnimation") as Storyboard;
|
150
|
+
|
151
|
+
BeginStoryboard(sb);
|
152
|
+
|
153
|
+
break;
|
154
|
+
|
155
|
+
}
|
156
|
+
|
157
|
+
}
|
158
|
+
|
159
|
+
|
160
|
+
|
161
|
+
private void Storyboard_Completed(object sender, EventArgs e)
|
162
|
+
|
163
|
+
{
|
164
|
+
|
165
|
+
ph.ChangePhraseAfterAnimation();
|
166
|
+
|
167
|
+
}
|
168
|
+
|
169
|
+
```
|