Exemple #1
0
        private void UpdateSpace(object sender = null, EventArgs e = null)
        {
            if (Type == FileItemType.Computer)
            {
                int count = children.Count;
                for (int i = 0; i < count; i++)
                {
                    if (children[i] is RootItem root)
                    {
                        root.UpdateSpace(sender, e);
                    }
                }
            }

            // ShowTotalSpace means only the absolute root will show space
            // !ShowTotalSpace means only the file root will show space
            // We do this check because absolute roots can also be file roots
            bool baseShow = (IsAbsoluteRootType && scanning.ShowTotalSpace) ||
                            (IsFileRootType && !scanning.ShowTotalSpace);

            bool showFree    = scanning.ShowFreeSpace && baseShow;
            bool showUnknown = scanning.ShowUnknown && baseShow;

            // Create some children so we can lock things down
            EnsureChildren(2);

            lock (children) {
                if (showFree)
                {
                    FreeSpace.UpdateSize();
                }
                if (showUnknown)
                {
                    Unknown.UpdateSize(GetUsedSize());
                }
                AddOrRemove(FreeSpace, showFree);
                AddOrRemove(Unknown, showUnknown);

                // If nothing was added or removed and children was created,
                // children was never set back to empty.
                EnsureEmptyChildren();

                Invalidate();
            }

            if (IsAbsoluteRootType)
            {
                RootValidate();
            }
        }