Esempio n. 1
0
        protected override void OnDrawItem(DrawItemEventArgs e)
        {
            base.OnDrawItem(e);

            if (Items.Count > 0)
            {
                FileBoxItem item = (FileBoxItem)Items[e.Index];

                if (!item.IsImageLoaded)
                {
                    OnDemandImageLoadStack.Push(e);
                    ImageLoadTimer.Enabled = true;
                }

                item.DrawItem(e, this);
            }
        }
Esempio n. 2
0
        private void LoadImage(object sender, ElapsedEventArgs e)
        {
            if (OnDemandImageLoadStack.Count == 0)
            {
                ImageLoadTimer.Enabled = false;
                return;
            }

            try {
                DrawItemEventArgs itemEventArgs = OnDemandImageLoadStack.Pop();
                int         index = itemEventArgs.Index;
                FileBoxItem item  = (FileBoxItem)Items[index];
                item.LoadImage(ImageSize.Width, ImageSize.Height);

                int numVisibleItems = ClientSize.Height / ItemHeight;
                int nextIndex       = -1;
                if (OnDemandImageLoadStack.Count > 0)
                {
                    try {
                        nextIndex = OnDemandImageLoadStack.Peek().Index;
                    } catch (NullReferenceException) {
                        // Null event args
                    }
                }
                this.InvokeSafe(() => {
                    // Refresh only if we aren't going to have to refresh after the next item as well
                    if ((index >= TopIndex && index <= TopIndex + numVisibleItems) &&
                        !(nextIndex >= TopIndex && nextIndex <= TopIndex + numVisibleItems))
                    {
                        Refresh();
                    }
                });
            } catch (ArgumentOutOfRangeException) {
                // ignored
            }
        }
Esempio n. 3
0
 protected bool Equals(FileBoxItem other)
 {
     return(string.Equals(DirectoryName, other.DirectoryName, StringComparison.OrdinalIgnoreCase) &&
            string.Equals(FileName, other.FileName, StringComparison.OrdinalIgnoreCase));
 }