Esempio n. 1
0
        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);
            }
        }
Esempio n. 2
0
        public void AddTruncatedCone()
        {
            ModelPart newModel = new ModelPart()
            {
                Name = "Part" + m_counter++, Node = new TruncatedConeNode()
                {
                    TopRadius = 1, BaseRadius = 2, Height = 1, Normal = new Vector3D(0, 1, 0), Fill = new SolidColorBrush(Colors.Blue.ChangeAlpha(0x20))
                }
            };

            if (m_collection.Count > 0)
            {
                ModelPart last = m_collection.Last();
                last.AddChild(newModel);
            }
            else
            {
                m_root.Node.GetModel().Children.Add(newModel.Node.GetModel());
            }

            m_collection.Add(newModel);
        }