private IEnumerable <IMapObject> GetVisgroupObjects(VisgroupItem item) { if (item?.Tag is Primitives.MapData.Visgroup v) { return(v.Objects); } if (item?.Tag is AutomaticVisgroup av) { return(av.Objects); } var children = VisgroupPanel.GetAllItems().Where(x => x.Parent == item).SelectMany(GetVisgroupObjects); return(new HashSet <IMapObject>(children)); }
private void SelectionChanged(object sender, VisgroupItem visgroupItem) { ColourPanel.Enabled = RemoveButton.Enabled = GroupName.Enabled = visgroupItem != null; ColourPanel.BackColor = SystemColors.Control; if (visgroupItem != null) { var visgroup = (Vg)visgroupItem.Tag; GroupName.Text = visgroup.Name; ColourPanel.BackColor = visgroup.Colour; ColourPanel.ForeColor = visgroup.Colour.GetIdealForegroundColour(); } else { GroupName.Text = ""; } }
private void VisgroupToggled(object sender, VisgroupItem visgroup, CheckState state) { if (state == CheckState.Indeterminate) { return; } var visible = state == CheckState.Checked; var objects = GetVisgroupObjects(visgroup).SelectMany(x => x.FindAll()).ToList(); if (objects.Any() && _activeDocument.TryGetTarget(out MapDocument md)) { MapDocumentOperation.Perform(md, new TrivialOperation( d => objects.ForEach(x => x.Data.Replace(new VisgroupHidden(!visible))), c => c.AddRange(objects) )); } }
private void VisgroupSelected(object sender, VisgroupItem visgroup) { }
private List <VisgroupItem> GetItemHierarchies(MapDocument document) { var list = new List <VisgroupItem>(); // add user visgroups var visgroups = document.Map.Data.Get <Primitives.MapData.Visgroup>().ToList(); foreach (var v in visgroups) { list.Add(new VisgroupItem(v.Name) { CheckState = GetVisibilityCheckState(v.Objects), Colour = v.Colour, Tag = v }); } var auto = new VisgroupItem(AutoVisgroups) { Disabled = true }; list.Insert(0, auto); // add auto visgroups var autoVisgroups = document.Map.Data.Get <AutomaticVisgroup>().ToList(); var parents = new Dictionary <string, VisgroupItem> { { "", auto } }; foreach (var av in autoVisgroups.OrderBy(x => x.Path.Length)) { VisgroupItem parent = auto; if (!parents.ContainsKey(av.Path)) { var path = new List <string>(); foreach (var spl in av.Path.Split('/')) { path.Add(spl); var seg = String.Join("/", path); if (!parents.ContainsKey(seg)) { var group = new VisgroupItem(_translation.GetString(spl)) { Parent = parent, Disabled = true }; list.Add(group); parents[seg] = group; } parent = parents[seg]; } } else { parent = parents[av.Path]; } list.Add(new VisgroupItem(_translation.GetString(av.Key)) { CheckState = GetVisibilityCheckState(av.Objects), Tag = av, Parent = parent }); } for (var i = list.Count - 1; i >= 0; i--) { var v = list[i]; if (v.Tag != null) { continue; } var children = list.Where(x => x.Parent == v).ToList(); if (children.All(x => x.CheckState == CheckState.Checked)) { v.CheckState = CheckState.Checked; } else if (children.All(x => x.CheckState == CheckState.Unchecked)) { v.CheckState = CheckState.Unchecked; } else { v.CheckState = CheckState.Indeterminate; } } return(list); }
private void OnVisgroupSelected(VisgroupItem visgroup) { VisgroupSelected?.Invoke(this, visgroup); }
private void OnVisgroupToggled(VisgroupItem visgroup, CheckState state) { VisgroupToggled?.Invoke(this, visgroup, state); }