private MeshElement3D _Lier([NotNull] MeshElement3D forme, [NotNull] FormeWrapper source) { var fill = new Binding($"{ nameof(source.Materiau) }.{ nameof(source.Materiau.Fill) }") { Source = source, Mode = BindingMode.OneWay }; var transform = new MultiBinding() { Converter = TransformConverter, Mode = BindingMode.TwoWay }; transform.Bindings.AddRange(new Binding[] { new Binding(nameof(source.Origine)) { Source = source, Mode = BindingMode.TwoWay }, new Binding(nameof(source.Rotation)) { Source = source, Mode = BindingMode.TwoWay } }); BindingOperations.SetBinding(forme, MeshElement3D.TransformProperty, transform); BindingOperations.SetBinding(forme, MeshElement3D.FillProperty, fill); return(forme); }
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); } }
public void CreateRack(string gr, string type, MouseButtonEventArgs e, double centerz, double centery) { PipeVisual3D pipe = new PipeVisual3D(); pipe.Diameter = 1; pipe.Point1 = new Point3D(0, 0, 0); pipe.Point2 = new Point3D(1, 0, 0); MeshElement3D tpipe = pipe as MeshElement3D; tpipe.Model.Material = Materials.White; ImageBrush texture = new ImageBrush(new BitmapImage(new Uri(@"Images//Задняя стена белый.jpg", UriKind.Relative))); tpipe.Model.Material = new DiffuseMaterial(texture); ModelUIElement3D modelUI = new ModelUIElement3D(); modelUI.MouseUp += win.ClickOnModel; modelUI.Model = tpipe.Model; ElementCabinet tempmodel = new ElementCabinet(modelUI, 0, 0, 0, 0, 0, 0); tempmodel.groupel = gr; tempmodel.ingroupel = "Rack"; tempmodel.objgr = "S"; tempmodel.thickness = 0.015; tempmodel.select = win.CreatedElements[win.selectedobject.GetHashCode()] as ElementCabinet; if (win.twoselectedobject != null) { tempmodel.twoselect = win.CreatedElements[win.twoselectedobject.GetHashCode()] as ElementCabinet; } if (type == "L") { tempmodel.napr = 1; } if (type == "R") { tempmodel.napr = -1; } tempmodel.hashtable = win.CreatedElements; tempmodel.center = centerz - tempmodel.select.AxisZ; tempmodel.centery = centery - tempmodel.select.AxisY; tempmodel.changeTexture(win.soureseDefault, win.iddefault); _3DObject tempmodel1 = win.CreatedElements[win.selectedobject.GetHashCode()] as _3DObject; Transform3DGroup group3d = tempmodel1.thismodel.Transform as Transform3DGroup; ScaleTransform3D tln = group3d.Children.OfType <ScaleTransform3D>().FirstOrDefault(); tempmodel.changeObject(0, tln.ScaleY, 0, 0, 0, 0); win.CreatedElements.Add(modelUI.GetHashCode(), tempmodel); win.container.Children.Add(modelUI); win.ClickOnCamera(modelUI, e as MouseButtonEventArgs); win.ClickOnModel(modelUI, e); }
public void CreateRackEl(string groupel, string ingroupel, string objgr, double AxisX, double AxisY, double AxisZ, double LenX, double LenY, double LenZ, double thickness, ModelUIElement3D thisobject1, ModelUIElement3D thisobject2, int napr, double center, double centery, ArrayList conttemp, string text = "-1", int id = -1) { if (text == "-1") { text = win.soureseDefault; } if (id == -1) { id = win.iddefault; } PipeVisual3D pipe = new PipeVisual3D(); pipe.Diameter = 1; pipe.Point1 = new Point3D(0, 0, 0); pipe.Point2 = new Point3D(1, 0, 0); MeshElement3D tpipe = pipe as MeshElement3D; tpipe.Model.Material = Materials.White; ImageBrush texture = new ImageBrush(new BitmapImage(new Uri(text, UriKind.Relative))); tpipe.Model.Material = new DiffuseMaterial(texture); ModelUIElement3D modelUI = new ModelUIElement3D(); modelUI.MouseUp += win.ClickOnModel; modelUI.Model = tpipe.Model; ElementCabinet tempmodel = new ElementCabinet(modelUI, 0, 0, 0, 0, 0, 0); tempmodel.groupel = groupel; tempmodel.ingroupel = ingroupel; tempmodel.objgr = objgr; tempmodel.thickness = thickness; tempmodel.select = win.CreatedElements[thisobject1.GetHashCode()] as ElementCabinet; tempmodel.twoselect = win.CreatedElements[thisobject2.GetHashCode()] as ElementCabinet; tempmodel.napr = -1; tempmodel.hashtable = win.CreatedElements; tempmodel.center = center; tempmodel.centery = centery; tempmodel.changeObject(LenX, LenY, LenZ, AxisX, AxisY, AxisZ); win.CreatedElements.Add(modelUI.GetHashCode(), tempmodel); win.container.Children.Add(modelUI); conttemp.Add(modelUI); tempmodel.changeTexture(text, id); }
public MeshElement3D Lier([NotNull] MeshElement3D forme, [NotNull] FormeWrapper source) { switch (forme) { case TruncatedConeVisual3D cone: return(Lier(cone, (ConeWrapper)source)); case CylinderVisual3D cylinder: return(Lier(cylinder, (CylindreWrapper)source)); case EllipsoidVisual3D ellipsoide: return(Lier(ellipsoide, (EllipsoideWrapper)source)); case BoxVisual3D prisme: return(Lier(prisme, (PrismeRectangulaireWrapper)source)); default: throw new ArgumentException(Resources.UnknownChild(nameof(MeshElement3D)), nameof(forme)); } }
public FormeWrapper Convertir([NotNull] MeshElement3D mesh) => (FormeWrapper)BindingOperations.GetMultiBinding(mesh, ModelVisual3D.TransformProperty)?.Bindings?.OfType <Binding>()?.First()?.Source;