/// <summary> /// 加载一个歌曲数据并解析 /// </summary> /// <param name="sc"></param> private void Load(MusicInfo mi) { speed = mi.Speed; //计算到敲击点延迟 CalcDelayOffset(); //解析实体类 string[] datas = mi.MusicData.Split(','); CadenceSigns = new CadenceSign[datas.Length]; string temp = string.Empty; int delaytime = 0; int ttime = 0; int i = 0; foreach (string t in datas) { temp = t.Substring(0, 2); ttime = int.Parse(t.Substring(3, t.Length - 3)); delaytime += ttime; CadenceSign cs = new CadenceSign(); cs.drumType = CommHelper.DrumTypeToKeyCode(temp); cs.DelayTimeMill = delaytime; //图像 Image img = new Image(); if (cs.drumType == DrumType.FaceAll) { img.Width = 45; img.Height = 45; img.Source = ResourceMgr.SignimgBgCache[1]; } else if (cs.drumType == DrumType.SideAll) { img.Width = 45; img.Height = 45; img.Source = ResourceMgr.SignimgBgCache[3]; } else if (cs.drumType == DrumType.RightFace || cs.drumType == DrumType.LeftFace) { img.Width = 35; img.Height = 35; img.Source = ResourceMgr.SignimgBgCache[0]; } else { img.Width = 35; img.Height = 35; img.Source = ResourceMgr.SignimgBgCache[2]; } //img.Visibility = System.Windows.Visibility.Collapsed; //TranslateTransform ttf = new TranslateTransform(); //ttf.X = 0; ttf.Y = 0; //img.RenderTransform = new TranslateTransform(); img.RenderTransform = null; img.Effect = null; img.CacheMode = new BitmapCache(); if (cs.drumType == DrumType.RightFace || cs.drumType == DrumType.LeftFace || cs.drumType == DrumType.RightSide || cs.drumType == DrumType.LeftSide) { Canvas.SetLeft(img, signLeftLocation); Canvas.SetTop(img, 33); } else { Canvas.SetLeft(img, signLeftLocation); Canvas.SetTop(img, 28); } cs.currentSign = img; CadenceSigns[i] = cs; i++; } //添入显示控件 foreach (CadenceSign cs in CadenceSigns) { LayoutRoot.Children.Add(cs.currentSign); } AddLastBecloud(); firstlongTime = CadenceSigns[0].DelayTimeMill; signCount = CadenceSigns.Length; }