示例#1
0
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            if (value is IWidthHeightInterface)
            {
                IWidthHeightInterface ao = (IWidthHeightInterface)value;

                return(-ao.Height / 2);
            }
            else if (value is LfStaticCircleViewModel)
            {
                LfStaticCircleViewModel ao = (LfStaticCircleViewModel)value;

                return(-ao.Radius);
            }

            return(null);
        }
        private StateShapeCollectionViewModel SetShapes(CompoundObject co, bool enabledChildren = true)
        {
            StateShapeCollectionViewModel shapes = new StateShapeCollectionViewModel(this, this, MainVm, enabledChildren);

            foreach (LfSpriteBox sb in co.SpriteBoxes)
            {
                LfSpriteBoxViewModel shapevm = new LfSpriteBoxViewModel(shapes, this, MainVm, sb, enabledChildren);
                shapes.Shapes.Add(shapevm);
            }

            foreach (LfSpritePolygon sp in co.SpritePolygons)
            {
                LfSpritePolygonViewModel shapevm = new LfSpritePolygonViewModel(shapes, this, MainVm, sp, enabledChildren);

                foreach (LfDragablePoint dragPoint in sp.Points)
                {
                    LfDragablePointViewModel dragPointVm = new LfDragablePointViewModel(shapevm, this, MainVm, shapevm, dragPoint, enabledChildren);
                    shapevm.PointVms.Add(dragPointVm);
                }

                shapes.Shapes.Add(shapevm);
            }

            foreach (LfStaticBox sb in co.StaticBoxes)
            {
                LfStaticBoxViewModel shapevm = new LfStaticBoxViewModel(shapes, this, MainVm, sb, enabledChildren);
                shapes.Shapes.Add(shapevm);
            }

            foreach (LfStaticCircle sb in co.StaticCircles)
            {
                LfStaticCircleViewModel shapevm = new LfStaticCircleViewModel(shapes, this, MainVm, sb, enabledChildren);
                shapes.Shapes.Add(shapevm);
            }

            foreach (LfStaticPolygon sp in co.StaticPolygons)
            {
                LfStaticPolygonViewModel shapevm = new LfStaticPolygonViewModel(shapes, this, MainVm, sp, enabledChildren);

                foreach (LfDragablePoint dragPoint in sp.Points)
                {
                    LfDragablePointViewModel dragPointVm = new LfDragablePointViewModel(shapevm, this, MainVm, shapevm, dragPoint, enabledChildren);
                    shapevm.PointVms.Add(dragPointVm);
                }

                shapes.Shapes.Add(shapevm);
            }

            foreach (LfDynamicBox db in co.DynamicBoxes)
            {
                LfDynamicBoxViewModel shapevm = new LfDynamicBoxViewModel(shapes, this, MainVm, db, enabledChildren);
                shapes.Shapes.Add(shapevm);
            }

            foreach (LfDynamicCircle db in co.DynamicCircles)
            {
                LfDynamicCircleViewModel shapevm = new LfDynamicCircleViewModel(shapes, this, MainVm, db, enabledChildren);
                shapes.Shapes.Add(shapevm);
            }

            foreach (LfDynamicPolygon dp in co.DynamicPolygons)
            {
                LfDynamicPolygonViewModel shapevm = new LfDynamicPolygonViewModel(shapes, this, MainVm, dp, enabledChildren);

                foreach (LfDragablePoint dragPoint in dp.Points)
                {
                    LfDragablePointViewModel dragPointVm = new LfDragablePointViewModel(shapevm, this, MainVm, shapevm, dragPoint, enabledChildren);
                    shapevm.PointVms.Add(dragPointVm);
                }

                shapes.Shapes.Add(shapevm);
            }

            foreach (LfStaticBoxedSpritePolygon bsp in co.StaticBoxedSpritePolygons)
            {
                LfStaticBoxedSpritePolygonViewModel shapevm = new LfStaticBoxedSpritePolygonViewModel(shapes, this, MainVm, bsp, enabledChildren);

                foreach (LfDragablePoint dragPoint in bsp.Points)
                {
                    LfDragablePointViewModel dragPointVm = new LfDragablePointViewModel(shapevm, this, MainVm, shapevm, dragPoint, enabledChildren);
                    shapevm.PointVms.Add(dragPointVm);
                }

                shapes.Shapes.Add(shapevm);
            }

            foreach (LfDynamicBoxedSpritePolygon bsp in co.DynamicBoxedSpritePolygons)
            {
                LfDynamicBoxedSpritePolygonViewModel shapevm = new LfDynamicBoxedSpritePolygonViewModel(shapes, this, MainVm, bsp, enabledChildren);

                foreach (LfDragablePoint dragPoint in bsp.Points)
                {
                    LfDragablePointViewModel dragPointVm = new LfDragablePointViewModel(shapevm, this, MainVm, shapevm, dragPoint, enabledChildren);
                    shapevm.PointVms.Add(dragPointVm);
                }

                shapes.Shapes.Add(shapevm);
            }

            return(shapes);
        }