in wpf 4.0 project, have observablecollection contain selected visual3d view :
public observablecollection<visual3d> selectedelements { { return _selectedelements; } set { if (equals(_selectedelements, value)) { return; } _selectedelements = value; raisepropertychanged(() => selectedelements); } }
visual3d elements selected clicking , source-code in vm :
public hittestresultbehavior hittestdown(hittestresult result) { var resultmesh = result raymeshgeometry3dhittestresult; if (resultmesh == null) return hittestresultbehavior.continue; // obtain clicked modelvisual3d. var vis = resultmesh.visualhit modelvisual3d; if (vis != null) { type vistype = vis.gettype(); if (vistype.name == "truncatedconevisual3d" || vistype.name == "boxvisual3d") { var geomodel = resultmesh.modelhit geometrymodel3d; if (geomodel != null) { var selectemat = geomodel.material diffusematerial; if (selectemat != null) selectemat.brush.opacity = selectemat.brush.opacity <= 0.7 ? 1 : 0.7; } // otherwise it's chair. transform3dgroup. var xformgrp = vis.transform transform3dgroup; // should not happen, play safe anyway. if (xformgrp == null) { return hittestresultbehavior.stop; } // loop through child tranforms. foreach (transform3d t in xformgrp.children) { // find translatetransform3d. var trans = t translatetransform3d; if (trans != null) { // define animation transform. var anima = new doubleanimation(); if (trans.offsety == 0) { dependencyproperty prop = translatetransform3d.offsetzproperty; if (math.abs(trans.offsetz) < 2) { anima.to = 20.5*math.sign(trans.offsetz); debug.assert(selectedelements != null, "selectedelements != null"); } else { anima.to = 1*math.sign(trans.offsetz); selectedelements.add(vis); } // start animation , stop hit-testing. trans.beginanimation(prop, anima); return hittestresultbehavior.stop; } } } } } return (hittestresultbehavior) hittestfilterbehavior.continue; }
and want delete 1 or visual3d element thank in advance
i have implemented methode it's not work :
private void unloadproduct() { if (canunload) { foreach (visual3d selectedelement in selectedelements) { if (selectedelement.dependencyobjecttype.name == "truncatedconevisual3d") { var test = (truncatedconevisual3d) selectedelement; int id = test.visualid; elementscollection.removeat(id); raisepropertychanged(() => elementscollection); } else { var test = (boxvisual3d) selectedelement; int id = test.visualid; productscollection.removeat(id); } } } }
Comments
Post a Comment