Exemplo n.º 1
0
        public Rectangle GetItemBounds(TimelineListItem item)
        {
            int bound_left  = 0;
            int bound_width = Width;

            if (m_Scrollbar.Visible)
            {
                bound_left  = m_Scrollbar.Width;
                bound_width = Width - m_Scrollbar.Width;
            }
            for (int i = 0; i < m_VisibleItems.Count; ++i)
            {
                if (m_VisibleItems[i] != item)
                {
                    continue;
                }
                Rectangle itemBounds = new Rectangle();
                itemBounds.X      = bound_left;
                itemBounds.Y      = i * m_ItemHeight;
                itemBounds.Width  = bound_width - 1;
                itemBounds.Height = m_ItemHeight;
                return(itemBounds);
            }
            return(new Rectangle(0, 0, 0, 0));
        }
Exemplo n.º 2
0
        //----------------------------------------------------------------------------------------
        public void ShowItem(TimelineStreams item)
        {
            for (int i = 0; i < item.GetStreamCount(); ++i)
            {
                TimelineListItem li = new TimelineListItem();
                li.Streams     = item;
                li.StreamIndex = i;
                m_Items.Add(li);
            }
            int visible_count = Height / m_ItemHeight;

            if (visible_count < m_Items.Count)
            {
                m_Scrollbar.Enabled = true;
                m_Scrollbar.Minimum = 0;
                m_Scrollbar.Maximum = m_Items.Count - visible_count - 1;
                m_Scrollbar.Visible = true;
                m_Scrollbar.Maximum = m_Scrollbar.Maximum + m_Scrollbar.LargeChange;
            }
            else
            {
                m_Scrollbar.Enabled = false;
                m_Scrollbar.Visible = false;
            }
            UpdateVisibleList();
        }
Exemplo n.º 3
0
 public void Clear()
 {
     m_Items.Clear();
     m_Scrollbar.Enabled = false;
     m_Scrollbar.Visible = false;
     m_VisibleItems.Clear();
     m_SelectedItem = null;
     Invalidate();
 }
Exemplo n.º 4
0
        protected override void OnMouseDown(MouseEventArgs e)
        {
            base.OnMouseDown(e);
            TimelineListItem item = GetItemInPosition(e.X, e.Y);

            if (item != null)
            {
                Rectangle itemBound = GetItemBounds(item);
                //如果是按在色彩方块中,则修改相应的色彩方块,否则选中当前项目
                Rectangle rect = new Rectangle(itemBound.Right - 20, itemBound.Top + (m_ItemHeight - 10) / 2, 10, 10);
                if (rect.Contains(e.X, e.Y))
                {
                    item.Streams.SetStreamEnable(item.StreamIndex, !item.Streams.GetStreamEnable(item.StreamIndex));
                    Invalidate(itemBound);
                    return;
                }
                m_SelectedItem = item;
            }
            else
            {
                m_SelectedItem = null;
            }
            Invalidate();
        }