private void SetCheckState(int visgroupId, ICollection <MapObject> visItems) { if (visItems.Count > 0) // Only override default checkbox behavior if necessary { var numHidden = visItems.Count(x => x.IsVisgroupHidden); CheckState state; if (numHidden == visItems.Count && numHidden != 0) { state = CheckState.Unchecked; // All hidden } else if (numHidden > 0) { state = CheckState.Indeterminate; // Some hidden } else { state = CheckState.Checked; // None hidden } VisgroupPanel.SetCheckState(visgroupId, state); } else { VisgroupPanel.SetCheckState(visgroupId, CheckState.Indeterminate); } }
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)); }
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; }
private void SetCheckState(int visgroupId, ICollection <MapObject> visItems) { var numHidden = visItems.Count(x => x.IsVisgroupHidden); CheckState state; if (numHidden == visItems.Count) { state = CheckState.Unchecked; // All hidden } else if (numHidden > 0) { state = CheckState.Indeterminate; // Some hidden } else { state = CheckState.Checked; // None hidden } VisgroupPanel.SetCheckState(visgroupId, state); }
private void VisgroupsChanged() { VisgroupPanel.Update(DocumentManager.CurrentDocument); }
private void DocumentAllClosed() { VisgroupPanel.Update(DocumentManager.CurrentDocument); }
public void Clear() { VisgroupPanel.Clear(); }