private void UpdatePropertiesView(params object[] objects) { PropertiesForm.SelectObjects(objects); PropertiesForm.RefreshProperties(); }
void propertiesForm_ContextMenuOpening(ContextMenuStrip contextMenuStrip) { if (PropertiesForm.SelectedGridItem != null && PropertiesForm.SelectedGridItem.Label == "Tags") { List <Entity> entitiesSelected = EntityWorld.Instance.SelectedEntities; var q = entitiesSelected.Select(_entity => { var _tags = _entity.Tags.Select(_tag => new Entity.TagInfo(_tag.Name, _tag.Value)); return(new UndoObjectsPropertyChangeAction.Item(_entity, typeof(Entity).GetProperty("Tags"), _tags)); }); contextMenuStrip.Items.Add(new ToolStripSeparator()); //* string textAddTag = ToolsLocalization.Translate("Various", "Add Tag"); ToolStripMenuItem tsmiAddTag = new ToolStripMenuItem(textAddTag, Properties.Resources.new_16, delegate(object s, EventArgs e2) { EntityAddTagDialog entityAddTagDialog = new EntityAddTagDialog(); if (entityAddTagDialog.ShowDialog() == DialogResult.OK) { UndoSystem.Instance.CommitAction(new UndoObjectsPropertyChangeAction(q.ToArray())); foreach (Entity current in entitiesSelected) { current.SetTag(entityAddTagDialog.TagName, entityAddTagDialog.TagValue); } PropertiesForm.RefreshProperties(); MapWorld.Instance.Modified = true; } }); tsmiAddTag.Enabled = true; contextMenuStrip.Items.Add(tsmiAddTag); List <string> tagsSet = entitiesSelected.SelectMany(_entity => _entity.Tags.Select(_tag => _tag.Name)).Distinct().ToList(); string textRemoveTag = ToolsLocalization.Translate("Various", "Remove Tag"); ToolStripMenuItem tsmiRemoveTag = new ToolStripMenuItem(textRemoveTag, Properties.Resources.delete_16); tsmiRemoveTag.Enabled = (tagsSet.Count != 0); contextMenuStrip.Items.Add(tsmiRemoveTag); foreach (string tag in tagsSet) { ToolStripMenuItem tsmiDeleteTag = new ToolStripMenuItem(tag, Properties.Resources.item_16, delegate(object s, EventArgs e2) { string name = (string)((ToolStripMenuItem)s).Tag; UndoSystem.Instance.CommitAction(new UndoObjectsPropertyChangeAction(q.ToArray())); foreach (Entity current in entitiesSelected) { current.RemoveTag(name); } PropertiesForm.RefreshProperties(); MapWorld.Instance.Modified = true; }); tsmiDeleteTag.Tag = tag; contextMenuStrip.Items.Add(tsmiRemoveTag); tsmiRemoveTag.DropDownItems.Add(tsmiDeleteTag); } } }