Exemplo n.º 1
0
        /// <summary>
        /// Selects the label.
        /// </summary>
        /// <param name="li">The li.</param>
        private void SelectLabel(UCListItemExt li)
        {
            try
            {
                Wells.WellsMetroControl.ControlHelper.FreezeControl(this, true);
                this.FindForm().ActiveControl = this;
                if (_current != null)
                {
                    if (_current == li && !_selectedCanClick)
                    {
                        return;
                    }
                    _current.ItemBackColor  = _itemBackColor;
                    _current.ItemForeColor  = _itemForeColor;
                    _current.ItemForeColor2 = _itemForeColor2;
                }
                li.ItemBackColor  = _itemSelectedBackColor;
                li.ItemForeColor  = _itemSelectedForeColor;
                li.ItemForeColor2 = _itemSelectedForeColor2;

                _current = li;
                if (ItemClick != null)
                {
                    ItemClick(li);
                }
            }
            finally
            {
                Wells.WellsMetroControl.ControlHelper.FreezeControl(this, false);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Sets the list.
        /// </summary>
        /// <param name="lst">The LST.</param>
        public void SetList(List <ListEntity> lst)
        {
            try
            {
                ControlHelper.FreezeControl(this, true);
                this.Controls.Clear();
                this.SuspendLayout();
                UCListItemExt _first = null;
                for (int i = lst.Count - 1; i >= 0; i--)
                {
                    var           item = lst[i];
                    UCListItemExt li   = new UCListItemExt();
                    li.SplitColor     = splitColor;
                    li.Height         = _itemHeight;
                    li.TitleFont      = _titleFont;
                    li.Title2Font     = _title2Font;
                    li.ItemBackColor  = _itemBackColor;
                    li.ItemForeColor  = _itemForeColor;
                    li.ItemForeColor2 = _itemForeColor2;
                    li.Dock           = DockStyle.Top;
                    li.SetData(item);
                    li.ItemClick += (s, e) => { SelectLabel((UCListItemExt)s); };
                    this.Controls.Add(li);
                    _first = li;
                }
                if (_autoSelectFirst)
                {
                    SelectLabel(_first);
                }
                this.ResumeLayout(false);

                Timer timer = new Timer();
                timer.Interval = 10;
                timer.Tick    += (a, b) =>
                {
                    timer.Enabled             = false;
                    this.VerticalScroll.Value = 1;
                    this.VerticalScroll.Value = 0;
                    this.Refresh();
                };
                timer.Enabled = true;
            }
            finally
            {
                ControlHelper.FreezeControl(this, false);
            }
        }