public TopTen(MainWnd mainWnd, Int32 delayInterval) { m_WaitDelaySec = delayInterval; //m_Items = new TopTenCollection(this); m_MainWnd = mainWnd; m_ItemsStringFormat = new StringFormat(StringFormatFlags.NoWrap); m_ItemsStringFormat.Alignment = StringAlignment.Near; m_ItemsStringFormat.LineAlignment = StringAlignment.Near; m_ItemsStringFormat.Trimming = StringTrimming.EllipsisCharacter; mainWnd.pbTopTen.Paint += new PaintEventHandler(pbTopTen_Paint); mainWnd.pbTopTen.MouseDown += delegate { m_Delay.Start(); }; mainWnd.pbTopTen.MouseUp += delegate { if (m_Delay.Enabled) { m_Delay.Stop(); } }; m_Delay.Interval = Convert.ToInt32(TimeSpan.FromSeconds(m_WaitDelaySec).TotalMilliseconds); m_Delay.Tick += delegate { m_Delay.Stop(); if (Delay != null) { Delay(this, EventArgs.Empty); } }; }
public PriceList(MainWnd mainWnd) { m_Parent = mainWnd; m_Parent.pbPriceList.Paint += new System.Windows.Forms.PaintEventHandler(pbPriceList_Paint); m_Parent.pbPriceList.MouseDown += new MouseEventHandler(pbPriceList_MouseDown); }
public PlayList(MainWnd mainWnd) { m_Parent = mainWnd; m_ItemsStringFormat = new StringFormat(StringFormatFlags.NoWrap); m_ItemsStringFormat.Trimming = StringTrimming.EllipsisCharacter; PlayManager.Instance.ItemsCountChanged += delegate { //Index adjust Int32 itemsWithoutTopLength = PlayManager.Instance.GetItemsWithoutTop().Length; if (itemsWithoutTopLength < m_ScrollableItemsCount) { m_nOffset = 0; } else { if (m_nOffset + m_ScrollableItemsCount > itemsWithoutTopLength) { m_nOffset = itemsWithoutTopLength - m_ScrollableItemsCount; } } m_Parent.pbPlayListItems.Invalidate(); m_Parent.pbPlayListScrollBar.Invalidate(); m_Parent.pbTitles.Invalidate(); }; PlayManager.Instance.PlayState += delegate(Object sender, Main.PlayManager.PlayStateEventArgs e) { try { m_Parent.progressBarPlayList.BeginInvoke(new InvokeUIDel( delegate() { m_Parent.progressBarPlayList.Value = e.State; })); } catch (Exception em) { Debug.WriteLine("Progress Exception" + em.Message); } }; new ScrollWrapper(m_Parent.pbPlayListTopScrollBtn, m_Parent.pbPlayListBottomScrollBtn, imgSTopPress, imgSBottomPress, 1, 60, new ScrollDel( delegate(Int32 nPos) { if (PlayManager.Instance.GetItemsWithoutTop().Length > m_ScrollableItemsCount) { if (nPos + m_nOffset >= 0 && nPos + m_nOffset + m_ScrollableItemsCount <= PlayManager.Instance.GetItemsWithoutTop().Length) { m_nOffset += nPos; m_Parent.pbPlayListItems.Invalidate(); m_Parent.pbPlayListScrollBar.Invalidate(); } } })); m_Parent.pbPlayListScrollBar.Paint += delegate(Object sender, PaintEventArgs pe) { PictureBox pbTemp = (PictureBox)sender; Int32 nScrollerHeight = 20; Single nYScrollOffset = 0; FileNameAndDemo[] itemsWithoutTop = PlayManager.Instance.GetItemsWithoutTop(); if (itemsWithoutTop.Length > m_ScrollableItemsCount) { Int32 nScrollArea = pbTemp.Height - nScrollerHeight; Int32 nRestElements = (itemsWithoutTop.Length) - m_ScrollableItemsCount; Single nScrollStep = (Single)nScrollArea / (Single)nRestElements; nYScrollOffset = nScrollStep * m_nOffset; } pe.Graphics.FillRectangle(Brushes.Red, new RectangleF(pbTemp.Width / 2 - 4, nYScrollOffset, 10, nScrollerHeight)); }; m_Parent.pbPlayListItems.Paint += new PaintEventHandler(pbItems_Paint); m_Parent.pbTitles.Paint += new PaintEventHandler(pbTitles_Paint); }