// Override me virtual public void GenerateTriangles() { foreach (object o in ShapeCollection.Shapes) { if (o is LfPolygonViewModel) { LfPolygonViewModel pvm = (LfPolygonViewModel)o; pvm.GenerateTriangles(); } } }
public LfDragablePointViewModel( TreeViewViewModel treeParent, CompoundObjectViewModel parentVm, MainViewModel mainVm, LfPolygonViewModel parent, LfDragablePoint modelObject, bool enabled = true) : base(treeParent, parentVm, mainVm, enabled) { MainVm = mainVm; Parent = parent; ModelObject = modelObject; IsSelected = false; }
public void DeselectAllChildren() { if ((Behaviour != null) && (Behaviour.BehaviourProperties != null)) { Behaviour.BehaviourProperties.IsSelected = false; } if ((StateShapes != null) && (StateShapes.Shapes != null)) { foreach (object o in StateShapes.Shapes) { if (o is LfPolygonViewModel) { LfPolygonViewModel pvm = o as LfPolygonViewModel; pvm.DeselectAllPoints(); pvm.IsSelected = false; } else if (o is LfShapeViewModel) { LfShapeViewModel shape = o as LfShapeViewModel; shape.IsSelected = false; } } } if (StateJoints != null) { foreach (object o in StateJoints.Joints) { if (o is WeldJointViewModel) { WeldJointViewModel joint = (WeldJointViewModel)o; joint.IsSelected = false; } } } if (ChildObjectsWithStates != null) { foreach (ChildObjectViewModel child in ChildObjectsWithStates.Children) { child.DeselectAllChildren(); child.IsSelected = false; } } }
public LfDragablePointViewModel AddPoint(LfPolygonViewModel polyVm, Point position) { LfPolygonViewModel newPolygon = polyVm; Point parentObjectOrigo = new Point(newPolygon.ParentVm.PosX, newPolygon.ParentVm.PosY); Point shapeOrigo = new Point(newPolygon.PosX, newPolygon.PosY); shapeOrigo.Offset(parentObjectOrigo.X, parentObjectOrigo.Y); Point localClickPoint = new Point(); localClickPoint = (Point)(position - shapeOrigo); LfDragablePointViewModel newPoint = newPolygon.AddPoint(localClickPoint); return(newPoint); }
public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture) { if (values.Count() == 3) { if ((values[0] is double) && (values[1] is LfDragablePointViewModel) && (values[2] is TriangleViewModel)) { LfDragablePointViewModel origVertex = (LfDragablePointViewModel)values[1]; LfPolygonViewModel polygon = origVertex.Parent; TriangleViewModel tvm = (TriangleViewModel)values[2]; int i = tvm.PointVms.IndexOf(origVertex); if (i == -1) { return(null); } LfDragablePointViewModel vertex; if (i > 0) { vertex = tvm.PointVms[i - 1]; } else { vertex = tvm.PointVms[tvm.PointVms.Count() - 1]; } Point p = new Point(vertex.PosX, vertex.PosY); Point rp = polygon.RotatedPointFromLocal(p); if (parameter as string == "x") { return(rp.X); } else { return(rp.Y); } } } return(null); }
public void GenerateTriangles() { foreach (object o in StateShapes.Shapes) { if (o is LfPolygonViewModel) { LfPolygonViewModel pvm = (LfPolygonViewModel)o; pvm.GenerateTriangles(); } } foreach (ChildObjectViewModel covm in ChildObjectsWithStates.Children) { foreach (ChildCOViewModel propvm in covm.StateProperties) { propvm.GenerateTriangles(); } } }
virtual public void DeselectAllChildren() { if ((ShapeCollection != null) && (ShapeCollection.Shapes != null)) { foreach (object o in ShapeCollection.Shapes) { if (o is LfPolygonViewModel) { LfPolygonViewModel pvm = o as LfPolygonViewModel; pvm.DeselectAllPoints(); pvm.IsSelected = false; } else if (o is LfShapeViewModel) { LfShapeViewModel shape = o as LfShapeViewModel; shape.IsSelected = false; } } } }
public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture) { // Values should be: PosX, PosY, Angle and either a LfDragablePointViewModel // or a LfPointViewModel with its parent a IBoxPointsInterface. // Parameter is "x" or "y", returns rotated point x or y value, depending on parameter. // PosX and PosY is not really used, but they will force an update if they are // changed if (values.Count() == 4) { if ((values[0] is double) && (values[1] is double) && (values[2] is double)) { Point p = new Point(0, 0); double angle = (double)values[2]; if (values[3] is LfDragablePointViewModel) { LfDragablePointViewModel vertex; LfDragablePointViewModel origVertex = (LfDragablePointViewModel)values[3]; LfPolygonViewModel polygon = origVertex.Parent; // Resolve the previous point, it is index - 1 // except if index == 0, in which case it is // count - 1 int i = polygon.PointVms.IndexOf(origVertex); if (i == -1) { return(null); } if (i > 0) { vertex = polygon.PointVms[i - 1]; } else { vertex = polygon.PointVms[polygon.PointVms.Count() - 1]; } p = new Point(vertex.PosX, vertex.PosY); } else if (values[3] is LfPointViewModel) { LfPointViewModel vertex; LfPointViewModel origVertex = (LfPointViewModel)values[3]; IBoxPointsInterface boxVm = origVertex.PointsParent; int i = boxVm.PointVms.IndexOf(origVertex); if (i == -1) { return(null); } if (i > 0) { vertex = boxVm.PointVms[i - 1]; } else { vertex = boxVm.PointVms[boxVm.PointVms.Count() - 1]; } p = new Point(vertex.PosX, vertex.PosY); } else { return(null); } Point rp = CoordinateTransformations.RotatedPointFromLocal(p, angle); if (parameter as string == "x") { return(rp.X); } return(rp.Y); } } return(null); }
public TriangleViewModel(LfPolygonViewModel parent, Triangle modelObject) { Parent = parent; ModelObject = modelObject; BuildPoints(); }