コード例 #1
0
ファイル: ListView.cs プロジェクト: whgfu/ScoreboardUI
        protected override void OnItemsChanged()
        {
            var itemsControls = new List <ListViewItem>();
            var top           = 0;

            if (Template == null)
            {
                new InvalidOperationException("Template is null");
            }
            foreach (var item in Items)
            {
                var itemControls = (ListViewItem)Template.Clone();
                itemControls.Location = new Point()
                {
                    Left = 0, Top = top
                };
                top += ItemHeight;
                itemControls.Position = PositionEnum.RELATIVE;
                itemControls.Parent   = this;
                foreach (var control in itemControls.Controls)
                {
                    ScoreboardContext.CurrentState.AddToControlList(control);
                    control.CompositionLevel = CompositionLevel + 1;
                }
                itemsControls.Add(itemControls);
                ItemDataBound?.Invoke(this, new ItemInformation <TItem> {
                    Item = item, ItemControls = itemControls.Controls.ToArray()
                });
            }
            Clear();
            ItemsControls = itemsControls;
        }
コード例 #2
0
        private void CreateItemTemplateControl(PageData page, int level, bool hasChildren, PageReference currentPageLink)
        {
            PageTemplateContainer template = new PageTemplateContainer(page, level, hasChildren);

            if (level == 1)
            {
                if (page.PageLink.CompareToIgnoreWorkID(currentPageLink) && this.IsExpanded(page.PageLink))
                {
                    this.InstantiateSelectedExpandedTopTemplate(template);
                }
                else if (this.IsExpanded(page.PageLink))
                {
                    this.InstantiateExpandedTopTemplate(template);
                }
                else if (page.PageLink.CompareToIgnoreWorkID(currentPageLink))
                {
                    this.InstantiateSelectedTopTemplate(template);
                }
                else
                {
                    this.InstantiateTopTemplate(template);
                }
            }
            else if (page.PageLink.CompareToIgnoreWorkID(currentPageLink) && this.IsExpanded(page.PageLink))
            {
                this.InstantiateSelectedExpandedItemTemplate(template);
            }
            else if (this.IsExpanded(page.PageLink))
            {
                this.InstantiateExpandedItemTemplate(template);
            }
            else if (page.PageLink.CompareToIgnoreWorkID(currentPageLink))
            {
                this.InstantiateSelectedItemTemplate(template);
            }
            else
            {
                this.InstantiateItemTemplate(template);
            }
            if (ItemDataBound != null)
            {
                var pageTreeEventArgs = new PageTreeEventArgs
                {
                    Item     = template,
                    DataItem = page
                };
                ItemDataBound.Invoke(this, pageTreeEventArgs);
            }
            this.Controls.Add(template);
        }
コード例 #3
0
 protected virtual void OnItemDataBound(TreeListItemDataBoundEventArgs e)
 {
     ItemDataBound?.Invoke(this, e);
 }