public void UpdateVisualState(VisualState newVisualState = null)
        {
            var seeAllVersionsOld = visualState?.seeAllVersions ?? false;
            var selectedVersionIdOld = visualState?.selectedVersionId ?? string.Empty;

            visualState = newVisualState?.Clone() ?? visualState ?? new VisualState(package?.uniqueId);

            if (UIUtils.IsElementVisible(this) != visualState.visible)
                UIUtils.SetElementDisplay(this, visualState.visible);

            if (selectedVersion != null && visualState != null && selectedVersion != targetVersion)
            {
                var keyVersions = package.versions.key.Where(p => p != package.versions.primary);
                var allVersions = package.versions.Where(p => p != package.versions.primary);

                visualState.expanded = visualState.expanded || allVersions.Contains(selectedVersion);
                visualState.seeAllVersions = visualState.seeAllVersions || !keyVersions.Contains(selectedVersion);
            }

            var expansionChanged = UIUtils.IsElementVisible(versionsContainer) != visualState.expanded;
            if (expansionChanged)
                UpdateExpanderUI(visualState.expanded);

            if (expansionChanged || seeAllVersionsOld != visualState.seeAllVersions)
                RefreshVersions();

            if (selectedVersionIdOld != visualState.selectedVersionId)
                RefreshSelection();
        }
Пример #2
0
        public void UpdateVisualState(VisualState newVisualState = null)
        {
            var seeAllVersionsOld    = visualState?.seeAllVersions ?? false;
            var selectedVersionIdOld = visualState?.selectedVersionId ?? string.Empty;

            visualState = newVisualState?.Clone() ?? visualState ?? new VisualState(package?.uniqueId);

            if (UIUtils.IsElementVisible(this) != visualState.visible)
            {
                UIUtils.SetElementDisplay(this, visualState.visible);
            }

            var expansionChanged = expander.expanded != visualState.expanded;

            if (expansionChanged)
            {
                UpdateExpanderUI(visualState.expanded);
            }

            if (expansionChanged || seeAllVersionsOld != visualState.seeAllVersions)
            {
                RefreshVersions();
            }

            if (selectedVersionIdOld != visualState.selectedVersionId)
            {
                RefreshSelection();
            }
        }