protected override void OnMouseMove(MouseEventArgs e) { base.OnMouseMove(e); if (!Enable) { if (ellipseBarRect.Contains(e.Location) && !_isEllipeBarDown) { _isEllipeBarHover = true; } else if (!ellipseBarRect.Contains(e.Location)) { ThreadPool.QueueUserWorkItem(new WaitCallback(delegate(object obj) { if (topInfoRect.Contains(e.Location)) { foreach (SmallButton item in _buttons) { if (item.ButtonRect.Contains(e.Location)) { this.Invoke(new MethodInvoker(delegate() { this.Cursor = Cursors.Hand; })); item.DownState = DownState.Hover; _hoverButton = item; base.Invalidate(item.ButtonRect); return; } else if (_hoverButton != null && !_hoverButton.ButtonRect.Contains(e.Location)) { _hoverButton = null; this.Invoke(new MethodInvoker(delegate() { this.Cursor = Cursors.Default; })); } } } else { this.Invoke(new MethodInvoker(delegate() { this.Cursor = Cursors.Default; })); _hoverButton = null; for (int i = 0; i < Items.Count; i++) { MusicEntity item = Items[i]; if (item.Rect.Contains(e.Location)) { _hoverEntity = item; base.Invalidate(item.Rect); return; } } } })); } else { _isEllipeBarHover = false; } if (_isEllipeBarDown) { int y = e.Y - jY; if (y < topInfoRect.Y + topInfoRect.Height + 2) y = topInfoRect.Y + topInfoRect.Height + 2; if (y > this.Height - ellipseBarRect.Height - 1) y = this.Height - ellipseBarRect.Height - 1; ellipseBarRect = new Rectangle( ellipseBarRect.X, y, ellipseBarRect.Width, ellipseBarRect.Height); } base.Invalidate(); } }
protected override void OnMouseDown(MouseEventArgs e) { base.OnMouseDown(e); if (ellipseBarRect.Contains(e.Location)) { _isEllipeBarHover = false; _isEllipeBarDown = true; jY = e.Y - ellipseBarRect.Y; } else if (_hoverEntity != null && _hoverEntity.Rect.Contains(e.Location)) { _downEntity = _hoverEntity; } else { _isEllipeBarDown = false; } if (_hoverButton != null && _hoverButton.ButtonRect.Contains(e.Location)) { _hoverButton.IsDown = true; } base.Invalidate(); }
protected override void OnMouseLeave(EventArgs e) { base.OnMouseLeave(e); _isEllipeBarDown = false; _isEllipeBarHover = false; _hoverEntity = null; _hoverButton = null; base.Invalidate(); }
public void Add(MusicEntity entity) { Items.Add(entity); int height = (gBarRect.Height / _itemHeight) * gBarRect.Height / Items.Count; ellipseBarRect = new Rectangle( ellipseBarRect.X, ellipseBarRect.Y, ellipseBarRect.Width, height); base.Invalidate(); }
private void ProcessingItems(object index) { plearList.Clear(); PublicInterFace.LogErro("处理数据.."); HttpWebRequest request = WebRequest.Create("http://www.songtaste.com/music/" + index.ToString()) as HttpWebRequest; StreamReader responseStream = new StreamReader(request.GetResponse().GetResponseStream(), Encoding.GetEncoding("GB2312")); string str = responseStream.ReadToEnd(); PublicInterFace.LogErro("得到返回处理.."); MatchCollection items = Regex.Matches(str, @"(?<=MSL\().*(?=\);)"); PublicInterFace.LogErro("循环列表项.."); foreach (Match item in items) { string rItem = item.Value.Replace(@"""", ""); rItem = rItem.Replace(", ", "\t"); string[] strs = rItem.Split('\t'); MusicEntity entity = new MusicEntity(); entity.MusicName = strs[0]; entity.MusicId = strs[1]; entity.SharePeople = strs[2]; plearList.Invoke(new MethodInvoker(delegate() { plearList.Add(entity); })); } PublicInterFace.LogErro("添加完毕.."); }
private void decodeMusicEntity(MusicEntity entity) { if (entity.MusicPath == null) { System.Threading.Thread thread = new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(DecodeMusicEntity)); thread.IsBackground = true; thread.Start(entity); } }
private void decode(MusicEntity entity) { PublicInterFace.LogErro("启动线程解码"); System.Threading.Thread thread = new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Decode)); thread.IsBackground = true; thread.Start(entity); plearList.Enable = true; }
public void playerList1_OnItemDoubleClick(object sender, MusicEntity entity) { PublicInterFace.LogErro("触发双击事件"); decode(entity); }