예제 #1
0
파일: ServerAgent.cs 프로젝트: ixmilia/bcad
        private void AddPrimitiveToDrawing(ClientDrawing clientDrawing, IPrimitive primitive, CadColor?fallBackColor)
        {
            var primitiveColor = primitive.Color ?? fallBackColor;

            primitive.DoPrimitive(
                ellipse =>
            {
                var startAngle = ellipse.StartAngle.CorrectAngleDegrees();
                var endAngle   = ellipse.EndAngle.CorrectAngleDegrees();
                if (endAngle <= startAngle)
                {
                    endAngle += 360.0;
                }
                var transform = Matrix4.CreateScale(1.0, 1.0, 0.0) * ellipse.FromUnitCircle;     // flatten display in z-plane
                clientDrawing.Ellipses.Add(new ClientEllipse(startAngle, endAngle, transform.ToTransposeArray(), primitiveColor));
            },
                line => clientDrawing.Lines.Add(new ClientLine(line.P1, line.P2, primitiveColor)),
                point => clientDrawing.Points.Add(new ClientPointLocation(point.Location, primitiveColor)),
                text => clientDrawing.Text.Add(new ClientText(text.Value, text.Location, text.Height, text.Rotation, primitiveColor)),
                bezier =>
            {
                var lineSegments = 10;
                var last         = bezier.P1;
                for (int i = 1; i <= lineSegments; i++)
                {
                    var t    = (double)i / lineSegments;
                    var next = bezier.ComputeParameterizedPoint(t);
                    clientDrawing.Lines.Add(new ClientLine(last, next, primitiveColor));
                    last = next;
                }
            },
                image => clientDrawing.Images.Add(new ClientImage(image.Location, Convert.ToBase64String(image.ImageData), image.Path, image.Width, image.Height, image.Rotation, image.Color))
                );
        }
예제 #2
0
파일: ServerAgent.cs 프로젝트: ixmilia/bcad
        private ClientDrawing GetDrawing()
        {
            var drawing       = Workspace.Drawing;
            var clientDrawing = new ClientDrawing(drawing.Settings.FileName);

            clientDrawing.CurrentLayer = drawing.CurrentLayerName;
            foreach (var layer in drawing.GetLayers())
            {
                clientDrawing.Layers.Add(layer.Name);
                if (layer.IsVisible)
                {
                    foreach (var entity in layer.GetEntities())
                    {
                        var entityColor = entity.Color ?? layer.Color;
                        foreach (var primitive in entity.GetPrimitives())
                        {
                            AddPrimitiveToDrawing(clientDrawing, primitive, fallBackColor: entityColor);
                        }
                    }
                }
            }

            clientDrawing.Layers.Sort();
            return(clientDrawing);
        }