public static void RemoveAll(this Visual3DCollection collection, IEnumerable <Visual3D> visuals) { foreach (Visual3D visual in visuals) { collection.Remove(visual); } }
public void DeletePart(int a_index) { if (a_index < m_collection.Count && a_index >= 0) { ModelPart needDel = m_collection[a_index]; MeshElement3D modelDel = needDel.Node.GetModel(); var parent = VisualTreeHelper.GetParent(modelDel); var pip = parent.GetType().GetProperty("Children", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public); Visual3DCollection parentChildren = pip.GetValue(parent, null) as Visual3DCollection; parentChildren.Remove(modelDel); if (modelDel.Children.Count != 0) { modelDel.Children.Clear(); int index = m_collection.IndexOf(needDel); if (index > 0) { ModelPart parentModelPart = m_collection.ElementAt(index - 1); parentModelPart.AddChild(m_collection.ElementAt(index + 1)); } else { m_root.AddChild(m_collection.ElementAt(index + 1)); } } m_collection.Remove(needDel); } }