Esempio n. 1
0
        public Brush RenderLayer(RailLayer layer)
        {
            DrawingVisual drawingVisual = new DrawingVisual();

            using (DrawingContext drawingContext = drawingVisual.RenderOpen())
            {
                if (layer.PlateColor != Colors.Transparent)
                {
                    Color ground = layer.PlateColor;
                    ground.A = 150;
                    drawingContext.DrawGeometry(new SolidColorBrush(ground), blackPen, new PathGeometry(new PathFigureCollection
                    {
                        new PathFigure(this.RailPlan.PlatePoints.FirstOrDefault(), new PathSegmentCollection
                                       (
                                           this.RailPlan.PlatePoints.Skip(1).Select(p => new LineSegment(p, true))
                                       ), true)
                    }));
                }

                this.RailPlan.Rails.Where(r => r.Layer == layer.Id).ForEach(r => r.DrawRailItem(drawingContext, RailViewMode.Terrain, layer));
            }
            RenderTargetBitmap bitmap = new RenderTargetBitmap(this.railPlan.Width, this.railPlan.Height, 96, 96, PixelFormats.Default);

            bitmap.Render(drawingVisual);
            return(new ImageBrush(bitmap));
        }
Esempio n. 2
0
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            Guid      guid      = (Guid)value;
            RailPlan  railPlan  = (RailPlan)parameter;
            RailLayer railLayer = railPlan.Layers.FirstOrDefault(l => l.Id == guid);

            return(railLayer);
        }
Esempio n. 3
0
 public LayerViewModel(RailLayer layer)
 {
     this.Id         = layer.Id;
     this.Name       = layer.Name;
     this.Show       = layer.Show;
     this.Height     = layer.Height;
     this.TrackColor = ColorViewModel.colors.FirstOrDefault(c => c.Color == layer.TrackColor);
     this.PlateColor = ColorViewModel.colors.FirstOrDefault(c => c.Color == layer.PlateColor);
 }
Esempio n. 4
0
        public void CreateLayer(RailLayer layer, double heigth)
        {
            if (!layer.Show)
            {
                return;
            }
            GeometryModel3D model = new GeometryModel3D();

            // geometrie
            MeshGeometry3D geometrie = new MeshGeometry3D();

            geometrie.Positions = new Point3DCollection()
            {
                new Point3D(-this.railPlan.Width / 2, -this.railPlan.Height / 2, heigth),
                new Point3D(+this.railPlan.Width / 2, -this.railPlan.Height / 2, heigth),
                new Point3D(-this.railPlan.Width / 2, +this.railPlan.Height / 2, heigth),
                new Point3D(+this.railPlan.Width / 2, +this.railPlan.Height / 2, heigth)
            };
            geometrie.Normals            = new Vector3DCollection(new Vector3D[] { new Vector3D(0, 0, 1), new Vector3D(0, 0, 1), new Vector3D(0, 0, 1), new Vector3D(0, 0, 1) });
            geometrie.TextureCoordinates = new PointCollection(new Point[] { new Point(0, 1), new Point(1, 1), new Point(0, 0), new Point(1, 0) });
            geometrie.TriangleIndices    = new Int32Collection(new int[] { 0, 1, 2, 1, 3, 2 });
            model.Geometry = geometrie;

            // material
            model.Material = new DiffuseMaterial(RenderLayer(layer));

            // transform
            Transform3DGroup group = new Transform3DGroup();

            //ScaleTransform3D zoomTransformation = new ScaleTransform3D();
            //Binding zoomBinding = new Binding("ZoomFactor");
            //zoomBinding.Source = this.ZoomFactor;
            //BindingOperations.SetBinding(zoomTransformation, ScaleTransform3D.ScaleXProperty, zoomBinding);
            //BindingOperations.SetBinding(zoomTransformation, ScaleTransform3D.ScaleYProperty, zoomBinding);
            //BindingOperations.SetBinding(zoomTransformation, ScaleTransform3D.ScaleZProperty, zoomBinding);
            //group.Children.Add(zoomTransformation);
            group.Children.Add(new ScaleTransform3D(ZoomFactor, ZoomFactor, ZoomFactor));
            group.Children.Add(new RotateTransform3D(new AxisAngleRotation3D(new Vector3D(1, 0, 0), TiltAngle)));
            group.Children.Add(new RotateTransform3D(new AxisAngleRotation3D(new Vector3D(0, 1, 0), RotationAngle)));
            model.Transform = group;

            this.Layers3D.Add(model);
        }
Esempio n. 5
0
        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            RailLayer railLayer = (RailLayer)value;

            return(railLayer.Id);
        }