コード例 #1
0
        private IAction GetUpdateVisgroupsAction()
        {
            var states = VisgroupPanel.GetAllCheckStates();
            var add    = states.Where(x => x.Value == CheckState.Checked).Select(x => x.Key).ToList();
            var rem    = states.Where(x => x.Value == CheckState.Unchecked).Select(x => x.Key).ToList();

            // If all the objects are in the add groups and none are in the remove groups, nothing needs to be changed
            if (Objects.All(x => add.All(y => x.IsInVisgroup(y, false)) && !rem.Any(y => x.IsInVisgroup(y, false))))
            {
                return(null);
            }
            return(new EditObjectVisgroups(Objects, add, rem));
        }
コード例 #2
0
        private void UpdateVisgroups(bool retainCheckStates)
        {
            _populating = true;

            var visgroups = Document.Map.Visgroups.Select(x => x.Clone()).ToList();

            Action <Visgroup> setVisible = null;

            setVisible = x =>
            {
                x.Visible = false;
                x.Children.ForEach(y => setVisible(y));
            };
            visgroups.ForEach(x => setVisible(x));

            Dictionary <int, CheckState> states;

            if (retainCheckStates)
            {
                states = VisgroupPanel.GetAllCheckStates();
            }
            else
            {
                states = Objects.SelectMany(x => x.Visgroups)
                         .GroupBy(x => x)
                         .Select(x => new { ID = x.Key, Count = x.Count() })
                         .Where(g => g.Count > 0)
                         .ToDictionary(g => g.ID, g => g.Count == Objects.Count
                                                      ? CheckState.Checked
                                                      : CheckState.Indeterminate);
            }

            VisgroupPanel.Update(visgroups);

            foreach (var kv in states)
            {
                VisgroupPanel.SetCheckState(kv.Key, kv.Value);
            }

            VisgroupPanel.ExpandAllNodes();

            _populating = false;
        }