温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:MoonlightPiano月光钢琴源码
当前文件:
MoonlightPiano/AphroditePiano/Controls/Indication.xaml.cs[4K,2009-6-12 11:47:38],打开代码结构图
MoonlightPiano/AphroditePiano/Controls/Indication.xaml.cs[4K,2009-6-12 11:47:38],打开代码结构图1using System; 2
using System.Windows; 3
using System.Windows.Controls; 4
using System.Windows.Documents; 5
using System.Windows.Ink; 6
using System.Windows.Input; 7
using System.Windows.Media; 8
using System.Windows.Media.Animation; 9
using System.Windows.Shapes; 10
using AphroditePiano.VO; 11
using System.Windows.Threading; 12
using AphroditePiano.Controls; 13
14
namespace AphroditePiano 15
{ 16
public partial class Indication : UserControl 17
{ 18
private MusicVO music; 19
20
musicVO (DependencyProperty) 50
51
public Indication() 52
{ 53
// Required to initialize variables 54
InitializeComponent(); 55
BtnStart.Click += new RoutedEventHandler(BtnStart_Click); 56
gapTimer.Tick += new EventHandler(gapTimer_Tick); 57
paragraphTimer.Tick += new EventHandler(paragraphTimer_Tick); 58
} 59
60
PlaySpeed (DependencyProperty) 89
90
public TimeSpan gapTimeSpan = TimeSpan.FromSeconds(.4); 91
public TimeSpan paragraphTimeSpan = TimeSpan.FromSeconds(.8); 92
public DispatcherTimer gapTimer = new DispatcherTimer(); 93
public DispatcherTimer paragraphTimer = new DispatcherTimer(); 94
95
public string[] keys; 96
97
public int keyIndex = 0; 98
99
void paragraphTimer_Tick(object sender, EventArgs e) 100
{ 101
paragraphTimer.Stop(); 102
gapTimer.Start(); 103
} 104
105
void gapTimer_Tick(object sender, EventArgs e) 106
{ 107
//UpAllKeys(); 108
if (keyIndex < keys.Length - 1) 109
{ 110
if (keys[keyIndex] != "|") 111
{ 112
string ks = keys[keyIndex].Replace("&", string.Empty); 113
IndicationKey ikey = new IndicationKey(); 114
ikey.setTxt(ks); 115
ikey.HorizontalAlignment = HorizontalAlignment.Right; 116
ikey.VerticalAlignment = VerticalAlignment.Center; 117
xGrid.Children.Add(ikey); 118
ikey.run(); 119
} 120
else 121
{ 122
gapTimer.Stop(); 123
paragraphTimer.Start(); 124
} 125
keyIndex++; 126
} 127
else 128
{ 129
gapTimer.Stop(); 130
paragraphTimer.Stop(); 131
keyIndex = 0; 132
} 133
} 134
135
136
void BtnStart_Click(object sender, RoutedEventArgs e) 137
{ 138
if (this.music != null) 139
{ 140
VisualStateManager.GoToState(this, "Start", true); 141
142
keyIndex = 0; 143
gapTimer.Interval = gapTimeSpan; 144
paragraphTimer.Interval = paragraphTimeSpan; 145
146
keys = music.PassKey.Split(','); 147
148
gapTimer.Start(); 149
} 150
} 151
} 152
}






}